composer.phar 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346
  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.phpæ'��.óïgæ'���‘Õt¤������1���src/Composer/Advisory/IgnoredSecurityAdvisory.phpT��.óïgT��"¼ï¤������1���src/Composer/Advisory/PartialSecurityAdvisory.php��.óïg��•ôã¤������*���src/Composer/Advisory/SecurityAdvisory.phpü��.óïgü��µ5t0¤������+���src/Composer/Autoload/AutoloadGenerator.phpŠ��.óïgŠ��A��¤������+���src/Composer/Autoload/ClassMapGenerator.php’��.óïg’���¨|S¤���������src/Composer/Cache.phpx��.óïgx��Ѐ%z¤������%���src/Composer/Command/AboutCommand.phpW��.óïgW��â:†!¤������'���src/Composer/Command/ArchiveCommand.phpG��.óïgG��3í2á¤������%���src/Composer/Command/AuditCommand.phpŽ ��.óïgŽ ��‡Ðܤ������$���src/Composer/Command/BaseCommand.php_+��.óïg_+��ˆ)™Û¤������.���src/Composer/Command/BaseDependencyCommand.phpò#��.óïgò#��#¨rd¤������$���src/Composer/Command/BumpCommand.php���.óïg���è "¤������1���src/Composer/Command/CheckPlatformReqsCommand.php`��.óïg`��ù<t¤������*���src/Composer/Command/ClearCacheCommand.php| ��.óïg| �� æL ¤������(���src/Composer/Command/CompletionTrait.phpV��.óïgV��c7õ¤������&���src/Composer/Command/ConfigCommand.php“q��.óïg“q��DìîÚ¤������-���src/Composer/Command/CreateProjectCommand.phpK��.óïgK��¡ãޤ������'���src/Composer/Command/DependsCommand.phpE��.óïgE���z¤������(���src/Composer/Command/DiagnoseCommand.phpJh��.óïgJh��Ó%:¤������,���src/Composer/Command/DumpAutoloadCommand.phpù��.óïgù��Iªè‚¤������$���src/Composer/Command/ExecCommand.php ��.óïg ��Oì¡0¤������$���src/Composer/Command/FundCommand.phpÁ��.óïgÁ��5`ÈG¤������&���src/Composer/Command/GlobalCommand.phpÄ��.óïgÄ��Q#½y¤������$���src/Composer/Command/HomeCommand.phpG��.óïgG��¡gˆ¤������$���src/Composer/Command/InitCommand.php[E��.óïg[E��fŒÝ›¤������'���src/Composer/Command/InstallCommand.phpa��.óïga��ÛáÅ£¤������(���src/Composer/Command/LicensesCommand.php½��.óïg½��ƃi]¤������(���src/Composer/Command/OutdatedCommand.php’��.óïg’��@c�¤������.���src/Composer/Command/PackageDiscoveryTrait.php�6��.óïg�6��œðóº¤������)���src/Composer/Command/ProhibitsCommand.phpå��.óïgå��ÊDrø¤������)���src/Composer/Command/ReinstallCommand.php}��.óïg}��Ièפ������&���src/Composer/Command/RemoveCommand.phpÕ.��.óïgÕ.��Æ  m¤������'���src/Composer/Command/RequireCommand.phpšZ��.óïgšZ��è2LX¤������)���src/Composer/Command/RunScriptCommand.php��.óïg��f¿¤������+���src/Composer/Command/ScriptAliasCommand.phpò��.óïgò��sä*-¤������&���src/Composer/Command/SearchCommand.phpY��.óïgY��óì•ü¤������*���src/Composer/Command/SelfUpdateCommand.phpbL��.óïgbL��!™�¤������$���src/Composer/Command/ShowCommand.phpÙ¼��.óïgÙ¼��Ô-ƒú¤������&���src/Composer/Command/StatusCommand.php·��.óïg·��éB˜¾¤������(���src/Composer/Command/SuggestsCommand.phpÉ ��.óïgÉ ��ùÏfk¤������&���src/Composer/Command/UpdateCommand.php—C��.óïg—C�� ò4r¤������(���src/Composer/Command/ValidateCommand.php'��.óïg'��ŒéÔɤ���������src/Composer/Composer.php���.óïg���Ÿë‰l¤���������src/Composer/Config.php :��.óïg :��½ [¤������-���src/Composer/Config/ConfigSourceInterface.phpº��.óïgº��½Ó¤������(���src/Composer/Config/JsonConfigSource.phpÂ��.óïgÂ��Ž?z¤������$���src/Composer/Console/Application.php_[��.óïg_[��lkF¤������*���src/Composer/Console/GithubActionError.php��.óïg��`±‰æ¤������,���src/Composer/Console/HtmlOutputFormatter.php>��.óïg>��Ò ïR¤������,���src/Composer/Console/Input/InputArgument.php¶��.óïg¶��ª¼K¤������*���src/Composer/Console/Input/InputOption.phpg��.óïgg��ˆ7'4¤������-���src/Composer/DependencyResolver/Decisions.phpé��.óïgé��;$@ ¤������1���src/Composer/DependencyResolver/DefaultPolicy.php²��.óïg²��èMJ¤������/���src/Composer/DependencyResolver/GenericRule.php6��.óïg6��¥²l|¤������8���src/Composer/DependencyResolver/LocalRepoTransaction.php½��.óïg½��ßšHš¤������3���src/Composer/DependencyResolver/LockTransaction.phpA��.óïgA��f±+q¤������5���src/Composer/DependencyResolver/MultiConflictRule.phpË��.óïgË��´9 �¤������>���src/Composer/DependencyResolver/Operation/InstallOperation.phpÿ��.óïgÿ��=ú§§¤������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php��.óïg���1NJ¤������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php��.óïg��tw ¤������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpø���.óïgø���÷Wý¤������=���src/Composer/DependencyResolver/Operation/SolverOperation.phpH��.óïgH��§¤������@���src/Composer/DependencyResolver/Operation/UninstallOperation.phpç��.óïgç��|ÁR¤������=���src/Composer/DependencyResolver/Operation/UpdateOperation.phpŸ��.óïgŸ��Ü7椤������3���src/Composer/DependencyResolver/PolicyInterface.phpž��.óïgž��øÎá¤������(���src/Composer/DependencyResolver/Pool.php ��.óïg ��xF!¤������/���src/Composer/DependencyResolver/PoolBuilder.phpËJ��.óïgËJ��’@øI¤������1���src/Composer/DependencyResolver/PoolOptimizer.phpõ)��.óïgõ)��KY•¤������+���src/Composer/DependencyResolver/Problem.phpµ]��.óïgµ]�� áÇy¤������+���src/Composer/DependencyResolver/Request.php˜��.óïg˜��$£”¤������(���src/Composer/DependencyResolver/Rule.phpµ0��.óïgµ0��Ê{ Q¤������1���src/Composer/DependencyResolver/Rule2Literals.php��.óïg��3vþ¤������+���src/Composer/DependencyResolver/RuleSet.php¾ ��.óïg¾ ��¹u¨¤������4���src/Composer/DependencyResolver/RuleSetGenerator.phpC��.óïgC��/]Zž¤������3���src/Composer/DependencyResolver/RuleSetIterator.phpõ��.óïgõ��œ y¤������2���src/Composer/DependencyResolver/RuleWatchChain.php{��.óïg{��‚hóD¤������2���src/Composer/DependencyResolver/RuleWatchGraph.phpœ ��.óïgœ ��Zœ{|¤������1���src/Composer/DependencyResolver/RuleWatchNode.phpv��.óïgv��p™·¤������*���src/Composer/DependencyResolver/Solver.phpL8��.óïgL8��Ó�Z²¤������6���src/Composer/DependencyResolver/SolverBugException.php¹��.óïg¹��z­=¤������;���src/Composer/DependencyResolver/SolverProblemsException.phpË��.óïgË��£?¤������/���src/Composer/DependencyResolver/Transaction.phpC��.óïgC��¹]
  29. ¤������-���src/Composer/Downloader/ArchiveDownloader.phpï��.óïgï��?ÄþN¤������1���src/Composer/Downloader/ChangeReportInterface.phpõ���.óïgõ���­ÃÂB¤������+���src/Composer/Downloader/DownloadManager.phpª��.óïgª��²œ?g¤������/���src/Composer/Downloader/DownloaderInterface.phpÓ��.óïgÓ��bm[Ȥ������3���src/Composer/Downloader/DvcsDownloaderInterface.phpú���.óïgú���à%'¤������*���src/Composer/Downloader/FileDownloader.phph4��.óïgh4��$^°¤������/���src/Composer/Downloader/FilesystemException.php/��.óïg/��!‹å&¤������,���src/Composer/Downloader/FossilDownloader.phpP ��.óïgP ��„ð:à¤������)���src/Composer/Downloader/GitDownloader.php’C��.óïg’C��ùîÆ¤������*���src/Composer/Downloader/GzipDownloader.phpœ��.óïgœ��0•ÿ¤������(���src/Composer/Downloader/HgDownloader.php ��.óïg ��Ý‘›¤������8���src/Composer/Downloader/MaxFileSizeExceededException.phpŒ���.óïgŒ���ÚºÔ¤������*���src/Composer/Downloader/PathDownloader.phpA"��.óïgA"��Òཥ¤������.���src/Composer/Downloader/PerforceDownloader.php‹ ��.óïg‹ ���<­�¤������*���src/Composer/Downloader/PharDownloader.phpª��.óïgª��XÈȤ������)���src/Composer/Downloader/RarDownloader.phpd��.óïgd��G'°¤������)���src/Composer/Downloader/SvnDownloader.php~��.óïg~��ÈC¤������)���src/Composer/Downloader/TarDownloader.php¨��.óïg¨��×rß‚¤������.���src/Composer/Downloader/TransportException.php
  30. ��.óïg
  31. ��Þé:‡¤������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpý���.óïgý���ä6¤¤������)���src/Composer/Downloader/VcsDownloader.phpA��.óïgA��Æ3^´¤������(���src/Composer/Downloader/XzDownloader.phpˆ��.óïgˆ��E'§Á¤������)���src/Composer/Downloader/ZipDownloader.php_&��.óïg_&��RIFÿ¤������&���src/Composer/EventDispatcher/Event.phpØ��.óïgØ��…÷¡ð¤������0���src/Composer/EventDispatcher/EventDispatcher.phpïH��.óïgïH��ba\¤������9���src/Composer/EventDispatcher/EventSubscriberInterface.phpÂ���.óïgÂ���}=é¤������9���src/Composer/EventDispatcher/ScriptExecutionException.php‘���.óïg‘���XvèϤ������9���src/Composer/Exception/IrrecoverableDownloadException.php����.óïg����0Þ4 ¤������)���src/Composer/Exception/NoSslException.php����.óïg����ØU¦Ò¤���������src/Composer/Factory.phpÝR��.óïgÝR��«Åã¤������T���src/Composer/Filter/PlatformRequirementFilter/IgnoreAllPlatformRequirementFilter.php®��.óïg®��Zkª¤������U���src/Composer/Filter/PlatformRequirementFilter/IgnoreListPlatformRequirementFilter.php.��.óïg.��!;¤������X���src/Composer/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilter.phpT��.óïgT��ÇàÙ¤������R���src/Composer/Filter/PlatformRequirementFilter/PlatformRequirementFilterFactory.phpw��.óïgw��ÑT¿¤������T���src/Composer/Filter/PlatformRequirementFilter/PlatformRequirementFilterInterface.phpø���.óïgø���‰µÒg¤���������src/Composer/IO/BaseIO.phpÕ��.óïgÕ��§zPâ¤���������src/Composer/IO/BufferIO.php���.óïg���ÇÅ£¤���������src/Composer/IO/ConsoleIO.phpë��.óïgë��«ýâ¤���������src/Composer/IO/IOInterface.phpÐ��.óïgÐ��~ÿh­¤���������src/Composer/IO/NullIO.phpO��.óïgO��bˆ¨s¤���������src/Composer/Installer.phpÔ���.óïgÔ���Ì-ZÞ¤������*���src/Composer/Installer/BinaryInstaller.php*��.óïg*��°†Y¥¤������2���src/Composer/Installer/BinaryPresenceInterface.phpæ���.óïgæ���®3—Œ¤������.���src/Composer/Installer/InstallationManager.php6��.óïg6��Ñþ.©¤������)���src/Composer/Installer/InstallerEvent.php*��.óïg*��FZäÙ¤������*���src/Composer/Installer/InstallerEvents.php¥���.óïg¥���>•íǤ������-���src/Composer/Installer/InstallerInterface.php~��.óïg~���͔դ������+���src/Composer/Installer/LibraryInstaller.php��.óïg��ºc2¤������/���src/Composer/Installer/MetapackageInstaller.phpÖ��.óïgÖ��û
  32. õ"¤������(���src/Composer/Installer/NoopInstaller.phpa��.óïga��êxQn¤������'���src/Composer/Installer/PackageEvent.phpô��.óïgô��b‘\A¤������(���src/Composer/Installer/PackageEvents.phpû��.óïgû��ò«K¤������*���src/Composer/Installer/PluginInstaller.php� ��.óïg� ��ò”=¤������+���src/Composer/Installer/ProjectInstaller.php9 ��.óïg9 ��Uц¤������4���src/Composer/Installer/SuggestedPackagesReporter.php¥��.óïg¥��ö”Oë¤���������src/Composer/Json/JsonFile.phpW��.óïgW��‘b&”¤������#���src/Composer/Json/JsonFormatter.phpŒ��.óïgŒ��0Ûùd¤������%���src/Composer/Json/JsonManipulator.php‘8��.óïg‘8��n·¤������-���src/Composer/Json/JsonValidationException.php—��.óïg—���^^´¤������2���src/Composer/PHPStan/ConfigReturnTypeExtension.php
  33. ��.óïg
  34. ��†CëP¤������:���src/Composer/PHPStan/RuleReasonDataReturnTypeExtension.php~��.óïg~��¦ç¬H¤������%���src/Composer/Package/AliasPackage.php¸��.óïg¸��ÝB1¤������7���src/Composer/Package/Archiver/ArchivableFilesFilter.phpS��.óïgS��'25f¤������7���src/Composer/Package/Archiver/ArchivableFilesFinder.phpÕ��.óïgÕ��3äN¤������0���src/Composer/Package/Archiver/ArchiveManager.php~��.óïg~��¶&O»¤������3���src/Composer/Package/Archiver/ArchiverInterface.phpS��.óïgS��ÿì?î¤������3���src/Composer/Package/Archiver/BaseExcludeFilter.php��.óïg��xÆ6Ȥ������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php?��.óïg?��?�`^¤������2���src/Composer/Package/Archiver/GitExcludeFilter.php$��.óïg$��t�8N¤������.���src/Composer/Package/Archiver/PharArchiver.phpÆ��.óïgÆ��-íÙª¤������-���src/Composer/Package/Archiver/ZipArchiver.php‰��.óïg‰��Á8œý¤������$���src/Composer/Package/BasePackage.php)��.óïg)��¢õ/¤������*���src/Composer/Package/Comparer/Comparer.phpÒ ��.óïgÒ ��ûÚ°ˆ¤������-���src/Composer/Package/CompleteAliasPackage.phpq
  35. ��.óïgq
  36. ��ú #·¤������(���src/Composer/Package/CompletePackage.php
  37. ��.óïg
  38. ��† J±¤������1���src/Composer/Package/CompletePackageInterface.php���.óïg���‰‘”¤������+���src/Composer/Package/Dumper/ArrayDumper.php¸ ��.óïg¸ ��–Ú•u¤���������src/Composer/Package/Link.phpö��.óïgö�� "j¥¤������+���src/Composer/Package/Loader/ArrayLoader.php(.��.óïg(.��Áƒwy¤������7���src/Composer/Package/Loader/InvalidPackageException.php„��.óïg„��èMü•¤������*���src/Composer/Package/Loader/JsonLoader.php“��.óïg“��褢4¤������/���src/Composer/Package/Loader/LoaderInterface.phpž��.óïgž��FB¤¤������1���src/Composer/Package/Loader/RootPackageLoader.phpÌ��.óïgÌ��|³’¤������5���src/Composer/Package/Loader/ValidatingArrayLoader.php7R��.óïg7R��h’5¯¤���������src/Composer/Package/Locker.phpu4��.óïgu4��ÙœŒ�¤������ ���src/Composer/Package/Package.php%��.óïg%��Îböþ¤������)���src/Composer/Package/PackageInterface.php ��.óïg ��¡E¤¤������)���src/Composer/Package/RootAliasPackage.phpç ��.óïgç ��A:–D¤������$���src/Composer/Package/RootPackage.php©��.óïg©�� º¤������-���src/Composer/Package/RootPackageInterface.php=��.óïg=��¶Ù]Ĥ������0���src/Composer/Package/Version/StabilityFilter.php��.óïg��Ýhj¤������.���src/Composer/Package/Version/VersionBumper.phpÿ ��.óïgÿ ��ñSA¤������/���src/Composer/Package/Version/VersionGuesser.php(+��.óïg(+��Ò³8a¤������.���src/Composer/Package/Version/VersionParser.phpÔ��.óïgÔ��Øà’æ¤������0���src/Composer/Package/Version/VersionSelector.phpn��.óïgn��„NUŒ¤������ ���src/Composer/PartialComposer.php”��.óïg”��¬1°Æ¤������&���src/Composer/Platform/HhvmDetector.php��.óïg���±óè¤������!���src/Composer/Platform/Runtime.phpò��.óïgò��'V 5¤������!���src/Composer/Platform/Version.phpª��.óïgª��Ë]¯ß¤������-���src/Composer/Plugin/Capability/Capability.phpp���.óïgp���š#c;¤������2���src/Composer/Plugin/Capability/CommandProvider.php°���.óïg°���FüÙ¤¤���������src/Composer/Plugin/Capable.php˜���.óïg˜���û°hª¤������$���src/Composer/Plugin/CommandEvent.php?��.óïg?��|U`¤������.���src/Composer/Plugin/PluginBlockedException.php§���.óïg§���öùr¤������$���src/Composer/Plugin/PluginEvents.php¨��.óïg¨��\K“Ö¤������'���src/Composer/Plugin/PluginInterface.php«��.óïg«��õ1i ¤������%���src/Composer/Plugin/PluginManager.phpøR��.óïgøR��A·ì¤������-���src/Composer/Plugin/PostFileDownloadEvent.php¿��.óïg¿��à@>‰¤������*���src/Composer/Plugin/PreCommandRunEvent.php/��.óïg/��3 ±¤������,���src/Composer/Plugin/PreFileDownloadEvent.php ��.óïg ��´qŠl¤������*���src/Composer/Plugin/PrePoolCreateEvent.php±��.óïg±��ó¼Û¤������4���src/Composer/Question/StrictConfirmationQuestion.phpŽ��.óïgŽ��Ñr¤������5���src/Composer/Repository/AdvisoryProviderInterface.php©��.óïg©��•а¤������+���src/Composer/Repository/ArrayRepository.php4��.óïg4��º�ÒÕ¤������.���src/Composer/Repository/ArtifactRepository.php| ��.óïg| ��¬ñ~3¤������2���src/Composer/Repository/CanonicalPackagesTrait.phpÄ��.óïgÄ��¦{ë¤������.���src/Composer/Repository/ComposerRepository.phpU·��.óïgU·��¼”È–¤������/���src/Composer/Repository/CompositeRepository.php… ��.óïg… ��û«ߤ������;���src/Composer/Repository/ConfigurableRepositoryInterface.php¡���.óïg¡���ce*2¤������0���src/Composer/Repository/FilesystemRepository.php›*��.óïg›*��¦ªlõ¤������,���src/Composer/Repository/FilterRepository.phpg��.óïgg��+¯F¾¤������4���src/Composer/Repository/InstalledArrayRepository.phpX��.óïgX��¼,[¤������9���src/Composer/Repository/InstalledFilesystemRepository.phpJ��.óïgJ��'kCè¤������/���src/Composer/Repository/InstalledRepository.phpm��.óïgm��ú:Ô¤������8���src/Composer/Repository/InstalledRepositoryInterface.phpà���.óïgà���¾²ÿg¤������6���src/Composer/Repository/InvalidRepositoryException.php‡���.óïg‡��� W<_¤������/���src/Composer/Repository/LockArrayRepository.phpâ���.óïgâ����^†ú¤������-���src/Composer/Repository/PackageRepository.php ��.óïg ��\/*þ¤������*���src/Composer/Repository/PathRepository.phpæ��.óïgæ��Ú™Mº¤������*���src/Composer/Repository/PearRepository.php��.óïg��QuÏj¤������.���src/Composer/Repository/PlatformRepository.php±Z��.óïg±Z��¬h`R¤������-���src/Composer/Repository/RepositoryFactory.phpW��.óïgW��è(¤������/���src/Composer/Repository/RepositoryInterface.php¥��.óïg¥��1"ï�¤������-���src/Composer/Repository/RepositoryManager.php¢ ��.óïg¢ ��,}~¤������7���src/Composer/Repository/RepositorySecurityException.phpˆ���.óïgˆ���qœ×t¤������)���src/Composer/Repository/RepositorySet.php�#��.óïg�#��“ƒzå¤������+���src/Composer/Repository/RepositoryUtils.php™��.óïg™��)[�ݤ������1���src/Composer/Repository/RootPackageRepository.php\��.óïg\��¾`9ü¤������,���src/Composer/Repository/Vcs/FossilDriver.php��.óïg��,YÓU¤������2���src/Composer/Repository/Vcs/GitBitbucketDriver.phpÖ&��.óïgÖ&��ëy!†¤������)���src/Composer/Repository/Vcs/GitDriver.phpE��.óïgE��ú uȤ������,���src/Composer/Repository/Vcs/GitHubDriver.phpÃ;��.óïgÃ;��Ü.®s¤������,���src/Composer/Repository/Vcs/GitLabDriver.phpŽ2��.óïgŽ2��µ&¿g¤������(���src/Composer/Repository/Vcs/HgDriver.php���.óïg���yè÷Ǥ������.���src/Composer/Repository/Vcs/PerforceDriver.php ��.óïg ��Î%ÿÚ¤������)���src/Composer/Repository/Vcs/SvnDriver.phpý��.óïgý��O]©¤������)���src/Composer/Repository/Vcs/VcsDriver.php ��.óïg ��Î&þ:¤������2���src/Composer/Repository/Vcs/VcsDriverInterface.php±��.óïg±��TŠ„ø¤������)���src/Composer/Repository/VcsRepository.phpw5��.óïgw5��…Œ£>¤������1���src/Composer/Repository/VersionCacheInterface.php¹���.óïg¹���‚h‡¤������3���src/Composer/Repository/WritableArrayRepository.phpÙ��.óïgÙ��l&´#¤������7���src/Composer/Repository/WritableRepositoryInterface.phpw��.óïgw��Õ~¼0¤���������src/Composer/Script/Event.phpå��.óïgå��м y¤������$���src/Composer/Script/ScriptEvents.phpI��.óïgI��¤£D4¤������ ���src/Composer/SelfUpdate/Keys.phpÙ��.óïgÙ��É ¨s¤������$���src/Composer/SelfUpdate/Versions.php] ��.óïg] ��Øޤ������ ���src/Composer/Util/AuthHelper.phpv#��.óïgv#��3̱¤���������src/Composer/Util/Bitbucket.phpN��.óïgN��j j¤������$���src/Composer/Util/ComposerMirror.php��.óïg��£4ˤ������%���src/Composer/Util/ConfigValidator.phps��.óïgs��ÕH¡ü¤������"���src/Composer/Util/ErrorHandler.php€ ��.óïg€ ��z
  39. ¨¤������ ���src/Composer/Util/Filesystem.phpáA��.óïgáA��òî!¶¤���������src/Composer/Util/Git.php_B��.óïg_B��*Ö§ ¤���������src/Composer/Util/GitHub.php?��.óïg?��¡Å²n¤���������src/Composer/Util/GitLab.phpæ��.óïgæ��Ø,p ¤���������src/Composer/Util/Hg.php… ��.óïg… ��¸’ø¤������)���src/Composer/Util/Http/CurlDownloader.phpDP��.óïgDP��^¡0›¤������'���src/Composer/Util/Http/CurlResponse.php•��.óïg•��’;©¹¤������$���src/Composer/Util/Http/ProxyItem.phpE��.óïgE��yŸÝÕ¤������'���src/Composer/Util/Http/ProxyManager.phpº ��.óïgº ��§II/¤������'���src/Composer/Util/Http/RequestProxy.php†��.óïg†��YD?¤������#���src/Composer/Util/Http/Response.phpÞ��.óïgÞ��Ü… £¤������$���src/Composer/Util/HttpDownloader.phpï)��.óïgï)��ó'kö¤���������src/Composer/Util/IniHelper.phpŽ��.óïgŽ��™m®B¤���������src/Composer/Util/Loop.phpý��.óïgý��Ÿû£¤������&���src/Composer/Util/MetadataMinifier.phpC��.óïgC��d ˜¤������$���src/Composer/Util/NoProxyPattern.php(��.óïg(��Mû ¡¤������!���src/Composer/Util/PackageInfo.phpà��.óïgà���RX¤������#���src/Composer/Util/PackageSorter.phpÅ��.óïgÅ��öµ›ž¤���������src/Composer/Util/Perforce.phpN5��.óïgN5��ªÑ{4¤���������src/Composer/Util/Platform.phpË��.óïgË�� óàø¤������%���src/Composer/Util/ProcessExecutor.php™*��.óïg™*��VQsw¤������&���src/Composer/Util/RemoteFilesystem.phpµA��.óïgµA��©lf¤���������src/Composer/Util/Silencer.phpñ��.óïgñ��G�ÏE¤������*���src/Composer/Util/StreamContextFactory.php˜��.óïg˜��{®Tߤ���������src/Composer/Util/Svn.php›��.óïg›��ƒtT¢¤������ ���src/Composer/Util/SyncHelper.phpÿ��.óïgÿ��ÐzA¤���������src/Composer/Util/Tar.php‘��.óïg‘�� hÆô¤���������src/Composer/Util/TlsHelper.php§ ��.óïg§ ��%þx-¤���������src/Composer/Util/Url.phpË ��.óïgË ��4f¤���������src/Composer/Util/Zip.php��.óïg��£DÙ‘¤���������src/bootstrap.php
  40. ��.óïg
  41. ��ÑÄ-Ȥ������%���src/Composer/Autoload/ClassLoader.phpú?��.óïgú?��2@u¤������"���src/Composer/InstalledVersions.phpóC��.óïgóC��<nw¤���������res/composer-lock-schema.json¯ ��.óïg¯ ��·Ærf¤������#���res/composer-repository-schema.jsonø ��.óïgø ��×븂¤���������res/composer-schema.jsoná��.óïgá��0ÿl¤���������vendor/autoload.phpl��.óïgl��ee$P¤���������vendor/composer/ClassLoader.php/��.óïg/��˜Õâ’¤������%���vendor/composer/InstalledVersions.phpç��.óïgç�� EÎJ¤������%���vendor/composer/autoload_classmap.phpä��.óïgä��")¤������"���vendor/composer/autoload_files.php��.óïg��‹ebd¤������'���vendor/composer/autoload_namespaces.phpZ���.óïgZ���ë¦á–¤������!���vendor/composer/autoload_psr4.phpí��.óïgí��×µ‹¤������!���vendor/composer/autoload_real.phpÆ��.óïgÆ��DDM”¤������#���vendor/composer/autoload_static.php–��.óïg–��Mð+&¤������!���vendor/composer/ca-bundle/LICENSE��.óïg��G _¤������(���vendor/composer/ca-bundle/res/cacert.pem/��.óïg/��œÄ\{¤������*���vendor/composer/ca-bundle/src/CaBundle.php��.óïg��nª¿¤������+���vendor/composer/class-map-generator/LICENSE��.óïg��=ù¾õ¤������4���vendor/composer/class-map-generator/src/ClassMap.php
  42. ��.óïg
  43. ��ÙÚq�¤������=���vendor/composer/class-map-generator/src/ClassMapGenerator.phpY��.óïgY��_#¡h¤������4���vendor/composer/class-map-generator/src/FileList.php$��.óïg$��hôSq¤������:���vendor/composer/class-map-generator/src/PhpFileCleaner.php ��.óïg ��/<;*¤������9���vendor/composer/class-map-generator/src/PhpFileParser.php˜ ��.óïg˜ ��ôïÌ£¤���������vendor/composer/installed.jsonj0�.óïgj0�è`@K¤���������vendor/composer/installed.phpš!��.óïgš!��
  44. Sޤ������)���vendor/composer/metadata-minifier/LICENSE��.óïg��½£ëǤ������:���vendor/composer/metadata-minifier/src/MetadataMinifier.phpÐ��.óïgÐ��Â0&À¤���������vendor/composer/pcre/LICENSE��.óïg��½£ëǤ������+���vendor/composer/pcre/src/MatchAllResult.php��.óïg�� \9ÿ¤������7���vendor/composer/pcre/src/MatchAllStrictGroupsResult.php)��.óïg)��hIŸ…¤������6���vendor/composer/pcre/src/MatchAllWithOffsetsResult.php*��.óïg*��øA à¤������(���vendor/composer/pcre/src/MatchResult.phpï���.óïgï���<äÀ¤������4���vendor/composer/pcre/src/MatchStrictGroupsResult.phpû���.óïgû���§Ë0Q¤������3���vendor/composer/pcre/src/MatchWithOffsetsResult.phpü���.óïgü���{*,o¤������<���vendor/composer/pcre/src/PHPStan/InvalidRegexPatternRule.phpâ ��.óïgâ ��üØîפ������3���vendor/composer/pcre/src/PHPStan/PregMatchFlags.phpp��.óïgp��YÊM¤������G���vendor/composer/pcre/src/PHPStan/PregMatchParameterOutTypeExtension.php1��.óïg1��Â}ÌÒ¤������E���vendor/composer/pcre/src/PHPStan/PregMatchTypeSpecifyingExtension.phpÙ ��.óïgÙ ��CºÇ¤������L���vendor/composer/pcre/src/PHPStan/PregReplaceCallbackClosureTypeExtension.phpˆ��.óïgˆ��Øø/¤������?���vendor/composer/pcre/src/PHPStan/UnsafeStrictGroupsCallRule.phpk
  45. ��.óïgk
  46. ��3E½¤������*���vendor/composer/pcre/src/PcreException.phpj��.óïgj��*»ª\¤������!���vendor/composer/pcre/src/Preg.php0"��.óïg0"��ѹ”{¤������"���vendor/composer/pcre/src/Regex.php ��.óïg ��£ù뇤������*���vendor/composer/pcre/src/ReplaceResult.php��.óïg��'±Èð¤������9���vendor/composer/pcre/src/UnexpectedNullMatchException.php��.óïg�� îÀò¤���������vendor/composer/semver/LICENSE��.óïg��ÇSRm¤������)���vendor/composer/semver/src/Comparator.php��.óïg��^_E“¤������/���vendor/composer/semver/src/CompilingMatcher.phpc��.óïgc��„€¦¤������/���vendor/composer/semver/src/Constraint/Bound.phpw��.óïgw��W4]W¤������4���vendor/composer/semver/src/Constraint/Constraint.phpø��.óïgø��’‹ˆ½¤������=���vendor/composer/semver/src/Constraint/ConstraintInterface.php¡��.óïg¡��Ž5´y¤������<���vendor/composer/semver/src/Constraint/MatchAllConstraint.php¯��.óïg¯��²Eú¤������=���vendor/composer/semver/src/Constraint/MatchNoneConstraint.phpÉ��.óïgÉ��֯خ¤������9���vendor/composer/semver/src/Constraint/MultiConstraint.phpŠ��.óïgŠ��ÍÕĤ������'���vendor/composer/semver/src/Interval.phpæ��.óïgæ��=[i¤������(���vendor/composer/semver/src/Intervals.php¤+��.óïg¤+��@1º«¤������%���vendor/composer/semver/src/Semver.phpù��.óïgù��á-i¤������,���vendor/composer/semver/src/VersionParser.php×-��.óïg×-��*›p¤������%���vendor/composer/spdx-licenses/LICENSE��.óïg��ÇSRm¤������6���vendor/composer/spdx-licenses/res/spdx-exceptions.json��.óïg��"mÓê¤������4���vendor/composer/spdx-licenses/res/spdx-licenses.jsonï��.óïgï��
  47. ‘x ¤������2���vendor/composer/spdx-licenses/src/SpdxLicenses.php{��.óïg{��cE�¤������&���vendor/composer/xdebug-handler/LICENSE+��.óïg+��Öã@T¤������0���vendor/composer/xdebug-handler/src/PhpConfig.php‰��.óïg‰��gÔ�v¤������.���vendor/composer/xdebug-handler/src/Process.phpò��.óïgò��fžZ.¤������-���vendor/composer/xdebug-handler/src/Status.phpÒ ��.óïgÒ ��±Ít¤������4���vendor/composer/xdebug-handler/src/XdebugHandler.phpÓ,��.óïgÓ,��:@Óã¤������(���vendor/justinrainbow/json-schema/LICENSE"��.óïg"�� |»™¤������C���vendor/justinrainbow/json-schema/src/JsonSchema/ConstraintError.phpz��.óïgz���6Á¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.phpq ��.óïgq ��µ©²E¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.phpw
  48. ��.óïgw
  49. ��%º1*¤������O���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstConstraint.phpH��.óïgH��Þ÷�¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php“��.óïg“��Þ������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php��.óïg��­Vñã¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.phpÓ��.óïgÓ��pqg‹¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.php» ��.óïg» ��Ü㲕¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.phps��.óïgs��˜©¬¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.phpE��.óïgE��Ï”E<¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php­��.óïg­��ôÙ¡“¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.phpq ��.óïgq ��§«¯œ¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.php#��.óïg#��üì5º¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.php���.óïg���Ðj�&¤������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php±��.óïg±�� 9šh¤������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php£��.óïg£��¸A ¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php­��.óïg­��̤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.phpT$��.óïgT$��—�Š´¤������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.php#��.óïg#��aæIí¤������8���vendor/justinrainbow/json-schema/src/JsonSchema/Enum.phpg���.óïgg���½/ʤ������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpc���.óïgc���Wf¢ž¤������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php¯���.óïg¯���Ft* ¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.php†���.óïg†���))œZ¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.php†���.óïg†���€:'s¤������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.php����.óïg����wTT:¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.php‘���.óïg‘���õË ~¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpù��.óïgù��ñQ3<¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.php‰���.óïg‰���¹/ñ¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.phpŸ���.óïgŸ���7b‹Ð¤������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.phpš���.óïgš���\´*¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.php„���.óïg„���M߈‡¤������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.php€���.óïg€���lã¤������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php>��.óïg>��ìT™(¤������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.phpÂ��.óïgÂ��µ­CŒ¤������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.phpl��.óïgl��ÒWåʤ������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php��.óïg��LcÕð¤������E���vendor/justinrainbow/json-schema/src/JsonSchema/Tool/DeepComparer.phpb��.óïgb��šEÚ�¤������A���vendor/justinrainbow/json-schema/src/JsonSchema/Tool/DeepCopy.php—��.óïg—��x/3¤������]���vendor/justinrainbow/json-schema/src/JsonSchema/Tool/Validator/RelativeReferenceValidator.php÷��.óïg÷��€löϤ������O���vendor/justinrainbow/json-schema/src/JsonSchema/Tool/Validator/UriValidator.phpZ��.óïgZ��b‡}3¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpü���.óïgü���ã`Œ<¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php¸��.óïg¸��vÆg—¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.phpI��.óïgI��ÕK'¬¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.phpF��.óïgF���rØ+¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.phpÈ���.óïgÈ���5€…¤������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php� ��.óïg� ��l¬¦�¤������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.phpO��.óïgO��ÖbÛS¤������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.php����.óïg����£¾Cñ¤������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.phpŸ���.óïgŸ���Ò¡"¤������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.php½��.óïg½��¯÷Èë¤������%���vendor/marc-mabe/php-enum/LICENSE.txtø��.óïgø���—CѤ������&���vendor/marc-mabe/php-enum/src/Enum.php"��.óïg"��ÄE /¤������)���vendor/marc-mabe/php-enum/src/EnumMap.phpC��.óïgC��{~ʤ������7���vendor/marc-mabe/php-enum/src/EnumSerializableTrait.php��.óïg��³;蟤������)���vendor/marc-mabe/php-enum/src/EnumSet.php¦6��.óïg¦6��œ¦_¤������.���vendor/marc-mabe/php-enum/stubs/Stringable.phpb���.óïgb���ÃÑ›<¤���������vendor/psr/container/LICENSE{��.óïg{��ÕÓ�e¤������8���vendor/psr/container/src/ContainerExceptionInterface.phpN���.óïgN���üLƒ¤������/���vendor/psr/container/src/ContainerInterface.php·���.óïg·���Šã¼¤������7���vendor/psr/container/src/NotFoundExceptionInterface.phpq���.óïgq���Rúõ¤���������vendor/psr/log/LICENSE?��.óïg?��„ù ¤������)���vendor/psr/log/Psr/Log/AbstractLogger.php;��.óïg;��ñ>3[¤������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`���.óïg`��� ˆX1¤������#���vendor/psr/log/Psr/Log/LogLevel.phpû���.óïgû���jðñ8¤������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|���.óïg|���$£ˆ¤������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§���.óïg§���T½úB¤������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÈ��.óïgÈ��šx¤������&���vendor/psr/log/Psr/Log/LoggerTrait.phpk��.óïgk��£}‰’¤������%���vendor/psr/log/Psr/Log/NullLogger.phpŸ���.óïgŸ����Xóª¤������)���vendor/psr/log/Psr/Log/Test/DummyTest.phpp���.óïgp���Τ������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php ��.óïg ��$/Ò¤������*���vendor/psr/log/Psr/Log/Test/TestLogger.php<��.óïg<��þ(åI¤���������vendor/react/promise/LICENSEi��.óïgi��3}‹¤������%���vendor/react/promise/src/Deferred.phpS��.óïgS��½ö׆¤������9���vendor/react/promise/src/Exception/CompositeException.phpŒ��.óïgŒ��!ŒÏâ¤������6���vendor/react/promise/src/Exception/LengthException.php^���.óïg^���?q¤������7���vendor/react/promise/src/Internal/CancellationQueue.phpr��.óïgr���x_±¤������6���vendor/react/promise/src/Internal/FulfilledPromise.phpw��.óïgw��ÿV÷¯¤������5���vendor/react/promise/src/Internal/RejectedPromise.phpõ��.óïgõ��Ÿ‡ú¤������$���vendor/react/promise/src/Promise.php���.óïg���²eªÒ¤������-���vendor/react/promise/src/PromiseInterface.phpi��.óïgi��&](¤������&���vendor/react/promise/src/functions.phpÇ��.óïgÇ��<îÂ`¤������.���vendor/react/promise/src/functions_include.php]���.óïg]���QÑ<¡¤���������vendor/seld/jsonlint/LICENSE$��.óïg$��4:‡~¤������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.php|��.óïg|��šÊ ì¤������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.phpM9��.óïgM9��|Án¤������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php¥��.óïg¥��È»_¤¤������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php(��.óïg(��>Ûv}¤������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>���.óïg>���ÿqŸŸ¤���������vendor/seld/phar-utils/LICENSE$��.óïg$��š,M§¤������%���vendor/seld/phar-utils/src/Linter.phpi��.óïgi�� �Þ¤������)���vendor/seld/phar-utils/src/Timestamps.php^ ��.óïg^ ���åÃD¤������"���vendor/seld/signal-handler/LICENSE$��.óïg$��š,M§¤������0���vendor/seld/signal-handler/src/SignalHandler.php°��.óïg°����
  50. ¤������&���vendor/symfony/console/Application.phpq��.óïgq��ým!„¤������.���vendor/symfony/console/Attribute/AsCommand.phpÔ��.óïgÔ��½3Üþ¤������2���vendor/symfony/console/CI/GithubActionReporter.phpõ��.óïgõ��¾Û"g¤������ ���vendor/symfony/console/Color.phph��.óïgh��Gbç—¤������*���vendor/symfony/console/Command/Command.phpJ'��.óïgJ'��� Úw¤������2���vendor/symfony/console/Command/CompleteCommand.php‹��.óïg‹��¾}¤������8���vendor/symfony/console/Command/DumpCompletionCommand.php���.óïg���9›9¤������.���vendor/symfony/console/Command/HelpCommand.php ��.óïg ��}—¥¤������.���vendor/symfony/console/Command/LazyCommand.php›��.óïg›��žmå¤������.���vendor/symfony/console/Command/ListCommand.php1 ��.óïg1 ��$D»|¤������0���vendor/symfony/console/Command/LockableTrait.php��.óïg��q5gj¤������=���vendor/symfony/console/Command/SignalableCommandInterface.phpÓ���.óïgÓ���»B`¾¤������?���vendor/symfony/console/CommandLoader/CommandLoaderInterface.phpQ��.óïgQ��›žH¤������?���vendor/symfony/console/CommandLoader/ContainerCommandLoader.phpU��.óïgU��Ë_ü¤������=���vendor/symfony/console/CommandLoader/FactoryCommandLoader.php¯��.óïg¯��d¼"z¤������5���vendor/symfony/console/Completion/CompletionInput.php��.óïg��”$„k¤������;���vendor/symfony/console/Completion/CompletionSuggestions.phpÂ��.óïgÂ��A¡¤������A���vendor/symfony/console/Completion/Output/BashCompletionOutput.phpg��.óïgg��‡ìùW¤������F���vendor/symfony/console/Completion/Output/CompletionOutputInterface.phpF��.óïgF��Ô2nM¤������0���vendor/symfony/console/Completion/Suggestion.php3��.óïg3��̆ ¤������(���vendor/symfony/console/ConsoleEvents.phpÕ��.óïgÕ���gw]¤������!���vendor/symfony/console/Cursor.php� ��.óïg� ��Æ«§Ž¤������D���vendor/symfony/console/DependencyInjection/AddConsoleCommandPass.phpf��.óïgf��#Ô $¤������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpÙ ��.óïgÙ ��çpC^¤������0���vendor/symfony/console/Descriptor/Descriptor.php}��.óïg}��±ê3^¤������9���vendor/symfony/console/Descriptor/DescriptorInterface.php÷���.óïg÷���µå@à¤������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpë��.óïgë��1%è�¤������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.phpQ��.óïgQ��t ˆv¤������4���vendor/symfony/console/Descriptor/TextDescriptor.phpç"��.óïgç"��ȸÌˤ������3���vendor/symfony/console/Descriptor/XmlDescriptor.php��.óïg��uI@š¤������4���vendor/symfony/console/Event/ConsoleCommandEvent.phpÉ��.óïgÉ��°Öá¤������2���vendor/symfony/console/Event/ConsoleErrorEvent.phpý��.óïgý��é%˜¤������-���vendor/symfony/console/Event/ConsoleEvent.phpÆ��.óïgÆ��ÅoÛÙ¤������3���vendor/symfony/console/Event/ConsoleSignalEvent.phpG��.óïgG��Žû ¤������6���vendor/symfony/console/Event/ConsoleTerminateEvent.php~��.óïg~��hr½Ö¤������6���vendor/symfony/console/EventListener/ErrorListener.php'��.óïg'��𢡉¤������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÛ��.óïgÛ��K}ž¤������7���vendor/symfony/console/Exception/ExceptionInterface.phpy���.óïgy���Ù9[&¤������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦���.óïg¦���Ö̽Z¤������;���vendor/symfony/console/Exception/InvalidOptionException.php¦���.óïg¦���Ë×H¤������3���vendor/symfony/console/Exception/LogicException.php’���.óïg’���ÍO\e¤������:���vendor/symfony/console/Exception/MissingInputException.phpœ���.óïgœ���æS
  51. þ¤������?���vendor/symfony/console/Exception/NamespaceNotFoundException.php‹���.óïg‹���‚ón©¤������5���vendor/symfony/console/Exception/RuntimeException.php–���.óïg–���Ùí,6¤������8���vendor/symfony/console/Formatter/NullOutputFormatter.php���.óïg���!& u¤������=���vendor/symfony/console/Formatter/NullOutputFormatterStyle.php ��.óïg ��Ê0‡Ø¤������4���vendor/symfony/console/Formatter/OutputFormatter.php��.óïg��Üæ¥¤������=���vendor/symfony/console/Formatter/OutputFormatterInterface.php£��.óïg£��Y §ß¤������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpz��.óïgz��ÿja­¤������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.phpŸ��.óïgŸ��ø€Äw¤������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.php…��.óïg…��LÙኤ������F���vendor/symfony/console/Formatter/WrappableOutputFormatterInterface.phpÖ���.óïgÖ���¡Z·¤������6���vendor/symfony/console/Helper/DebugFormatterHelper.php¸��.óïg¸��¤ð6 ¤������2���vendor/symfony/console/Helper/DescriptorHelper.phpÀ��.óïgÀ��¦gÌ„¤������(���vendor/symfony/console/Helper/Dumper.php��.óïg��Ÿ<Ëߤ������1���vendor/symfony/console/Helper/FormatterHelper.phpi��.óïgi��¤¶€w¤������(���vendor/symfony/console/Helper/Helper.php� ��.óïg� ��Á”1T¤������1���vendor/symfony/console/Helper/HelperInterface.phpæ���.óïgæ���`RÂ\¤������+���vendor/symfony/console/Helper/HelperSet.phpI��.óïgI��=‡âD¤������2���vendor/symfony/console/Helper/InputAwareHelper.phpc��.óïgc��Ìøƒ¤������/���vendor/symfony/console/Helper/ProcessHelper.php\ ��.óïg\ ��ÄzA¤������-���vendor/symfony/console/Helper/ProgressBar.phpX/��.óïgX/��2p’ä¤������3���vendor/symfony/console/Helper/ProgressIndicator.phpÀ��.óïgÀ��‡Ëeõ¤������0���vendor/symfony/console/Helper/QuestionHelper.phpR-��.óïgR-��æ§1i¤������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php ��.óïg ��à�dÿ¤������'���vendor/symfony/console/Helper/Table.php´J��.óïg´J��S×Á­¤������+���vendor/symfony/console/Helper/TableCell.phpA��.óïgA��èÓ ¤������0���vendor/symfony/console/Helper/TableCellStyle.phpî��.óïgî��Ñ�¹_¤������+���vendor/symfony/console/Helper/TableRows.php)��.óïg)��WŠ3z¤������0���vendor/symfony/console/Helper/TableSeparator.phpÅ���.óïgÅ���¼õËü¤������,���vendor/symfony/console/Helper/TableStyle.php���.óïg���Wº¤������*���vendor/symfony/console/Input/ArgvInput.php+��.óïg+��F±¶Ñ¤������+���vendor/symfony/console/Input/ArrayInput.php ��.óïg ��ñ¦Ÿ.¤������&���vendor/symfony/console/Input/Input.php¤ ��.óïg¤ ��ÚÜo±¤������.���vendor/symfony/console/Input/InputArgument.php��.óïg��ΠÀú¤������4���vendor/symfony/console/Input/InputAwareInterface.php˜���.óïg˜���­O°¤������0���vendor/symfony/console/Input/InputDefinition.php#��.óïg#�� Œ!3¤������/���vendor/symfony/console/Input/InputInterface.phpü��.óïgü��G¶ô¨¤������,���vendor/symfony/console/Input/InputOption.php��.óïg��Iªž/¤������9���vendor/symfony/console/Input/StreamableInputInterface.phpÎ���.óïgÎ���ÖÕB›¤������,���vendor/symfony/console/Input/StringInput.php?��.óïg?��±’ˤ���������vendor/symfony/console/LICENSE.��.óïg.��÷ºk¤������/���vendor/symfony/console/Logger/ConsoleLogger.php ��.óïg ��Ç Q¤������0���vendor/symfony/console/Output/BufferedOutput.phpl��.óïgl��y:¸¤������/���vendor/symfony/console/Output/ConsoleOutput.php‘ ��.óïg‘ ��\Ýïb¤������8���vendor/symfony/console/Output/ConsoleOutputInterface.php��.óïg��‰ê÷´¤������6���vendor/symfony/console/Output/ConsoleSectionOutput.php” ��.óïg” ��Àgo@¤������,���vendor/symfony/console/Output/NullOutput.phpB��.óïgB��%#RƤ������(���vendor/symfony/console/Output/Output.phpÈ ��.óïgÈ ��ŸË8x¤������1���vendor/symfony/console/Output/OutputInterface.phpí��.óïgí��ð޾¤������.���vendor/symfony/console/Output/StreamOutput.php¢��.óïg¢��,¾"ü¤������5���vendor/symfony/console/Output/TrimmedBufferOutput.phpÛ��.óïgÛ��lkƒ~¤������2���vendor/symfony/console/Question/ChoiceQuestion.phpÝ
  52. ��.óïgÝ
  53. �� c䦤������8���vendor/symfony/console/Question/ConfirmationQuestion.php��.óïg��îyÅ„¤������,���vendor/symfony/console/Question/Question.php" ��.óïg" ��ÊÞ¹Û¤������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$��.óïg�$��•�¥v¤������0���vendor/symfony/console/Resources/completion.bashÏ
  54. ��.óïgÏ
  55. ��›'r¤������8���vendor/symfony/console/SignalRegistry/SignalRegistry.php!��.óïg!��~.:¯¤������3���vendor/symfony/console/SingleCommandApplication.php7��.óïg7��Í1¾¤������,���vendor/symfony/console/Style/OutputStyle.phpt��.óïgt��O;Ƥ������/���vendor/symfony/console/Style/StyleInterface.php��.óïg��\ž¤������-���vendor/symfony/console/Style/SymfonyStyle.php5'��.óïg5'��yl÷ô¤������#���vendor/symfony/console/Terminal.phpm ��.óïgm ��‡¥Pv¤������3���vendor/symfony/console/Tester/ApplicationTester.phpŒ��.óïgŒ��Iû¤������9���vendor/symfony/console/Tester/CommandCompletionTester.phpÚ��.óïgÚ��Ê›;°¤������/���vendor/symfony/console/Tester/CommandTester.phpÙ��.óïgÙ��D¶¤������@���vendor/symfony/console/Tester/Constraint/CommandIsSuccessful.phpÖ��.óïgÖ��ƃ‚¤������-���vendor/symfony/console/Tester/TesterTrait.php¬ ��.óïg¬ ��2'L²¤������,���vendor/symfony/deprecation-contracts/LICENSE.��.óïg.��äôˆ¤������1���vendor/symfony/deprecation-contracts/function.php=��.óïg=��žÁ´ ¤������:���vendor/symfony/filesystem/Exception/ExceptionInterface.php|���.óïg|����éD¤������=���vendor/symfony/filesystem/Exception/FileNotFoundException.phpÑ��.óïgÑ��bæ}´¤������3���vendor/symfony/filesystem/Exception/IOException.php›��.óïg›��3_Ãê¤������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦���.óïg¦���jÙwM¤������@���vendor/symfony/filesystem/Exception/InvalidArgumentException.php©���.óïg©����!Ǥ������8���vendor/symfony/filesystem/Exception/RuntimeException.php™���.óïg™���ÝUUH¤������(���vendor/symfony/filesystem/Filesystem.php$B��.óïg$B��’Àw;¤������!���vendor/symfony/filesystem/LICENSE.��.óïg.��÷ºk¤������"���vendor/symfony/filesystem/Path.phpb'��.óïgb'��ߣ¤������/���vendor/symfony/finder/Comparator/Comparator.php4��.óïg4��"ì¼Õ¤������3���vendor/symfony/finder/Comparator/DateComparator.php��.óïg��Ï%úe¤������5���vendor/symfony/finder/Comparator/NumberComparator.phpz��.óïgz��+¼�h¤������9���vendor/symfony/finder/Exception/AccessDeniedException.php„���.óïg„���½¾sœ¤������>���vendor/symfony/finder/Exception/DirectoryNotFoundException.php‰���.óïg‰���a)ÿ¤������ ���vendor/symfony/finder/Finder.phpÖ'��.óïgÖ'��Ž?ä¤������#���vendor/symfony/finder/Gitignore.php³��.óïg³��s 4¤���������vendor/symfony/finder/Glob.phpÇ��.óïgÇ��Db‡³¤������7���vendor/symfony/finder/Iterator/CustomFilterIterator.phpc��.óïgc��7ð™¤������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.php���.óïg���Pšs¤������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.php��.óïg��§Ž¤������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php0��.óïg0��.wv¤������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpˆ��.óïgˆ��^¶"û¤������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.phpW��.óïgW��ÂÅÙ¤������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.php”��.óïg”��=™Üô¤������/���vendor/symfony/finder/Iterator/LazyIterator.phpQ��.óïgQ��n]¿¼¤������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php���.óïg���¢€×¤������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpò��.óïgò��g"_¤������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.phpK ��.óïgK ��é†F ¤������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.php|��.óïg|��3ÙŸ¤������3���vendor/symfony/finder/Iterator/SortableIterator.php(
  56. ��.óïg(
  57. ��Ó⮤������;���vendor/symfony/finder/Iterator/VcsIgnoredFilterIterator.phpw
  58. ��.óïgw
  59. ��ŵ3¤���������vendor/symfony/finder/LICENSE.��.óïg.��÷ºk¤������%���vendor/symfony/finder/SplFileInfo.php½��.óïg½��y¤������'���vendor/symfony/polyfill-ctype/Ctype.php‡
  60. ��.óïg‡
  61. ��~¶d¸¤������%���vendor/symfony/polyfill-ctype/LICENSE.��.óïg.��¦¸©X¤������+���vendor/symfony/polyfill-ctype/bootstrap.php2��.óïg2��Èa­8¤������-���vendor/symfony/polyfill-ctype/bootstrap80.phph��.óïgh��K¿y¸¤������2���vendor/symfony/polyfill-intl-grapheme/Grapheme.phpÚ��.óïgÚ��� ›¤������-���vendor/symfony/polyfill-intl-grapheme/LICENSE.��.óïg.��Ëk¤������3���vendor/symfony/polyfill-intl-grapheme/bootstrap.phpÏ��.óïgÏ��ý9À|¤������5���vendor/symfony/polyfill-intl-grapheme/bootstrap80.phpY ��.óïgY ��¨! ¤������/���vendor/symfony/polyfill-intl-normalizer/LICENSE.��.óïg.��Ëk¤������6���vendor/symfony/polyfill-intl-normalizer/Normalizer.phpö��.óïgö��êiÝe¤������F���vendor/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php.��.óïg.��Qs$—¤������R���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/canonicalComposition.php‰=��.óïg‰=��*ïo?¤������T���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/canonicalDecomposition.phpaˆ��.óïgaˆ��çR½}¤������L���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/combiningClass.phpt.��.óïgt.�� q�ܤ������X���vendor/symfony/polyfill-intl-normalizer/Resources/unidata/compatibilityDecomposition.php™è��.óïg™è��o”e)¤������5���vendor/symfony/polyfill-intl-normalizer/bootstrap.phpë��.óïgë��Pú£D¤������7���vendor/symfony/polyfill-intl-normalizer/bootstrap80.phpé��.óïgé��=år´¤������(���vendor/symfony/polyfill-mbstring/LICENSE.��.óïg.��Ëk¤������-���vendor/symfony/polyfill-mbstring/Mbstring.phpô^��.óïgô^��ÇXô«¤������B���vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php•��.óïg•��ô¶³ã¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.phpùT��.óïgùT��•±+¤������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã��.óïgã��öy_•¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php8[��.óïg8[��+RØ*¤������.���vendor/symfony/polyfill-mbstring/bootstrap.phpm��.óïgm��Oé; ¤������0���vendor/symfony/polyfill-mbstring/bootstrap80.phpr%��.óïgr%��ï_Q¤������%���vendor/symfony/polyfill-php73/LICENSE.��.óïg.��¦¸©X¤������'���vendor/symfony/polyfill-php73/Php73.phpn��.óïgn��Cs¥l¤������?���vendor/symfony/polyfill-php73/Resources/stubs/JsonException.php[���.óïg[���M²Ü¤������+���vendor/symfony/polyfill-php73/bootstrap.phpù��.óïgù��AY8Ƥ������%���vendor/symfony/polyfill-php80/LICENSE.��.óïg.��äôˆ¤������'���vendor/symfony/polyfill-php80/Php80.php¡ ��.óïg¡ ��[Âk ¤������*���vendor/symfony/polyfill-php80/PhpToken.php��.óïg��M£�I¤������;���vendor/symfony/polyfill-php80/Resources/stubs/Attribute.phpÇ��.óïgÇ��ÝÞíû¤������:���vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php����.óïg����Ú”ݤ������<���vendor/symfony/polyfill-php80/Resources/stubs/Stringable.phpk���.óïgk���Ðý+¤������E���vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php]���.óïg]���ºgä������<���vendor/symfony/polyfill-php80/Resources/stubs/ValueError.phpT���.óïgT���‘Öw—¤������+���vendor/symfony/polyfill-php80/bootstrap.phpú��.óïgú��×îå¤������%���vendor/symfony/polyfill-php81/LICENSE.��.óïg.��;c©§¤������'���vendor/symfony/polyfill-php81/Php81.php;��.óïg;��ù«d¤������@���vendor/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php‚��.óïg‚��áÁ?ì¤������F���vendor/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.phpŸ���.óïgŸ���ÎÀ¾ü¤������+���vendor/symfony/polyfill-php81/bootstrap.phpô��.óïgô��ˆÓÐ\¤������7���vendor/symfony/process/Exception/ExceptionInterface.phpy���.óïgy���qVXJ¤������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨���.óïg¨���ÐÀ+_¤������3���vendor/symfony/process/Exception/LogicException.php”���.óïg”��� ³ãñ¤������;���vendor/symfony/process/Exception/ProcessFailedException.phpx��.óïgx��¨Ìzy¤������=���vendor/symfony/process/Exception/ProcessSignaledException.php��.óïg��Yשâ¤������=���vendor/symfony/process/Exception/ProcessTimedOutException.php1��.óïg1��‚'Z¤������5���vendor/symfony/process/Exception/RuntimeException.php˜���.óïg˜���¢Ø:¤������+���vendor/symfony/process/ExecutableFinder.phpø��.óïgø��¿[ª¤������&���vendor/symfony/process/InputStream.php0��.óïg0��Œ„>‡¤���������vendor/symfony/process/LICENSE.��.óïg.��÷ºk¤������.���vendor/symfony/process/PhpExecutableFinder.phpÿ��.óïgÿ��ê®ÅŒ¤������%���vendor/symfony/process/PhpProcess.phpø��.óïgø��pÄX¤������.���vendor/symfony/process/Pipes/AbstractPipes.php ��.óïg ��kSQ¤������/���vendor/symfony/process/Pipes/PipesInterface.php™��.óïg™��fQÚ ¤������*���vendor/symfony/process/Pipes/UnixPipes.php€��.óïg€��¾”Vv¤������-���vendor/symfony/process/Pipes/WindowsPipes.php4 ��.óïg4 �� VÄà¤������"���vendor/symfony/process/Process.phpBh��.óïgBh��H"Τ������'���vendor/symfony/process/ProcessUtils.php��.óïg��ÓXì¤������7���vendor/symfony/service-contracts/Attribute/Required.php¨���.óïg¨���xj네������@���vendor/symfony/service-contracts/Attribute/SubscribedService.php
  62. ��.óïg
  63. ��1I®T¤������(���vendor/symfony/service-contracts/LICENSE.��.óïg.��¦¸©X¤������3���vendor/symfony/service-contracts/ResetInterface.phpy���.óïgy���°·jå¤������8���vendor/symfony/service-contracts/ServiceLocatorTrait.phpã ��.óïgã ��"�5é¤������=���vendor/symfony/service-contracts/ServiceProviderInterface.phpÞ���.óïgÞ���úRèk¤������?���vendor/symfony/service-contracts/ServiceSubscriberInterface.php³���.óïg³���—öd ¤������;���vendor/symfony/service-contracts/ServiceSubscriberTrait.php`
  64. ��.óïg`
  65. ��È3u¤������<���vendor/symfony/service-contracts/Test/ServiceLocatorTest.php²���.óïg²���mùªÔ¤������@���vendor/symfony/service-contracts/Test/ServiceLocatorTestCase.phpœ��.óïgœ��ÅšŒ½¤������(���vendor/symfony/string/AbstractString.php*4��.óïg*4��°J û¤������/���vendor/symfony/string/AbstractUnicodeString.php¸R��.óïg¸R��#·¤������$���vendor/symfony/string/ByteString.phpÿ+��.óïgÿ+��K«Ó^¤������)���vendor/symfony/string/CodePointString.phpõ��.óïgõ��BÂ�¤������6���vendor/symfony/string/Exception/ExceptionInterface.phps���.óïgs���qHV‘¤������<���vendor/symfony/string/Exception/InvalidArgumentException.php¢���.óïg¢���¥A¤������4���vendor/symfony/string/Exception/RuntimeException.php’���.óïg’���u‘g¤������4���vendor/symfony/string/Inflector/EnglishInflector.phpJ��.óïgJ��³Ø3¤������3���vendor/symfony/string/Inflector/FrenchInflector.phpˆ
  66. ��.óïgˆ
  67. ��·ŠH¤������6���vendor/symfony/string/Inflector/InflectorInterface.php×���.óïg×���hD£¤���������vendor/symfony/string/LICENSE.��.óïg.��š?ôw¤������$���vendor/symfony/string/LazyString.phpC ��.óïgC ��§á¬b¤������<���vendor/symfony/string/Resources/data/wcswidth_table_wide.php$��.óïg$��¥À–K¤������<���vendor/symfony/string/Resources/data/wcswidth_table_zero.phpÔ��.óïgÔ��Òþ$¤������-���vendor/symfony/string/Resources/functions.php��.óïg��cÚª"¤������.���vendor/symfony/string/Slugger/AsciiSlugger.phpì��.óïgì��}&ʤ������2���vendor/symfony/string/Slugger/SluggerInterface.php��.óïg���kñ¨¤������'���vendor/symfony/string/UnicodeString.phpí%��.óïgí%��ýÁ˜5¤������ ���bin/composer¦ ��.óïg¦ ��˜tÈ?¤���������LICENSE.��.óïg.�� Õ¤������<?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 const ABANDONEDS = [
  94. self::ABANDONED_IGNORE,
  95. self::ABANDONED_REPORT,
  96. self::ABANDONED_FAIL,
  97. ];
  98. public const STATUS_OK = 0;
  99. public const STATUS_VULNERABLE = 1;
  100. public const STATUS_ABANDONED = 2;
  101. public function audit(IOInterface $io, RepositorySet $repoSet, array $packages, string $format, bool $warningOnly = true, array $ignoreList = [], string $abandoned = self::ABANDONED_FAIL, array $ignoredSeverities = []): int
  102. {
  103. $allAdvisories = $repoSet->getMatchingSecurityAdvisories($packages, $format === self::FORMAT_SUMMARY);
  104. if (count($allAdvisories) > 0 && $ignoreList !== [] && $format === self::FORMAT_SUMMARY) {
  105. $allAdvisories = $repoSet->getMatchingSecurityAdvisories($packages, false);
  106. }
  107. ['advisories' => $advisories, 'ignoredAdvisories' => $ignoredAdvisories] = $this->processAdvisories($allAdvisories, $ignoreList, $ignoredSeverities);
  108. $abandonedCount = 0;
  109. $affectedPackagesCount = count($advisories);
  110. if ($abandoned === self::ABANDONED_IGNORE) {
  111. $abandonedPackages = [];
  112. } else {
  113. $abandonedPackages = $this->filterAbandonedPackages($packages);
  114. if ($abandoned === self::ABANDONED_FAIL) {
  115. $abandonedCount = count($abandonedPackages);
  116. }
  117. }
  118. $auditBitmask = $this->calculateBitmask(0 < $affectedPackagesCount, 0 < $abandonedCount);
  119. if (self::FORMAT_JSON === $format) {
  120. $json = ['advisories' => $advisories];
  121. if ($ignoredAdvisories !== []) {
  122. $json['ignored-advisories'] = $ignoredAdvisories;
  123. }
  124. $json['abandoned'] = array_reduce($abandonedPackages, static function (array $carry, CompletePackageInterface $package): array {
  125. $carry[$package->getPrettyName()] = $package->getReplacementPackage();
  126. return $carry;
  127. }, []);
  128. $io->write(JsonFile::encode($json));
  129. return $auditBitmask;
  130. }
  131. $errorOrWarn = $warningOnly ? 'warning' : 'error';
  132. if ($affectedPackagesCount > 0 || count($ignoredAdvisories) > 0) {
  133. $passes = [
  134. [$ignoredAdvisories, "<info>Found %d ignored security vulnerability advisor%s affecting %d package%s%s</info>"],
  135. [$advisories, "<$errorOrWarn>Found %d security vulnerability advisor%s affecting %d package%s%s</$errorOrWarn>"],
  136. ];
  137. foreach ($passes as [$advisoriesToOutput, $message]) {
  138. [$pkgCount, $totalAdvisoryCount] = $this->countAdvisories($advisoriesToOutput);
  139. if ($pkgCount > 0) {
  140. $plurality = $totalAdvisoryCount === 1 ? 'y' : 'ies';
  141. $pkgPlurality = $pkgCount === 1 ? '' : 's';
  142. $punctuation = $format === 'summary' ? '.' : ':';
  143. $io->writeError(sprintf($message, $totalAdvisoryCount, $plurality, $pkgCount, $pkgPlurality, $punctuation));
  144. $this->outputAdvisories($io, $advisoriesToOutput, $format);
  145. }
  146. }
  147. if ($format === self::FORMAT_SUMMARY) {
  148. $io->writeError('Run "composer audit" for a full list of advisories.');
  149. }
  150. } else {
  151. $io->writeError('<info>No security vulnerability advisories found.</info>');
  152. }
  153. if (count($abandonedPackages) > 0 && $format !== self::FORMAT_SUMMARY) {
  154. $this->outputAbandonedPackages($io, $abandonedPackages, $format);
  155. }
  156. return $auditBitmask;
  157. }
  158. private function filterAbandonedPackages(array $packages): array
  159. {
  160. return array_filter($packages, static function (PackageInterface $pkg): bool {
  161. return $pkg instanceof CompletePackageInterface && $pkg->isAbandoned();
  162. });
  163. }
  164. private function processAdvisories(array $allAdvisories, array $ignoreList, array $ignoredSeverities): array
  165. {
  166. if ($ignoreList === [] && $ignoredSeverities === []) {
  167. return ['advisories' => $allAdvisories, 'ignoredAdvisories' => []];
  168. }
  169. if (\count($ignoreList) > 0 && !\array_is_list($ignoreList)) {
  170. $ignoredIds = array_keys($ignoreList);
  171. } else {
  172. $ignoredIds = $ignoreList;
  173. }
  174. $advisories = [];
  175. $ignored = [];
  176. $ignoreReason = null;
  177. foreach ($allAdvisories as $package => $pkgAdvisories) {
  178. foreach ($pkgAdvisories as $advisory) {
  179. $isActive = true;
  180. if (in_array($advisory->advisoryId, $ignoredIds, true)) {
  181. $isActive = false;
  182. $ignoreReason = $ignoreList[$advisory->advisoryId] ?? null;
  183. }
  184. if ($advisory instanceof SecurityAdvisory) {
  185. if (in_array($advisory->severity, $ignoredSeverities, true)) {
  186. $isActive = false;
  187. $ignoreReason = "Ignored via --ignore-severity={$advisory->severity}";
  188. }
  189. if (in_array($advisory->cve, $ignoredIds, true)) {
  190. $isActive = false;
  191. $ignoreReason = $ignoreList[$advisory->cve] ?? null;
  192. }
  193. foreach ($advisory->sources as $source) {
  194. if (in_array($source['remoteId'], $ignoredIds, true)) {
  195. $isActive = false;
  196. $ignoreReason = $ignoreList[$source['remoteId']] ?? null;
  197. break;
  198. }
  199. }
  200. }
  201. if ($isActive) {
  202. $advisories[$package][] = $advisory;
  203. continue;
  204. }
  205. if ($advisory instanceof SecurityAdvisory) {
  206. $advisory = $advisory->toIgnoredAdvisory($ignoreReason);
  207. }
  208. $ignored[$package][] = $advisory;
  209. }
  210. }
  211. return ['advisories' => $advisories, 'ignoredAdvisories' => $ignored];
  212. }
  213. private function countAdvisories(array $advisories): array
  214. {
  215. $count = 0;
  216. foreach ($advisories as $packageAdvisories) {
  217. $count += count($packageAdvisories);
  218. }
  219. return [count($advisories), $count];
  220. }
  221. private function outputAdvisories(IOInterface $io, array $advisories, string $format): void
  222. {
  223. switch ($format) {
  224. case self::FORMAT_TABLE:
  225. if (!($io instanceof ConsoleIO)) {
  226. throw new InvalidArgumentException('Cannot use table format with ' . get_class($io));
  227. }
  228. $this->outputAdvisoriesTable($io, $advisories);
  229. return;
  230. case self::FORMAT_PLAIN:
  231. $this->outputAdvisoriesPlain($io, $advisories);
  232. return;
  233. case self::FORMAT_SUMMARY:
  234. return;
  235. default:
  236. throw new InvalidArgumentException('Invalid format "'.$format.'".');
  237. }
  238. }
  239. private function outputAdvisoriesTable(ConsoleIO $io, array $advisories): void
  240. {
  241. foreach ($advisories as $packageAdvisories) {
  242. foreach ($packageAdvisories as $advisory) {
  243. $headers = [
  244. 'Package',
  245. 'Severity',
  246. 'CVE',
  247. 'Title',
  248. 'URL',
  249. 'Affected versions',
  250. 'Reported at',
  251. ];
  252. $row = [
  253. $advisory->packageName,
  254. $this->getSeverity($advisory),
  255. $this->getCVE($advisory),
  256. $advisory->title,
  257. $this->getURL($advisory),
  258. $advisory->affectedVersions->getPrettyString(),
  259. $advisory->reportedAt->format(DATE_ATOM),
  260. ];
  261. if ($advisory->cve === null) {
  262. $headers[] = 'Advisory ID';
  263. $row[] = $advisory->advisoryId;
  264. }
  265. if ($advisory instanceof IgnoredSecurityAdvisory) {
  266. $headers[] = 'Ignore reason';
  267. $row[] = $advisory->ignoreReason ?? 'None specified';
  268. }
  269. $io->getTable()
  270. ->setHorizontal()
  271. ->setHeaders($headers)
  272. ->addRow($row)
  273. ->setColumnWidth(1, 80)
  274. ->setColumnMaxWidth(1, 80)
  275. ->render();
  276. }
  277. }
  278. }
  279. private function outputAdvisoriesPlain(IOInterface $io, array $advisories): void
  280. {
  281. $error = [];
  282. $firstAdvisory = true;
  283. foreach ($advisories as $packageAdvisories) {
  284. foreach ($packageAdvisories as $advisory) {
  285. if (!$firstAdvisory) {
  286. $error[] = '--------';
  287. }
  288. $error[] = "Package: ".$advisory->packageName;
  289. $error[] = "Severity: ".$this->getSeverity($advisory);
  290. $error[] = "CVE: ".$this->getCVE($advisory);
  291. if ($advisory->cve === null) {
  292. $error[] = "Advisory ID: ".$advisory->advisoryId;
  293. }
  294. $error[] = "Title: ".OutputFormatter::escape($advisory->title);
  295. $error[] = "URL: ".$this->getURL($advisory);
  296. $error[] = "Affected versions: ".OutputFormatter::escape($advisory->affectedVersions->getPrettyString());
  297. $error[] = "Reported at: ".$advisory->reportedAt->format(DATE_ATOM);
  298. if ($advisory instanceof IgnoredSecurityAdvisory) {
  299. $error[] = "Ignore reason: ".($advisory->ignoreReason ?? 'None specified');
  300. }
  301. $firstAdvisory = false;
  302. }
  303. }
  304. $io->writeError($error);
  305. }
  306. private function outputAbandonedPackages(IOInterface $io, array $packages, string $format): void
  307. {
  308. $io->writeError(sprintf('<error>Found %d abandoned package%s:</error>', count($packages), count($packages) > 1 ? 's' : ''));
  309. if ($format === self::FORMAT_PLAIN) {
  310. foreach ($packages as $pkg) {
  311. $replacement = $pkg->getReplacementPackage() !== null
  312. ? 'Use '.$pkg->getReplacementPackage().' instead'
  313. : 'No replacement was suggested';
  314. $io->writeError(sprintf(
  315. '%s is abandoned. %s.',
  316. $this->getPackageNameWithLink($pkg),
  317. $replacement
  318. ));
  319. }
  320. return;
  321. }
  322. if (!($io instanceof ConsoleIO)) {
  323. throw new InvalidArgumentException('Cannot use table format with ' . get_class($io));
  324. }
  325. $table = $io->getTable()
  326. ->setHeaders(['Abandoned Package', 'Suggested Replacement'])
  327. ->setColumnWidth(1, 80)
  328. ->setColumnMaxWidth(1, 80);
  329. foreach ($packages as $pkg) {
  330. $replacement = $pkg->getReplacementPackage() !== null ? $pkg->getReplacementPackage() : 'none';
  331. $table->addRow([$this->getPackageNameWithLink($pkg), $replacement]);
  332. }
  333. $table->render();
  334. }
  335. private function getPackageNameWithLink(PackageInterface $package): string
  336. {
  337. $packageUrl = PackageInfo::getViewSourceOrHomepageUrl($package);
  338. return $packageUrl !== null ? '<href=' . OutputFormatter::escape($packageUrl) . '>' . $package->getPrettyName() . '</>' : $package->getPrettyName();
  339. }
  340. private function getSeverity(SecurityAdvisory $advisory): string
  341. {
  342. if ($advisory->severity === null) {
  343. return '';
  344. }
  345. return $advisory->severity;
  346. }
  347. private function getCVE(SecurityAdvisory $advisory): string
  348. {
  349. if ($advisory->cve === null) {
  350. return 'NO CVE';
  351. }
  352. return '<href=https://cve.mitre.org/cgi-bin/cvename.cgi?name='.$advisory->cve.'>'.$advisory->cve.'</>';
  353. }
  354. private function getURL(SecurityAdvisory $advisory): string
  355. {
  356. if ($advisory->link === null) {
  357. return '';
  358. }
  359. return '<href='.OutputFormatter::escape($advisory->link).'>'.OutputFormatter::escape($advisory->link).'</>';
  360. }
  361. private function calculateBitmask(bool $hasVulnerablePackages, bool $hasAbandonedPackages): int
  362. {
  363. $bitmask = self::STATUS_OK;
  364. if ($hasVulnerablePackages) {
  365. $bitmask |= self::STATUS_VULNERABLE;
  366. }
  367. if ($hasAbandonedPackages) {
  368. $bitmask |= self::STATUS_ABANDONED;
  369. }
  370. return $bitmask;
  371. }
  372. }
  373. <?php declare(strict_types=1);
  374. namespace Composer\Advisory;
  375. use Composer\Semver\Constraint\ConstraintInterface;
  376. use DateTimeImmutable;
  377. class IgnoredSecurityAdvisory extends SecurityAdvisory
  378. {
  379. public $ignoreReason;
  380. public function __construct(string $packageName, string $advisoryId, ConstraintInterface $affectedVersions, string $title, array $sources, DateTimeImmutable $reportedAt, ?string $cve = null, ?string $link = null, ?string $ignoreReason = null, ?string $severity = null)
  381. {
  382. parent::__construct($packageName, $advisoryId, $affectedVersions, $title, $sources, $reportedAt, $cve, $link, $severity);
  383. $this->ignoreReason = $ignoreReason;
  384. }
  385. #[\ReturnTypeWillChange]
  386. public function jsonSerialize()
  387. {
  388. $data = parent::jsonSerialize();
  389. if ($this->ignoreReason === NULL) {
  390. unset($data['ignoreReason']);
  391. }
  392. return $data;
  393. }
  394. }
  395. <?php declare(strict_types=1);
  396. namespace Composer\Advisory;
  397. use Composer\Semver\Constraint\ConstraintInterface;
  398. use Composer\Semver\VersionParser;
  399. use JsonSerializable;
  400. class PartialSecurityAdvisory implements JsonSerializable
  401. {
  402. public $advisoryId;
  403. public $packageName;
  404. public $affectedVersions;
  405. public static function create(string $packageName, array $data, VersionParser $parser): self
  406. {
  407. $constraint = $parser->parseConstraints($data['affectedVersions']);
  408. if (isset($data['title'], $data['sources'], $data['reportedAt'])) {
  409. return new SecurityAdvisory($packageName, $data['advisoryId'], $constraint, $data['title'], $data['sources'], new \DateTimeImmutable($data['reportedAt'], new \DateTimeZone('UTC')), $data['cve'] ?? null, $data['link'] ?? null, $data['severity'] ?? null);
  410. }
  411. return new self($packageName, $data['advisoryId'], $constraint);
  412. }
  413. public function __construct(string $packageName, string $advisoryId, ConstraintInterface $affectedVersions)
  414. {
  415. $this->advisoryId = $advisoryId;
  416. $this->packageName = $packageName;
  417. $this->affectedVersions = $affectedVersions;
  418. }
  419. #[\ReturnTypeWillChange]
  420. public function jsonSerialize()
  421. {
  422. $data = (array) $this;
  423. $data['affectedVersions'] = $data['affectedVersions']->getPrettyString();
  424. return $data;
  425. }
  426. }
  427. <?php declare(strict_types=1);
  428. namespace Composer\Advisory;
  429. use Composer\Semver\Constraint\ConstraintInterface;
  430. use DateTimeImmutable;
  431. class SecurityAdvisory extends PartialSecurityAdvisory
  432. {
  433. public $title;
  434. public $cve;
  435. public $link;
  436. public $reportedAt;
  437. public $sources;
  438. public $severity;
  439. public function __construct(string $packageName, string $advisoryId, ConstraintInterface $affectedVersions, string $title, array $sources, DateTimeImmutable $reportedAt, ?string $cve = null, ?string $link = null, ?string $severity = null)
  440. {
  441. parent::__construct($packageName, $advisoryId, $affectedVersions);
  442. $this->title = $title;
  443. $this->sources = $sources;
  444. $this->reportedAt = $reportedAt;
  445. $this->cve = $cve;
  446. $this->link = $link;
  447. $this->severity = $severity;
  448. }
  449. public function toIgnoredAdvisory(?string $ignoreReason): IgnoredSecurityAdvisory
  450. {
  451. return new IgnoredSecurityAdvisory(
  452. $this->packageName,
  453. $this->advisoryId,
  454. $this->affectedVersions,
  455. $this->title,
  456. $this->sources,
  457. $this->reportedAt,
  458. $this->cve,
  459. $this->link,
  460. $ignoreReason,
  461. $this->severity
  462. );
  463. }
  464. #[\ReturnTypeWillChange]
  465. public function jsonSerialize()
  466. {
  467. $data = parent::jsonSerialize();
  468. $data['reportedAt'] = $data['reportedAt']->format(DATE_RFC3339);
  469. return $data;
  470. }
  471. }
  472. <?php declare(strict_types=1);
  473. namespace Composer\Autoload;
  474. use Composer\ClassMapGenerator\ClassMap;
  475. use Composer\ClassMapGenerator\ClassMapGenerator;
  476. use Composer\Config;
  477. use Composer\EventDispatcher\EventDispatcher;
  478. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  479. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  480. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  481. use Composer\Installer\InstallationManager;
  482. use Composer\IO\IOInterface;
  483. use Composer\IO\NullIO;
  484. use Composer\Package\AliasPackage;
  485. use Composer\Package\PackageInterface;
  486. use Composer\Package\RootPackageInterface;
  487. use Composer\Pcre\Preg;
  488. use Composer\Repository\InstalledRepositoryInterface;
  489. use Composer\Semver\Constraint\Bound;
  490. use Composer\Util\Filesystem;
  491. use Composer\Util\Platform;
  492. use Composer\Script\ScriptEvents;
  493. use Composer\Util\PackageSorter;
  494. use Composer\Json\JsonFile;
  495. use Composer\Package\Locker;
  496. use Symfony\Component\Console\Formatter\OutputFormatter;
  497. class AutoloadGenerator
  498. {
  499. private $eventDispatcher;
  500. private $io;
  501. private $devMode = null;
  502. private $classMapAuthoritative = false;
  503. private $apcu = false;
  504. private $apcuPrefix;
  505. private $dryRun = false;
  506. private $runScripts = false;
  507. private $platformRequirementFilter;
  508. public function __construct(EventDispatcher $eventDispatcher, ?IOInterface $io = null)
  509. {
  510. $this->eventDispatcher = $eventDispatcher;
  511. $this->io = $io ?? new NullIO();
  512. $this->platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  513. }
  514. public function setDevMode(bool $devMode = true)
  515. {
  516. $this->devMode = $devMode;
  517. }
  518. public function setClassMapAuthoritative(bool $classMapAuthoritative)
  519. {
  520. $this->classMapAuthoritative = $classMapAuthoritative;
  521. }
  522. public function setApcu(bool $apcu, ?string $apcuPrefix = null)
  523. {
  524. $this->apcu = $apcu;
  525. $this->apcuPrefix = $apcuPrefix;
  526. }
  527. public function setRunScripts(bool $runScripts = true)
  528. {
  529. $this->runScripts = $runScripts;
  530. }
  531. public function setDryRun(bool $dryRun = true): void
  532. {
  533. $this->dryRun = $dryRun;
  534. }
  535. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  536. {
  537. trigger_error('AutoloadGenerator::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead.', E_USER_DEPRECATED);
  538. $this->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  539. }
  540. public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter)
  541. {
  542. $this->platformRequirementFilter = $platformRequirementFilter;
  543. }
  544. public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, string $targetDir, bool $scanPsrPackages = false, ?string $suffix = null, ?Locker $locker = null, bool $strictAmbiguous = false)
  545. {
  546. if ($this->classMapAuthoritative) {
  547. $scanPsrPackages = true;
  548. }
  549. if (null === $this->devMode) {
  550. $this->devMode = false;
  551. $installedJson = new JsonFile($config->get('vendor-dir').'/composer/installed.json');
  552. if ($installedJson->exists()) {
  553. $installedJson = $installedJson->read();
  554. if (isset($installedJson['dev'])) {
  555. $this->devMode = $installedJson['dev'];
  556. }
  557. }
  558. }
  559. if ($this->runScripts) {
  560. if (!isset($_SERVER['COMPOSER_DEV_MODE'])) {
  561. Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
  562. }
  563. $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, [], [
  564. 'optimize' => $scanPsrPackages,
  565. ]);
  566. }
  567. $classMapGenerator = new ClassMapGenerator(['php', 'inc', 'hh']);
  568. $classMapGenerator->avoidDuplicateScans();
  569. $filesystem = new Filesystem();
  570. $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
  571. $basePath = $filesystem->normalizePath(realpath(realpath(Platform::getCwd())));
  572. $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
  573. $useGlobalIncludePath = $config->get('use-include-path');
  574. $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
  575. $targetDir = $vendorPath.'/'.$targetDir;
  576. $filesystem->ensureDirectoryExists($targetDir);
  577. $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
  578. $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
  579. $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
  580. $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
  581. $namespacesFile = <<<EOF
  582. <?php
  583. // autoload_namespaces.php @generated by Composer
  584. \$vendorDir = $vendorPathCode;
  585. \$baseDir = $appBaseDirCode;
  586. return array(
  587. EOF;
  588. $psr4File = <<<EOF
  589. <?php
  590. // autoload_psr4.php @generated by Composer
  591. \$vendorDir = $vendorPathCode;
  592. \$baseDir = $appBaseDirCode;
  593. return array(
  594. EOF;
  595. $devPackageNames = $localRepo->getDevPackageNames();
  596. $packageMap = $this->buildPackageMap($installationManager, $rootPackage, $localRepo->getCanonicalPackages());
  597. if ($this->devMode) {
  598. $filteredDevPackages = false;
  599. } else {
  600. $filteredDevPackages = $devPackageNames ?: true;
  601. }
  602. $autoloads = $this->parseAutoloads($packageMap, $rootPackage, $filteredDevPackages);
  603. foreach ($autoloads['psr-0'] as $namespace => $paths) {
  604. $exportedPaths = [];
  605. foreach ($paths as $path) {
  606. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  607. }
  608. $exportedPrefix = var_export($namespace, true);
  609. $namespacesFile .= " $exportedPrefix => ";
  610. $namespacesFile .= "array(".implode(', ', $exportedPaths)."),\n";
  611. }
  612. $namespacesFile .= ");\n";
  613. foreach ($autoloads['psr-4'] as $namespace => $paths) {
  614. $exportedPaths = [];
  615. foreach ($paths as $path) {
  616. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  617. }
  618. $exportedPrefix = var_export($namespace, true);
  619. $psr4File .= " $exportedPrefix => ";
  620. $psr4File .= "array(".implode(', ', $exportedPaths)."),\n";
  621. }
  622. $psr4File .= ");\n";
  623. $targetDirLoader = null;
  624. $mainAutoload = $rootPackage->getAutoload();
  625. if ($rootPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
  626. $levels = substr_count($filesystem->normalizePath($rootPackage->getTargetDir()), '/') + 1;
  627. $prefixes = implode(', ', array_map(static function ($prefix): string {
  628. return var_export($prefix, true);
  629. }, array_keys($mainAutoload['psr-0'])));
  630. $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
  631. $targetDirLoader = <<<EOF
  632. public static function autoload(\$class)
  633. {
  634. \$dir = $baseDirFromTargetDirCode . '/';
  635. \$prefixes = array($prefixes);
  636. foreach (\$prefixes as \$prefix) {
  637. if (0 !== strpos(\$class, \$prefix)) {
  638. continue;
  639. }
  640. \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), $levels)).'.php';
  641. if (!\$path = stream_resolve_include_path(\$path)) {
  642. return false;
  643. }
  644. require \$path;
  645. return true;
  646. }
  647. }
  648. EOF;
  649. }
  650. $excluded = [];
  651. if (!empty($autoloads['exclude-from-classmap'])) {
  652. $excluded = $autoloads['exclude-from-classmap'];
  653. }
  654. foreach ($autoloads['classmap'] as $dir) {
  655. $classMapGenerator->scanPaths($dir, $this->buildExclusionRegex($dir, $excluded));
  656. }
  657. if ($scanPsrPackages) {
  658. $namespacesToScan = [];
  659. foreach (['psr-4', 'psr-0'] as $psrType) {
  660. foreach ($autoloads[$psrType] as $namespace => $paths) {
  661. $namespacesToScan[$namespace][] = ['paths' => $paths, 'type' => $psrType];
  662. }
  663. }
  664. krsort($namespacesToScan);
  665. foreach ($namespacesToScan as $namespace => $groups) {
  666. foreach ($groups as $group) {
  667. foreach ($group['paths'] as $dir) {
  668. $dir = $filesystem->normalizePath($filesystem->isAbsolutePath($dir) ? $dir : $basePath.'/'.$dir);
  669. if (!is_dir($dir)) {
  670. continue;
  671. }
  672. if (str_contains($vendorPath, $dir.'/')) {
  673. $exclusionRegex = $this->buildExclusionRegex($dir, array_merge($excluded, [$vendorPath.'/']));
  674. } else {
  675. $exclusionRegex = $this->buildExclusionRegex($dir, $excluded);
  676. }
  677. $classMapGenerator->scanPaths($dir, $exclusionRegex, $group['type'], $namespace);
  678. }
  679. }
  680. }
  681. }
  682. $classMap = $classMapGenerator->getClassMap();
  683. if ($strictAmbiguous) {
  684. $ambiguousClasses = $classMap->getAmbiguousClasses(false);
  685. } else {
  686. $ambiguousClasses = $classMap->getAmbiguousClasses();
  687. }
  688. foreach ($ambiguousClasses as $className => $ambiguousPaths) {
  689. if (count($ambiguousPaths) > 1) {
  690. $this->io->writeError(
  691. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  692. ' was found '. (count($ambiguousPaths) + 1) .'x: in "'.$classMap->getClassPath($className).'" and "'. implode('", "', $ambiguousPaths) .'", the first will be used.</warning>'
  693. );
  694. } else {
  695. $this->io->writeError(
  696. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  697. ' was found in both "'.$classMap->getClassPath($className).'" and "'. implode('", "', $ambiguousPaths) .'", the first will be used.</warning>'
  698. );
  699. }
  700. }
  701. if (\count($ambiguousClasses) > 0) {
  702. $this->io->writeError('<info>To resolve ambiguity in classes not under your control you can ignore them by path using <href='.OutputFormatter::escape('https://getcomposer.org/doc/04-schema.md#exclude-files-from-classmaps').'>exclude-files-from-classmap</>');
  703. }
  704. $classMap->clearPsrViolationsByPath($vendorPath);
  705. foreach ($classMap->getPsrViolations() as $msg) {
  706. $this->io->writeError("<warning>$msg</warning>");
  707. }
  708. $classMap->addClass('Composer\InstalledVersions', $vendorPath . '/composer/InstalledVersions.php');
  709. $classMap->sort();
  710. $classmapFile = <<<EOF
  711. <?php
  712. // autoload_classmap.php @generated by Composer
  713. \$vendorDir = $vendorPathCode;
  714. \$baseDir = $appBaseDirCode;
  715. return array(
  716. EOF;
  717. foreach ($classMap->getMap() as $className => $path) {
  718. $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
  719. $classmapFile .= ' '.var_export($className, true).' => '.$pathCode;
  720. }
  721. $classmapFile .= ");\n";
  722. if ('' === $suffix) {
  723. $suffix = null;
  724. }
  725. if (null === $suffix) {
  726. $suffix = $config->get('autoloader-suffix');
  727. if (null === $suffix && Filesystem::isReadable($vendorPath.'/autoload.php')) {
  728. $content = (string) file_get_contents($vendorPath.'/autoload.php');
  729. if (Preg::isMatch('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
  730. $suffix = $match[1];
  731. }
  732. }
  733. if (null === $suffix) {
  734. $suffix = $locker !== null && $locker->isLocked() ? $locker->getLockData()['content-hash'] : bin2hex(random_bytes(16));
  735. }
  736. }
  737. if ($this->dryRun) {
  738. return $classMap;
  739. }
  740. $filesystem->filePutContentsIfModified($targetDir.'/autoload_namespaces.php', $namespacesFile);
  741. $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
  742. $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
  743. $includePathFilePath = $targetDir.'/include_paths.php';
  744. if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
  745. $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
  746. } elseif (file_exists($includePathFilePath)) {
  747. unlink($includePathFilePath);
  748. }
  749. $includeFilesFilePath = $targetDir.'/autoload_files.php';
  750. if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)) {
  751. $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
  752. } elseif (file_exists($includeFilesFilePath)) {
  753. unlink($includeFilesFilePath);
  754. }
  755. $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath));
  756. $checkPlatform = $config->get('platform-check') !== false && !($this->platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter);
  757. $platformCheckContent = null;
  758. if ($checkPlatform) {
  759. $platformCheckContent = $this->getPlatformCheck($packageMap, $config->get('platform-check'), $devPackageNames);
  760. if (null === $platformCheckContent) {
  761. $checkPlatform = false;
  762. }
  763. }
  764. if ($checkPlatform) {
  765. $filesystem->filePutContentsIfModified($targetDir.'/platform_check.php', $platformCheckContent);
  766. } elseif (file_exists($targetDir.'/platform_check.php')) {
  767. unlink($targetDir.'/platform_check.php');
  768. }
  769. $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
  770. $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $checkPlatform));
  771. $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
  772. $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
  773. if ($this->runScripts) {
  774. $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, [], [
  775. 'optimize' => $scanPsrPackages,
  776. ]);
  777. }
  778. return $classMap;
  779. }
  780. private function buildExclusionRegex(string $dir, array $excluded): ?string
  781. {
  782. if ([] === $excluded) {
  783. return null;
  784. }
  785. if (file_exists($dir)) {
  786. $dirMatch = preg_quote(strtr(realpath($dir), '\\', '/'));
  787. foreach ($excluded as $index => $pattern) {
  788. $pattern = Preg::replace('{^(([^.+*?\[^\]$(){}=!<>|:\\\\#-]+|\\\\[.+*?\[^\]$(){}=!<>|:#-])*).*}', '$1', $pattern);
  789. if (0 !== strpos($pattern, $dirMatch) && 0 !== strpos($dirMatch, $pattern)) {
  790. unset($excluded[$index]);
  791. }
  792. }
  793. }
  794. return \count($excluded) > 0 ? '{(' . implode('|', $excluded) . ')}' : null;
  795. }
  796. public function buildPackageMap(InstallationManager $installationManager, PackageInterface $rootPackage, array $packages)
  797. {
  798. $packageMap = [[$rootPackage, '']];
  799. foreach ($packages as $package) {
  800. if ($package instanceof AliasPackage) {
  801. continue;
  802. }
  803. $this->validatePackage($package);
  804. $packageMap[] = [
  805. $package,
  806. $installationManager->getInstallPath($package),
  807. ];
  808. }
  809. return $packageMap;
  810. }
  811. protected function validatePackage(PackageInterface $package)
  812. {
  813. $autoload = $package->getAutoload();
  814. if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
  815. $name = $package->getName();
  816. $package->getTargetDir();
  817. throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '$name'.");
  818. }
  819. if (!empty($autoload['psr-4'])) {
  820. foreach ($autoload['psr-4'] as $namespace => $dirs) {
  821. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  822. throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '$namespace' does not, use '$namespace\\'.");
  823. }
  824. }
  825. }
  826. }
  827. public function parseAutoloads(array $packageMap, PackageInterface $rootPackage, $filteredDevPackages = false)
  828. {
  829. $rootPackageMap = array_shift($packageMap);
  830. if (is_array($filteredDevPackages)) {
  831. $packageMap = array_filter($packageMap, static function ($item) use ($filteredDevPackages): bool {
  832. return !in_array($item[0]->getName(), $filteredDevPackages, true);
  833. });
  834. } elseif ($filteredDevPackages) {
  835. $packageMap = $this->filterPackageMap($packageMap, $rootPackage);
  836. }
  837. $sortedPackageMap = $this->sortPackageMap($packageMap);
  838. $sortedPackageMap[] = $rootPackageMap;
  839. $reverseSortedMap = array_reverse($sortedPackageMap);
  840. $psr0 = $this->parseAutoloadsType($reverseSortedMap, 'psr-0', $rootPackage);
  841. $psr4 = $this->parseAutoloadsType($reverseSortedMap, 'psr-4', $rootPackage);
  842. $classmap = $this->parseAutoloadsType($reverseSortedMap, 'classmap', $rootPackage);
  843. $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $rootPackage);
  844. $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $rootPackage);
  845. krsort($psr0);
  846. krsort($psr4);
  847. return [
  848. 'psr-0' => $psr0,
  849. 'psr-4' => $psr4,
  850. 'classmap' => $classmap,
  851. 'files' => $files,
  852. 'exclude-from-classmap' => $exclude,
  853. ];
  854. }
  855. public function createLoader(array $autoloads, ?string $vendorDir = null)
  856. {
  857. $loader = new ClassLoader($vendorDir);
  858. if (isset($autoloads['psr-0'])) {
  859. foreach ($autoloads['psr-0'] as $namespace => $path) {
  860. $loader->add($namespace, $path);
  861. }
  862. }
  863. if (isset($autoloads['psr-4'])) {
  864. foreach ($autoloads['psr-4'] as $namespace => $path) {
  865. $loader->addPsr4($namespace, $path);
  866. }
  867. }
  868. if (isset($autoloads['classmap'])) {
  869. $excluded = [];
  870. if (!empty($autoloads['exclude-from-classmap'])) {
  871. $excluded = $autoloads['exclude-from-classmap'];
  872. }
  873. $classMapGenerator = new ClassMapGenerator(['php', 'inc', 'hh']);
  874. $classMapGenerator->avoidDuplicateScans();
  875. foreach ($autoloads['classmap'] as $dir) {
  876. try {
  877. $classMapGenerator->scanPaths($dir, $this->buildExclusionRegex($dir, $excluded));
  878. } catch (\RuntimeException $e) {
  879. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  880. }
  881. }
  882. $loader->addClassMap($classMapGenerator->getClassMap()->getMap());
  883. }
  884. return $loader;
  885. }
  886. protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode)
  887. {
  888. $includePaths = [];
  889. foreach ($packageMap as $item) {
  890. [$package, $installPath] = $item;
  891. if (null === $installPath) {
  892. continue;
  893. }
  894. if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
  895. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  896. }
  897. foreach ($package->getIncludePaths() as $includePath) {
  898. $includePath = trim($includePath, '/');
  899. $includePaths[] = $installPath === '' ? $includePath : $installPath.'/'.$includePath;
  900. }
  901. }
  902. if (\count($includePaths) === 0) {
  903. return null;
  904. }
  905. $includePathsCode = '';
  906. foreach ($includePaths as $path) {
  907. $includePathsCode .= " " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
  908. }
  909. return <<<EOF
  910. <?php
  911. // include_paths.php @generated by Composer
  912. \$vendorDir = $vendorPathCode;
  913. \$baseDir = $appBaseDirCode;
  914. return array(
  915. $includePathsCode);
  916. EOF;
  917. }
  918. protected function getIncludeFilesFile(array $files, Filesystem $filesystem, string $basePath, string $vendorPath, string $vendorPathCode, string $appBaseDirCode)
  919. {
  920. $files = array_map(
  921. function (string $functionFile) use ($filesystem, $basePath, $vendorPath): string {
  922. return $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile);
  923. },
  924. $files
  925. );
  926. $uniqueFiles = array_unique($files);
  927. if (count($uniqueFiles) < count($files)) {
  928. $this->io->writeError('<warning>The following "files" autoload rules are included multiple times, this may cause issues and should be resolved:</warning>');
  929. foreach (array_unique(array_diff_assoc($files, $uniqueFiles)) as $duplicateFile) {
  930. $this->io->writeError('<warning> - '.$duplicateFile.'</warning>');
  931. }
  932. }
  933. unset($uniqueFiles);
  934. $filesCode = '';
  935. foreach ($files as $fileIdentifier => $functionFile) {
  936. $filesCode .= ' ' . var_export($fileIdentifier, true) . ' => ' . $functionFile . ",\n";
  937. }
  938. if (!$filesCode) {
  939. return null;
  940. }
  941. return <<<EOF
  942. <?php
  943. // autoload_files.php @generated by Composer
  944. \$vendorDir = $vendorPathCode;
  945. \$baseDir = $appBaseDirCode;
  946. return array(
  947. $filesCode);
  948. EOF;
  949. }
  950. protected function getPathCode(Filesystem $filesystem, string $basePath, string $vendorPath, string $path)
  951. {
  952. if (!$filesystem->isAbsolutePath($path)) {
  953. $path = $basePath . '/' . $path;
  954. }
  955. $path = $filesystem->normalizePath($path);
  956. $baseDir = '';
  957. if (strpos($path.'/', $vendorPath.'/') === 0) {
  958. $path = (string) substr($path, strlen($vendorPath));
  959. $baseDir = '$vendorDir . ';
  960. } else {
  961. $path = $filesystem->normalizePath($filesystem->findShortestPath($basePath, $path, true));
  962. if (!$filesystem->isAbsolutePath($path)) {
  963. $baseDir = '$baseDir . ';
  964. $path = '/' . $path;
  965. }
  966. }
  967. if (Preg::isMatch('{\.phar([\\\\/]|$)}', $path)) {
  968. $baseDir = "'phar://' . " . $baseDir;
  969. }
  970. return $baseDir . var_export($path, true);
  971. }
  972. protected function getPlatformCheck(array $packageMap, $checkPlatform, array $devPackageNames)
  973. {
  974. $lowestPhpVersion = Bound::zero();
  975. $requiredPhp64bit = false;
  976. $requiredExtensions = [];
  977. $extensionProviders = [];
  978. foreach ($packageMap as $item) {
  979. $package = $item[0];
  980. foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) {
  981. if (Preg::isMatch('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  982. $extensionProviders[$match[1]][] = $link->getConstraint();
  983. }
  984. }
  985. }
  986. foreach ($packageMap as $item) {
  987. $package = $item[0];
  988. if (in_array($package->getName(), $devPackageNames, true)) {
  989. continue;
  990. }
  991. foreach ($package->getRequires() as $link) {
  992. if ($this->platformRequirementFilter->isIgnored($link->getTarget())) {
  993. continue;
  994. }
  995. if (in_array($link->getTarget(), ['php', 'php-64bit'], true)) {
  996. $constraint = $link->getConstraint();
  997. if ($constraint->getLowerBound()->compareTo($lowestPhpVersion, '>')) {
  998. $lowestPhpVersion = $constraint->getLowerBound();
  999. }
  1000. }
  1001. if ('php-64bit' === $link->getTarget()) {
  1002. $requiredPhp64bit = true;
  1003. }
  1004. if ($checkPlatform === true && Preg::isMatch('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  1005. if (isset($extensionProviders[$match[1]])) {
  1006. foreach ($extensionProviders[$match[1]] as $provided) {
  1007. if ($provided->matches($link->getConstraint())) {
  1008. continue 2;
  1009. }
  1010. }
  1011. }
  1012. if ($match[1] === 'zend-opcache') {
  1013. $match[1] = 'zend opcache';
  1014. }
  1015. $extension = var_export($match[1], true);
  1016. if ($match[1] === 'pcntl' || $match[1] === 'readline') {
  1017. $requiredExtensions[$extension] = "PHP_SAPI !== 'cli' || extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  1018. } else {
  1019. $requiredExtensions[$extension] = "extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  1020. }
  1021. }
  1022. }
  1023. }
  1024. ksort($requiredExtensions);
  1025. $formatToPhpVersionId = static function (Bound $bound): int {
  1026. if ($bound->isZero()) {
  1027. return 0;
  1028. }
  1029. if ($bound->isPositiveInfinity()) {
  1030. return 99999;
  1031. }
  1032. $version = str_replace('-', '.', $bound->getVersion());
  1033. $chunks = array_map('intval', explode('.', $version));
  1034. return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
  1035. };
  1036. $formatToHumanReadable = static function (Bound $bound) {
  1037. if ($bound->isZero()) {
  1038. return 0;
  1039. }
  1040. if ($bound->isPositiveInfinity()) {
  1041. return 99999;
  1042. }
  1043. $version = str_replace('-', '.', $bound->getVersion());
  1044. $chunks = explode('.', $version);
  1045. $chunks = array_slice($chunks, 0, 3);
  1046. return implode('.', $chunks);
  1047. };
  1048. $requiredPhp = '';
  1049. $requiredPhpError = '';
  1050. if (!$lowestPhpVersion->isZero()) {
  1051. $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>';
  1052. $requiredPhp = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion);
  1053. $requiredPhpError = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"';
  1054. }
  1055. if ($requiredPhp) {
  1056. $requiredPhp = <<<PHP_CHECK
  1057. if (!($requiredPhp)) {
  1058. \$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
  1059. }
  1060. PHP_CHECK;
  1061. }
  1062. if ($requiredPhp64bit) {
  1063. $requiredPhp .= <<<PHP_CHECK
  1064. if (PHP_INT_SIZE !== 8) {
  1065. \$issues[] = 'Your Composer dependencies require a 64-bit build of PHP.';
  1066. }
  1067. PHP_CHECK;
  1068. }
  1069. $requiredExtensions = implode('', $requiredExtensions);
  1070. if ('' !== $requiredExtensions) {
  1071. $requiredExtensions = <<<EXT_CHECKS
  1072. \$missingExtensions = array();
  1073. $requiredExtensions
  1074. if (\$missingExtensions) {
  1075. \$issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', \$missingExtensions) . '.';
  1076. }
  1077. EXT_CHECKS;
  1078. }
  1079. if (!$requiredPhp && !$requiredExtensions) {
  1080. return null;
  1081. }
  1082. return <<<PLATFORM_CHECK
  1083. <?php
  1084. // platform_check.php @generated by Composer
  1085. \$issues = array();
  1086. {$requiredPhp}{$requiredExtensions}
  1087. if (\$issues) {
  1088. if (!headers_sent()) {
  1089. header('HTTP/1.1 500 Internal Server Error');
  1090. }
  1091. if (!ini_get('display_errors')) {
  1092. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  1093. fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, \$issues) . PHP_EOL.PHP_EOL);
  1094. } elseif (!headers_sent()) {
  1095. 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;
  1096. }
  1097. }
  1098. trigger_error(
  1099. 'Composer detected issues in your platform: ' . implode(' ', \$issues),
  1100. E_USER_ERROR
  1101. );
  1102. }
  1103. PLATFORM_CHECK;
  1104. }
  1105. protected function getAutoloadFile(string $vendorPathToTargetDirCode, string $suffix)
  1106. {
  1107. $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
  1108. if ("'" === $lastChar || '"' === $lastChar) {
  1109. $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
  1110. } else {
  1111. $vendorPathToTargetDirCode .= " . '/autoload_real.php'";
  1112. }
  1113. return <<<AUTOLOAD
  1114. <?php
  1115. // autoload.php @generated by Composer
  1116. if (PHP_VERSION_ID < 50600) {
  1117. if (!headers_sent()) {
  1118. header('HTTP/1.1 500 Internal Server Error');
  1119. }
  1120. \$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;
  1121. if (!ini_get('display_errors')) {
  1122. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  1123. fwrite(STDERR, \$err);
  1124. } elseif (!headers_sent()) {
  1125. echo \$err;
  1126. }
  1127. }
  1128. throw new RuntimeException(\$err);
  1129. }
  1130. require_once $vendorPathToTargetDirCode;
  1131. return ComposerAutoloaderInit$suffix::getLoader();
  1132. AUTOLOAD;
  1133. }
  1134. protected function getAutoloadRealFile(bool $useClassMap, bool $useIncludePath, ?string $targetDirLoader, bool $useIncludeFiles, string $vendorPathCode, string $appBaseDirCode, string $suffix, bool $useGlobalIncludePath, string $prependAutoloader, bool $checkPlatform)
  1135. {
  1136. $file = <<<HEADER
  1137. <?php
  1138. // autoload_real.php @generated by Composer
  1139. class ComposerAutoloaderInit$suffix
  1140. {
  1141. private static \$loader;
  1142. public static function loadClassLoader(\$class)
  1143. {
  1144. if ('Composer\\Autoload\\ClassLoader' === \$class) {
  1145. require __DIR__ . '/ClassLoader.php';
  1146. }
  1147. }
  1148. /**
  1149. * @return \Composer\Autoload\ClassLoader
  1150. */
  1151. public static function getLoader()
  1152. {
  1153. if (null !== self::\$loader) {
  1154. return self::\$loader;
  1155. }
  1156. HEADER;
  1157. if ($checkPlatform) {
  1158. $file .= <<<'PLATFORM_CHECK'
  1159. require __DIR__ . '/platform_check.php';
  1160. PLATFORM_CHECK;
  1161. }
  1162. $file .= <<<CLASSLOADER_INIT
  1163. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
  1164. self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(__DIR__));
  1165. spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
  1166. CLASSLOADER_INIT;
  1167. if ($useIncludePath) {
  1168. $file .= <<<'INCLUDE_PATH'
  1169. $includePaths = require __DIR__ . '/include_paths.php';
  1170. $includePaths[] = get_include_path();
  1171. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  1172. INCLUDE_PATH;
  1173. }
  1174. $file .= <<<STATIC_INIT
  1175. require __DIR__ . '/autoload_static.php';
  1176. call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
  1177. STATIC_INIT;
  1178. if ($this->classMapAuthoritative) {
  1179. $file .= <<<'CLASSMAPAUTHORITATIVE'
  1180. $loader->setClassMapAuthoritative(true);
  1181. CLASSMAPAUTHORITATIVE;
  1182. }
  1183. if ($this->apcu) {
  1184. $apcuPrefix = var_export(($this->apcuPrefix !== null ? $this->apcuPrefix : bin2hex(random_bytes(10))), true);
  1185. $file .= <<<APCU
  1186. \$loader->setApcuPrefix($apcuPrefix);
  1187. APCU;
  1188. }
  1189. if ($useGlobalIncludePath) {
  1190. $file .= <<<'INCLUDEPATH'
  1191. $loader->setUseIncludePath(true);
  1192. INCLUDEPATH;
  1193. }
  1194. if ($targetDirLoader) {
  1195. $file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
  1196. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true, true);
  1197. REGISTER_TARGET_DIR_AUTOLOAD;
  1198. }
  1199. $file .= <<<REGISTER_LOADER
  1200. \$loader->register($prependAutoloader);
  1201. REGISTER_LOADER;
  1202. if ($useIncludeFiles) {
  1203. $file .= <<<INCLUDE_FILES
  1204. \$filesToLoad = \Composer\Autoload\ComposerStaticInit$suffix::\$files;
  1205. \$requireFile = \Closure::bind(static function (\$fileIdentifier, \$file) {
  1206. if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
  1207. \$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
  1208. require \$file;
  1209. }
  1210. }, null, null);
  1211. foreach (\$filesToLoad as \$fileIdentifier => \$file) {
  1212. \$requireFile(\$fileIdentifier, \$file);
  1213. }
  1214. INCLUDE_FILES;
  1215. }
  1216. $file .= <<<METHOD_FOOTER
  1217. return \$loader;
  1218. }
  1219. METHOD_FOOTER;
  1220. $file .= $targetDirLoader;
  1221. return $file . <<<FOOTER
  1222. }
  1223. FOOTER;
  1224. }
  1225. protected function getStaticFile(string $suffix, string $targetDir, string $vendorPath, string $basePath)
  1226. {
  1227. $file = <<<HEADER
  1228. <?php
  1229. // autoload_static.php @generated by Composer
  1230. namespace Composer\Autoload;
  1231. class ComposerStaticInit$suffix
  1232. {
  1233. HEADER;
  1234. $loader = new ClassLoader();
  1235. $map = require $targetDir . '/autoload_namespaces.php';
  1236. foreach ($map as $namespace => $path) {
  1237. $loader->set($namespace, $path);
  1238. }
  1239. $map = require $targetDir . '/autoload_psr4.php';
  1240. foreach ($map as $namespace => $path) {
  1241. $loader->setPsr4($namespace, $path);
  1242. }
  1243. $classMap = require $targetDir . '/autoload_classmap.php';
  1244. if ($classMap) {
  1245. $loader->addClassMap($classMap);
  1246. }
  1247. $filesystem = new Filesystem();
  1248. $vendorPathCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  1249. $vendorPharPathCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  1250. $appBaseDirCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  1251. $appBaseDirPharCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  1252. $absoluteVendorPathCode = ' => ' . substr(var_export(rtrim($vendorDir, '\\/') . '/', true), 0, -1);
  1253. $absoluteVendorPharPathCode = ' => ' . substr(var_export(rtrim('phar://' . $vendorDir, '\\/') . '/', true), 0, -1);
  1254. $absoluteAppBaseDirCode = ' => ' . substr(var_export(rtrim($baseDir, '\\/') . '/', true), 0, -1);
  1255. $absoluteAppBaseDirPharCode = ' => ' . substr(var_export(rtrim('phar://' . $baseDir, '\\/') . '/', true), 0, -1);
  1256. $initializer = '';
  1257. $prefix = "\0Composer\Autoload\ClassLoader\0";
  1258. $prefixLen = strlen($prefix);
  1259. if (file_exists($targetDir . '/autoload_files.php')) {
  1260. $maps = ['files' => require $targetDir . '/autoload_files.php'];
  1261. } else {
  1262. $maps = [];
  1263. }
  1264. foreach ((array) $loader as $prop => $value) {
  1265. if (!is_array($value) || \count($value) === 0 || !str_starts_with($prop, $prefix)) {
  1266. continue;
  1267. }
  1268. $maps[substr($prop, $prefixLen)] = $value;
  1269. }
  1270. foreach ($maps as $prop => $value) {
  1271. $value = strtr(
  1272. var_export($value, true),
  1273. [
  1274. $absoluteVendorPathCode => $vendorPathCode,
  1275. $absoluteVendorPharPathCode => $vendorPharPathCode,
  1276. $absoluteAppBaseDirCode => $appBaseDirCode,
  1277. $absoluteAppBaseDirPharCode => $appBaseDirPharCode,
  1278. ]
  1279. );
  1280. $value = ltrim(Preg::replace('/^ */m', ' $0$0', $value));
  1281. $file .= sprintf(" public static $%s = %s;\n\n", $prop, $value);
  1282. if ('files' !== $prop) {
  1283. $initializer .= " \$loader->$prop = ComposerStaticInit$suffix::\$$prop;\n";
  1284. }
  1285. }
  1286. return $file . <<<INITIALIZER
  1287. public static function getInitializer(ClassLoader \$loader)
  1288. {
  1289. return \Closure::bind(function () use (\$loader) {
  1290. $initializer
  1291. }, null, ClassLoader::class);
  1292. }
  1293. }
  1294. INITIALIZER;
  1295. }
  1296. protected function parseAutoloadsType(array $packageMap, string $type, RootPackageInterface $rootPackage)
  1297. {
  1298. $autoloads = [];
  1299. foreach ($packageMap as $item) {
  1300. [$package, $installPath] = $item;
  1301. if (null === $installPath) {
  1302. continue;
  1303. }
  1304. $autoload = $package->getAutoload();
  1305. if ($this->devMode && $package === $rootPackage) {
  1306. $autoload = array_merge_recursive($autoload, $package->getDevAutoload());
  1307. }
  1308. if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
  1309. continue;
  1310. }
  1311. if (null !== $package->getTargetDir() && $package !== $rootPackage) {
  1312. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  1313. }
  1314. foreach ($autoload[$type] as $namespace => $paths) {
  1315. if (in_array($type, ['psr-4', 'psr-0'], true)) {
  1316. $namespace = ltrim($namespace, '\\');
  1317. }
  1318. foreach ((array) $paths as $path) {
  1319. if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !Filesystem::isReadable($installPath.'/'.$path)) {
  1320. if ($package === $rootPackage) {
  1321. $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(['/', '\\'], '<dirsep>', $package->getTargetDir())));
  1322. $path = ltrim(Preg::replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');
  1323. } else {
  1324. $path = $package->getTargetDir() . '/' . $path;
  1325. }
  1326. }
  1327. if ($type === 'exclude-from-classmap') {
  1328. $path = Preg::replace('{/+}', '/', preg_quote(trim(strtr($path, '\\', '/'), '/')));
  1329. $path = strtr($path, ['\\*\\*' => '.+?', '\\*' => '[^/]+?']);
  1330. $updir = null;
  1331. $path = Preg::replaceCallback(
  1332. '{^((?:(?:\\\\\\.){1,2}+/)+)}',
  1333. static function ($matches) use (&$updir): string {
  1334. $updir = str_replace('\\.', '.', $matches[1]);
  1335. return '';
  1336. },
  1337. $path
  1338. );
  1339. if (empty($installPath)) {
  1340. $installPath = strtr(Platform::getCwd(), '\\', '/');
  1341. }
  1342. $resolvedPath = realpath($installPath . '/' . $updir);
  1343. if (false === $resolvedPath) {
  1344. continue;
  1345. }
  1346. $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path . '($|/)';
  1347. continue;
  1348. }
  1349. $relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
  1350. if ($type === 'files') {
  1351. $autoloads[$this->getFileIdentifier($package, $path)] = $relativePath;
  1352. continue;
  1353. }
  1354. if ($type === 'classmap') {
  1355. $autoloads[] = $relativePath;
  1356. continue;
  1357. }
  1358. $autoloads[$namespace][] = $relativePath;
  1359. }
  1360. }
  1361. }
  1362. return $autoloads;
  1363. }
  1364. protected function getFileIdentifier(PackageInterface $package, string $path)
  1365. {
  1366. return hash('md5', $package->getName() . ':' . $path);
  1367. }
  1368. protected function filterPackageMap(array $packageMap, RootPackageInterface $rootPackage)
  1369. {
  1370. $packages = [];
  1371. $include = [];
  1372. $replacedBy = [];
  1373. foreach ($packageMap as $item) {
  1374. $package = $item[0];
  1375. $name = $package->getName();
  1376. $packages[$name] = $package;
  1377. foreach ($package->getReplaces() as $replace) {
  1378. $replacedBy[$replace->getTarget()] = $name;
  1379. }
  1380. }
  1381. $add = static function (PackageInterface $package) use (&$add, $packages, &$include, $replacedBy): void {
  1382. foreach ($package->getRequires() as $link) {
  1383. $target = $link->getTarget();
  1384. if (isset($replacedBy[$target])) {
  1385. $target = $replacedBy[$target];
  1386. }
  1387. if (!isset($include[$target])) {
  1388. $include[$target] = true;
  1389. if (isset($packages[$target])) {
  1390. $add($packages[$target]);
  1391. }
  1392. }
  1393. }
  1394. };
  1395. $add($rootPackage);
  1396. return array_filter(
  1397. $packageMap,
  1398. static function ($item) use ($include): bool {
  1399. $package = $item[0];
  1400. foreach ($package->getNames() as $name) {
  1401. if (isset($include[$name])) {
  1402. return true;
  1403. }
  1404. }
  1405. return false;
  1406. }
  1407. );
  1408. }
  1409. protected function sortPackageMap(array $packageMap)
  1410. {
  1411. $packages = [];
  1412. $paths = [];
  1413. foreach ($packageMap as $item) {
  1414. [$package, $path] = $item;
  1415. $name = $package->getName();
  1416. $packages[$name] = $package;
  1417. $paths[$name] = $path;
  1418. }
  1419. $sortedPackages = PackageSorter::sortPackages($packages);
  1420. $sortedPackageMap = [];
  1421. foreach ($sortedPackages as $package) {
  1422. $name = $package->getName();
  1423. $sortedPackageMap[] = [$packages[$name], $paths[$name]];
  1424. }
  1425. return $sortedPackageMap;
  1426. }
  1427. }
  1428. function composerRequire(string $fileIdentifier, string $file): void
  1429. {
  1430. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  1431. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  1432. require $file;
  1433. }
  1434. }
  1435. <?php declare(strict_types=1);
  1436. namespace Composer\Autoload;
  1437. use Composer\ClassMapGenerator\FileList;
  1438. use Composer\IO\IOInterface;
  1439. class ClassMapGenerator
  1440. {
  1441. public static function dump(iterable $dirs, string $file): void
  1442. {
  1443. $maps = [];
  1444. foreach ($dirs as $dir) {
  1445. $maps = array_merge($maps, static::createMap($dir));
  1446. }
  1447. file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
  1448. }
  1449. public static function createMap($path, ?string $excluded = null, ?IOInterface $io = null, ?string $namespace = null, ?string $autoloadType = null, array &$scannedFiles = []): array
  1450. {
  1451. $generator = new \Composer\ClassMapGenerator\ClassMapGenerator(['php', 'inc', 'hh']);
  1452. $fileList = new FileList();
  1453. $fileList->files = $scannedFiles;
  1454. $generator->avoidDuplicateScans($fileList);
  1455. $generator->scanPaths($path, $excluded, $autoloadType ?? 'classmap', $namespace);
  1456. $classMap = $generator->getClassMap();
  1457. $scannedFiles = $fileList->files;
  1458. if ($io !== null) {
  1459. foreach ($classMap->getPsrViolations() as $msg) {
  1460. $io->writeError("<warning>$msg</warning>");
  1461. }
  1462. foreach ($classMap->getAmbiguousClasses() as $class => $paths) {
  1463. if (count($paths) > 1) {
  1464. $io->writeError(
  1465. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  1466. ' was found '. (count($paths) + 1) .'x: in "'.$classMap->getClassPath($class).'" and "'. implode('", "', $paths) .'", the first will be used.</warning>'
  1467. );
  1468. } else {
  1469. $io->writeError(
  1470. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  1471. ' was found in both "'.$classMap->getClassPath($class).'" and "'. implode('", "', $paths) .'", the first will be used.</warning>'
  1472. );
  1473. }
  1474. }
  1475. }
  1476. return $classMap->getMap();
  1477. }
  1478. }
  1479. <?php declare(strict_types=1);
  1480. namespace Composer;
  1481. use Composer\IO\IOInterface;
  1482. use Composer\Pcre\Preg;
  1483. use Composer\Util\Filesystem;
  1484. use Composer\Util\Platform;
  1485. use Composer\Util\Silencer;
  1486. use Symfony\Component\Finder\Finder;
  1487. class Cache
  1488. {
  1489. private static $cacheCollected = null;
  1490. private $io;
  1491. private $root;
  1492. private $enabled = null;
  1493. private $allowlist;
  1494. private $filesystem;
  1495. private $readOnly;
  1496. public function __construct(IOInterface $io, string $cacheDir, string $allowlist = 'a-z0-9._', ?Filesystem $filesystem = null, bool $readOnly = false)
  1497. {
  1498. $this->io = $io;
  1499. $this->root = rtrim($cacheDir, '/\\') . '/';
  1500. $this->allowlist = $allowlist;
  1501. $this->filesystem = $filesystem ?: new Filesystem();
  1502. $this->readOnly = $readOnly;
  1503. if (!self::isUsable($cacheDir)) {
  1504. $this->enabled = false;
  1505. }
  1506. }
  1507. public function setReadOnly(bool $readOnly)
  1508. {
  1509. $this->readOnly = $readOnly;
  1510. }
  1511. public function isReadOnly()
  1512. {
  1513. return $this->readOnly;
  1514. }
  1515. public static function isUsable(string $path)
  1516. {
  1517. return !Preg::isMatch('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
  1518. }
  1519. public function isEnabled()
  1520. {
  1521. if ($this->enabled === null) {
  1522. $this->enabled = true;
  1523. if (
  1524. !$this->readOnly
  1525. && (
  1526. (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
  1527. || !is_writable($this->root)
  1528. )
  1529. ) {
  1530. $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>');
  1531. $this->enabled = false;
  1532. }
  1533. }
  1534. return $this->enabled;
  1535. }
  1536. public function getRoot()
  1537. {
  1538. return $this->root;
  1539. }
  1540. public function read(string $file)
  1541. {
  1542. if ($this->isEnabled()) {
  1543. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1544. if (file_exists($this->root . $file)) {
  1545. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1546. return file_get_contents($this->root . $file);
  1547. }
  1548. }
  1549. return false;
  1550. }
  1551. public function write(string $file, string $contents)
  1552. {
  1553. $wasEnabled = $this->enabled === true;
  1554. if ($this->isEnabled() && !$this->readOnly) {
  1555. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1556. $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
  1557. $tempFileName = $this->root . $file . bin2hex(random_bytes(5)) . '.tmp';
  1558. try {
  1559. return file_put_contents($tempFileName, $contents) !== false && rename($tempFileName, $this->root . $file);
  1560. } catch (\ErrorException $e) {
  1561. if ($wasEnabled) {
  1562. clearstatcache();
  1563. $this->enabled = null;
  1564. return $this->write($file, $contents);
  1565. }
  1566. $this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
  1567. if (Preg::isMatch('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
  1568. unlink($tempFileName);
  1569. $message = sprintf(
  1570. '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$s bytes of free space available</warning>',
  1571. $tempFileName,
  1572. $m[1],
  1573. $m[2],
  1574. function_exists('disk_free_space') ? @disk_free_space(dirname($tempFileName)) : 'unknown'
  1575. );
  1576. $this->io->writeError($message);
  1577. return false;
  1578. }
  1579. throw $e;
  1580. }
  1581. }
  1582. return false;
  1583. }
  1584. public function copyFrom(string $file, string $source)
  1585. {
  1586. if ($this->isEnabled() && !$this->readOnly) {
  1587. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1588. $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
  1589. if (!file_exists($source)) {
  1590. $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');
  1591. } elseif ($this->io->isDebug()) {
  1592. $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
  1593. }
  1594. return $this->filesystem->copy($source, $this->root . $file);
  1595. }
  1596. return false;
  1597. }
  1598. public function copyTo(string $file, string $target)
  1599. {
  1600. if ($this->isEnabled()) {
  1601. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1602. if (file_exists($this->root . $file)) {
  1603. try {
  1604. touch($this->root . $file, (int) filemtime($this->root . $file), time());
  1605. } catch (\ErrorException $e) {
  1606. Silencer::call('touch', $this->root . $file);
  1607. }
  1608. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1609. return $this->filesystem->copy($this->root . $file, $target);
  1610. }
  1611. }
  1612. return false;
  1613. }
  1614. public function gcIsNecessary()
  1615. {
  1616. if (self::$cacheCollected) {
  1617. return false;
  1618. }
  1619. self::$cacheCollected = true;
  1620. if (Platform::getEnv('COMPOSER_TEST_SUITE')) {
  1621. return false;
  1622. }
  1623. if (Platform::isInputCompletionProcess()) {
  1624. return false;
  1625. }
  1626. return !random_int(0, 50);
  1627. }
  1628. public function remove(string $file)
  1629. {
  1630. if ($this->isEnabled() && !$this->readOnly) {
  1631. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1632. if (file_exists($this->root . $file)) {
  1633. return $this->filesystem->unlink($this->root . $file);
  1634. }
  1635. }
  1636. return false;
  1637. }
  1638. public function clear()
  1639. {
  1640. if ($this->isEnabled() && !$this->readOnly) {
  1641. $this->filesystem->emptyDirectory($this->root);
  1642. return true;
  1643. }
  1644. return false;
  1645. }
  1646. public function getAge(string $file)
  1647. {
  1648. if ($this->isEnabled()) {
  1649. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1650. if (file_exists($this->root . $file) && ($mtime = filemtime($this->root . $file)) !== false) {
  1651. return abs(time() - $mtime);
  1652. }
  1653. }
  1654. return false;
  1655. }
  1656. public function gc(int $ttl, int $maxSize)
  1657. {
  1658. if ($this->isEnabled() && !$this->readOnly) {
  1659. $expire = new \DateTime();
  1660. $expire->modify('-'.$ttl.' seconds');
  1661. $finder = $this->getFinder()->date('until '.$expire->format('Y-m-d H:i:s'));
  1662. foreach ($finder as $file) {
  1663. $this->filesystem->unlink($file->getPathname());
  1664. }
  1665. $totalSize = $this->filesystem->size($this->root);
  1666. if ($totalSize > $maxSize) {
  1667. $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
  1668. while ($totalSize > $maxSize && $iterator->valid()) {
  1669. $filepath = $iterator->current()->getPathname();
  1670. $totalSize -= $this->filesystem->size($filepath);
  1671. $this->filesystem->unlink($filepath);
  1672. $iterator->next();
  1673. }
  1674. }
  1675. self::$cacheCollected = true;
  1676. return true;
  1677. }
  1678. return false;
  1679. }
  1680. public function gcVcsCache(int $ttl): bool
  1681. {
  1682. if ($this->isEnabled()) {
  1683. $expire = new \DateTime();
  1684. $expire->modify('-'.$ttl.' seconds');
  1685. $finder = Finder::create()->in($this->root)->directories()->depth(0)->date('until '.$expire->format('Y-m-d H:i:s'));
  1686. foreach ($finder as $file) {
  1687. $this->filesystem->removeDirectory($file->getPathname());
  1688. }
  1689. self::$cacheCollected = true;
  1690. return true;
  1691. }
  1692. return false;
  1693. }
  1694. public function sha1(string $file)
  1695. {
  1696. if ($this->isEnabled()) {
  1697. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1698. if (file_exists($this->root . $file)) {
  1699. return hash_file('sha1', $this->root . $file);
  1700. }
  1701. }
  1702. return false;
  1703. }
  1704. public function sha256(string $file)
  1705. {
  1706. if ($this->isEnabled()) {
  1707. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1708. if (file_exists($this->root . $file)) {
  1709. return hash_file('sha256', $this->root . $file);
  1710. }
  1711. }
  1712. return false;
  1713. }
  1714. protected function getFinder()
  1715. {
  1716. return Finder::create()->in($this->root)->files();
  1717. }
  1718. }
  1719. <?php declare(strict_types=1);
  1720. namespace Composer\Command;
  1721. use Composer\Composer;
  1722. use Symfony\Component\Console\Input\InputInterface;
  1723. use Symfony\Component\Console\Output\OutputInterface;
  1724. class AboutCommand extends BaseCommand
  1725. {
  1726. protected function configure(): void
  1727. {
  1728. $this
  1729. ->setName('about')
  1730. ->setDescription('Shows a short information about Composer')
  1731. ->setHelp(
  1732. <<<EOT
  1733. <info>php composer.phar about</info>
  1734. EOT
  1735. )
  1736. ;
  1737. }
  1738. protected function execute(InputInterface $input, OutputInterface $output): int
  1739. {
  1740. $composerVersion = Composer::getVersion();
  1741. $this->getIO()->write(
  1742. <<<EOT
  1743. <info>Composer - Dependency Manager for PHP - version $composerVersion</info>
  1744. <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
  1745. See https://getcomposer.org/ for more information.</comment>
  1746. EOT
  1747. );
  1748. return 0;
  1749. }
  1750. }
  1751. <?php declare(strict_types=1);
  1752. namespace Composer\Command;
  1753. use Composer\Factory;
  1754. use Composer\IO\IOInterface;
  1755. use Composer\Config;
  1756. use Composer\Composer;
  1757. use Composer\Package\BasePackage;
  1758. use Composer\Package\CompletePackageInterface;
  1759. use Composer\Package\Version\VersionParser;
  1760. use Composer\Package\Version\VersionSelector;
  1761. use Composer\Pcre\Preg;
  1762. use Composer\Repository\CompositeRepository;
  1763. use Composer\Repository\RepositoryFactory;
  1764. use Composer\Repository\RepositorySet;
  1765. use Composer\Script\ScriptEvents;
  1766. use Composer\Plugin\CommandEvent;
  1767. use Composer\Plugin\PluginEvents;
  1768. use Composer\Util\Filesystem;
  1769. use Composer\Util\Loop;
  1770. use Composer\Util\Platform;
  1771. use Composer\Util\ProcessExecutor;
  1772. use Composer\Console\Input\InputArgument;
  1773. use Symfony\Component\Console\Input\InputInterface;
  1774. use Composer\Console\Input\InputOption;
  1775. use Symfony\Component\Console\Output\OutputInterface;
  1776. class ArchiveCommand extends BaseCommand
  1777. {
  1778. use CompletionTrait;
  1779. private const FORMATS = ['tar', 'tar.gz', 'tar.bz2', 'zip'];
  1780. protected function configure(): void
  1781. {
  1782. $this
  1783. ->setName('archive')
  1784. ->setDescription('Creates an archive of this composer package')
  1785. ->setDefinition([
  1786. new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project', null, $this->suggestAvailablePackage()),
  1787. new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'),
  1788. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar, tar.gz, tar.bz2 or zip (default tar)', null, self::FORMATS),
  1789. new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
  1790. new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
  1791. .' Note that the format will be appended.'),
  1792. new InputOption('ignore-filters', null, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
  1793. ])
  1794. ->setHelp(
  1795. <<<EOT
  1796. The <info>archive</info> command creates an archive of the specified format
  1797. containing the files and directories of the Composer project or the specified
  1798. package in the specified version and writes it to the specified directory.
  1799. <info>php composer.phar archive [--format=zip] [--dir=/foo] [--file=filename] [package [version]]</info>
  1800. Read more at https://getcomposer.org/doc/03-cli.md#archive
  1801. EOT
  1802. )
  1803. ;
  1804. }
  1805. protected function execute(InputInterface $input, OutputInterface $output): int
  1806. {
  1807. $composer = $this->tryComposer();
  1808. $config = null;
  1809. if ($composer) {
  1810. $config = $composer->getConfig();
  1811. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
  1812. $eventDispatcher = $composer->getEventDispatcher();
  1813. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  1814. $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
  1815. }
  1816. if (!$config) {
  1817. $config = Factory::createConfig();
  1818. }
  1819. $format = $input->getOption('format') ?? $config->get('archive-format');
  1820. $dir = $input->getOption('dir') ?? $config->get('archive-dir');
  1821. $returnCode = $this->archive(
  1822. $this->getIO(),
  1823. $config,
  1824. $input->getArgument('package'),
  1825. $input->getArgument('version'),
  1826. $format,
  1827. $dir,
  1828. $input->getOption('file'),
  1829. $input->getOption('ignore-filters'),
  1830. $composer
  1831. );
  1832. if (0 === $returnCode && $composer) {
  1833. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
  1834. }
  1835. return $returnCode;
  1836. }
  1837. protected function archive(IOInterface $io, Config $config, ?string $packageName, ?string $version, string $format, string $dest, ?string $fileName, bool $ignoreFilters, ?Composer $composer): int
  1838. {
  1839. if ($composer) {
  1840. $archiveManager = $composer->getArchiveManager();
  1841. } else {
  1842. $factory = new Factory;
  1843. $process = new ProcessExecutor();
  1844. $httpDownloader = Factory::createHttpDownloader($io, $config);
  1845. $downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
  1846. $archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
  1847. }
  1848. if ($packageName) {
  1849. $package = $this->selectPackage($io, $packageName, $version);
  1850. if (!$package) {
  1851. return 1;
  1852. }
  1853. } else {
  1854. $package = $this->requireComposer()->getPackage();
  1855. }
  1856. $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
  1857. $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
  1858. $fs = new Filesystem;
  1859. $shortPath = $fs->findShortestPath(Platform::getCwd(), $packagePath, true);
  1860. $io->writeError('Created: ', false);
  1861. $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
  1862. return 0;
  1863. }
  1864. protected function selectPackage(IOInterface $io, string $packageName, ?string $version = null)
  1865. {
  1866. $io->writeError('<info>Searching for the specified package.</info>');
  1867. if ($composer = $this->tryComposer()) {
  1868. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  1869. $repo = new CompositeRepository(array_merge([$localRepo], $composer->getRepositoryManager()->getRepositories()));
  1870. $minStability = $composer->getPackage()->getMinimumStability();
  1871. } else {
  1872. $defaultRepos = RepositoryFactory::defaultReposWithDefaultManager($io);
  1873. $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
  1874. $repo = new CompositeRepository($defaultRepos);
  1875. $minStability = 'stable';
  1876. }
  1877. if ($version !== null && Preg::isMatchStrictGroups('{@(stable|RC|beta|alpha|dev)$}i', $version, $match)) {
  1878. $minStability = VersionParser::normalizeStability($match[1]);
  1879. $version = (string) substr($version, 0, -strlen($match[0]));
  1880. }
  1881. $repoSet = new RepositorySet($minStability);
  1882. $repoSet->addRepository($repo);
  1883. $parser = new VersionParser();
  1884. $constraint = $version !== null ? $parser->parseConstraints($version) : null;
  1885. $packages = $repoSet->findPackages(strtolower($packageName), $constraint);
  1886. if (count($packages) > 1) {
  1887. $versionSelector = new VersionSelector($repoSet);
  1888. $package = $versionSelector->findBestCandidate(strtolower($packageName), $version, $minStability);
  1889. if ($package === false) {
  1890. $package = reset($packages);
  1891. }
  1892. $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
  1893. $io->writeError('Alternatives were '.implode(', ', array_map(static function ($p): string {
  1894. return $p->getPrettyString();
  1895. }, $packages)).'.');
  1896. $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
  1897. } elseif (count($packages) === 1) {
  1898. $package = reset($packages);
  1899. $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
  1900. } else {
  1901. $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
  1902. return false;
  1903. }
  1904. if (!$package instanceof CompletePackageInterface) {
  1905. throw new \LogicException('Expected a CompletePackageInterface instance but found '.get_class($package));
  1906. }
  1907. if (!$package instanceof BasePackage) {
  1908. throw new \LogicException('Expected a BasePackage instance but found '.get_class($package));
  1909. }
  1910. return $package;
  1911. }
  1912. }
  1913. <?php declare(strict_types=1);
  1914. namespace Composer\Command;
  1915. use Composer\Composer;
  1916. use Composer\Repository\RepositorySet;
  1917. use Composer\Repository\RepositoryUtils;
  1918. use Symfony\Component\Console\Input\InputInterface;
  1919. use Symfony\Component\Console\Output\OutputInterface;
  1920. use Composer\Package\PackageInterface;
  1921. use Composer\Repository\InstalledRepository;
  1922. use Composer\Advisory\Auditor;
  1923. use Composer\Console\Input\InputOption;
  1924. class AuditCommand extends BaseCommand
  1925. {
  1926. protected function configure(): void
  1927. {
  1928. $this
  1929. ->setName('audit')
  1930. ->setDescription('Checks for security vulnerability advisories for installed packages')
  1931. ->setDefinition([
  1932. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables auditing of require-dev packages.'),
  1933. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_TABLE, Auditor::FORMATS),
  1934. new InputOption('locked', null, InputOption::VALUE_NONE, 'Audit based on the lock file instead of the installed packages.'),
  1935. new InputOption('abandoned', null, InputOption::VALUE_REQUIRED, 'Behavior on abandoned packages. Must be "ignore", "report", or "fail".', null, Auditor::ABANDONEDS),
  1936. new InputOption('ignore-severity', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Ignore advisories of a certain severity level.', [], ['low', 'medium', 'high', 'critical']),
  1937. ])
  1938. ->setHelp(
  1939. <<<EOT
  1940. The <info>audit</info> command checks for security vulnerability advisories for installed packages.
  1941. If you do not want to include dev dependencies in the audit you can omit them with --no-dev
  1942. Read more at https://getcomposer.org/doc/03-cli.md#audit
  1943. EOT
  1944. )
  1945. ;
  1946. }
  1947. protected function execute(InputInterface $input, OutputInterface $output): int
  1948. {
  1949. $composer = $this->requireComposer();
  1950. $packages = $this->getPackages($composer, $input);
  1951. if (count($packages) === 0) {
  1952. $this->getIO()->writeError('No packages - skipping audit.');
  1953. return 0;
  1954. }
  1955. $auditor = new Auditor();
  1956. $repoSet = new RepositorySet();
  1957. foreach ($composer->getRepositoryManager()->getRepositories() as $repo) {
  1958. $repoSet->addRepository($repo);
  1959. }
  1960. $auditConfig = $composer->getConfig()->get('audit');
  1961. $abandoned = $input->getOption('abandoned');
  1962. if ($abandoned !== null && !in_array($abandoned, Auditor::ABANDONEDS, true)) {
  1963. throw new \InvalidArgumentException('--audit must be one of '.implode(', ', Auditor::ABANDONEDS).'.');
  1964. }
  1965. $abandoned = $abandoned ?? $auditConfig['abandoned'] ?? Auditor::ABANDONED_FAIL;
  1966. $ignoreSeverities = $input->getOption('ignore-severity') ?? [];
  1967. return min(255, $auditor->audit(
  1968. $this->getIO(),
  1969. $repoSet,
  1970. $packages,
  1971. $this->getAuditFormat($input, 'format'),
  1972. false,
  1973. $auditConfig['ignore'] ?? [],
  1974. $abandoned,
  1975. $ignoreSeverities
  1976. ));
  1977. }
  1978. private function getPackages(Composer $composer, InputInterface $input): array
  1979. {
  1980. if ($input->getOption('locked')) {
  1981. if (!$composer->getLocker()->isLocked()) {
  1982. throw new \UnexpectedValueException('Valid composer.json and composer.lock files are required to run this command with --locked');
  1983. }
  1984. $locker = $composer->getLocker();
  1985. return $locker->getLockedRepository(!$input->getOption('no-dev'))->getPackages();
  1986. }
  1987. $rootPkg = $composer->getPackage();
  1988. $installedRepo = new InstalledRepository([$composer->getRepositoryManager()->getLocalRepository()]);
  1989. if ($input->getOption('no-dev')) {
  1990. return RepositoryUtils::filterRequiredPackages($installedRepo->getPackages(), $rootPkg);
  1991. }
  1992. return $installedRepo->getPackages();
  1993. }
  1994. }
  1995. <?php declare(strict_types=1);
  1996. namespace Composer\Command;
  1997. use Composer\Composer;
  1998. use Composer\Config;
  1999. use Composer\Console\Application;
  2000. use Composer\Console\Input\InputArgument;
  2001. use Composer\Console\Input\InputOption;
  2002. use Composer\Factory;
  2003. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  2004. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  2005. use Composer\IO\IOInterface;
  2006. use Composer\IO\NullIO;
  2007. use Composer\Plugin\PreCommandRunEvent;
  2008. use Composer\Package\Version\VersionParser;
  2009. use Composer\Plugin\PluginEvents;
  2010. use Composer\Advisory\Auditor;
  2011. use Composer\Util\Platform;
  2012. use Symfony\Component\Console\Completion\CompletionInput;
  2013. use Symfony\Component\Console\Completion\CompletionSuggestions;
  2014. use Symfony\Component\Console\Helper\Table;
  2015. use Symfony\Component\Console\Helper\TableSeparator;
  2016. use Symfony\Component\Console\Input\InputInterface;
  2017. use Symfony\Component\Console\Output\OutputInterface;
  2018. use Symfony\Component\Console\Command\Command;
  2019. use Symfony\Component\Console\Terminal;
  2020. abstract class BaseCommand extends Command
  2021. {
  2022. private $composer;
  2023. private $io;
  2024. public function getApplication(): Application
  2025. {
  2026. $application = parent::getApplication();
  2027. if (!$application instanceof Application) {
  2028. throw new \RuntimeException('Composer commands can only work with an '.Application::class.' instance set');
  2029. }
  2030. return $application;
  2031. }
  2032. public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null)
  2033. {
  2034. if ($required) {
  2035. return $this->requireComposer($disablePlugins, $disableScripts);
  2036. }
  2037. return $this->tryComposer($disablePlugins, $disableScripts);
  2038. }
  2039. public function requireComposer(?bool $disablePlugins = null, ?bool $disableScripts = null): Composer
  2040. {
  2041. if (null === $this->composer) {
  2042. $application = parent::getApplication();
  2043. if ($application instanceof Application) {
  2044. $this->composer = $application->getComposer(true, $disablePlugins, $disableScripts);
  2045. assert($this->composer instanceof Composer);
  2046. } else {
  2047. throw new \RuntimeException(
  2048. 'Could not create a Composer\Composer instance, you must inject '.
  2049. 'one if this command is not used with a Composer\Console\Application instance'
  2050. );
  2051. }
  2052. }
  2053. return $this->composer;
  2054. }
  2055. public function tryComposer(?bool $disablePlugins = null, ?bool $disableScripts = null): ?Composer
  2056. {
  2057. if (null === $this->composer) {
  2058. $application = parent::getApplication();
  2059. if ($application instanceof Application) {
  2060. $this->composer = $application->getComposer(false, $disablePlugins, $disableScripts);
  2061. }
  2062. }
  2063. return $this->composer;
  2064. }
  2065. public function setComposer(Composer $composer)
  2066. {
  2067. $this->composer = $composer;
  2068. }
  2069. public function resetComposer()
  2070. {
  2071. $this->composer = null;
  2072. $this->getApplication()->resetComposer();
  2073. }
  2074. public function isProxyCommand()
  2075. {
  2076. return false;
  2077. }
  2078. public function getIO()
  2079. {
  2080. if (null === $this->io) {
  2081. $application = parent::getApplication();
  2082. if ($application instanceof Application) {
  2083. $this->io = $application->getIO();
  2084. } else {
  2085. $this->io = new NullIO();
  2086. }
  2087. }
  2088. return $this->io;
  2089. }
  2090. public function setIO(IOInterface $io)
  2091. {
  2092. $this->io = $io;
  2093. }
  2094. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  2095. {
  2096. $definition = $this->getDefinition();
  2097. $name = (string) $input->getCompletionName();
  2098. if (CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType()
  2099. && $definition->hasOption($name)
  2100. && ($option = $definition->getOption($name)) instanceof InputOption
  2101. ) {
  2102. $option->complete($input, $suggestions);
  2103. } elseif (CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType()
  2104. && $definition->hasArgument($name)
  2105. && ($argument = $definition->getArgument($name)) instanceof InputArgument
  2106. ) {
  2107. $argument->complete($input, $suggestions);
  2108. } else {
  2109. parent::complete($input, $suggestions);
  2110. }
  2111. }
  2112. protected function initialize(InputInterface $input, OutputInterface $output)
  2113. {
  2114. $disablePlugins = $input->hasParameterOption('--no-plugins');
  2115. $disableScripts = $input->hasParameterOption('--no-scripts');
  2116. $application = parent::getApplication();
  2117. if ($application instanceof Application && $application->getDisablePluginsByDefault()) {
  2118. $disablePlugins = true;
  2119. }
  2120. if ($application instanceof Application && $application->getDisableScriptsByDefault()) {
  2121. $disableScripts = true;
  2122. }
  2123. if ($this instanceof SelfUpdateCommand) {
  2124. $disablePlugins = true;
  2125. $disableScripts = true;
  2126. }
  2127. $composer = $this->tryComposer($disablePlugins, $disableScripts);
  2128. $io = $this->getIO();
  2129. if (null === $composer) {
  2130. $composer = Factory::createGlobal($this->getIO(), $disablePlugins, $disableScripts);
  2131. }
  2132. if ($composer) {
  2133. $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
  2134. $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
  2135. }
  2136. if (true === $input->hasParameterOption(['--no-ansi']) && $input->hasOption('no-progress')) {
  2137. $input->setOption('no-progress', true);
  2138. }
  2139. $envOptions = [
  2140. 'COMPOSER_NO_AUDIT' => ['no-audit'],
  2141. 'COMPOSER_NO_DEV' => ['no-dev', 'update-no-dev'],
  2142. 'COMPOSER_PREFER_STABLE' => ['prefer-stable'],
  2143. 'COMPOSER_PREFER_LOWEST' => ['prefer-lowest'],
  2144. 'COMPOSER_MINIMAL_CHANGES' => ['minimal-changes'],
  2145. 'COMPOSER_WITH_DEPENDENCIES' => ['with-dependencies'],
  2146. 'COMPOSER_WITH_ALL_DEPENDENCIES' => ['with-all-dependencies'],
  2147. ];
  2148. foreach ($envOptions as $envName => $optionNames) {
  2149. foreach ($optionNames as $optionName) {
  2150. if (true === $input->hasOption($optionName)) {
  2151. if (false === $input->getOption($optionName) && (bool) Platform::getEnv($envName)) {
  2152. $input->setOption($optionName, true);
  2153. }
  2154. }
  2155. }
  2156. }
  2157. if (true === $input->hasOption('ignore-platform-reqs')) {
  2158. if (!$input->getOption('ignore-platform-reqs') && (bool) Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQS')) {
  2159. $input->setOption('ignore-platform-reqs', true);
  2160. $io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQS is set. You may experience unexpected errors.</warning>');
  2161. }
  2162. }
  2163. if (true === $input->hasOption('ignore-platform-req') && (!$input->hasOption('ignore-platform-reqs') || !$input->getOption('ignore-platform-reqs'))) {
  2164. $ignorePlatformReqEnv = Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQ');
  2165. if (0 === count($input->getOption('ignore-platform-req')) && is_string($ignorePlatformReqEnv) && '' !== $ignorePlatformReqEnv) {
  2166. $input->setOption('ignore-platform-req', explode(',', $ignorePlatformReqEnv));
  2167. $io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQ is set to ignore '.$ignorePlatformReqEnv.'. You may experience unexpected errors.</warning>');
  2168. }
  2169. }
  2170. parent::initialize($input, $output);
  2171. }
  2172. protected function createComposerInstance(InputInterface $input, IOInterface $io, $config = null, ?bool $disablePlugins = null, ?bool $disableScripts = null): Composer
  2173. {
  2174. $disablePlugins = $disablePlugins === true || $input->hasParameterOption('--no-plugins');
  2175. $disableScripts = $disableScripts === true || $input->hasParameterOption('--no-scripts');
  2176. $application = parent::getApplication();
  2177. if ($application instanceof Application && $application->getDisablePluginsByDefault()) {
  2178. $disablePlugins = true;
  2179. }
  2180. if ($application instanceof Application && $application->getDisableScriptsByDefault()) {
  2181. $disableScripts = true;
  2182. }
  2183. return Factory::create($io, $config, $disablePlugins, $disableScripts);
  2184. }
  2185. protected function getPreferredInstallOptions(Config $config, InputInterface $input, bool $keepVcsRequiresPreferSource = false)
  2186. {
  2187. $preferSource = false;
  2188. $preferDist = false;
  2189. switch ($config->get('preferred-install')) {
  2190. case 'source':
  2191. $preferSource = true;
  2192. break;
  2193. case 'dist':
  2194. $preferDist = true;
  2195. break;
  2196. case 'auto':
  2197. default:
  2198. break;
  2199. }
  2200. if (!$input->hasOption('prefer-dist') || !$input->hasOption('prefer-source')) {
  2201. return [$preferSource, $preferDist];
  2202. }
  2203. if ($input->hasOption('prefer-install') && is_string($input->getOption('prefer-install'))) {
  2204. if ($input->getOption('prefer-source')) {
  2205. throw new \InvalidArgumentException('--prefer-source can not be used together with --prefer-install');
  2206. }
  2207. if ($input->getOption('prefer-dist')) {
  2208. throw new \InvalidArgumentException('--prefer-dist can not be used together with --prefer-install');
  2209. }
  2210. switch ($input->getOption('prefer-install')) {
  2211. case 'dist':
  2212. $input->setOption('prefer-dist', true);
  2213. break;
  2214. case 'source':
  2215. $input->setOption('prefer-source', true);
  2216. break;
  2217. case 'auto':
  2218. $preferDist = false;
  2219. $preferSource = false;
  2220. break;
  2221. default:
  2222. throw new \UnexpectedValueException('--prefer-install accepts one of "dist", "source" or "auto", got '.$input->getOption('prefer-install'));
  2223. }
  2224. }
  2225. if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) {
  2226. $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'));
  2227. $preferDist = $input->getOption('prefer-dist');
  2228. }
  2229. return [$preferSource, $preferDist];
  2230. }
  2231. protected function getPlatformRequirementFilter(InputInterface $input): PlatformRequirementFilterInterface
  2232. {
  2233. if (!$input->hasOption('ignore-platform-reqs') || !$input->hasOption('ignore-platform-req')) {
  2234. throw new \LogicException('Calling getPlatformRequirementFilter from a command which does not define the --ignore-platform-req[s] flags is not permitted.');
  2235. }
  2236. if (true === $input->getOption('ignore-platform-reqs')) {
  2237. return PlatformRequirementFilterFactory::ignoreAll();
  2238. }
  2239. $ignores = $input->getOption('ignore-platform-req');
  2240. if (count($ignores) > 0) {
  2241. return PlatformRequirementFilterFactory::fromBoolOrList($ignores);
  2242. }
  2243. return PlatformRequirementFilterFactory::ignoreNothing();
  2244. }
  2245. protected function formatRequirements(array $requirements)
  2246. {
  2247. $requires = [];
  2248. $requirements = $this->normalizeRequirements($requirements);
  2249. foreach ($requirements as $requirement) {
  2250. if (!isset($requirement['version'])) {
  2251. throw new \UnexpectedValueException('Option '.$requirement['name'] .' is missing a version constraint, use e.g. '.$requirement['name'].':^1.0');
  2252. }
  2253. $requires[$requirement['name']] = $requirement['version'];
  2254. }
  2255. return $requires;
  2256. }
  2257. protected function normalizeRequirements(array $requirements)
  2258. {
  2259. $parser = new VersionParser();
  2260. return $parser->parseNameVersionPairs($requirements);
  2261. }
  2262. protected function renderTable(array $table, OutputInterface $output)
  2263. {
  2264. $renderer = new Table($output);
  2265. $renderer->setStyle('compact');
  2266. $renderer->setRows($table)->render();
  2267. }
  2268. protected function getTerminalWidth()
  2269. {
  2270. $terminal = new Terminal();
  2271. $width = $terminal->getWidth();
  2272. if (Platform::isWindows()) {
  2273. $width--;
  2274. } else {
  2275. $width = max(80, $width);
  2276. }
  2277. return $width;
  2278. }
  2279. protected function getAuditFormat(InputInterface $input, string $optName = 'audit-format'): string
  2280. {
  2281. if (!$input->hasOption($optName)) {
  2282. throw new \LogicException('This should not be called on a Command which has no '.$optName.' option defined.');
  2283. }
  2284. $val = $input->getOption($optName);
  2285. if (!in_array($val, Auditor::FORMATS, true)) {
  2286. throw new \InvalidArgumentException('--'.$optName.' must be one of '.implode(', ', Auditor::FORMATS).'.');
  2287. }
  2288. return $val;
  2289. }
  2290. }
  2291. <?php declare(strict_types=1);
  2292. namespace Composer\Command;
  2293. use Composer\Package\Link;
  2294. use Composer\Package\Package;
  2295. use Composer\Package\PackageInterface;
  2296. use Composer\Package\CompletePackageInterface;
  2297. use Composer\Package\RootPackage;
  2298. use Composer\Repository\InstalledArrayRepository;
  2299. use Composer\Repository\CompositeRepository;
  2300. use Composer\Repository\RootPackageRepository;
  2301. use Composer\Repository\InstalledRepository;
  2302. use Composer\Repository\PlatformRepository;
  2303. use Composer\Repository\RepositoryFactory;
  2304. use Composer\Plugin\CommandEvent;
  2305. use Composer\Plugin\PluginEvents;
  2306. use Composer\Semver\Constraint\Bound;
  2307. use Composer\Util\Platform;
  2308. use Symfony\Component\Console\Formatter\OutputFormatter;
  2309. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  2310. use Composer\Package\Version\VersionParser;
  2311. use Symfony\Component\Console\Input\InputInterface;
  2312. use Symfony\Component\Console\Output\OutputInterface;
  2313. use Composer\Util\PackageInfo;
  2314. abstract class BaseDependencyCommand extends BaseCommand
  2315. {
  2316. protected const ARGUMENT_PACKAGE = 'package';
  2317. protected const ARGUMENT_CONSTRAINT = 'version';
  2318. protected const OPTION_RECURSIVE = 'recursive';
  2319. protected const OPTION_TREE = 'tree';
  2320. protected $colors;
  2321. protected function doExecute(InputInterface $input, OutputInterface $output, bool $inverted = false): int
  2322. {
  2323. $composer = $this->requireComposer();
  2324. $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
  2325. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  2326. $repos = [];
  2327. $repos[] = new RootPackageRepository(clone $composer->getPackage());
  2328. if ($input->getOption('locked')) {
  2329. $locker = $composer->getLocker();
  2330. if (!$locker->isLocked()) {
  2331. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --locked');
  2332. }
  2333. $repos[] = $locker->getLockedRepository(true);
  2334. $repos[] = new PlatformRepository([], $locker->getPlatformOverrides());
  2335. } else {
  2336. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  2337. $rootPkg = $composer->getPackage();
  2338. if (count($localRepo->getPackages()) === 0 && (count($rootPkg->getRequires()) > 0 || count($rootPkg->getDevRequires()) > 0)) {
  2339. $output->writeln('<warning>No dependencies installed. Try running composer install or update, or use --locked.</warning>');
  2340. return 1;
  2341. }
  2342. $repos[] = $localRepo;
  2343. $platformOverrides = $composer->getConfig()->get('platform') ?: [];
  2344. $repos[] = new PlatformRepository([], $platformOverrides);
  2345. }
  2346. $installedRepo = new InstalledRepository($repos);
  2347. $needle = $input->getArgument(self::ARGUMENT_PACKAGE);
  2348. $textConstraint = $input->hasArgument(self::ARGUMENT_CONSTRAINT) ? $input->getArgument(self::ARGUMENT_CONSTRAINT) : '*';
  2349. $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
  2350. if (empty($packages)) {
  2351. throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
  2352. }
  2353. $matchedPackage = $installedRepo->findPackage($needle, $textConstraint);
  2354. if (!$matchedPackage) {
  2355. $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO(), $composer->getConfig(), $composer->getRepositoryManager()));
  2356. if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
  2357. $installedRepo->addRepository(new InstalledArrayRepository([clone $match]));
  2358. } elseif (PlatformRepository::isPlatformPackage($needle)) {
  2359. $parser = new VersionParser();
  2360. $constraint = $parser->parseConstraints($textConstraint);
  2361. if ($constraint->getLowerBound() !== Bound::zero()) {
  2362. $tempPlatformPkg = new Package($needle, $constraint->getLowerBound()->getVersion(), $constraint->getLowerBound()->getVersion());
  2363. $installedRepo->addRepository(new InstalledArrayRepository([$tempPlatformPkg]));
  2364. }
  2365. } else {
  2366. $this->getIO()->writeError('<error>Package "'.$needle.'" could not be found with constraint "'.$textConstraint.'", results below will most likely be incomplete.</error>');
  2367. }
  2368. } elseif (PlatformRepository::isPlatformPackage($needle)) {
  2369. $extraNotice = '';
  2370. if (($matchedPackage->getExtra()['config.platform'] ?? false) === true) {
  2371. $extraNotice = ' (version provided by config.platform)';
  2372. }
  2373. $this->getIO()->writeError('<info>Package "'.$needle.' '.$textConstraint.'" found in version "'.$matchedPackage->getPrettyVersion().'"'.$extraNotice.'.</info>');
  2374. } elseif ($inverted) {
  2375. $this->getIO()->write('<comment>Package "'.$needle.'" '.$matchedPackage->getPrettyVersion().' is already installed! To find out why, run `composer why '.$needle.'`</comment>');
  2376. return 0;
  2377. }
  2378. $needles = [$needle];
  2379. if ($inverted) {
  2380. foreach ($packages as $package) {
  2381. $needles = array_merge($needles, array_map(static function (Link $link): string {
  2382. return $link->getTarget();
  2383. }, $package->getReplaces()));
  2384. }
  2385. }
  2386. if ('*' !== $textConstraint) {
  2387. $versionParser = new VersionParser();
  2388. $constraint = $versionParser->parseConstraints($textConstraint);
  2389. } else {
  2390. $constraint = null;
  2391. }
  2392. $renderTree = $input->getOption(self::OPTION_TREE);
  2393. $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
  2394. $return = $inverted ? 1 : 0;
  2395. $results = $installedRepo->getDependents($needles, $constraint, $inverted, $recursive);
  2396. if (empty($results)) {
  2397. $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
  2398. $this->getIO()->writeError(sprintf(
  2399. '<info>There is no installed package depending on "%s"%s</info>',
  2400. $needle,
  2401. $extra
  2402. ));
  2403. $return = $inverted ? 0 : 1;
  2404. } elseif ($renderTree) {
  2405. $this->initStyles($output);
  2406. $root = $packages[0];
  2407. $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root instanceof CompletePackageInterface ? $root->getDescription() : ''));
  2408. $this->printTree($results);
  2409. } else {
  2410. $this->printTable($output, $results);
  2411. }
  2412. if ($inverted && $input->hasArgument(self::ARGUMENT_CONSTRAINT) && !PlatformRepository::isPlatformPackage($needle)) {
  2413. $composerCommand = 'update';
  2414. foreach ($composer->getPackage()->getRequires() as $rootRequirement) {
  2415. if ($rootRequirement->getTarget() === $needle) {
  2416. $composerCommand = 'require';
  2417. break;
  2418. }
  2419. }
  2420. foreach ($composer->getPackage()->getDevRequires() as $rootRequirement) {
  2421. if ($rootRequirement->getTarget() === $needle) {
  2422. $composerCommand = 'require --dev';
  2423. break;
  2424. }
  2425. }
  2426. $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.');
  2427. }
  2428. return $return;
  2429. }
  2430. protected function printTable(OutputInterface $output, array $results): void
  2431. {
  2432. $table = [];
  2433. $doubles = [];
  2434. do {
  2435. $queue = [];
  2436. $rows = [];
  2437. foreach ($results as $result) {
  2438. [$package, $link, $children] = $result;
  2439. $unique = (string) $link;
  2440. if (isset($doubles[$unique])) {
  2441. continue;
  2442. }
  2443. $doubles[$unique] = true;
  2444. $version = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '-' : $package->getPrettyVersion();
  2445. $packageUrl = PackageInfo::getViewSourceOrHomepageUrl($package);
  2446. $nameWithLink = $packageUrl !== null ? '<href=' . OutputFormatter::escape($packageUrl) . '>' . $package->getPrettyName() . '</>' : $package->getPrettyName();
  2447. $rows[] = [$nameWithLink, $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint())];
  2448. if (is_array($children)) {
  2449. $queue = array_merge($queue, $children);
  2450. }
  2451. }
  2452. $results = $queue;
  2453. $table = array_merge($rows, $table);
  2454. } while (\count($results) > 0);
  2455. $this->renderTable($table, $output);
  2456. }
  2457. protected function initStyles(OutputInterface $output): void
  2458. {
  2459. $this->colors = [
  2460. 'green',
  2461. 'yellow',
  2462. 'cyan',
  2463. 'magenta',
  2464. 'blue',
  2465. ];
  2466. foreach ($this->colors as $color) {
  2467. $style = new OutputFormatterStyle($color);
  2468. $output->getFormatter()->setStyle($color, $style);
  2469. }
  2470. }
  2471. protected function printTree(array $results, string $prefix = '', int $level = 1): void
  2472. {
  2473. $count = count($results);
  2474. $idx = 0;
  2475. foreach ($results as $result) {
  2476. [$package, $link, $children] = $result;
  2477. $color = $this->colors[$level % count($this->colors)];
  2478. $prevColor = $this->colors[($level - 1) % count($this->colors)];
  2479. $isLast = (++$idx === $count);
  2480. $versionText = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '' : $package->getPrettyVersion();
  2481. $packageUrl = PackageInfo::getViewSourceOrHomepageUrl($package);
  2482. $nameWithLink = $packageUrl !== null ? '<href=' . OutputFormatter::escape($packageUrl) . '>' . $package->getPrettyName() . '</>' : $package->getPrettyName();
  2483. $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $nameWithLink, $versionText));
  2484. $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
  2485. $circularWarn = $children === false ? '(circular dependency aborted here)' : '';
  2486. $this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
  2487. if (is_array($children)) {
  2488. $this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
  2489. }
  2490. }
  2491. }
  2492. private function writeTreeLine(string $line): void
  2493. {
  2494. $io = $this->getIO();
  2495. if (!$io->isDecorated()) {
  2496. $line = str_replace(['└', '├', '──', '│'], ['`-', '|-', '-', '|'], $line);
  2497. }
  2498. $io->write($line);
  2499. }
  2500. }
  2501. <?php declare(strict_types=1);
  2502. namespace Composer\Command;
  2503. use Composer\IO\IOInterface;
  2504. use Composer\Package\AliasPackage;
  2505. use Composer\Package\BasePackage;
  2506. use Composer\Package\Locker;
  2507. use Composer\Package\Version\VersionBumper;
  2508. use Composer\Pcre\Preg;
  2509. use Composer\Util\Filesystem;
  2510. use Symfony\Component\Console\Input\InputInterface;
  2511. use Composer\Console\Input\InputArgument;
  2512. use Composer\Console\Input\InputOption;
  2513. use Symfony\Component\Console\Output\OutputInterface;
  2514. use Composer\Factory;
  2515. use Composer\Json\JsonFile;
  2516. use Composer\Json\JsonManipulator;
  2517. use Composer\Repository\PlatformRepository;
  2518. use Composer\Util\Silencer;
  2519. final class BumpCommand extends BaseCommand
  2520. {
  2521. private const ERROR_GENERIC = 1;
  2522. private const ERROR_LOCK_OUTDATED = 2;
  2523. use CompletionTrait;
  2524. protected function configure(): void
  2525. {
  2526. $this
  2527. ->setName('bump')
  2528. ->setDescription('Increases the lower limit of your composer.json requirements to the currently installed versions')
  2529. ->setDefinition([
  2530. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Optional package name(s) to restrict which packages are bumped.', null, $this->suggestRootRequirement()),
  2531. new InputOption('dev-only', 'D', InputOption::VALUE_NONE, 'Only bump requirements in "require-dev".'),
  2532. new InputOption('no-dev-only', 'R', InputOption::VALUE_NONE, 'Only bump requirements in "require".'),
  2533. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the packages to bump, but will not execute anything.'),
  2534. ])
  2535. ->setHelp(
  2536. <<<EOT
  2537. The <info>bump</info> command increases the lower limit of your composer.json requirements
  2538. to the currently installed versions. This helps to ensure your dependencies do not
  2539. accidentally get downgraded due to some other conflict, and can slightly improve
  2540. dependency resolution performance as it limits the amount of package versions
  2541. Composer has to look at.
  2542. Running this blindly on libraries is **NOT** recommended as it will narrow down
  2543. your allowed dependencies, which may cause dependency hell for your users.
  2544. Running it with <info>--dev-only</info> on libraries may be fine however as dev requirements
  2545. are local to the library and do not affect consumers of the package.
  2546. EOT
  2547. )
  2548. ;
  2549. }
  2550. protected function execute(InputInterface $input, OutputInterface $output): int
  2551. {
  2552. return $this->doBump(
  2553. $this->getIO(),
  2554. $input->getOption('dev-only'),
  2555. $input->getOption('no-dev-only'),
  2556. $input->getOption('dry-run'),
  2557. $input->getArgument('packages')
  2558. );
  2559. }
  2560. public function doBump(
  2561. IOInterface $io,
  2562. bool $devOnly,
  2563. bool $noDevOnly,
  2564. bool $dryRun,
  2565. array $packagesFilter
  2566. ): int {
  2567. $composerJsonPath = Factory::getComposerFile();
  2568. if (!Filesystem::isReadable($composerJsonPath)) {
  2569. $io->writeError('<error>'.$composerJsonPath.' is not readable.</error>');
  2570. return self::ERROR_GENERIC;
  2571. }
  2572. $composerJson = new JsonFile($composerJsonPath);
  2573. $contents = file_get_contents($composerJson->getPath());
  2574. if (false === $contents) {
  2575. $io->writeError('<error>'.$composerJsonPath.' is not readable.</error>');
  2576. return self::ERROR_GENERIC;
  2577. }
  2578. if (!is_writable($composerJsonPath) && false === Silencer::call('file_put_contents', $composerJsonPath, $contents)) {
  2579. $io->writeError('<error>'.$composerJsonPath.' is not writable.</error>');
  2580. return self::ERROR_GENERIC;
  2581. }
  2582. unset($contents);
  2583. $composer = $this->requireComposer();
  2584. if ($composer->getLocker()->isLocked()) {
  2585. if (!$composer->getLocker()->isFresh()) {
  2586. $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>');
  2587. return self::ERROR_LOCK_OUTDATED;
  2588. }
  2589. $repo = $composer->getLocker()->getLockedRepository(true);
  2590. } else {
  2591. $repo = $composer->getRepositoryManager()->getLocalRepository();
  2592. }
  2593. if ($composer->getPackage()->getType() !== 'project' && !$devOnly) {
  2594. $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>');
  2595. $contents = $composerJson->read();
  2596. if (!isset($contents['type'])) {
  2597. $io->writeError('<warning>If your package is not a library, you can explicitly specify the "type" by using "composer config type project".</warning>');
  2598. $io->writeError('<warning>Alternatively you can use --dev-only to only bump dependencies within "require-dev".</warning>');
  2599. }
  2600. unset($contents);
  2601. }
  2602. $bumper = new VersionBumper();
  2603. $tasks = [];
  2604. if (!$devOnly) {
  2605. $tasks['require'] = $composer->getPackage()->getRequires();
  2606. }
  2607. if (!$noDevOnly) {
  2608. $tasks['require-dev'] = $composer->getPackage()->getDevRequires();
  2609. }
  2610. if (count($packagesFilter) > 0) {
  2611. $packagesFilter = array_map(function ($constraint) {
  2612. return Preg::replace('{[:= ].+}', '', $constraint);
  2613. }, $packagesFilter);
  2614. $pattern = BasePackage::packageNamesToRegexp(array_unique(array_map('strtolower', $packagesFilter)));
  2615. foreach ($tasks as $key => $reqs) {
  2616. foreach ($reqs as $pkgName => $link) {
  2617. if (!Preg::isMatch($pattern, $pkgName)) {
  2618. unset($tasks[$key][$pkgName]);
  2619. }
  2620. }
  2621. }
  2622. }
  2623. $updates = [];
  2624. foreach ($tasks as $key => $reqs) {
  2625. foreach ($reqs as $pkgName => $link) {
  2626. if (PlatformRepository::isPlatformPackage($pkgName)) {
  2627. continue;
  2628. }
  2629. $currentConstraint = $link->getPrettyConstraint();
  2630. $package = $repo->findPackage($pkgName, '*');
  2631. if (null === $package) {
  2632. continue;
  2633. }
  2634. while ($package instanceof AliasPackage) {
  2635. $package = $package->getAliasOf();
  2636. }
  2637. $bumped = $bumper->bumpRequirement($link->getConstraint(), $package);
  2638. if ($bumped === $currentConstraint) {
  2639. continue;
  2640. }
  2641. $updates[$key][$pkgName] = $bumped;
  2642. }
  2643. }
  2644. if (!$dryRun && !$this->updateFileCleanly($composerJson, $updates)) {
  2645. $composerDefinition = $composerJson->read();
  2646. foreach ($updates as $key => $packages) {
  2647. foreach ($packages as $package => $version) {
  2648. $composerDefinition[$key][$package] = $version;
  2649. }
  2650. }
  2651. $composerJson->write($composerDefinition);
  2652. }
  2653. $changeCount = array_sum(array_map('count', $updates));
  2654. if ($changeCount > 0) {
  2655. if ($dryRun) {
  2656. $io->write('<info>' . $composerJsonPath . ' would be updated with:</info>');
  2657. foreach ($updates as $requireType => $packages) {
  2658. foreach ($packages as $package => $version) {
  2659. $io->write(sprintf('<info> - %s.%s: %s</info>', $requireType, $package, $version));
  2660. }
  2661. }
  2662. } else {
  2663. $io->write('<info>' . $composerJsonPath . ' has been updated (' . $changeCount . ' changes).</info>');
  2664. }
  2665. } else {
  2666. $io->write('<info>No requirements to update in '.$composerJsonPath.'.</info>');
  2667. }
  2668. if (!$dryRun && $composer->getLocker()->isLocked() && $composer->getConfig()->get('lock') && $changeCount > 0) {
  2669. $composer->getLocker()->updateHash($composerJson);
  2670. }
  2671. if ($dryRun && $changeCount > 0) {
  2672. return self::ERROR_GENERIC;
  2673. }
  2674. return 0;
  2675. }
  2676. private function updateFileCleanly(JsonFile $json, array $updates): bool
  2677. {
  2678. $contents = file_get_contents($json->getPath());
  2679. if (false === $contents) {
  2680. throw new \RuntimeException('Unable to read '.$json->getPath().' contents.');
  2681. }
  2682. $manipulator = new JsonManipulator($contents);
  2683. foreach ($updates as $key => $packages) {
  2684. foreach ($packages as $package => $version) {
  2685. if (!$manipulator->addLink($key, $package, $version)) {
  2686. return false;
  2687. }
  2688. }
  2689. }
  2690. if (false === file_put_contents($json->getPath(), $manipulator->getContents())) {
  2691. throw new \RuntimeException('Unable to write new '.$json->getPath().' contents.');
  2692. }
  2693. return true;
  2694. }
  2695. }
  2696. <?php declare(strict_types=1);
  2697. namespace Composer\Command;
  2698. use Composer\Package\Link;
  2699. use Composer\Semver\Constraint\Constraint;
  2700. use Symfony\Component\Console\Input\InputInterface;
  2701. use Composer\Console\Input\InputOption;
  2702. use Symfony\Component\Console\Output\OutputInterface;
  2703. use Composer\Repository\PlatformRepository;
  2704. use Composer\Repository\RootPackageRepository;
  2705. use Composer\Repository\InstalledRepository;
  2706. use Composer\Json\JsonFile;
  2707. class CheckPlatformReqsCommand extends BaseCommand
  2708. {
  2709. protected function configure(): void
  2710. {
  2711. $this->setName('check-platform-reqs')
  2712. ->setDescription('Check that platform requirements are satisfied')
  2713. ->setDefinition([
  2714. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
  2715. new InputOption('lock', null, InputOption::VALUE_NONE, 'Checks requirements only from the lock file, not from installed packages.'),
  2716. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['json', 'text']),
  2717. ])
  2718. ->setHelp(
  2719. <<<EOT
  2720. Checks that your PHP and extensions versions match the platform requirements of the installed packages.
  2721. 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.
  2722. <info>php composer.phar check-platform-reqs</info>
  2723. EOT
  2724. );
  2725. }
  2726. protected function execute(InputInterface $input, OutputInterface $output): int
  2727. {
  2728. $composer = $this->requireComposer();
  2729. $requires = [];
  2730. $removePackages = [];
  2731. if ($input->getOption('lock')) {
  2732. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
  2733. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  2734. } else {
  2735. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  2736. if (!$installedRepo->getPackages()) {
  2737. $this->getIO()->writeError('<warning>No vendor dir present, checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements from the lock file</warning>');
  2738. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  2739. } else {
  2740. if ($input->getOption('no-dev')) {
  2741. $removePackages = $installedRepo->getDevPackageNames();
  2742. }
  2743. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements for packages in the vendor dir</info>');
  2744. }
  2745. }
  2746. if (!$input->getOption('no-dev')) {
  2747. foreach ($composer->getPackage()->getDevRequires() as $require => $link) {
  2748. $requires[$require] = [$link];
  2749. }
  2750. }
  2751. $installedRepo = new InstalledRepository([$installedRepo, new RootPackageRepository(clone $composer->getPackage())]);
  2752. foreach ($installedRepo->getPackages() as $package) {
  2753. if (in_array($package->getName(), $removePackages, true)) {
  2754. continue;
  2755. }
  2756. foreach ($package->getRequires() as $require => $link) {
  2757. $requires[$require][] = $link;
  2758. }
  2759. }
  2760. ksort($requires);
  2761. $installedRepo->addRepository(new PlatformRepository([], []));
  2762. $results = [];
  2763. $exitCode = 0;
  2764. foreach ($requires as $require => $links) {
  2765. if (PlatformRepository::isPlatformPackage($require)) {
  2766. $candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
  2767. if ($candidates) {
  2768. $reqResults = [];
  2769. foreach ($candidates as $candidate) {
  2770. $candidateConstraint = null;
  2771. if ($candidate->getName() === $require) {
  2772. $candidateConstraint = new Constraint('=', $candidate->getVersion());
  2773. $candidateConstraint->setPrettyString($candidate->getPrettyVersion());
  2774. } else {
  2775. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  2776. if ($link->getTarget() === $require) {
  2777. $candidateConstraint = $link->getConstraint();
  2778. break;
  2779. }
  2780. }
  2781. }
  2782. if (!$candidateConstraint) {
  2783. continue;
  2784. }
  2785. foreach ($links as $link) {
  2786. if (!$link->getConstraint()->matches($candidateConstraint)) {
  2787. $reqResults[] = [
  2788. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  2789. $candidateConstraint->getPrettyString(),
  2790. $link,
  2791. '<error>failed</error>',
  2792. $candidate->getName() === $require ? '' : '<comment>provided by '.$candidate->getPrettyName().'</comment>',
  2793. ];
  2794. continue 2;
  2795. }
  2796. }
  2797. $results[] = [
  2798. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  2799. $candidateConstraint->getPrettyString(),
  2800. null,
  2801. '<info>success</info>',
  2802. $candidate->getName() === $require ? '' : '<comment>provided by '.$candidate->getPrettyName().'</comment>',
  2803. ];
  2804. continue 2;
  2805. }
  2806. $results = array_merge($results, $reqResults);
  2807. $exitCode = max($exitCode, 1);
  2808. continue;
  2809. }
  2810. $results[] = [
  2811. $require,
  2812. 'n/a',
  2813. $links[0],
  2814. '<error>missing</error>',
  2815. '',
  2816. ];
  2817. $exitCode = max($exitCode, 2);
  2818. }
  2819. }
  2820. $this->printTable($output, $results, $input->getOption('format'));
  2821. return $exitCode;
  2822. }
  2823. protected function printTable(OutputInterface $output, array $results, string $format): void
  2824. {
  2825. $rows = [];
  2826. foreach ($results as $result) {
  2827. [$platformPackage, $version, $link, $status, $provider] = $result;
  2828. if ('json' === $format) {
  2829. $rows[] = [
  2830. "name" => $platformPackage,
  2831. "version" => $version,
  2832. "status" => strip_tags($status),
  2833. "failed_requirement" => $link instanceof Link ? [
  2834. 'source' => $link->getSource(),
  2835. 'type' => $link->getDescription(),
  2836. 'target' => $link->getTarget(),
  2837. 'constraint' => $link->getPrettyConstraint(),
  2838. ] : null,
  2839. "provider" => $provider === '' ? null : strip_tags($provider),
  2840. ];
  2841. } else {
  2842. $rows[] = [
  2843. $platformPackage,
  2844. $version,
  2845. $link,
  2846. $link ? sprintf('%s %s %s (%s)', $link->getSource(), $link->getDescription(), $link->getTarget(), $link->getPrettyConstraint()) : '',
  2847. rtrim($status.' '.$provider),
  2848. ];
  2849. }
  2850. }
  2851. if ('json' === $format) {
  2852. $this->getIO()->write(JsonFile::encode($rows));
  2853. } else {
  2854. $this->renderTable($rows, $output);
  2855. }
  2856. }
  2857. }
  2858. <?php declare(strict_types=1);
  2859. namespace Composer\Command;
  2860. use Composer\Cache;
  2861. use Composer\Factory;
  2862. use Symfony\Component\Console\Input\InputInterface;
  2863. use Symfony\Component\Console\Input\InputOption;
  2864. use Symfony\Component\Console\Output\OutputInterface;
  2865. class ClearCacheCommand extends BaseCommand
  2866. {
  2867. protected function configure(): void
  2868. {
  2869. $this
  2870. ->setName('clear-cache')
  2871. ->setAliases(['clearcache', 'cc'])
  2872. ->setDescription('Clears composer\'s internal package cache')
  2873. ->setDefinition([
  2874. new InputOption('gc', null, InputOption::VALUE_NONE, 'Only run garbage collection, not a full cache clear'),
  2875. ])
  2876. ->setHelp(
  2877. <<<EOT
  2878. The <info>clear-cache</info> deletes all cached packages from composer's
  2879. cache directory.
  2880. Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc
  2881. EOT
  2882. )
  2883. ;
  2884. }
  2885. protected function execute(InputInterface $input, OutputInterface $output): int
  2886. {
  2887. $composer = $this->tryComposer();
  2888. if ($composer !== null) {
  2889. $config = $composer->getConfig();
  2890. } else {
  2891. $config = Factory::createConfig();
  2892. }
  2893. $io = $this->getIO();
  2894. $cachePaths = [
  2895. 'cache-vcs-dir' => $config->get('cache-vcs-dir'),
  2896. 'cache-repo-dir' => $config->get('cache-repo-dir'),
  2897. 'cache-files-dir' => $config->get('cache-files-dir'),
  2898. 'cache-dir' => $config->get('cache-dir'),
  2899. ];
  2900. foreach ($cachePaths as $key => $cachePath) {
  2901. if ($key === 'cache-dir' && $input->getOption('gc')) {
  2902. continue;
  2903. }
  2904. $cachePath = realpath($cachePath);
  2905. if (!$cachePath) {
  2906. $io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
  2907. continue;
  2908. }
  2909. $cache = new Cache($io, $cachePath);
  2910. $cache->setReadOnly($config->get('cache-read-only'));
  2911. if (!$cache->isEnabled()) {
  2912. $io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
  2913. continue;
  2914. }
  2915. if ($input->getOption('gc')) {
  2916. $io->writeError("<info>Garbage-collecting cache ($key): $cachePath</info>");
  2917. if ($key === 'cache-files-dir') {
  2918. $cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
  2919. } elseif ($key === 'cache-repo-dir') {
  2920. $cache->gc($config->get('cache-ttl'), 1024 * 1024 * 1024 );
  2921. } elseif ($key === 'cache-vcs-dir') {
  2922. $cache->gcVcsCache($config->get('cache-ttl'));
  2923. }
  2924. } else {
  2925. $io->writeError("<info>Clearing cache ($key): $cachePath</info>");
  2926. $cache->clear();
  2927. }
  2928. }
  2929. if ($input->getOption('gc')) {
  2930. $io->writeError('<info>All caches garbage-collected.</info>');
  2931. } else {
  2932. $io->writeError('<info>All caches cleared.</info>');
  2933. }
  2934. return 0;
  2935. }
  2936. }
  2937. <?php declare(strict_types=1);
  2938. namespace Composer\Command;
  2939. use Composer\Composer;
  2940. use Composer\Package\BasePackage;
  2941. use Composer\Package\PackageInterface;
  2942. use Composer\Pcre\Preg;
  2943. use Composer\Repository\CompositeRepository;
  2944. use Composer\Repository\InstalledRepository;
  2945. use Composer\Repository\PlatformRepository;
  2946. use Composer\Repository\RepositoryInterface;
  2947. use Composer\Repository\RootPackageRepository;
  2948. use Symfony\Component\Console\Completion\CompletionInput;
  2949. trait CompletionTrait
  2950. {
  2951. abstract public function requireComposer(?bool $disablePlugins = null, ?bool $disableScripts = null): Composer;
  2952. private function suggestPreferInstall(): array
  2953. {
  2954. return ['dist', 'source', 'auto'];
  2955. }
  2956. private function suggestRootRequirement(): \Closure
  2957. {
  2958. return function (CompletionInput $input): array {
  2959. $composer = $this->requireComposer();
  2960. return array_merge(array_keys($composer->getPackage()->getRequires()), array_keys($composer->getPackage()->getDevRequires()));
  2961. };
  2962. }
  2963. private function suggestInstalledPackage(bool $includeRootPackage = true, bool $includePlatformPackages = false): \Closure
  2964. {
  2965. return function (CompletionInput $input) use ($includeRootPackage, $includePlatformPackages): array {
  2966. $composer = $this->requireComposer();
  2967. $installedRepos = [];
  2968. if ($includeRootPackage) {
  2969. $installedRepos[] = new RootPackageRepository(clone $composer->getPackage());
  2970. }
  2971. $locker = $composer->getLocker();
  2972. if ($locker->isLocked()) {
  2973. $installedRepos[] = $locker->getLockedRepository(true);
  2974. } else {
  2975. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  2976. }
  2977. $platformHint = [];
  2978. if ($includePlatformPackages) {
  2979. if ($locker->isLocked()) {
  2980. $platformRepo = new PlatformRepository([], $locker->getPlatformOverrides());
  2981. } else {
  2982. $platformRepo = new PlatformRepository([], $composer->getConfig()->get('platform'));
  2983. }
  2984. if ($input->getCompletionValue() === '') {
  2985. $hintsToFind = ['ext-' => 0, 'lib-' => 0, 'php' => 99, 'composer' => 99];
  2986. foreach ($platformRepo->getPackages() as $pkg) {
  2987. foreach ($hintsToFind as $hintPrefix => $hintCount) {
  2988. if (str_starts_with($pkg->getName(), $hintPrefix)) {
  2989. if ($hintCount === 0 || $hintCount >= 99) {
  2990. $platformHint[] = $pkg->getName();
  2991. $hintsToFind[$hintPrefix]++;
  2992. } elseif ($hintCount === 1) {
  2993. unset($hintsToFind[$hintPrefix]);
  2994. $platformHint[] = substr($pkg->getName(), 0, max(strlen($pkg->getName()) - 3, strlen($hintPrefix) + 1)).'...';
  2995. }
  2996. continue 2;
  2997. }
  2998. }
  2999. }
  3000. } else {
  3001. $installedRepos[] = $platformRepo;
  3002. }
  3003. }
  3004. $installedRepo = new InstalledRepository($installedRepos);
  3005. return array_merge(
  3006. array_map(static function (PackageInterface $package) {
  3007. return $package->getName();
  3008. }, $installedRepo->getPackages()),
  3009. $platformHint
  3010. );
  3011. };
  3012. }
  3013. private function suggestInstalledPackageTypes(bool $includeRootPackage = true): \Closure
  3014. {
  3015. return function (CompletionInput $input) use ($includeRootPackage): array {
  3016. $composer = $this->requireComposer();
  3017. $installedRepos = [];
  3018. if ($includeRootPackage) {
  3019. $installedRepos[] = new RootPackageRepository(clone $composer->getPackage());
  3020. }
  3021. $locker = $composer->getLocker();
  3022. if ($locker->isLocked()) {
  3023. $installedRepos[] = $locker->getLockedRepository(true);
  3024. } else {
  3025. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  3026. }
  3027. $installedRepo = new InstalledRepository($installedRepos);
  3028. return array_values(array_unique(
  3029. array_map(static function (PackageInterface $package) {
  3030. return $package->getType();
  3031. }, $installedRepo->getPackages())
  3032. ));
  3033. };
  3034. }
  3035. private function suggestAvailablePackage(int $max = 99): \Closure
  3036. {
  3037. return function (CompletionInput $input) use ($max): array {
  3038. if ($max < 1) {
  3039. return [];
  3040. }
  3041. $composer = $this->requireComposer();
  3042. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  3043. $results = [];
  3044. $showVendors = false;
  3045. if (!str_contains($input->getCompletionValue(), '/')) {
  3046. $results = $repos->search('^' . preg_quote($input->getCompletionValue()), RepositoryInterface::SEARCH_VENDOR);
  3047. $showVendors = true;
  3048. }
  3049. if (\count($results) <= 1) {
  3050. $results = $repos->search('^'.preg_quote($input->getCompletionValue()), RepositoryInterface::SEARCH_NAME);
  3051. $showVendors = false;
  3052. }
  3053. $results = array_column($results, 'name');
  3054. if ($showVendors) {
  3055. $results = array_map(static function (string $name): string {
  3056. return $name.'/';
  3057. }, $results);
  3058. usort($results, static function (string $a, string $b) {
  3059. $lenA = \strlen($a);
  3060. $lenB = \strlen($b);
  3061. if ($lenA === $lenB) {
  3062. return $a <=> $b;
  3063. }
  3064. return $lenA - $lenB;
  3065. });
  3066. $pinned = [];
  3067. $completionInput = $input->getCompletionValue().'/';
  3068. if (false !== ($exactIndex = array_search($completionInput, $results, true))) {
  3069. $pinned[] = $completionInput;
  3070. array_splice($results, $exactIndex, 1);
  3071. }
  3072. return array_merge($pinned, array_slice($results, 0, $max - \count($pinned)));
  3073. }
  3074. return array_slice($results, 0, $max);
  3075. };
  3076. }
  3077. private function suggestAvailablePackageInclPlatform(): \Closure
  3078. {
  3079. return function (CompletionInput $input): array {
  3080. if (Preg::isMatch('{^(ext|lib|php)(-|$)|^com}', $input->getCompletionValue())) {
  3081. $matches = $this->suggestPlatformPackage()($input);
  3082. } else {
  3083. $matches = [];
  3084. }
  3085. return array_merge($matches, $this->suggestAvailablePackage(99 - \count($matches))($input));
  3086. };
  3087. }
  3088. private function suggestPlatformPackage(): \Closure
  3089. {
  3090. return function (CompletionInput $input): array {
  3091. $repos = new PlatformRepository([], $this->requireComposer()->getConfig()->get('platform'));
  3092. $pattern = BasePackage::packageNameToRegexp($input->getCompletionValue().'*');
  3093. return array_filter(array_map(static function (PackageInterface $package) {
  3094. return $package->getName();
  3095. }, $repos->getPackages()), static function (string $name) use ($pattern): bool {
  3096. return Preg::isMatch($pattern, $name);
  3097. });
  3098. };
  3099. }
  3100. }
  3101. <?php declare(strict_types=1);
  3102. namespace Composer\Command;
  3103. use Composer\Advisory\Auditor;
  3104. use Composer\Pcre\Preg;
  3105. use Composer\Util\Filesystem;
  3106. use Composer\Util\Platform;
  3107. use Composer\Util\Silencer;
  3108. use Symfony\Component\Console\Input\InputInterface;
  3109. use Composer\Console\Input\InputArgument;
  3110. use Symfony\Component\Console\Completion\CompletionInput;
  3111. use Symfony\Component\Console\Input\InputOption;
  3112. use Symfony\Component\Console\Output\OutputInterface;
  3113. use Composer\Config;
  3114. use Composer\Config\JsonConfigSource;
  3115. use Composer\Factory;
  3116. use Composer\IO\IOInterface;
  3117. use Composer\Json\JsonFile;
  3118. use Composer\Semver\VersionParser;
  3119. use Composer\Package\BasePackage;
  3120. class ConfigCommand extends BaseCommand
  3121. {
  3122. protected const CONFIGURABLE_PACKAGE_PROPERTIES = [
  3123. 'name',
  3124. 'type',
  3125. 'description',
  3126. 'homepage',
  3127. 'version',
  3128. 'minimum-stability',
  3129. 'prefer-stable',
  3130. 'keywords',
  3131. 'license',
  3132. 'repositories',
  3133. 'suggest',
  3134. 'extra',
  3135. ];
  3136. protected $config;
  3137. protected $configFile;
  3138. protected $configSource;
  3139. protected $authConfigFile;
  3140. protected $authConfigSource;
  3141. protected function configure(): void
  3142. {
  3143. $this
  3144. ->setName('config')
  3145. ->setDescription('Sets config options')
  3146. ->setDefinition([
  3147. new InputOption('global', 'g', InputOption::VALUE_NONE, 'Apply command to the global config file'),
  3148. new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
  3149. new InputOption('auth', 'a', InputOption::VALUE_NONE, 'Affect auth config file (only used for --editor)'),
  3150. new InputOption('unset', null, InputOption::VALUE_NONE, 'Unset the given setting-key'),
  3151. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
  3152. new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
  3153. new InputOption('absolute', null, InputOption::VALUE_NONE, 'Returns absolute paths when fetching *-dir config values instead of relative'),
  3154. new InputOption('json', 'j', InputOption::VALUE_NONE, 'JSON decode the setting value, to be used with extra.* keys'),
  3155. 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'),
  3156. 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)'),
  3157. new InputOption('source', null, InputOption::VALUE_NONE, 'Display where the config value is loaded from'),
  3158. new InputArgument('setting-key', null, 'Setting key', null, $this->suggestSettingKeys()),
  3159. new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
  3160. ])
  3161. ->setHelp(
  3162. <<<EOT
  3163. This command allows you to edit composer config settings and repositories
  3164. in either the local composer.json file or the global config.json file.
  3165. Additionally it lets you edit most properties in the local composer.json.
  3166. To set a config setting:
  3167. <comment>%command.full_name% bin-dir bin/</comment>
  3168. To read a config setting:
  3169. <comment>%command.full_name% bin-dir</comment>
  3170. Outputs: <info>bin</info>
  3171. To edit the global config.json file:
  3172. <comment>%command.full_name% --global</comment>
  3173. To add a repository:
  3174. <comment>%command.full_name% repositories.foo vcs https://bar.com</comment>
  3175. To remove a repository (repo is a short alias for repositories):
  3176. <comment>%command.full_name% --unset repo.foo</comment>
  3177. To disable packagist:
  3178. <comment>%command.full_name% repo.packagist false</comment>
  3179. You can alter repositories in the global config.json file by passing in the
  3180. <info>--global</info> option.
  3181. To add or edit suggested packages you can use:
  3182. <comment>%command.full_name% suggest.package reason for the suggestion</comment>
  3183. To add or edit extra properties you can use:
  3184. <comment>%command.full_name% extra.property value</comment>
  3185. Or to add a complex value you can use json with:
  3186. <comment>%command.full_name% extra.property --json '{"foo":true, "bar": []}'</comment>
  3187. To edit the file in an external editor:
  3188. <comment>%command.full_name% --editor</comment>
  3189. To choose your editor you can set the "EDITOR" env variable.
  3190. To get a list of configuration values in the file:
  3191. <comment>%command.full_name% --list</comment>
  3192. You can always pass more than one option. As an example, if you want to edit the
  3193. global config.json file.
  3194. <comment>%command.full_name% --editor --global</comment>
  3195. Read more at https://getcomposer.org/doc/03-cli.md#config
  3196. EOT
  3197. )
  3198. ;
  3199. }
  3200. protected function initialize(InputInterface $input, OutputInterface $output): void
  3201. {
  3202. parent::initialize($input, $output);
  3203. if ($input->getOption('global') && null !== $input->getOption('file')) {
  3204. throw new \RuntimeException('--file and --global can not be combined');
  3205. }
  3206. $io = $this->getIO();
  3207. $this->config = Factory::createConfig($io);
  3208. $configFile = $this->getComposerConfigFile($input, $this->config);
  3209. if (
  3210. ($configFile === 'composer.json' || $configFile === './composer.json')
  3211. && !file_exists($configFile)
  3212. && realpath(Platform::getCwd()) === realpath($this->config->get('home'))
  3213. ) {
  3214. file_put_contents($configFile, "{\n}\n");
  3215. }
  3216. $this->configFile = new JsonFile($configFile, null, $io);
  3217. $this->configSource = new JsonConfigSource($this->configFile);
  3218. $authConfigFile = $this->getAuthConfigFile($input, $this->config);
  3219. $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
  3220. $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
  3221. if ($input->getOption('global') && !$this->configFile->exists()) {
  3222. touch($this->configFile->getPath());
  3223. $this->configFile->write(['config' => new \ArrayObject]);
  3224. Silencer::call('chmod', $this->configFile->getPath(), 0600);
  3225. }
  3226. if ($input->getOption('global') && !$this->authConfigFile->exists()) {
  3227. touch($this->authConfigFile->getPath());
  3228. $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]);
  3229. Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
  3230. }
  3231. if (!$this->configFile->exists()) {
  3232. throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
  3233. }
  3234. }
  3235. protected function execute(InputInterface $input, OutputInterface $output): int
  3236. {
  3237. if (true === $input->getOption('editor')) {
  3238. $editor = Platform::getEnv('EDITOR');
  3239. if (false === $editor || '' === $editor) {
  3240. if (Platform::isWindows()) {
  3241. $editor = 'notepad';
  3242. } else {
  3243. foreach (['editor', 'vim', 'vi', 'nano', 'pico', 'ed'] as $candidate) {
  3244. if (exec('which '.$candidate)) {
  3245. $editor = $candidate;
  3246. break;
  3247. }
  3248. }
  3249. }
  3250. } else {
  3251. $editor = escapeshellcmd($editor);
  3252. }
  3253. $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
  3254. system($editor . ' ' . $file . (Platform::isWindows() ? '' : ' > `tty`'));
  3255. return 0;
  3256. }
  3257. if (false === $input->getOption('global')) {
  3258. $this->config->merge($this->configFile->read(), $this->configFile->getPath());
  3259. $this->config->merge(['config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : []], $this->authConfigFile->getPath());
  3260. }
  3261. $this->getIO()->loadConfiguration($this->config);
  3262. if (true === $input->getOption('list')) {
  3263. $this->listConfiguration($this->config->all(), $this->config->raw(), $output, null, $input->getOption('source'));
  3264. return 0;
  3265. }
  3266. $settingKey = $input->getArgument('setting-key');
  3267. if (!is_string($settingKey)) {
  3268. return 0;
  3269. }
  3270. if ([] !== $input->getArgument('setting-value') && $input->getOption('unset')) {
  3271. throw new \RuntimeException('You can not combine a setting value with --unset');
  3272. }
  3273. if ([] === $input->getArgument('setting-value') && !$input->getOption('unset')) {
  3274. $properties = self::CONFIGURABLE_PACKAGE_PROPERTIES;
  3275. $propertiesDefaults = [
  3276. 'type' => 'library',
  3277. 'description' => '',
  3278. 'homepage' => '',
  3279. 'minimum-stability' => 'stable',
  3280. 'prefer-stable' => false,
  3281. 'keywords' => [],
  3282. 'license' => [],
  3283. 'suggest' => [],
  3284. 'extra' => [],
  3285. ];
  3286. $rawData = $this->configFile->read();
  3287. $data = $this->config->all();
  3288. $source = $this->config->getSourceOfValue($settingKey);
  3289. if (Preg::isMatch('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
  3290. if (!isset($matches[1])) {
  3291. $value = $data['repositories'] ?? [];
  3292. } else {
  3293. if (!isset($data['repositories'][$matches[1]])) {
  3294. throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
  3295. }
  3296. $value = $data['repositories'][$matches[1]];
  3297. }
  3298. } elseif (strpos($settingKey, '.')) {
  3299. $bits = explode('.', $settingKey);
  3300. if ($bits[0] === 'extra' || $bits[0] === 'suggest') {
  3301. $data = $rawData;
  3302. } else {
  3303. $data = $data['config'];
  3304. }
  3305. $match = false;
  3306. foreach ($bits as $bit) {
  3307. $key = isset($key) ? $key.'.'.$bit : $bit;
  3308. $match = false;
  3309. if (isset($data[$key])) {
  3310. $match = true;
  3311. $data = $data[$key];
  3312. unset($key);
  3313. }
  3314. }
  3315. if (!$match) {
  3316. throw new \RuntimeException($settingKey.' is not defined.');
  3317. }
  3318. $value = $data;
  3319. } elseif (isset($data['config'][$settingKey])) {
  3320. $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
  3321. if ($value === []) {
  3322. $schema = JsonFile::parseJson((string) file_get_contents(JsonFile::COMPOSER_SCHEMA_PATH));
  3323. if (
  3324. isset($schema['properties']['config']['properties'][$settingKey]['type'])
  3325. && in_array('object', (array) $schema['properties']['config']['properties'][$settingKey]['type'], true)
  3326. ) {
  3327. $value = new \stdClass;
  3328. }
  3329. }
  3330. } elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
  3331. $value = $rawData[$settingKey];
  3332. $source = $this->configFile->getPath();
  3333. } elseif (isset($propertiesDefaults[$settingKey])) {
  3334. $value = $propertiesDefaults[$settingKey];
  3335. $source = 'defaults';
  3336. } else {
  3337. throw new \RuntimeException($settingKey.' is not defined');
  3338. }
  3339. if (is_array($value) || is_object($value) || is_bool($value)) {
  3340. $value = JsonFile::encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
  3341. }
  3342. $sourceOfConfigValue = '';
  3343. if ($input->getOption('source')) {
  3344. $sourceOfConfigValue = ' (' . $source . ')';
  3345. }
  3346. $this->getIO()->write($value . $sourceOfConfigValue, true, IOInterface::QUIET);
  3347. return 0;
  3348. }
  3349. $values = $input->getArgument('setting-value');
  3350. $booleanValidator = static function ($val): bool {
  3351. return in_array($val, ['true', 'false', '1', '0'], true);
  3352. };
  3353. $booleanNormalizer = static function ($val): bool {
  3354. return $val !== 'false' && (bool) $val;
  3355. };
  3356. $uniqueConfigValues = [
  3357. 'process-timeout' => ['is_numeric', 'intval'],
  3358. 'use-include-path' => [$booleanValidator, $booleanNormalizer],
  3359. 'use-github-api' => [$booleanValidator, $booleanNormalizer],
  3360. 'preferred-install' => [
  3361. static function ($val): bool {
  3362. return in_array($val, ['auto', 'source', 'dist'], true);
  3363. },
  3364. static function ($val) {
  3365. return $val;
  3366. },
  3367. ],
  3368. 'gitlab-protocol' => [
  3369. static function ($val): bool {
  3370. return in_array($val, ['git', 'http', 'https'], true);
  3371. },
  3372. static function ($val) {
  3373. return $val;
  3374. },
  3375. ],
  3376. 'store-auths' => [
  3377. static function ($val): bool {
  3378. return in_array($val, ['true', 'false', 'prompt'], true);
  3379. },
  3380. static function ($val) {
  3381. if ('prompt' === $val) {
  3382. return 'prompt';
  3383. }
  3384. return $val !== 'false' && (bool) $val;
  3385. },
  3386. ],
  3387. 'notify-on-install' => [$booleanValidator, $booleanNormalizer],
  3388. 'vendor-dir' => ['is_string', static function ($val) {
  3389. return $val;
  3390. }],
  3391. 'bin-dir' => ['is_string', static function ($val) {
  3392. return $val;
  3393. }],
  3394. 'archive-dir' => ['is_string', static function ($val) {
  3395. return $val;
  3396. }],
  3397. 'archive-format' => ['is_string', static function ($val) {
  3398. return $val;
  3399. }],
  3400. 'data-dir' => ['is_string', static function ($val) {
  3401. return $val;
  3402. }],
  3403. 'cache-dir' => ['is_string', static function ($val) {
  3404. return $val;
  3405. }],
  3406. 'cache-files-dir' => ['is_string', static function ($val) {
  3407. return $val;
  3408. }],
  3409. 'cache-repo-dir' => ['is_string', static function ($val) {
  3410. return $val;
  3411. }],
  3412. 'cache-vcs-dir' => ['is_string', static function ($val) {
  3413. return $val;
  3414. }],
  3415. 'cache-ttl' => ['is_numeric', 'intval'],
  3416. 'cache-files-ttl' => ['is_numeric', 'intval'],
  3417. 'cache-files-maxsize' => [
  3418. static function ($val): bool {
  3419. return Preg::isMatch('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val);
  3420. },
  3421. static function ($val) {
  3422. return $val;
  3423. },
  3424. ],
  3425. 'bin-compat' => [
  3426. static function ($val): bool {
  3427. return in_array($val, ['auto', 'full', 'proxy', 'symlink']);
  3428. },
  3429. static function ($val) {
  3430. return $val;
  3431. },
  3432. ],
  3433. 'discard-changes' => [
  3434. static function ($val): bool {
  3435. return in_array($val, ['stash', 'true', 'false', '1', '0'], true);
  3436. },
  3437. static function ($val) {
  3438. if ('stash' === $val) {
  3439. return 'stash';
  3440. }
  3441. return $val !== 'false' && (bool) $val;
  3442. },
  3443. ],
  3444. 'autoloader-suffix' => ['is_string', static function ($val) {
  3445. return $val === 'null' ? null : $val;
  3446. }],
  3447. 'sort-packages' => [$booleanValidator, $booleanNormalizer],
  3448. 'optimize-autoloader' => [$booleanValidator, $booleanNormalizer],
  3449. 'classmap-authoritative' => [$booleanValidator, $booleanNormalizer],
  3450. 'apcu-autoloader' => [$booleanValidator, $booleanNormalizer],
  3451. 'prepend-autoloader' => [$booleanValidator, $booleanNormalizer],
  3452. 'disable-tls' => [$booleanValidator, $booleanNormalizer],
  3453. 'secure-http' => [$booleanValidator, $booleanNormalizer],
  3454. 'bump-after-update' => [
  3455. static function ($val): bool {
  3456. return in_array($val, ['dev', 'no-dev', 'true', 'false', '1', '0'], true);
  3457. },
  3458. static function ($val) {
  3459. if ('dev' === $val || 'no-dev' === $val) {
  3460. return $val;
  3461. }
  3462. return $val !== 'false' && (bool) $val;
  3463. },
  3464. ],
  3465. 'cafile' => [
  3466. static function ($val): bool {
  3467. return file_exists($val) && Filesystem::isReadable($val);
  3468. },
  3469. static function ($val) {
  3470. return $val === 'null' ? null : $val;
  3471. },
  3472. ],
  3473. 'capath' => [
  3474. static function ($val): bool {
  3475. return is_dir($val) && Filesystem::isReadable($val);
  3476. },
  3477. static function ($val) {
  3478. return $val === 'null' ? null : $val;
  3479. },
  3480. ],
  3481. 'github-expose-hostname' => [$booleanValidator, $booleanNormalizer],
  3482. 'htaccess-protect' => [$booleanValidator, $booleanNormalizer],
  3483. 'lock' => [$booleanValidator, $booleanNormalizer],
  3484. 'allow-plugins' => [$booleanValidator, $booleanNormalizer],
  3485. 'platform-check' => [
  3486. static function ($val): bool {
  3487. return in_array($val, ['php-only', 'true', 'false', '1', '0'], true);
  3488. },
  3489. static function ($val) {
  3490. if ('php-only' === $val) {
  3491. return 'php-only';
  3492. }
  3493. return $val !== 'false' && (bool) $val;
  3494. },
  3495. ],
  3496. 'use-parent-dir' => [
  3497. static function ($val): bool {
  3498. return in_array($val, ['true', 'false', 'prompt'], true);
  3499. },
  3500. static function ($val) {
  3501. if ('prompt' === $val) {
  3502. return 'prompt';
  3503. }
  3504. return $val !== 'false' && (bool) $val;
  3505. },
  3506. ],
  3507. 'audit.abandoned' => [
  3508. static function ($val): bool {
  3509. return in_array($val, [Auditor::ABANDONED_IGNORE, Auditor::ABANDONED_REPORT, Auditor::ABANDONED_FAIL], true);
  3510. },
  3511. static function ($val) {
  3512. return $val;
  3513. },
  3514. ],
  3515. ];
  3516. $multiConfigValues = [
  3517. 'github-protocols' => [
  3518. static function ($vals) {
  3519. if (!is_array($vals)) {
  3520. return 'array expected';
  3521. }
  3522. foreach ($vals as $val) {
  3523. if (!in_array($val, ['git', 'https', 'ssh'])) {
  3524. return 'valid protocols include: git, https, ssh';
  3525. }
  3526. }
  3527. return true;
  3528. },
  3529. static function ($vals) {
  3530. return $vals;
  3531. },
  3532. ],
  3533. 'github-domains' => [
  3534. static function ($vals) {
  3535. if (!is_array($vals)) {
  3536. return 'array expected';
  3537. }
  3538. return true;
  3539. },
  3540. static function ($vals) {
  3541. return $vals;
  3542. },
  3543. ],
  3544. 'gitlab-domains' => [
  3545. static function ($vals) {
  3546. if (!is_array($vals)) {
  3547. return 'array expected';
  3548. }
  3549. return true;
  3550. },
  3551. static function ($vals) {
  3552. return $vals;
  3553. },
  3554. ],
  3555. 'audit.ignore' => [
  3556. static function ($vals) {
  3557. if (!is_array($vals)) {
  3558. return 'array expected';
  3559. }
  3560. return true;
  3561. },
  3562. static function ($vals) {
  3563. return $vals;
  3564. },
  3565. ],
  3566. ];
  3567. if ($input->getOption('unset') && $settingKey === 'audit') {
  3568. $this->configSource->removeConfigSetting($settingKey);
  3569. return 0;
  3570. }
  3571. if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
  3572. if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
  3573. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  3574. }
  3575. $this->configSource->removeConfigSetting($settingKey);
  3576. return 0;
  3577. }
  3578. if (isset($uniqueConfigValues[$settingKey])) {
  3579. $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
  3580. return 0;
  3581. }
  3582. if (isset($multiConfigValues[$settingKey])) {
  3583. $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
  3584. return 0;
  3585. }
  3586. if (Preg::isMatch('/^preferred-install\.(.+)/', $settingKey, $matches)) {
  3587. if ($input->getOption('unset')) {
  3588. $this->configSource->removeConfigSetting($settingKey);
  3589. return 0;
  3590. }
  3591. [$validator] = $uniqueConfigValues['preferred-install'];
  3592. if (!$validator($values[0])) {
  3593. throw new \RuntimeException('Invalid value for '.$settingKey.'. Should be one of: auto, source, or dist');
  3594. }
  3595. $this->configSource->addConfigSetting($settingKey, $values[0]);
  3596. return 0;
  3597. }
  3598. if (Preg::isMatch('{^allow-plugins\.([a-zA-Z0-9/*-]+)}', $settingKey, $matches)) {
  3599. if ($input->getOption('unset')) {
  3600. $this->configSource->removeConfigSetting($settingKey);
  3601. return 0;
  3602. }
  3603. if (true !== $booleanValidator($values[0])) {
  3604. throw new \RuntimeException(sprintf(
  3605. '"%s" is an invalid value',
  3606. $values[0]
  3607. ));
  3608. }
  3609. $normalizedValue = $booleanNormalizer($values[0]);
  3610. $this->configSource->addConfigSetting($settingKey, $normalizedValue);
  3611. return 0;
  3612. }
  3613. $uniqueProps = [
  3614. 'name' => ['is_string', static function ($val) {
  3615. return $val;
  3616. }],
  3617. 'type' => ['is_string', static function ($val) {
  3618. return $val;
  3619. }],
  3620. 'description' => ['is_string', static function ($val) {
  3621. return $val;
  3622. }],
  3623. 'homepage' => ['is_string', static function ($val) {
  3624. return $val;
  3625. }],
  3626. 'version' => ['is_string', static function ($val) {
  3627. return $val;
  3628. }],
  3629. 'minimum-stability' => [
  3630. static function ($val): bool {
  3631. return isset(BasePackage::STABILITIES[VersionParser::normalizeStability($val)]);
  3632. },
  3633. static function ($val): string {
  3634. return VersionParser::normalizeStability($val);
  3635. },
  3636. ],
  3637. 'prefer-stable' => [$booleanValidator, $booleanNormalizer],
  3638. ];
  3639. $multiProps = [
  3640. 'keywords' => [
  3641. static function ($vals) {
  3642. if (!is_array($vals)) {
  3643. return 'array expected';
  3644. }
  3645. return true;
  3646. },
  3647. static function ($vals) {
  3648. return $vals;
  3649. },
  3650. ],
  3651. 'license' => [
  3652. static function ($vals) {
  3653. if (!is_array($vals)) {
  3654. return 'array expected';
  3655. }
  3656. return true;
  3657. },
  3658. static function ($vals) {
  3659. return $vals;
  3660. },
  3661. ],
  3662. ];
  3663. if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) {
  3664. 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');
  3665. }
  3666. if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
  3667. $this->configSource->removeProperty($settingKey);
  3668. return 0;
  3669. }
  3670. if (isset($uniqueProps[$settingKey])) {
  3671. $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
  3672. return 0;
  3673. }
  3674. if (isset($multiProps[$settingKey])) {
  3675. $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
  3676. return 0;
  3677. }
  3678. if (Preg::isMatchStrictGroups('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
  3679. if ($input->getOption('unset')) {
  3680. $this->configSource->removeRepository($matches[1]);
  3681. return 0;
  3682. }
  3683. if (2 === count($values)) {
  3684. $this->configSource->addRepository($matches[1], [
  3685. 'type' => $values[0],
  3686. 'url' => $values[1],
  3687. ], $input->getOption('append'));
  3688. return 0;
  3689. }
  3690. if (1 === count($values)) {
  3691. $value = strtolower($values[0]);
  3692. if (true === $booleanValidator($value)) {
  3693. if (false === $booleanNormalizer($value)) {
  3694. $this->configSource->addRepository($matches[1], false, $input->getOption('append'));
  3695. return 0;
  3696. }
  3697. } else {
  3698. $value = JsonFile::parseJson($values[0]);
  3699. $this->configSource->addRepository($matches[1], $value, $input->getOption('append'));
  3700. return 0;
  3701. }
  3702. }
  3703. throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
  3704. }
  3705. if (Preg::isMatch('/^extra\.(.+)/', $settingKey, $matches)) {
  3706. if ($input->getOption('unset')) {
  3707. $this->configSource->removeProperty($settingKey);
  3708. return 0;
  3709. }
  3710. $value = $values[0];
  3711. if ($input->getOption('json')) {
  3712. $value = JsonFile::parseJson($value);
  3713. if ($input->getOption('merge')) {
  3714. $currentValue = $this->configFile->read();
  3715. $bits = explode('.', $settingKey);
  3716. foreach ($bits as $bit) {
  3717. $currentValue = $currentValue[$bit] ?? null;
  3718. }
  3719. if (is_array($currentValue) && is_array($value)) {
  3720. if (array_is_list($currentValue) && array_is_list($value)) {
  3721. $value = array_merge($currentValue, $value);
  3722. } else {
  3723. $value = $value + $currentValue;
  3724. }
  3725. }
  3726. }
  3727. }
  3728. $this->configSource->addProperty($settingKey, $value);
  3729. return 0;
  3730. }
  3731. if (Preg::isMatch('/^suggest\.(.+)/', $settingKey, $matches)) {
  3732. if ($input->getOption('unset')) {
  3733. $this->configSource->removeProperty($settingKey);
  3734. return 0;
  3735. }
  3736. $this->configSource->addProperty($settingKey, implode(' ', $values));
  3737. return 0;
  3738. }
  3739. if (in_array($settingKey, ['suggest', 'extra'], true) && $input->getOption('unset')) {
  3740. $this->configSource->removeProperty($settingKey);
  3741. return 0;
  3742. }
  3743. if (Preg::isMatch('/^platform\.(.+)/', $settingKey, $matches)) {
  3744. if ($input->getOption('unset')) {
  3745. $this->configSource->removeConfigSetting($settingKey);
  3746. return 0;
  3747. }
  3748. $this->configSource->addConfigSetting($settingKey, $values[0] === 'false' ? false : $values[0]);
  3749. return 0;
  3750. }
  3751. if ($settingKey === 'platform' && $input->getOption('unset')) {
  3752. $this->configSource->removeConfigSetting($settingKey);
  3753. return 0;
  3754. }
  3755. if (Preg::isMatch('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|bearer)\.(.+)/', $settingKey, $matches)) {
  3756. if ($input->getOption('unset')) {
  3757. $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3758. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3759. return 0;
  3760. }
  3761. if ($matches[1] === 'bitbucket-oauth') {
  3762. if (2 !== count($values)) {
  3763. throw new \RuntimeException('Expected two arguments (consumer-key, consumer-secret), got '.count($values));
  3764. }
  3765. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3766. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], ['consumer-key' => $values[0], 'consumer-secret' => $values[1]]);
  3767. } elseif ($matches[1] === 'gitlab-token' && 2 === count($values)) {
  3768. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3769. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], ['username' => $values[0], 'token' => $values[1]]);
  3770. } elseif (in_array($matches[1], ['github-oauth', 'gitlab-oauth', 'gitlab-token', 'bearer'], true)) {
  3771. if (1 !== count($values)) {
  3772. throw new \RuntimeException('Too many arguments, expected only one token');
  3773. }
  3774. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3775. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
  3776. } elseif ($matches[1] === 'http-basic') {
  3777. if (2 !== count($values)) {
  3778. throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
  3779. }
  3780. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  3781. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], ['username' => $values[0], 'password' => $values[1]]);
  3782. }
  3783. return 0;
  3784. }
  3785. if (Preg::isMatch('/^scripts\.(.+)/', $settingKey, $matches)) {
  3786. if ($input->getOption('unset')) {
  3787. $this->configSource->removeProperty($settingKey);
  3788. return 0;
  3789. }
  3790. $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
  3791. return 0;
  3792. }
  3793. if ($input->getOption('unset')) {
  3794. $this->configSource->removeProperty($settingKey);
  3795. return 0;
  3796. }
  3797. throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
  3798. }
  3799. protected function handleSingleValue(string $key, array $callbacks, array $values, string $method): void
  3800. {
  3801. [$validator, $normalizer] = $callbacks;
  3802. if (1 !== count($values)) {
  3803. throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
  3804. }
  3805. if (true !== $validation = $validator($values[0])) {
  3806. throw new \RuntimeException(sprintf(
  3807. '"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  3808. $values[0]
  3809. ));
  3810. }
  3811. $normalizedValue = $normalizer($values[0]);
  3812. if ($key === 'disable-tls') {
  3813. if (!$normalizedValue && $this->config->get('disable-tls')) {
  3814. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  3815. } elseif ($normalizedValue && !$this->config->get('disable-tls')) {
  3816. $this->getIO()->writeError('<warning>You are now running Composer with SSL/TLS protection disabled.</warning>');
  3817. }
  3818. }
  3819. call_user_func([$this->configSource, $method], $key, $normalizedValue);
  3820. }
  3821. protected function handleMultiValue(string $key, array $callbacks, array $values, string $method): void
  3822. {
  3823. [$validator, $normalizer] = $callbacks;
  3824. if (true !== $validation = $validator($values)) {
  3825. throw new \RuntimeException(sprintf(
  3826. '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  3827. json_encode($values)
  3828. ));
  3829. }
  3830. call_user_func([$this->configSource, $method], $key, $normalizer($values));
  3831. }
  3832. protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, ?string $k = null, bool $showSource = false): void
  3833. {
  3834. $origK = $k;
  3835. $io = $this->getIO();
  3836. foreach ($contents as $key => $value) {
  3837. if ($k === null && !in_array($key, ['config', 'repositories'])) {
  3838. continue;
  3839. }
  3840. $rawVal = $rawContents[$key] ?? null;
  3841. if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
  3842. $k .= Preg::replace('{^config\.}', '', $key . '.');
  3843. $this->listConfiguration($value, $rawVal, $output, $k, $showSource);
  3844. $k = $origK;
  3845. continue;
  3846. }
  3847. if (is_array($value)) {
  3848. $value = array_map(static function ($val) {
  3849. return is_array($val) ? json_encode($val) : $val;
  3850. }, $value);
  3851. $value = '['.implode(', ', $value).']';
  3852. }
  3853. if (is_bool($value)) {
  3854. $value = var_export($value, true);
  3855. }
  3856. $source = '';
  3857. if ($showSource) {
  3858. $source = ' (' . $this->config->getSourceOfValue($k . $key) . ')';
  3859. }
  3860. if (null !== $k && 0 === strpos($k, 'repositories')) {
  3861. $link = 'https://getcomposer.org/doc/05-repositories.md';
  3862. } else {
  3863. $id = Preg::replace('{\..*$}', '', $k === '' || $k === null ? (string) $key : $k);
  3864. $id = Preg::replace('{[^a-z0-9]}i', '-', strtolower(trim($id)));
  3865. $id = Preg::replace('{-+}', '-', $id);
  3866. $link = 'https://getcomposer.org/doc/06-config.md#' . $id;
  3867. }
  3868. if (is_string($rawVal) && $rawVal !== $value) {
  3869. $io->write('[<fg=yellow;href=' . $link .'>' . $k . $key . '</>] <info>' . $rawVal . ' (' . $value . ')</info>' . $source, true, IOInterface::QUIET);
  3870. } else {
  3871. $io->write('[<fg=yellow;href=' . $link .'>' . $k . $key . '</>] <info>' . $value . '</info>' . $source, true, IOInterface::QUIET);
  3872. }
  3873. }
  3874. }
  3875. private function getComposerConfigFile(InputInterface $input, Config $config): string
  3876. {
  3877. return $input->getOption('global')
  3878. ? ($config->get('home') . '/config.json')
  3879. : ($input->getOption('file') ?: Factory::getComposerFile())
  3880. ;
  3881. }
  3882. private function getAuthConfigFile(InputInterface $input, Config $config): string
  3883. {
  3884. return $input->getOption('global')
  3885. ? ($config->get('home') . '/auth.json')
  3886. : dirname($this->getComposerConfigFile($input, $config)) . '/auth.json'
  3887. ;
  3888. }
  3889. private function suggestSettingKeys(): \Closure
  3890. {
  3891. return function (CompletionInput $input): array {
  3892. if ($input->getOption('list') || $input->getOption('editor') || $input->getOption('auth')) {
  3893. return [];
  3894. }
  3895. $config = Factory::createConfig();
  3896. $configFile = new JsonFile($this->getComposerConfigFile($input, $config));
  3897. if ($configFile->exists()) {
  3898. $config->merge($configFile->read(), $configFile->getPath());
  3899. }
  3900. $authConfigFile = new JsonFile($this->getAuthConfigFile($input, $config));
  3901. if ($authConfigFile->exists()) {
  3902. $config->merge(['config' => $authConfigFile->read()], $authConfigFile->getPath());
  3903. }
  3904. $rawConfig = $config->raw();
  3905. $keys = array_merge(
  3906. $this->flattenSettingKeys($rawConfig['config']),
  3907. $this->flattenSettingKeys($rawConfig['repositories'], 'repositories.')
  3908. );
  3909. if ($input->getOption('unset')) {
  3910. $sources = [$configFile->getPath(), $authConfigFile->getPath()];
  3911. $keys = array_filter(
  3912. $keys,
  3913. static function (string $key) use ($config, $sources): bool {
  3914. return in_array($config->getSourceOfValue($key), $sources, true);
  3915. }
  3916. );
  3917. } else {
  3918. $keys = array_merge($keys, self::CONFIGURABLE_PACKAGE_PROPERTIES);
  3919. }
  3920. if ($configFile->exists()) {
  3921. $properties = array_filter(
  3922. $configFile->read(),
  3923. static function (string $key): bool {
  3924. return in_array($key, self::CONFIGURABLE_PACKAGE_PROPERTIES, true);
  3925. },
  3926. ARRAY_FILTER_USE_KEY
  3927. );
  3928. $keys = array_merge(
  3929. $keys,
  3930. $this->flattenSettingKeys($properties)
  3931. );
  3932. }
  3933. $completionValue = $input->getCompletionValue();
  3934. if ($completionValue !== '') {
  3935. $keys = array_filter(
  3936. $keys,
  3937. static function (string $key) use ($completionValue): bool {
  3938. return str_starts_with($key, $completionValue);
  3939. }
  3940. );
  3941. }
  3942. sort($keys);
  3943. return array_unique($keys);
  3944. };
  3945. }
  3946. private function flattenSettingKeys(array $config, string $prefix = ''): array
  3947. {
  3948. $keys = [];
  3949. foreach ($config as $key => $value) {
  3950. $keys[] = [$prefix . $key];
  3951. if (is_array($value) && !array_is_list($value) && $prefix !== 'repositories.') {
  3952. $keys[] = $this->flattenSettingKeys($value, $prefix . $key . '.');
  3953. }
  3954. }
  3955. return array_merge(...$keys);
  3956. }
  3957. }
  3958. <?php declare(strict_types=1);
  3959. namespace Composer\Command;
  3960. use Composer\Config;
  3961. use Composer\Factory;
  3962. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  3963. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  3964. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  3965. use Composer\Installer;
  3966. use Composer\Installer\ProjectInstaller;
  3967. use Composer\Installer\SuggestedPackagesReporter;
  3968. use Composer\IO\IOInterface;
  3969. use Composer\Package\BasePackage;
  3970. use Composer\DependencyResolver\Operation\InstallOperation;
  3971. use Composer\Package\Version\VersionSelector;
  3972. use Composer\Package\AliasPackage;
  3973. use Composer\Pcre\Preg;
  3974. use Composer\Plugin\PluginBlockedException;
  3975. use Composer\Repository\RepositoryFactory;
  3976. use Composer\Repository\CompositeRepository;
  3977. use Composer\Repository\PlatformRepository;
  3978. use Composer\Repository\InstalledArrayRepository;
  3979. use Composer\Repository\RepositorySet;
  3980. use Composer\Script\ScriptEvents;
  3981. use Composer\Util\Silencer;
  3982. use Composer\Console\Input\InputArgument;
  3983. use Seld\Signal\SignalHandler;
  3984. use Symfony\Component\Console\Input\InputInterface;
  3985. use Composer\Console\Input\InputOption;
  3986. use Symfony\Component\Console\Output\OutputInterface;
  3987. use Symfony\Component\Finder\Finder;
  3988. use Composer\Json\JsonFile;
  3989. use Composer\Config\JsonConfigSource;
  3990. use Composer\Util\Filesystem;
  3991. use Composer\Util\Platform;
  3992. use Composer\Util\ProcessExecutor;
  3993. use Composer\Package\Version\VersionParser;
  3994. use Composer\Advisory\Auditor;
  3995. class CreateProjectCommand extends BaseCommand
  3996. {
  3997. use CompletionTrait;
  3998. protected $suggestedPackagesReporter;
  3999. protected function configure(): void
  4000. {
  4001. $this
  4002. ->setName('create-project')
  4003. ->setDescription('Creates new project from a package into given directory')
  4004. ->setDefinition([
  4005. new InputArgument('package', InputArgument::OPTIONAL, 'Package name to be installed', null, $this->suggestAvailablePackage()),
  4006. new InputArgument('directory', InputArgument::OPTIONAL, 'Directory where the files should be created'),
  4007. new InputArgument('version', InputArgument::OPTIONAL, 'Version, will default to latest'),
  4008. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum-stability allowed (unless a version is specified).'),
  4009. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  4010. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  4011. 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()),
  4012. 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'),
  4013. new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'DEPRECATED: Use --repository instead.'),
  4014. 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.'),
  4015. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  4016. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  4017. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  4018. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
  4019. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4020. 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.'),
  4021. new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'),
  4022. new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'),
  4023. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
  4024. 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).'),
  4025. new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json" or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
  4026. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4027. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4028. new InputOption('ask', null, InputOption::VALUE_NONE, 'Whether to ask for project directory.'),
  4029. ])
  4030. ->setHelp(
  4031. <<<EOT
  4032. The <info>create-project</info> command creates a new project from a given
  4033. package into a new directory. If executed without params and in a directory
  4034. with a composer.json file it installs the packages for the current project.
  4035. You can use this command to bootstrap new projects or setup a clean
  4036. version-controlled installation for developers of your project.
  4037. <info>php composer.phar create-project vendor/project target-directory [version]</info>
  4038. You can also specify the version with the package name using = or : as separator.
  4039. <info>php composer.phar create-project vendor/project:version target-directory</info>
  4040. To install unstable packages, either specify the version you want, or use the
  4041. --stability=dev (where dev can be one of RC, beta, alpha or dev).
  4042. To setup a developer workable version you should create the project using the source
  4043. controlled code by appending the <info>'--prefer-source'</info> flag.
  4044. To install a package from another repository than the default one you
  4045. can pass the <info>'--repository=https://myrepository.org'</info> flag.
  4046. Read more at https://getcomposer.org/doc/03-cli.md#create-project
  4047. EOT
  4048. )
  4049. ;
  4050. }
  4051. protected function execute(InputInterface $input, OutputInterface $output): int
  4052. {
  4053. $config = Factory::createConfig();
  4054. $io = $this->getIO();
  4055. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($config, $input, true);
  4056. if ($input->getOption('dev')) {
  4057. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  4058. }
  4059. if ($input->getOption('no-custom-installers')) {
  4060. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  4061. $input->setOption('no-plugins', true);
  4062. }
  4063. if ($input->isInteractive() && $input->getOption('ask')) {
  4064. $package = $input->getArgument('package');
  4065. if (null === $package) {
  4066. throw new \RuntimeException('Not enough arguments (missing: "package").');
  4067. }
  4068. $parts = explode("/", strtolower($package), 2);
  4069. $input->setArgument('directory', $io->ask('New project directory [<comment>'.array_pop($parts).'</comment>]: '));
  4070. }
  4071. return $this->installProject(
  4072. $io,
  4073. $config,
  4074. $input,
  4075. $input->getArgument('package'),
  4076. $input->getArgument('directory'),
  4077. $input->getArgument('version'),
  4078. $input->getOption('stability'),
  4079. $preferSource,
  4080. $preferDist,
  4081. !$input->getOption('no-dev'),
  4082. \count($input->getOption('repository')) > 0 ? $input->getOption('repository') : $input->getOption('repository-url'),
  4083. $input->getOption('no-plugins'),
  4084. $input->getOption('no-scripts'),
  4085. $input->getOption('no-progress'),
  4086. $input->getOption('no-install'),
  4087. $this->getPlatformRequirementFilter($input),
  4088. !$input->getOption('no-secure-http'),
  4089. $input->getOption('add-repository')
  4090. );
  4091. }
  4092. 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
  4093. {
  4094. $oldCwd = Platform::getCwd();
  4095. if ($repositories !== null && !is_array($repositories)) {
  4096. $repositories = (array) $repositories;
  4097. }
  4098. $platformRequirementFilter = $platformRequirementFilter ?? PlatformRequirementFilterFactory::ignoreNothing();
  4099. $io->loadConfiguration($config);
  4100. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($io);
  4101. if ($packageName !== null) {
  4102. $installedFromVcs = $this->installRootPackage($input, $io, $config, $packageName, $platformRequirementFilter, $directory, $packageVersion, $stability, $preferSource, $preferDist, $installDevPackages, $repositories, $disablePlugins, $disableScripts, $noProgress, $secureHttp);
  4103. } else {
  4104. $installedFromVcs = false;
  4105. }
  4106. if ($repositories !== null && $addRepository && is_file('composer.lock')) {
  4107. unlink('composer.lock');
  4108. }
  4109. $composer = $this->createComposerInstance($input, $io, null, $disablePlugins, $disableScripts);
  4110. if ($repositories !== null && $addRepository) {
  4111. foreach ($repositories as $index => $repo) {
  4112. $repoConfig = RepositoryFactory::configFromString($io, $composer->getConfig(), $repo, true);
  4113. $composerJsonRepositoriesConfig = $composer->getConfig()->getRepositories();
  4114. $name = RepositoryFactory::generateRepositoryName($index, $repoConfig, $composerJsonRepositoriesConfig);
  4115. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  4116. if (
  4117. (isset($repoConfig['packagist']) && $repoConfig === ['packagist' => false])
  4118. || (isset($repoConfig['packagist.org']) && $repoConfig === ['packagist.org' => false])
  4119. ) {
  4120. $configSource->addRepository('packagist.org', false);
  4121. } else {
  4122. $configSource->addRepository($name, $repoConfig, false);
  4123. }
  4124. $composer = $this->createComposerInstance($input, $io, null, $disablePlugins);
  4125. }
  4126. }
  4127. $process = $composer->getLoop()->getProcessExecutor();
  4128. $fs = new Filesystem($process);
  4129. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
  4130. $config = $composer->getConfig();
  4131. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($config, $input);
  4132. if ($noInstall === false) {
  4133. $composer->getInstallationManager()->setOutputProgress(!$noProgress);
  4134. $installer = Installer::create($io, $composer);
  4135. $installer->setPreferSource($preferSource)
  4136. ->setPreferDist($preferDist)
  4137. ->setDevMode($installDevPackages)
  4138. ->setPlatformRequirementFilter($platformRequirementFilter)
  4139. ->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
  4140. ->setOptimizeAutoloader($config->get('optimize-autoloader'))
  4141. ->setClassMapAuthoritative($config->get('classmap-authoritative'))
  4142. ->setApcuAutoloader($config->get('apcu-autoloader'))
  4143. ->setAudit(!$input->getOption('no-audit'))
  4144. ->setAuditFormat($this->getAuditFormat($input));
  4145. if (!$composer->getLocker()->isLocked()) {
  4146. $installer->setUpdate(true);
  4147. }
  4148. if ($disablePlugins) {
  4149. $installer->disablePlugins();
  4150. }
  4151. try {
  4152. $status = $installer->run();
  4153. if (0 !== $status) {
  4154. return $status;
  4155. }
  4156. } catch (PluginBlockedException $e) {
  4157. $io->writeError('<error>Hint: To allow running the config command recommended below before dependencies are installed, run create-project with --no-install.</error>');
  4158. $io->writeError('<error>You can then cd into '.getcwd().', configure allow-plugins, and finally run a composer install to complete the process.</error>');
  4159. throw $e;
  4160. }
  4161. }
  4162. $hasVcs = $installedFromVcs;
  4163. if (
  4164. !$input->getOption('keep-vcs')
  4165. && $installedFromVcs
  4166. && (
  4167. $input->getOption('remove-vcs')
  4168. || !$io->isInteractive()
  4169. || $io->askConfirmation('<info>Do you want to remove the existing VCS (.git, .svn..) history?</info> [<comment>Y,n</comment>]? ')
  4170. )
  4171. ) {
  4172. $finder = new Finder();
  4173. $finder->depth(0)->directories()->in(Platform::getCwd())->ignoreVCS(false)->ignoreDotFiles(false);
  4174. foreach (['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_'] as $vcsName) {
  4175. $finder->name($vcsName);
  4176. }
  4177. try {
  4178. $dirs = iterator_to_array($finder);
  4179. unset($finder);
  4180. foreach ($dirs as $dir) {
  4181. if (!$fs->removeDirectory((string) $dir)) {
  4182. throw new \RuntimeException('Could not remove '.$dir);
  4183. }
  4184. }
  4185. } catch (\Exception $e) {
  4186. $io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
  4187. }
  4188. $hasVcs = false;
  4189. }
  4190. if (!$hasVcs) {
  4191. $package = $composer->getPackage();
  4192. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  4193. foreach (BasePackage::$supportedLinkTypes as $type => $meta) {
  4194. foreach ($package->{'get'.$meta['method']}() as $link) {
  4195. if ($link->getPrettyConstraint() === 'self.version') {
  4196. $configSource->addLink($type, $link->getTarget(), $package->getPrettyVersion());
  4197. }
  4198. }
  4199. }
  4200. }
  4201. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
  4202. chdir($oldCwd);
  4203. return 0;
  4204. }
  4205. protected function installRootPackage(InputInterface $input, 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
  4206. {
  4207. $parser = new VersionParser();
  4208. $requirements = $parser->parseNameVersionPairs([$packageName]);
  4209. $name = strtolower($requirements[0]['name']);
  4210. if (!$packageVersion && isset($requirements[0]['version'])) {
  4211. $packageVersion = $requirements[0]['version'];
  4212. }
  4213. if (null === $directory) {
  4214. $parts = explode("/", $name, 2);
  4215. $directory = Platform::getCwd() . DIRECTORY_SEPARATOR . array_pop($parts);
  4216. }
  4217. $directory = rtrim($directory, '/\\');
  4218. $process = new ProcessExecutor($io);
  4219. $fs = new Filesystem($process);
  4220. if (!$fs->isAbsolutePath($directory)) {
  4221. $directory = Platform::getCwd() . DIRECTORY_SEPARATOR . $directory;
  4222. }
  4223. if ('' === $directory) {
  4224. throw new \UnexpectedValueException('Got an empty target directory, something went wrong');
  4225. }
  4226. $config->setBaseDir($directory);
  4227. if (!$secureHttp) {
  4228. $config->merge(['config' => ['secure-http' => false]], Config::SOURCE_COMMAND);
  4229. }
  4230. $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(Platform::getCwd(), $directory, true) . '"</info>');
  4231. if (file_exists($directory)) {
  4232. if (!is_dir($directory)) {
  4233. throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.');
  4234. }
  4235. if (!$fs->isDirEmpty($directory)) {
  4236. throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.');
  4237. }
  4238. }
  4239. if (null === $stability) {
  4240. if (null === $packageVersion) {
  4241. $stability = 'stable';
  4242. } elseif (Preg::isMatchStrictGroups('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::STABILITIES)).')$}i', $packageVersion, $match)) {
  4243. $stability = $match[1];
  4244. } else {
  4245. $stability = VersionParser::parseStability($packageVersion);
  4246. }
  4247. }
  4248. $stability = VersionParser::normalizeStability($stability);
  4249. if (!isset(BasePackage::STABILITIES[$stability])) {
  4250. throw new \InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::STABILITIES)));
  4251. }
  4252. $composer = $this->createComposerInstance($input, $io, $config->all(), $disablePlugins, $disableScripts);
  4253. $config = $composer->getConfig();
  4254. $config->setBaseDir($directory);
  4255. $rm = $composer->getRepositoryManager();
  4256. $repositorySet = new RepositorySet($stability);
  4257. if (null === $repositories) {
  4258. $repositorySet->addRepository(new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm)));
  4259. } else {
  4260. foreach ($repositories as $repo) {
  4261. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  4262. if (
  4263. (isset($repoConfig['packagist']) && $repoConfig === ['packagist' => false])
  4264. || (isset($repoConfig['packagist.org']) && $repoConfig === ['packagist.org' => false])
  4265. ) {
  4266. continue;
  4267. }
  4268. if (($repoConfig['type'] ?? null) === 'path' && !isset($repoConfig['options']['symlink'])) {
  4269. $repoConfig['options']['symlink'] = false;
  4270. }
  4271. $repositorySet->addRepository(RepositoryFactory::createRepo($io, $config, $repoConfig, $rm));
  4272. }
  4273. }
  4274. $platformOverrides = $config->get('platform');
  4275. $platformRepo = new PlatformRepository([], $platformOverrides);
  4276. $versionSelector = new VersionSelector($repositorySet, $platformRepo);
  4277. $package = $versionSelector->findBestCandidate($name, $packageVersion, $stability, $platformRequirementFilter, 0, $io);
  4278. if (!$package) {
  4279. $errorMessage = "Could not find package $name with " . ($packageVersion ? "version $packageVersion" : "stability $stability");
  4280. if (!($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter) && $versionSelector->findBestCandidate($name, $packageVersion, $stability, PlatformRequirementFilterFactory::ignoreAll())) {
  4281. throw new \InvalidArgumentException($errorMessage .' in a version installable using your PHP version, PHP extensions and Composer version.');
  4282. }
  4283. throw new \InvalidArgumentException($errorMessage .'.');
  4284. }
  4285. @mkdir($directory, 0777, true);
  4286. if (false !== ($realDir = realpath($directory))) {
  4287. $signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) use ($realDir) {
  4288. $this->getIO()->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG);
  4289. $fs = new Filesystem();
  4290. $fs->removeDirectory($realDir);
  4291. $handler->exitWithLastSignal();
  4292. });
  4293. }
  4294. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  4295. $package = $package->getAliasOf();
  4296. }
  4297. $io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
  4298. if ($disablePlugins) {
  4299. $io->writeError('<info>Plugins have been disabled.</info>');
  4300. }
  4301. if ($package instanceof AliasPackage) {
  4302. $package = $package->getAliasOf();
  4303. }
  4304. $dm = $composer->getDownloadManager();
  4305. $dm->setPreferSource($preferSource)
  4306. ->setPreferDist($preferDist);
  4307. $projectInstaller = new ProjectInstaller($directory, $dm, $fs);
  4308. $im = $composer->getInstallationManager();
  4309. $im->setOutputProgress(!$noProgress);
  4310. $im->addInstaller($projectInstaller);
  4311. $im->execute(new InstalledArrayRepository(), [new InstallOperation($package)]);
  4312. $im->notifyInstalls($io);
  4313. $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
  4314. $installedFromVcs = 'source' === $package->getInstallationSource();
  4315. $io->writeError('<info>Created project in ' . $directory . '</info>');
  4316. chdir($directory);
  4317. if (file_exists($directory.'/composer.json') && Platform::getEnv('COMPOSER') !== false) {
  4318. Platform::clearEnv('COMPOSER');
  4319. }
  4320. Platform::putEnv('COMPOSER_ROOT_VERSION', $package->getPrettyVersion());
  4321. if (isset($signalHandler)) {
  4322. $signalHandler->unregister();
  4323. }
  4324. return $installedFromVcs;
  4325. }
  4326. }
  4327. <?php declare(strict_types=1);
  4328. namespace Composer\Command;
  4329. use Symfony\Component\Console\Input\InputInterface;
  4330. use Symfony\Component\Console\Output\OutputInterface;
  4331. use Composer\Console\Input\InputArgument;
  4332. use Composer\Console\Input\InputOption;
  4333. class DependsCommand extends BaseDependencyCommand
  4334. {
  4335. use CompletionTrait;
  4336. protected function configure(): void
  4337. {
  4338. $this
  4339. ->setName('depends')
  4340. ->setAliases(['why'])
  4341. ->setDescription('Shows which packages cause the given package to be installed')
  4342. ->setDefinition([
  4343. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect', null, $this->suggestInstalledPackage(true, true)),
  4344. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  4345. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  4346. new InputOption('locked', null, InputOption::VALUE_NONE, 'Read dependency information from composer.lock'),
  4347. ])
  4348. ->setHelp(
  4349. <<<EOT
  4350. Displays detailed information about where a package is referenced.
  4351. <info>php composer.phar depends composer/composer</info>
  4352. Read more at https://getcomposer.org/doc/03-cli.md#depends-why
  4353. EOT
  4354. )
  4355. ;
  4356. }
  4357. protected function execute(InputInterface $input, OutputInterface $output): int
  4358. {
  4359. return parent::doExecute($input, $output);
  4360. }
  4361. }
  4362. <?php declare(strict_types=1);
  4363. namespace Composer\Command;
  4364. use Composer\Advisory\Auditor;
  4365. use Composer\Composer;
  4366. use Composer\Factory;
  4367. use Composer\Config;
  4368. use Composer\Downloader\TransportException;
  4369. use Composer\IO\BufferIO;
  4370. use Composer\Json\JsonFile;
  4371. use Composer\Json\JsonValidationException;
  4372. use Composer\Package\Locker;
  4373. use Composer\Package\RootPackage;
  4374. use Composer\Package\Version\VersionParser;
  4375. use Composer\Pcre\Preg;
  4376. use Composer\Repository\ComposerRepository;
  4377. use Composer\Repository\FilesystemRepository;
  4378. use Composer\Repository\PlatformRepository;
  4379. use Composer\Plugin\CommandEvent;
  4380. use Composer\Plugin\PluginEvents;
  4381. use Composer\Repository\RepositorySet;
  4382. use Composer\Repository\RootPackageRepository;
  4383. use Composer\Util\ConfigValidator;
  4384. use Composer\Util\Git;
  4385. use Composer\Util\IniHelper;
  4386. use Composer\Util\ProcessExecutor;
  4387. use Composer\Util\HttpDownloader;
  4388. use Composer\Util\StreamContextFactory;
  4389. use Composer\Util\Platform;
  4390. use Composer\SelfUpdate\Keys;
  4391. use Composer\SelfUpdate\Versions;
  4392. use Composer\IO\NullIO;
  4393. use Composer\Package\CompletePackageInterface;
  4394. use Composer\XdebugHandler\XdebugHandler;
  4395. use Symfony\Component\Console\Input\InputInterface;
  4396. use Symfony\Component\Console\Output\OutputInterface;
  4397. use Symfony\Component\Process\ExecutableFinder;
  4398. use Composer\Util\Http\ProxyManager;
  4399. use Composer\Util\Http\RequestProxy;
  4400. class DiagnoseCommand extends BaseCommand
  4401. {
  4402. protected $httpDownloader;
  4403. protected $process;
  4404. protected $exitCode = 0;
  4405. protected function configure(): void
  4406. {
  4407. $this
  4408. ->setName('diagnose')
  4409. ->setDescription('Diagnoses the system to identify common errors')
  4410. ->setHelp(
  4411. <<<EOT
  4412. The <info>diagnose</info> command checks common errors to help debugging problems.
  4413. The process exit code will be 1 in case of warnings and 2 for errors.
  4414. Read more at https://getcomposer.org/doc/03-cli.md#diagnose
  4415. EOT
  4416. )
  4417. ;
  4418. }
  4419. protected function execute(InputInterface $input, OutputInterface $output): int
  4420. {
  4421. $composer = $this->tryComposer();
  4422. $io = $this->getIO();
  4423. if ($composer) {
  4424. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  4425. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4426. $io->write('Checking composer.json: ', false);
  4427. $this->outputResult($this->checkComposerSchema());
  4428. if ($composer->getLocker()->isLocked()) {
  4429. $io->write('Checking composer.lock: ', false);
  4430. $this->outputResult($this->checkComposerLockSchema($composer->getLocker()));
  4431. }
  4432. $this->process = $composer->getLoop()->getProcessExecutor() ?? new ProcessExecutor($io);
  4433. } else {
  4434. $this->process = new ProcessExecutor($io);
  4435. }
  4436. if ($composer) {
  4437. $config = $composer->getConfig();
  4438. } else {
  4439. $config = Factory::createConfig();
  4440. }
  4441. $config->merge(['config' => ['secure-http' => false]], Config::SOURCE_COMMAND);
  4442. $config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
  4443. $this->httpDownloader = Factory::createHttpDownloader($io, $config);
  4444. $io->write('Checking platform settings: ', false);
  4445. $this->outputResult($this->checkPlatform());
  4446. $io->write('Checking git settings: ', false);
  4447. $this->outputResult($this->checkGit());
  4448. $io->write('Checking http connectivity to packagist: ', false);
  4449. $this->outputResult($this->checkHttp('http', $config));
  4450. $io->write('Checking https connectivity to packagist: ', false);
  4451. $this->outputResult($this->checkHttp('https', $config));
  4452. foreach ($config->getRepositories() as $repo) {
  4453. if (($repo['type'] ?? null) === 'composer' && isset($repo['url'])) {
  4454. $composerRepo = new ComposerRepository($repo, $this->getIO(), $config, $this->httpDownloader);
  4455. $reflMethod = new \ReflectionMethod($composerRepo, 'getPackagesJsonUrl');
  4456. if (PHP_VERSION_ID < 80100) {
  4457. $reflMethod->setAccessible(true);
  4458. }
  4459. $url = $reflMethod->invoke($composerRepo);
  4460. if (!str_starts_with($url, 'http')) {
  4461. continue;
  4462. }
  4463. if (str_starts_with($url, 'https://repo.packagist.org')) {
  4464. continue;
  4465. }
  4466. $io->write('Checking connectivity to ' . $repo['url'].': ', false);
  4467. $this->outputResult($this->checkComposerRepo($url, $config));
  4468. }
  4469. }
  4470. $proxyManager = ProxyManager::getInstance();
  4471. $protos = $config->get('disable-tls') === true ? ['http'] : ['http', 'https'];
  4472. try {
  4473. foreach ($protos as $proto) {
  4474. $proxy = $proxyManager->getProxyForRequest($proto.'://repo.packagist.org');
  4475. if ($proxy->getStatus() !== '') {
  4476. $type = $proxy->isSecure() ? 'HTTPS' : 'HTTP';
  4477. $io->write('Checking '.$type.' proxy with '.$proto.': ', false);
  4478. $this->outputResult($this->checkHttpProxy($proxy, $proto));
  4479. }
  4480. }
  4481. } catch (TransportException $e) {
  4482. $io->write('Checking HTTP proxy: ', false);
  4483. $status = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4484. $this->outputResult(is_string($status) ? $status : $e);
  4485. }
  4486. if (count($oauth = $config->get('github-oauth')) > 0) {
  4487. foreach ($oauth as $domain => $token) {
  4488. $io->write('Checking '.$domain.' oauth access: ', false);
  4489. $this->outputResult($this->checkGithubOauth($domain, $token));
  4490. }
  4491. } else {
  4492. $io->write('Checking github.com rate limit: ', false);
  4493. try {
  4494. $rate = $this->getGithubRateLimit('github.com');
  4495. if (!is_array($rate)) {
  4496. $this->outputResult($rate);
  4497. } elseif (10 > $rate['remaining']) {
  4498. $io->write('<warning>WARNING</warning>');
  4499. $io->write(sprintf(
  4500. '<comment>GitHub has a rate limit on their API. '
  4501. . 'You currently have <options=bold>%u</options=bold> '
  4502. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  4503. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  4504. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  4505. $rate['remaining'],
  4506. $rate['limit']
  4507. ));
  4508. } else {
  4509. $this->outputResult(true);
  4510. }
  4511. } catch (\Exception $e) {
  4512. if ($e instanceof TransportException && $e->getCode() === 401) {
  4513. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  4514. } else {
  4515. $this->outputResult($e);
  4516. }
  4517. }
  4518. }
  4519. $io->write('Checking disk free space: ', false);
  4520. $this->outputResult($this->checkDiskSpace($config));
  4521. if (strpos(__FILE__, 'phar:') === 0) {
  4522. $io->write('Checking pubkeys: ', false);
  4523. $this->outputResult($this->checkPubKeys($config));
  4524. $io->write('Checking Composer version: ', false);
  4525. $this->outputResult($this->checkVersion($config));
  4526. }
  4527. $io->write('Checking Composer and its dependencies for vulnerabilities: ', false);
  4528. $this->outputResult($this->checkComposerAudit($config));
  4529. $io->write(sprintf('Composer version: <comment>%s</comment>', Composer::getVersion()));
  4530. $platformOverrides = $config->get('platform') ?: [];
  4531. $platformRepo = new PlatformRepository([], $platformOverrides);
  4532. $phpPkg = $platformRepo->findPackage('php', '*');
  4533. $phpVersion = $phpPkg->getPrettyVersion();
  4534. if ($phpPkg instanceof CompletePackageInterface && str_contains((string) $phpPkg->getDescription(), 'overridden')) {
  4535. $phpVersion .= ' - ' . $phpPkg->getDescription();
  4536. }
  4537. $io->write(sprintf('PHP version: <comment>%s</comment>', $phpVersion));
  4538. if (defined('PHP_BINARY')) {
  4539. $io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
  4540. }
  4541. $io->write('OpenSSL version: ' . (defined('OPENSSL_VERSION_TEXT') ? '<comment>'.OPENSSL_VERSION_TEXT.'</comment>' : '<error>missing</error>'));
  4542. $io->write('curl version: ' . $this->getCurlVersion());
  4543. $finder = new ExecutableFinder;
  4544. $hasSystemUnzip = (bool) $finder->find('unzip');
  4545. $bin7zip = '';
  4546. if ($hasSystem7zip = (bool) $finder->find('7z', null, ['C:\Program Files\7-Zip'])) {
  4547. $bin7zip = '7z';
  4548. }
  4549. if (!Platform::isWindows() && !$hasSystem7zip && $hasSystem7zip = (bool) $finder->find('7zz')) {
  4550. $bin7zip = '7zz';
  4551. }
  4552. $io->write(
  4553. 'zip: ' . (extension_loaded('zip') ? '<comment>extension present</comment>' : '<comment>extension not loaded</comment>')
  4554. . ', ' . ($hasSystemUnzip ? '<comment>unzip present</comment>' : '<comment>unzip not available</comment>')
  4555. . ', ' . ($hasSystem7zip ? '<comment>7-Zip present ('.$bin7zip.')</comment>' : '<comment>7-Zip not available</comment>')
  4556. . (($hasSystem7zip || $hasSystemUnzip) && !function_exists('proc_open') ? ', <warning>proc_open is disabled or not present, unzip/7-z will not be usable</warning>' : '')
  4557. );
  4558. return $this->exitCode;
  4559. }
  4560. private function checkComposerSchema()
  4561. {
  4562. $validator = new ConfigValidator($this->getIO());
  4563. [$errors, , $warnings] = $validator->validate(Factory::getComposerFile());
  4564. if ($errors || $warnings) {
  4565. $messages = [
  4566. 'error' => $errors,
  4567. 'warning' => $warnings,
  4568. ];
  4569. $output = '';
  4570. foreach ($messages as $style => $msgs) {
  4571. foreach ($msgs as $msg) {
  4572. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  4573. }
  4574. }
  4575. return rtrim($output);
  4576. }
  4577. return true;
  4578. }
  4579. private function checkComposerLockSchema(Locker $locker)
  4580. {
  4581. $json = $locker->getJsonFile();
  4582. try {
  4583. $json->validateSchema(JsonFile::LOCK_SCHEMA);
  4584. } catch (JsonValidationException $e) {
  4585. $output = '';
  4586. foreach ($e->getErrors() as $error) {
  4587. $output .= '<error>'.$error.'</error>'.PHP_EOL;
  4588. }
  4589. return trim($output);
  4590. }
  4591. return true;
  4592. }
  4593. private function checkGit(): string
  4594. {
  4595. if (!function_exists('proc_open')) {
  4596. return '<comment>proc_open is not available, git cannot be used</comment>';
  4597. }
  4598. $this->process->execute(['git', 'config', 'color.ui'], $output);
  4599. if (strtolower(trim($output)) === 'always') {
  4600. 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>';
  4601. }
  4602. $gitVersion = Git::getVersion($this->process);
  4603. if (null === $gitVersion) {
  4604. return '<comment>No git process found</>';
  4605. }
  4606. if (version_compare('2.24.0', $gitVersion, '>')) {
  4607. return '<warning>Your git version ('.$gitVersion.') is too old and possibly will cause issues. Please upgrade to git 2.24 or above</>';
  4608. }
  4609. return '<info>OK</> <comment>git version '.$gitVersion.'</>';
  4610. }
  4611. private function checkHttp(string $proto, Config $config)
  4612. {
  4613. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4614. if ($result !== true) {
  4615. return $result;
  4616. }
  4617. $result = [];
  4618. if ($proto === 'https' && $config->get('disable-tls') === true) {
  4619. $tlsWarning = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  4620. }
  4621. try {
  4622. $this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
  4623. } catch (TransportException $e) {
  4624. $hints = HttpDownloader::getExceptionHints($e);
  4625. if (null !== $hints && count($hints) > 0) {
  4626. foreach ($hints as $hint) {
  4627. $result[] = $hint;
  4628. }
  4629. }
  4630. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  4631. }
  4632. if (isset($tlsWarning)) {
  4633. $result[] = $tlsWarning;
  4634. }
  4635. if (count($result) > 0) {
  4636. return $result;
  4637. }
  4638. return true;
  4639. }
  4640. private function checkComposerRepo(string $url, Config $config)
  4641. {
  4642. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4643. if ($result !== true) {
  4644. return $result;
  4645. }
  4646. $result = [];
  4647. if (str_starts_with($url, 'https://') && $config->get('disable-tls') === true) {
  4648. $tlsWarning = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  4649. }
  4650. try {
  4651. $this->httpDownloader->get($url);
  4652. } catch (TransportException $e) {
  4653. $hints = HttpDownloader::getExceptionHints($e);
  4654. if (null !== $hints && count($hints) > 0) {
  4655. foreach ($hints as $hint) {
  4656. $result[] = $hint;
  4657. }
  4658. }
  4659. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  4660. }
  4661. if (isset($tlsWarning)) {
  4662. $result[] = $tlsWarning;
  4663. }
  4664. if (count($result) > 0) {
  4665. return $result;
  4666. }
  4667. return true;
  4668. }
  4669. private function checkHttpProxy(RequestProxy $proxy, string $protocol)
  4670. {
  4671. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4672. if ($result !== true) {
  4673. return $result;
  4674. }
  4675. try {
  4676. $proxyStatus = $proxy->getStatus();
  4677. if ($proxy->isExcludedByNoProxy()) {
  4678. return '<info>SKIP</> <comment>Because repo.packagist.org is '.$proxyStatus.'</>';
  4679. }
  4680. $json = $this->httpDownloader->get($protocol.'://repo.packagist.org/packages.json')->decodeJson();
  4681. if (isset($json['provider-includes'])) {
  4682. $hash = reset($json['provider-includes']);
  4683. $hash = $hash['sha256'];
  4684. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  4685. $provider = $this->httpDownloader->get($protocol.'://repo.packagist.org/'.$path)->getBody();
  4686. if (hash('sha256', $provider) !== $hash) {
  4687. return '<warning>It seems that your proxy ('.$proxyStatus.') is modifying '.$protocol.' traffic on the fly</>';
  4688. }
  4689. }
  4690. return '<info>OK</> <comment>'.$proxyStatus.'</>';
  4691. } catch (\Exception $e) {
  4692. return $e;
  4693. }
  4694. }
  4695. private function checkGithubOauth(string $domain, string $token)
  4696. {
  4697. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4698. if ($result !== true) {
  4699. return $result;
  4700. }
  4701. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  4702. try {
  4703. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  4704. $response = $this->httpDownloader->get($url, [
  4705. 'retry-auth-failure' => false,
  4706. ]);
  4707. $expiration = $response->getHeader('github-authentication-token-expiration');
  4708. if ($expiration === null) {
  4709. return '<info>OK</> <comment>does not expire</>';
  4710. }
  4711. return '<info>OK</> <comment>expires on '. $expiration .'</>';
  4712. } catch (\Exception $e) {
  4713. if ($e instanceof TransportException && $e->getCode() === 401) {
  4714. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  4715. }
  4716. return $e;
  4717. }
  4718. }
  4719. private function getGithubRateLimit(string $domain, ?string $token = null)
  4720. {
  4721. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4722. if ($result !== true) {
  4723. return $result;
  4724. }
  4725. if ($token) {
  4726. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  4727. }
  4728. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  4729. $data = $this->httpDownloader->get($url, ['retry-auth-failure' => false])->decodeJson();
  4730. return $data['resources']['core'];
  4731. }
  4732. private function checkDiskSpace(Config $config)
  4733. {
  4734. if (!function_exists('disk_free_space')) {
  4735. return true;
  4736. }
  4737. $minSpaceFree = 1024 * 1024;
  4738. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  4739. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  4740. ) {
  4741. return '<error>The disk hosting '.$dir.' is full</error>';
  4742. }
  4743. return true;
  4744. }
  4745. private function checkPubKeys(Config $config)
  4746. {
  4747. $home = $config->get('home');
  4748. $errors = [];
  4749. $io = $this->getIO();
  4750. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  4751. $io->write('');
  4752. }
  4753. if (file_exists($home.'/keys.tags.pub')) {
  4754. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  4755. } else {
  4756. $errors[] = '<error>Missing pubkey for tags verification</error>';
  4757. }
  4758. if (file_exists($home.'/keys.dev.pub')) {
  4759. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  4760. } else {
  4761. $errors[] = '<error>Missing pubkey for dev verification</error>';
  4762. }
  4763. if ($errors) {
  4764. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  4765. }
  4766. return $errors ?: true;
  4767. }
  4768. private function checkVersion(Config $config)
  4769. {
  4770. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4771. if ($result !== true) {
  4772. return $result;
  4773. }
  4774. $versionsUtil = new Versions($config, $this->httpDownloader);
  4775. try {
  4776. $latest = $versionsUtil->getLatest();
  4777. } catch (\Exception $e) {
  4778. return $e;
  4779. }
  4780. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  4781. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  4782. }
  4783. return true;
  4784. }
  4785. private function checkComposerAudit(Config $config)
  4786. {
  4787. $result = $this->checkConnectivityAndComposerNetworkHttpEnablement();
  4788. if ($result !== true) {
  4789. return $result;
  4790. }
  4791. $auditor = new Auditor();
  4792. $repoSet = new RepositorySet();
  4793. $installedJson = new JsonFile(__DIR__ . '/../../../vendor/composer/installed.json');
  4794. if (!$installedJson->exists()) {
  4795. return '<warning>Could not find Composer\'s installed.json, this must be a non-standard Composer installation.</>';
  4796. }
  4797. $localRepo = new FilesystemRepository($installedJson);
  4798. $version = Composer::getVersion();
  4799. $packages = $localRepo->getCanonicalPackages();
  4800. if ($version !== '@package_version@') {
  4801. $versionParser = new VersionParser();
  4802. $normalizedVersion = $versionParser->normalize($version);
  4803. $rootPkg = new RootPackage('composer/composer', $normalizedVersion, $version);
  4804. $packages[] = $rootPkg;
  4805. }
  4806. $repoSet->addRepository(new ComposerRepository(['type' => 'composer', 'url' => 'https://packagist.org'], new NullIO(), $config, $this->httpDownloader));
  4807. try {
  4808. $io = new BufferIO();
  4809. $result = $auditor->audit($io, $repoSet, $packages, Auditor::FORMAT_TABLE, true, [], Auditor::ABANDONED_IGNORE);
  4810. } catch (\Throwable $e) {
  4811. return '<highlight>Failed performing audit: '.$e->getMessage().'</>';
  4812. }
  4813. if ($result > 0) {
  4814. return '<highlight>Audit found some issues:</>' . PHP_EOL . $io->getOutput();
  4815. }
  4816. return true;
  4817. }
  4818. private function getCurlVersion(): string
  4819. {
  4820. if (extension_loaded('curl')) {
  4821. if (!HttpDownloader::isCurlEnabled()) {
  4822. return '<error>disabled via disable_functions, using php streams fallback, which reduces performance</error>';
  4823. }
  4824. $version = curl_version();
  4825. $hasZstd = isset($version['features']) && defined('CURL_VERSION_ZSTD') && 0 !== ($version['features'] & CURL_VERSION_ZSTD);
  4826. return '<comment>'.$version['version'].'</comment> '.
  4827. 'libz <comment>'.($version['libz_version'] ?? 'missing').'</comment> '.
  4828. 'brotli <comment>'.($version['brotli_version'] ?? 'missing').'</comment> '.
  4829. 'zstd <comment>'.($hasZstd ? 'supported' : 'missing').'</comment> '.
  4830. 'ssl <comment>'.($version['ssl_version'] ?? 'missing').'</comment>';
  4831. }
  4832. return '<error>missing, using php streams fallback, which reduces performance</error>';
  4833. }
  4834. private function outputResult($result): void
  4835. {
  4836. $io = $this->getIO();
  4837. if (true === $result) {
  4838. $io->write('<info>OK</info>');
  4839. return;
  4840. }
  4841. $hadError = false;
  4842. $hadWarning = false;
  4843. if ($result instanceof \Exception) {
  4844. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  4845. }
  4846. if (!$result) {
  4847. $hadError = true;
  4848. } else {
  4849. if (!is_array($result)) {
  4850. $result = [$result];
  4851. }
  4852. foreach ($result as $message) {
  4853. if (false !== strpos($message, '<error>')) {
  4854. $hadError = true;
  4855. } elseif (false !== strpos($message, '<warning>')) {
  4856. $hadWarning = true;
  4857. }
  4858. }
  4859. }
  4860. if ($hadError) {
  4861. $io->write('<error>FAIL</error>');
  4862. $this->exitCode = max($this->exitCode, 2);
  4863. } elseif ($hadWarning) {
  4864. $io->write('<warning>WARNING</warning>');
  4865. $this->exitCode = max($this->exitCode, 1);
  4866. }
  4867. if ($result) {
  4868. foreach ($result as $message) {
  4869. $io->write(trim($message));
  4870. }
  4871. }
  4872. }
  4873. private function checkPlatform()
  4874. {
  4875. $output = '';
  4876. $out = static function ($msg, $style) use (&$output): void {
  4877. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  4878. };
  4879. $errors = [];
  4880. $warnings = [];
  4881. $displayIniMessage = false;
  4882. $iniMessage = PHP_EOL.PHP_EOL.IniHelper::getMessage();
  4883. $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.';
  4884. if (!function_exists('json_decode')) {
  4885. $errors['json'] = true;
  4886. }
  4887. if (!extension_loaded('Phar')) {
  4888. $errors['phar'] = true;
  4889. }
  4890. if (!extension_loaded('filter')) {
  4891. $errors['filter'] = true;
  4892. }
  4893. if (!extension_loaded('hash')) {
  4894. $errors['hash'] = true;
  4895. }
  4896. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  4897. $errors['iconv_mbstring'] = true;
  4898. }
  4899. if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  4900. $errors['allow_url_fopen'] = true;
  4901. }
  4902. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  4903. $errors['ioncube'] = ioncube_loader_version();
  4904. }
  4905. if (\PHP_VERSION_ID < 70205) {
  4906. $errors['php'] = PHP_VERSION;
  4907. }
  4908. if (!extension_loaded('openssl')) {
  4909. $errors['openssl'] = true;
  4910. }
  4911. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  4912. $warnings['openssl_version'] = true;
  4913. }
  4914. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
  4915. $warnings['apc_cli'] = true;
  4916. }
  4917. if (!extension_loaded('zlib')) {
  4918. $warnings['zlib'] = true;
  4919. }
  4920. ob_start();
  4921. phpinfo(INFO_GENERAL);
  4922. $phpinfo = ob_get_clean();
  4923. if (is_string($phpinfo) && Preg::isMatchStrictGroups('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  4924. $configure = $match[1];
  4925. if (str_contains($configure, '--enable-sigchild')) {
  4926. $warnings['sigchild'] = true;
  4927. }
  4928. if (str_contains($configure, '--with-curlwrappers')) {
  4929. $warnings['curlwrappers'] = true;
  4930. }
  4931. }
  4932. if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
  4933. $warnings['xdebug_profile'] = true;
  4934. } elseif (XdebugHandler::isXdebugActive()) {
  4935. $warnings['xdebug_loaded'] = true;
  4936. }
  4937. if (defined('PHP_WINDOWS_VERSION_BUILD')
  4938. && (version_compare(PHP_VERSION, '7.2.23', '<')
  4939. || (version_compare(PHP_VERSION, '7.3.0', '>=')
  4940. && version_compare(PHP_VERSION, '7.3.10', '<')))) {
  4941. $warnings['onedrive'] = PHP_VERSION;
  4942. }
  4943. if (extension_loaded('uopz')
  4944. && !(filter_var(ini_get('uopz.disable'), FILTER_VALIDATE_BOOLEAN)
  4945. || filter_var(ini_get('uopz.exit'), FILTER_VALIDATE_BOOLEAN))) {
  4946. $warnings['uopz'] = true;
  4947. }
  4948. if (!empty($errors)) {
  4949. foreach ($errors as $error => $current) {
  4950. switch ($error) {
  4951. case 'json':
  4952. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  4953. $text .= "Install it or recompile php without --disable-json";
  4954. break;
  4955. case 'phar':
  4956. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  4957. $text .= "Install it or recompile php without --disable-phar";
  4958. break;
  4959. case 'filter':
  4960. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  4961. $text .= "Install it or recompile php without --disable-filter";
  4962. break;
  4963. case 'hash':
  4964. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  4965. $text .= "Install it or recompile php without --disable-hash";
  4966. break;
  4967. case 'iconv_mbstring':
  4968. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  4969. $text .= "Install either of them or recompile php without --disable-iconv";
  4970. break;
  4971. case 'php':
  4972. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 7.2.5 or higher.";
  4973. break;
  4974. case 'allow_url_fopen':
  4975. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  4976. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  4977. $text .= " allow_url_fopen = On";
  4978. $displayIniMessage = true;
  4979. break;
  4980. case 'ioncube':
  4981. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  4982. $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;
  4983. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  4984. $displayIniMessage = true;
  4985. break;
  4986. case 'openssl':
  4987. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  4988. $text .= "If possible you should enable it or recompile php with --with-openssl";
  4989. break;
  4990. default:
  4991. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown error type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $error));
  4992. }
  4993. $out($text, 'error');
  4994. }
  4995. $output .= PHP_EOL;
  4996. }
  4997. if (!empty($warnings)) {
  4998. foreach ($warnings as $warning => $current) {
  4999. switch ($warning) {
  5000. case 'apc_cli':
  5001. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  5002. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  5003. $text .= " apc.enable_cli = Off";
  5004. $displayIniMessage = true;
  5005. break;
  5006. case 'zlib':
  5007. $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
  5008. $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
  5009. $displayIniMessage = true;
  5010. break;
  5011. case 'sigchild':
  5012. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  5013. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  5014. $text .= " https://bugs.php.net/bug.php?id=22999";
  5015. break;
  5016. case 'curlwrappers':
  5017. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  5018. $text .= " Recompile it without this flag if possible";
  5019. break;
  5020. case 'openssl_version':
  5021. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  5022. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  5023. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  5024. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  5025. break;
  5026. case 'xdebug_loaded':
  5027. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  5028. $text .= " Disabling it when using Composer is recommended.";
  5029. break;
  5030. case 'xdebug_profile':
  5031. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  5032. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  5033. $text .= " xdebug.profiler_enabled = 0";
  5034. $displayIniMessage = true;
  5035. break;
  5036. case 'onedrive':
  5037. $text = "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.".PHP_EOL;
  5038. $text .= "Upgrade your PHP ({$current}) to use this location with Composer.".PHP_EOL;
  5039. break;
  5040. case 'uopz':
  5041. $text = "The uopz extension ignores exit calls and may not work with all Composer commands.".PHP_EOL;
  5042. $text .= "Disabling it when using Composer is recommended.";
  5043. break;
  5044. default:
  5045. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown warning type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $warning));
  5046. }
  5047. $out($text, 'comment');
  5048. }
  5049. }
  5050. if ($displayIniMessage) {
  5051. $out($iniMessage, 'comment');
  5052. }
  5053. if (in_array(Platform::getEnv('COMPOSER_IPRESOLVE'), ['4', '6'], true)) {
  5054. $warnings['ipresolve'] = true;
  5055. $out('The COMPOSER_IPRESOLVE env var is set to ' . Platform::getEnv('COMPOSER_IPRESOLVE') .' which may result in network failures below.', 'comment');
  5056. }
  5057. return count($warnings) === 0 && count($errors) === 0 ? true : $output;
  5058. }
  5059. private function checkConnectivity()
  5060. {
  5061. if (!ini_get('allow_url_fopen')) {
  5062. return '<info>SKIP</> <comment>Because allow_url_fopen is missing.</>';
  5063. }
  5064. return true;
  5065. }
  5066. private function checkConnectivityAndComposerNetworkHttpEnablement()
  5067. {
  5068. $result = $this->checkConnectivity();
  5069. if ($result !== true) {
  5070. return $result;
  5071. }
  5072. $result = $this->checkComposerNetworkHttpEnablement();
  5073. if ($result !== true) {
  5074. return $result;
  5075. }
  5076. return true;
  5077. }
  5078. private function checkComposerNetworkHttpEnablement()
  5079. {
  5080. if ((bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  5081. return '<info>SKIP</> <comment>Network is disabled by COMPOSER_DISABLE_NETWORK.</>';
  5082. }
  5083. return true;
  5084. }
  5085. }
  5086. <?php declare(strict_types=1);
  5087. namespace Composer\Command;
  5088. use Composer\Package\AliasPackage;
  5089. use Composer\Plugin\CommandEvent;
  5090. use Composer\Plugin\PluginEvents;
  5091. use Symfony\Component\Console\Input\InputInterface;
  5092. use Symfony\Component\Console\Input\InputOption;
  5093. use Symfony\Component\Console\Output\OutputInterface;
  5094. class DumpAutoloadCommand extends BaseCommand
  5095. {
  5096. protected function configure()
  5097. {
  5098. $this
  5099. ->setName('dump-autoload')
  5100. ->setAliases(['dumpautoload'])
  5101. ->setDescription('Dumps the autoloader')
  5102. ->setDefinition([
  5103. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'),
  5104. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
  5105. new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5106. new InputOption('apcu-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu'),
  5107. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything.'),
  5108. 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.'),
  5109. 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.'),
  5110. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5111. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5112. 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.'),
  5113. new InputOption('strict-ambiguous', null, InputOption::VALUE_NONE, 'Return a failed status code (2) if the same class is found in multiple files. Requires --optimize to work.'),
  5114. ])
  5115. ->setHelp(
  5116. <<<EOT
  5117. <info>php composer.phar dump-autoload</info>
  5118. Read more at https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload
  5119. EOT
  5120. )
  5121. ;
  5122. }
  5123. protected function execute(InputInterface $input, OutputInterface $output): int
  5124. {
  5125. $composer = $this->requireComposer();
  5126. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
  5127. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5128. $installationManager = $composer->getInstallationManager();
  5129. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  5130. $package = $composer->getPackage();
  5131. $config = $composer->getConfig();
  5132. $missingDependencies = false;
  5133. foreach ($localRepo->getCanonicalPackages() as $localPkg) {
  5134. $installPath = $installationManager->getInstallPath($localPkg);
  5135. if ($installPath !== null && file_exists($installPath) === false) {
  5136. $missingDependencies = true;
  5137. $this->getIO()->write('<warning>Not all dependencies are installed. Make sure to run a "composer install" to install missing dependencies</warning>');
  5138. break;
  5139. }
  5140. }
  5141. $optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
  5142. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  5143. $apcuPrefix = $input->getOption('apcu-prefix');
  5144. $apcu = $apcuPrefix !== null || $input->getOption('apcu') || $config->get('apcu-autoloader');
  5145. if ($input->getOption('strict-psr') && !$optimize && !$authoritative) {
  5146. throw new \InvalidArgumentException('--strict-psr mode only works with optimized autoloader, use --optimize or --classmap-authoritative if you want a strict return value.');
  5147. }
  5148. if ($input->getOption('strict-ambiguous') && !$optimize && !$authoritative) {
  5149. throw new \InvalidArgumentException('--strict-ambiguous mode only works with optimized autoloader, use --optimize or --classmap-authoritative if you want a strict return value.');
  5150. }
  5151. if ($authoritative) {
  5152. $this->getIO()->write('<info>Generating optimized autoload files (authoritative)</info>');
  5153. } elseif ($optimize) {
  5154. $this->getIO()->write('<info>Generating optimized autoload files</info>');
  5155. } else {
  5156. $this->getIO()->write('<info>Generating autoload files</info>');
  5157. }
  5158. $generator = $composer->getAutoloadGenerator();
  5159. if ($input->getOption('dry-run')) {
  5160. $generator->setDryRun(true);
  5161. }
  5162. if ($input->getOption('no-dev')) {
  5163. $generator->setDevMode(false);
  5164. }
  5165. if ($input->getOption('dev')) {
  5166. if ($input->getOption('no-dev')) {
  5167. throw new \InvalidArgumentException('You can not use both --no-dev and --dev as they conflict with each other.');
  5168. }
  5169. $generator->setDevMode(true);
  5170. }
  5171. $generator->setClassMapAuthoritative($authoritative);
  5172. $generator->setRunScripts(true);
  5173. $generator->setApcu($apcu, $apcuPrefix);
  5174. $generator->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input));
  5175. $classMap = $generator->dump(
  5176. $config,
  5177. $localRepo,
  5178. $package,
  5179. $installationManager,
  5180. 'composer',
  5181. $optimize,
  5182. null,
  5183. $composer->getLocker(),
  5184. $input->getOption('strict-ambiguous')
  5185. );
  5186. $numberOfClasses = count($classMap);
  5187. if ($authoritative) {
  5188. $this->getIO()->write('<info>Generated optimized autoload files (authoritative) containing '. $numberOfClasses .' classes</info>');
  5189. } elseif ($optimize) {
  5190. $this->getIO()->write('<info>Generated optimized autoload files containing '. $numberOfClasses .' classes</info>');
  5191. } else {
  5192. $this->getIO()->write('<info>Generated autoload files</info>');
  5193. }
  5194. if ($missingDependencies || ($input->getOption('strict-psr') && count($classMap->getPsrViolations()) > 0)) {
  5195. return 1;
  5196. }
  5197. if ($input->getOption('strict-ambiguous') && count($classMap->getAmbiguousClasses(false)) > 0) {
  5198. return 2;
  5199. }
  5200. return 0;
  5201. }
  5202. }
  5203. <?php declare(strict_types=1);
  5204. namespace Composer\Command;
  5205. use Symfony\Component\Console\Input\InputInterface;
  5206. use Composer\Console\Input\InputOption;
  5207. use Symfony\Component\Console\Output\OutputInterface;
  5208. use Composer\Console\Input\InputArgument;
  5209. class ExecCommand extends BaseCommand
  5210. {
  5211. protected function configure()
  5212. {
  5213. $this
  5214. ->setName('exec')
  5215. ->setDescription('Executes a vendored binary/script')
  5216. ->setDefinition([
  5217. new InputOption('list', 'l', InputOption::VALUE_NONE),
  5218. new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit', null, function () {
  5219. return $this->getBinaries(false);
  5220. }),
  5221. new InputArgument(
  5222. 'args',
  5223. InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
  5224. 'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
  5225. ),
  5226. ])
  5227. ->setHelp(
  5228. <<<EOT
  5229. Executes a vendored binary/script.
  5230. Read more at https://getcomposer.org/doc/03-cli.md#exec
  5231. EOT
  5232. )
  5233. ;
  5234. }
  5235. protected function interact(InputInterface $input, OutputInterface $output): void
  5236. {
  5237. $binaries = $this->getBinaries(false);
  5238. if (count($binaries) === 0) {
  5239. return;
  5240. }
  5241. if ($input->getArgument('binary') !== null || $input->getOption('list')) {
  5242. return;
  5243. }
  5244. $io = $this->getIO();
  5245. $binary = $io->select(
  5246. 'Binary to run: ',
  5247. $binaries,
  5248. '',
  5249. 1,
  5250. 'Invalid binary name "%s"'
  5251. );
  5252. $input->setArgument('binary', $binaries[$binary]);
  5253. }
  5254. protected function execute(InputInterface $input, OutputInterface $output): int
  5255. {
  5256. $composer = $this->requireComposer();
  5257. if ($input->getOption('list') || null === $input->getArgument('binary')) {
  5258. $bins = $this->getBinaries(true);
  5259. if ([] === $bins) {
  5260. $binDir = $composer->getConfig()->get('bin-dir');
  5261. throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");
  5262. }
  5263. $this->getIO()->write(
  5264. <<<EOT
  5265. <comment>Available binaries:</comment>
  5266. EOT
  5267. );
  5268. foreach ($bins as $bin) {
  5269. $this->getIO()->write(
  5270. <<<EOT
  5271. <info>- $bin</info>
  5272. EOT
  5273. );
  5274. }
  5275. return 0;
  5276. }
  5277. $binary = $input->getArgument('binary');
  5278. $dispatcher = $composer->getEventDispatcher();
  5279. $dispatcher->addListener('__exec_command', $binary);
  5280. if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory() && $this->getApplication()->getInitialWorkingDirectory() !== false) {
  5281. try {
  5282. chdir($this->getApplication()->getInitialWorkingDirectory());
  5283. } catch (\Exception $e) {
  5284. throw new \RuntimeException('Could not switch back to working directory "'.$this->getApplication()->getInitialWorkingDirectory().'"', 0, $e);
  5285. }
  5286. }
  5287. return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
  5288. }
  5289. private function getBinaries(bool $forDisplay): array
  5290. {
  5291. $composer = $this->requireComposer();
  5292. $binDir = $composer->getConfig()->get('bin-dir');
  5293. $bins = glob($binDir . '/*');
  5294. $localBins = $composer->getPackage()->getBinaries();
  5295. if ($forDisplay) {
  5296. $localBins = array_map(static function ($e) {
  5297. return "$e (local)";
  5298. }, $localBins);
  5299. }
  5300. $binaries = [];
  5301. foreach (array_merge($bins, $localBins) as $bin) {
  5302. if (isset($previousBin) && $bin === $previousBin.'.bat') {
  5303. continue;
  5304. }
  5305. $previousBin = $bin;
  5306. $binaries[] = basename($bin);
  5307. }
  5308. return $binaries;
  5309. }
  5310. }
  5311. <?php declare(strict_types=1);
  5312. namespace Composer\Command;
  5313. use Composer\Json\JsonFile;
  5314. use Composer\Package\AliasPackage;
  5315. use Composer\Package\BasePackage;
  5316. use Composer\Package\CompletePackageInterface;
  5317. use Composer\Pcre\Preg;
  5318. use Composer\Repository\CompositeRepository;
  5319. use Composer\Semver\Constraint\MatchAllConstraint;
  5320. use Symfony\Component\Console\Formatter\OutputFormatter;
  5321. use Symfony\Component\Console\Input\InputInterface;
  5322. use Composer\Console\Input\InputOption;
  5323. use Symfony\Component\Console\Output\OutputInterface;
  5324. class FundCommand extends BaseCommand
  5325. {
  5326. protected function configure(): void
  5327. {
  5328. $this->setName('fund')
  5329. ->setDescription('Discover how to help fund the maintenance of your dependencies')
  5330. ->setDefinition([
  5331. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['text', 'json']),
  5332. ])
  5333. ;
  5334. }
  5335. protected function execute(InputInterface $input, OutputInterface $output): int
  5336. {
  5337. $composer = $this->requireComposer();
  5338. $repo = $composer->getRepositoryManager()->getLocalRepository();
  5339. $remoteRepos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  5340. $fundings = [];
  5341. $packagesToLoad = [];
  5342. foreach ($repo->getPackages() as $package) {
  5343. if ($package instanceof AliasPackage) {
  5344. continue;
  5345. }
  5346. $packagesToLoad[$package->getName()] = new MatchAllConstraint();
  5347. }
  5348. $result = $remoteRepos->loadPackages($packagesToLoad, ['dev' => BasePackage::STABILITY_DEV], []);
  5349. foreach ($result['packages'] as $package) {
  5350. if (
  5351. !$package instanceof AliasPackage
  5352. && $package instanceof CompletePackageInterface
  5353. && $package->isDefaultBranch()
  5354. && $package->getFunding()
  5355. && isset($packagesToLoad[$package->getName()])
  5356. ) {
  5357. $fundings = $this->insertFundingData($fundings, $package);
  5358. unset($packagesToLoad[$package->getName()]);
  5359. }
  5360. }
  5361. foreach ($repo->getPackages() as $package) {
  5362. if ($package instanceof AliasPackage || !isset($packagesToLoad[$package->getName()])) {
  5363. continue;
  5364. }
  5365. if ($package instanceof CompletePackageInterface && $package->getFunding()) {
  5366. $fundings = $this->insertFundingData($fundings, $package);
  5367. }
  5368. }
  5369. ksort($fundings);
  5370. $io = $this->getIO();
  5371. $format = $input->getOption('format');
  5372. if (!in_array($format, ['text', 'json'])) {
  5373. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  5374. return 1;
  5375. }
  5376. if ($fundings && $format === 'text') {
  5377. $prev = null;
  5378. $io->write('The following packages were found in your dependencies which publish funding information:');
  5379. foreach ($fundings as $vendor => $links) {
  5380. $io->write('');
  5381. $io->write(sprintf("<comment>%s</comment>", $vendor));
  5382. foreach ($links as $url => $packages) {
  5383. $line = sprintf(' <info>%s</info>', implode(', ', $packages));
  5384. if ($prev !== $line) {
  5385. $io->write($line);
  5386. $prev = $line;
  5387. }
  5388. $io->write(sprintf(' <href=%s>%s</>', OutputFormatter::escape($url), $url));
  5389. }
  5390. }
  5391. $io->write("");
  5392. $io->write("Please consider following these links and sponsoring the work of package authors!");
  5393. $io->write("Thank you!");
  5394. } elseif ($format === 'json') {
  5395. $io->write(JsonFile::encode($fundings));
  5396. } else {
  5397. $io->write("No funding links were found in your package dependencies. This doesn't mean they don't need your support!");
  5398. }
  5399. return 0;
  5400. }
  5401. private function insertFundingData(array $fundings, CompletePackageInterface $package): array
  5402. {
  5403. foreach ($package->getFunding() as $fundingOption) {
  5404. [$vendor, $packageName] = explode('/', $package->getPrettyName());
  5405. if (empty($fundingOption['url'])) {
  5406. continue;
  5407. }
  5408. $url = $fundingOption['url'];
  5409. if (!empty($fundingOption['type']) && $fundingOption['type'] === 'github' && Preg::isMatch('{^https://github.com/([^/]+)$}', $url, $match)) {
  5410. $url = 'https://github.com/sponsors/'.$match[1];
  5411. }
  5412. $fundings[$vendor][$url][] = $packageName;
  5413. }
  5414. return $fundings;
  5415. }
  5416. }
  5417. <?php declare(strict_types=1);
  5418. namespace Composer\Command;
  5419. use Composer\Factory;
  5420. use Composer\Pcre\Preg;
  5421. use Composer\Util\Filesystem;
  5422. use Composer\Util\Platform;
  5423. use Symfony\Component\Console\Command\Command;
  5424. use Symfony\Component\Console\Completion\CompletionInput;
  5425. use Symfony\Component\Console\Completion\CompletionSuggestions;
  5426. use Symfony\Component\Console\Input\InputInterface;
  5427. use Composer\Console\Input\InputArgument;
  5428. use Symfony\Component\Console\Input\StringInput;
  5429. use Symfony\Component\Console\Output\OutputInterface;
  5430. class GlobalCommand extends BaseCommand
  5431. {
  5432. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  5433. {
  5434. $application = $this->getApplication();
  5435. if ($input->mustSuggestArgumentValuesFor('command-name')) {
  5436. $suggestions->suggestValues(array_values(array_filter(
  5437. array_map(static function (Command $command) {
  5438. return $command->isHidden() ? null : $command->getName();
  5439. }, $application->all()), function (?string $cmd) {
  5440. return $cmd !== null;
  5441. }
  5442. )));
  5443. return;
  5444. }
  5445. if ($application->has($commandName = $input->getArgument('command-name'))) {
  5446. $input = $this->prepareSubcommandInput($input, true);
  5447. $input = CompletionInput::fromString($input->__toString(), 2);
  5448. $command = $application->find($commandName);
  5449. $command->mergeApplicationDefinition();
  5450. $input->bind($command->getDefinition());
  5451. $command->complete($input, $suggestions);
  5452. }
  5453. }
  5454. protected function configure(): void
  5455. {
  5456. $this
  5457. ->setName('global')
  5458. ->setDescription('Allows running commands in the global composer dir ($COMPOSER_HOME)')
  5459. ->setDefinition([
  5460. new InputArgument('command-name', InputArgument::REQUIRED, ''),
  5461. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5462. ])
  5463. ->setHelp(
  5464. <<<EOT
  5465. Use this command as a wrapper to run other Composer commands
  5466. within the global context of COMPOSER_HOME.
  5467. You can use this to install CLI utilities globally, all you need
  5468. is to add the COMPOSER_HOME/vendor/bin dir to your PATH env var.
  5469. COMPOSER_HOME is c:\Users\<user>\AppData\Roaming\Composer on Windows
  5470. and /home/<user>/.composer on unix systems.
  5471. If your system uses freedesktop.org standards, then it will first check
  5472. XDG_CONFIG_HOME or default to /home/<user>/.config/composer
  5473. Note: This path may vary depending on customizations to bin-dir in
  5474. composer.json or the environmental variable COMPOSER_BIN_DIR.
  5475. Read more at https://getcomposer.org/doc/03-cli.md#global
  5476. EOT
  5477. )
  5478. ;
  5479. }
  5480. public function run(InputInterface $input, OutputInterface $output): int
  5481. {
  5482. if (!method_exists($input, '__toString')) {
  5483. throw new \LogicException('Expected an Input instance that is stringable, got '.get_class($input));
  5484. }
  5485. $tokens = Preg::split('{\s+}', $input->__toString());
  5486. $args = [];
  5487. foreach ($tokens as $token) {
  5488. if ($token && $token[0] !== '-') {
  5489. $args[] = $token;
  5490. if (count($args) >= 2) {
  5491. break;
  5492. }
  5493. }
  5494. }
  5495. if (count($args) < 2) {
  5496. return parent::run($input, $output);
  5497. }
  5498. $input = $this->prepareSubcommandInput($input);
  5499. return $this->getApplication()->run($input, $output);
  5500. }
  5501. private function prepareSubcommandInput(InputInterface $input, bool $quiet = false): StringInput
  5502. {
  5503. if (!method_exists($input, '__toString')) {
  5504. throw new \LogicException('Expected an Input instance that is stringable, got '.get_class($input));
  5505. }
  5506. if (Platform::getEnv('COMPOSER')) {
  5507. Platform::clearEnv('COMPOSER');
  5508. }
  5509. $config = Factory::createConfig();
  5510. $home = $config->get('home');
  5511. if (!is_dir($home)) {
  5512. $fs = new Filesystem();
  5513. $fs->ensureDirectoryExists($home);
  5514. if (!is_dir($home)) {
  5515. throw new \RuntimeException('Could not create home directory');
  5516. }
  5517. }
  5518. try {
  5519. chdir($home);
  5520. } catch (\Exception $e) {
  5521. throw new \RuntimeException('Could not switch to home directory "'.$home.'"', 0, $e);
  5522. }
  5523. if (!$quiet) {
  5524. $this->getIO()->writeError('<info>Changed current directory to '.$home.'</info>');
  5525. }
  5526. $input = new StringInput(Preg::replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
  5527. $this->getApplication()->resetComposer();
  5528. return $input;
  5529. }
  5530. public function isProxyCommand(): bool
  5531. {
  5532. return true;
  5533. }
  5534. }
  5535. <?php declare(strict_types=1);
  5536. namespace Composer\Command;
  5537. use Composer\Package\CompletePackageInterface;
  5538. use Composer\Repository\RepositoryInterface;
  5539. use Composer\Repository\RootPackageRepository;
  5540. use Composer\Repository\RepositoryFactory;
  5541. use Composer\Util\Platform;
  5542. use Composer\Util\ProcessExecutor;
  5543. use Composer\Console\Input\InputArgument;
  5544. use Composer\Console\Input\InputOption;
  5545. use Symfony\Component\Console\Input\InputInterface;
  5546. use Symfony\Component\Console\Output\OutputInterface;
  5547. class HomeCommand extends BaseCommand
  5548. {
  5549. use CompletionTrait;
  5550. protected function configure(): void
  5551. {
  5552. $this
  5553. ->setName('browse')
  5554. ->setAliases(['home'])
  5555. ->setDescription('Opens the package\'s repository URL or homepage in your browser')
  5556. ->setDefinition([
  5557. new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.', null, $this->suggestInstalledPackage()),
  5558. new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
  5559. new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
  5560. ])
  5561. ->setHelp(
  5562. <<<EOT
  5563. The home command opens or shows a package's repository URL or
  5564. homepage in your default browser.
  5565. To open the homepage by default, use -H or --homepage.
  5566. To show instead of open the repository or homepage URL, use -s or --show.
  5567. Read more at https://getcomposer.org/doc/03-cli.md#browse-home
  5568. EOT
  5569. );
  5570. }
  5571. protected function execute(InputInterface $input, OutputInterface $output): int
  5572. {
  5573. $repos = $this->initializeRepos();
  5574. $io = $this->getIO();
  5575. $return = 0;
  5576. $packages = $input->getArgument('packages');
  5577. if (count($packages) === 0) {
  5578. $io->writeError('No package specified, opening homepage for the root package');
  5579. $packages = [$this->requireComposer()->getPackage()->getName()];
  5580. }
  5581. foreach ($packages as $packageName) {
  5582. $handled = false;
  5583. $packageExists = false;
  5584. foreach ($repos as $repo) {
  5585. foreach ($repo->findPackages($packageName) as $package) {
  5586. $packageExists = true;
  5587. if ($package instanceof CompletePackageInterface && $this->handlePackage($package, $input->getOption('homepage'), $input->getOption('show'))) {
  5588. $handled = true;
  5589. break 2;
  5590. }
  5591. }
  5592. }
  5593. if (!$packageExists) {
  5594. $return = 1;
  5595. $io->writeError('<warning>Package '.$packageName.' not found</warning>');
  5596. }
  5597. if (!$handled) {
  5598. $return = 1;
  5599. $io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
  5600. }
  5601. }
  5602. return $return;
  5603. }
  5604. private function handlePackage(CompletePackageInterface $package, bool $showHomepage, bool $showOnly): bool
  5605. {
  5606. $support = $package->getSupport();
  5607. $url = $support['source'] ?? $package->getSourceUrl();
  5608. if (!$url || $showHomepage) {
  5609. $url = $package->getHomepage();
  5610. }
  5611. if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
  5612. return false;
  5613. }
  5614. if ($showOnly) {
  5615. $this->getIO()->write(sprintf('<info>%s</info>', $url));
  5616. } else {
  5617. $this->openBrowser($url);
  5618. }
  5619. return true;
  5620. }
  5621. private function openBrowser(string $url): void
  5622. {
  5623. $process = new ProcessExecutor($this->getIO());
  5624. if (Platform::isWindows()) {
  5625. $process->execute(['start', '"web"', 'explorer', $url], $output);
  5626. return;
  5627. }
  5628. $linux = $process->execute(['which', 'xdg-open'], $output);
  5629. $osx = $process->execute(['which', 'open'], $output);
  5630. if (0 === $linux) {
  5631. $process->execute(['xdg-open', $url], $output);
  5632. } elseif (0 === $osx) {
  5633. $process->execute(['open', $url], $output);
  5634. } else {
  5635. $this->getIO()->writeError('No suitable browser opening command found, open yourself: ' . $url);
  5636. }
  5637. }
  5638. private function initializeRepos(): array
  5639. {
  5640. $composer = $this->tryComposer();
  5641. if ($composer) {
  5642. return array_merge(
  5643. [new RootPackageRepository(clone $composer->getPackage())],
  5644. [$composer->getRepositoryManager()->getLocalRepository()],
  5645. $composer->getRepositoryManager()->getRepositories()
  5646. );
  5647. }
  5648. return RepositoryFactory::defaultReposWithDefaultManager($this->getIO());
  5649. }
  5650. }
  5651. <?php declare(strict_types=1);
  5652. namespace Composer\Command;
  5653. use Composer\Factory;
  5654. use Composer\Json\JsonFile;
  5655. use Composer\Json\JsonValidationException;
  5656. use Composer\Package\BasePackage;
  5657. use Composer\Package\Package;
  5658. use Composer\Pcre\Preg;
  5659. use Composer\Repository\CompositeRepository;
  5660. use Composer\Repository\PlatformRepository;
  5661. use Composer\Repository\RepositoryFactory;
  5662. use Composer\Spdx\SpdxLicenses;
  5663. use Composer\Util\Filesystem;
  5664. use Composer\Util\Silencer;
  5665. use Symfony\Component\Console\Input\ArrayInput;
  5666. use Symfony\Component\Console\Input\InputInterface;
  5667. use Composer\Console\Input\InputOption;
  5668. use Composer\Util\ProcessExecutor;
  5669. use Symfony\Component\Console\Output\OutputInterface;
  5670. use Symfony\Component\Process\ExecutableFinder;
  5671. use Symfony\Component\Process\Process;
  5672. use Symfony\Component\Console\Helper\FormatterHelper;
  5673. class InitCommand extends BaseCommand
  5674. {
  5675. use CompletionTrait;
  5676. use PackageDiscoveryTrait;
  5677. private $gitConfig;
  5678. protected function configure()
  5679. {
  5680. $this
  5681. ->setName('init')
  5682. ->setDescription('Creates a basic composer.json file in current directory')
  5683. ->setDefinition([
  5684. new InputOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the package'),
  5685. new InputOption('description', null, InputOption::VALUE_REQUIRED, 'Description of package'),
  5686. new InputOption('author', null, InputOption::VALUE_REQUIRED, 'Author name of package'),
  5687. new InputOption('type', null, InputOption::VALUE_REQUIRED, 'Type of package (e.g. library, project, metapackage, composer-plugin)'),
  5688. new InputOption('homepage', null, InputOption::VALUE_REQUIRED, 'Homepage of package'),
  5689. 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()),
  5690. 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()),
  5691. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::STABILITIES)).')'),
  5692. new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
  5693. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories, either by URL or using JSON arrays'),
  5694. 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/)'),
  5695. ])
  5696. ->setHelp(
  5697. <<<EOT
  5698. The <info>init</info> command creates a basic composer.json file
  5699. in the current directory.
  5700. <info>php composer.phar init</info>
  5701. Read more at https://getcomposer.org/doc/03-cli.md#init
  5702. EOT
  5703. )
  5704. ;
  5705. }
  5706. protected function execute(InputInterface $input, OutputInterface $output): int
  5707. {
  5708. $io = $this->getIO();
  5709. $allowlist = ['name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license', 'autoload'];
  5710. $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist)), function ($val) { return $val !== null && $val !== []; });
  5711. if (isset($options['name']) && !Preg::isMatch('{^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]|-{1,2})?[a-z0-9]+)*$}D', $options['name'])) {
  5712. throw new \InvalidArgumentException(
  5713. '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_.-]+'
  5714. );
  5715. }
  5716. if (isset($options['author'])) {
  5717. $options['authors'] = $this->formatAuthors($options['author']);
  5718. unset($options['author']);
  5719. }
  5720. $repositories = $input->getOption('repository');
  5721. if (count($repositories) > 0) {
  5722. $config = Factory::createConfig($io);
  5723. foreach ($repositories as $repo) {
  5724. $options['repositories'][] = RepositoryFactory::configFromString($io, $config, $repo, true);
  5725. }
  5726. }
  5727. if (isset($options['stability'])) {
  5728. $options['minimum-stability'] = $options['stability'];
  5729. unset($options['stability']);
  5730. }
  5731. $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
  5732. if ([] === $options['require']) {
  5733. $options['require'] = new \stdClass;
  5734. }
  5735. if (isset($options['require-dev'])) {
  5736. $options['require-dev'] = $this->formatRequirements($options['require-dev']);
  5737. if ([] === $options['require-dev']) {
  5738. $options['require-dev'] = new \stdClass;
  5739. }
  5740. }
  5741. $autoloadPath = null;
  5742. if (isset($options['autoload'])) {
  5743. $autoloadPath = $options['autoload'];
  5744. $namespace = $this->namespaceFromPackageName((string) $input->getOption('name'));
  5745. $options['autoload'] = (object) [
  5746. 'psr-4' => [
  5747. $namespace . '\\' => $autoloadPath,
  5748. ],
  5749. ];
  5750. }
  5751. $file = new JsonFile(Factory::getComposerFile());
  5752. $json = JsonFile::encode($options);
  5753. if ($input->isInteractive()) {
  5754. $io->writeError(['', $json, '']);
  5755. if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ')) {
  5756. $io->writeError('<error>Command aborted</error>');
  5757. return 1;
  5758. }
  5759. } else {
  5760. if (json_encode($options) === '{"require":{}}') {
  5761. throw new \RuntimeException('You have to run this command in interactive mode, or specify at least some data using --name, --require, etc.');
  5762. }
  5763. $io->writeError('Writing '.$file->getPath());
  5764. }
  5765. $file->write($options);
  5766. try {
  5767. $file->validateSchema(JsonFile::LAX_SCHEMA);
  5768. } catch (JsonValidationException $e) {
  5769. $io->writeError('<error>Schema validation error, aborting</error>');
  5770. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  5771. $io->writeError($e->getMessage() . ':' . PHP_EOL . $errors);
  5772. Silencer::call('unlink', $file->getPath());
  5773. return 1;
  5774. }
  5775. if ($autoloadPath) {
  5776. $filesystem = new Filesystem();
  5777. $filesystem->ensureDirectoryExists($autoloadPath);
  5778. if (!$this->hasDependencies($options)) {
  5779. $this->runDumpAutoloadCommand($output);
  5780. }
  5781. }
  5782. if ($input->isInteractive() && is_dir('.git')) {
  5783. $ignoreFile = realpath('.gitignore');
  5784. if (false === $ignoreFile) {
  5785. $ignoreFile = realpath('.') . '/.gitignore';
  5786. }
  5787. if (!$this->hasVendorIgnore($ignoreFile)) {
  5788. $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
  5789. if ($io->askConfirmation($question)) {
  5790. $this->addVendorIgnore($ignoreFile);
  5791. }
  5792. }
  5793. }
  5794. $question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
  5795. if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question)) {
  5796. $this->updateDependencies($output);
  5797. }
  5798. if ($autoloadPath) {
  5799. $namespace = $this->namespaceFromPackageName((string) $input->getOption('name'));
  5800. $io->writeError('PSR-4 autoloading configured. Use "<comment>namespace '.$namespace.';</comment>" in '.$autoloadPath);
  5801. $io->writeError('Include the Composer autoloader with: <comment>require \'vendor/autoload.php\';</comment>');
  5802. }
  5803. return 0;
  5804. }
  5805. protected function interact(InputInterface $input, OutputInterface $output)
  5806. {
  5807. $git = $this->getGitConfig();
  5808. $io = $this->getIO();
  5809. $formatter = $this->getHelperSet()->get('formatter');
  5810. $repositories = $input->getOption('repository');
  5811. if (count($repositories) > 0) {
  5812. $config = Factory::createConfig($io);
  5813. $io->loadConfiguration($config);
  5814. $repoManager = RepositoryFactory::manager($io, $config);
  5815. $repos = [new PlatformRepository];
  5816. $createDefaultPackagistRepo = true;
  5817. foreach ($repositories as $repo) {
  5818. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  5819. if (
  5820. (isset($repoConfig['packagist']) && $repoConfig === ['packagist' => false])
  5821. || (isset($repoConfig['packagist.org']) && $repoConfig === ['packagist.org' => false])
  5822. ) {
  5823. $createDefaultPackagistRepo = false;
  5824. continue;
  5825. }
  5826. $repos[] = RepositoryFactory::createRepo($io, $config, $repoConfig, $repoManager);
  5827. }
  5828. if ($createDefaultPackagistRepo) {
  5829. $repos[] = RepositoryFactory::createRepo($io, $config, [
  5830. 'type' => 'composer',
  5831. 'url' => 'https://repo.packagist.org',
  5832. ], $repoManager);
  5833. }
  5834. $this->repos = new CompositeRepository($repos);
  5835. unset($repos, $config, $repositories);
  5836. }
  5837. $io->writeError([
  5838. '',
  5839. $formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
  5840. '',
  5841. ]);
  5842. $io->writeError([
  5843. '',
  5844. 'This command will guide you through creating your composer.json config.',
  5845. '',
  5846. ]);
  5847. $cwd = realpath(".");
  5848. $name = $input->getOption('name');
  5849. if (null === $name) {
  5850. $name = basename($cwd);
  5851. $name = $this->sanitizePackageNameComponent($name);
  5852. $vendor = $name;
  5853. if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) {
  5854. $vendor = $_SERVER['COMPOSER_DEFAULT_VENDOR'];
  5855. } elseif (isset($git['github.user'])) {
  5856. $vendor = $git['github.user'];
  5857. } elseif (!empty($_SERVER['USERNAME'])) {
  5858. $vendor = $_SERVER['USERNAME'];
  5859. } elseif (!empty($_SERVER['USER'])) {
  5860. $vendor = $_SERVER['USER'];
  5861. } elseif (get_current_user()) {
  5862. $vendor = get_current_user();
  5863. }
  5864. $vendor = $this->sanitizePackageNameComponent($vendor);
  5865. $name = $vendor . '/' . $name;
  5866. }
  5867. $name = $io->askAndValidate(
  5868. 'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
  5869. static function ($value) use ($name) {
  5870. if (null === $value) {
  5871. return $name;
  5872. }
  5873. if (!Preg::isMatch('{^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]|-{1,2})?[a-z0-9]+)*$}D', $value)) {
  5874. throw new \InvalidArgumentException(
  5875. '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_.-]+'
  5876. );
  5877. }
  5878. return $value;
  5879. },
  5880. null,
  5881. $name
  5882. );
  5883. $input->setOption('name', $name);
  5884. $description = $input->getOption('description') ?: null;
  5885. $description = $io->ask(
  5886. 'Description [<comment>'.$description.'</comment>]: ',
  5887. $description
  5888. );
  5889. $input->setOption('description', $description);
  5890. if (null === $author = $input->getOption('author')) {
  5891. if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) {
  5892. $author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
  5893. } elseif (isset($git['user.name'])) {
  5894. $author_name = $git['user.name'];
  5895. }
  5896. if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) {
  5897. $author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
  5898. } elseif (isset($git['user.email'])) {
  5899. $author_email = $git['user.email'];
  5900. }
  5901. if (isset($author_name, $author_email)) {
  5902. $author = sprintf('%s <%s>', $author_name, $author_email);
  5903. }
  5904. }
  5905. $author = $io->askAndValidate(
  5906. 'Author ['.(is_string($author) ? '<comment>'.$author.'</comment>, ' : '') . 'n to skip]: ',
  5907. function ($value) use ($author) {
  5908. if ($value === 'n' || $value === 'no') {
  5909. return;
  5910. }
  5911. $value = $value ?: $author;
  5912. $author = $this->parseAuthorString($value ?? '');
  5913. if ($author['email'] === null) {
  5914. return $author['name'];
  5915. }
  5916. return sprintf('%s <%s>', $author['name'], $author['email']);
  5917. },
  5918. null,
  5919. $author
  5920. );
  5921. $input->setOption('author', $author);
  5922. $minimumStability = $input->getOption('stability') ?: null;
  5923. $minimumStability = $io->askAndValidate(
  5924. 'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
  5925. static function ($value) use ($minimumStability) {
  5926. if (null === $value) {
  5927. return $minimumStability;
  5928. }
  5929. if (!isset(BasePackage::STABILITIES[$value])) {
  5930. throw new \InvalidArgumentException(
  5931. 'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
  5932. implode(', ', array_keys(BasePackage::STABILITIES))
  5933. );
  5934. }
  5935. return $value;
  5936. },
  5937. null,
  5938. $minimumStability
  5939. );
  5940. $input->setOption('stability', $minimumStability);
  5941. $type = $input->getOption('type');
  5942. $type = $io->ask(
  5943. 'Package Type (e.g. library, project, metapackage, composer-plugin) [<comment>'.$type.'</comment>]: ',
  5944. $type
  5945. );
  5946. if ($type === '' || $type === false) {
  5947. $type = null;
  5948. }
  5949. $input->setOption('type', $type);
  5950. if (null === $license = $input->getOption('license')) {
  5951. if (!empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) {
  5952. $license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
  5953. }
  5954. }
  5955. $license = $io->ask(
  5956. 'License [<comment>'.$license.'</comment>]: ',
  5957. $license
  5958. );
  5959. $spdx = new SpdxLicenses();
  5960. if (null !== $license && !$spdx->validate($license) && $license !== 'proprietary') {
  5961. throw new \InvalidArgumentException('Invalid license provided: '.$license.'. Only SPDX license identifiers (https://spdx.org/licenses/) or "proprietary" are accepted.');
  5962. }
  5963. $input->setOption('license', $license);
  5964. $io->writeError(['', 'Define your dependencies.', '']);
  5965. $repos = $this->getRepos();
  5966. $preferredStability = $minimumStability ?: 'stable';
  5967. $platformRepo = null;
  5968. if ($repos instanceof CompositeRepository) {
  5969. foreach ($repos->getRepositories() as $candidateRepo) {
  5970. if ($candidateRepo instanceof PlatformRepository) {
  5971. $platformRepo = $candidateRepo;
  5972. break;
  5973. }
  5974. }
  5975. }
  5976. $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
  5977. $require = $input->getOption('require');
  5978. $requirements = [];
  5979. if (count($require) > 0 || $io->askConfirmation($question)) {
  5980. $requirements = $this->determineRequirements($input, $output, $require, $platformRepo, $preferredStability);
  5981. }
  5982. $input->setOption('require', $requirements);
  5983. $question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
  5984. $requireDev = $input->getOption('require-dev');
  5985. $devRequirements = [];
  5986. if (count($requireDev) > 0 || $io->askConfirmation($question)) {
  5987. $devRequirements = $this->determineRequirements($input, $output, $requireDev, $platformRepo, $preferredStability);
  5988. }
  5989. $input->setOption('require-dev', $devRequirements);
  5990. $autoload = $input->getOption('autoload') ?: 'src/';
  5991. $namespace = $this->namespaceFromPackageName((string) $input->getOption('name'));
  5992. $autoload = $io->askAndValidate(
  5993. 'Add PSR-4 autoload mapping? Maps namespace "'.$namespace.'" to the entered relative path. [<comment>'.$autoload.'</comment>, n to skip]: ',
  5994. static function ($value) use ($autoload) {
  5995. if (null === $value) {
  5996. return $autoload;
  5997. }
  5998. if ($value === 'n' || $value === 'no') {
  5999. return;
  6000. }
  6001. $value = $value ?: $autoload;
  6002. if (!Preg::isMatch('{^[^/][A-Za-z0-9\-_/]+/$}', $value)) {
  6003. throw new \InvalidArgumentException(sprintf(
  6004. 'The src folder name "%s" is invalid. Please add a relative path with tailing forward slash. [A-Za-z0-9_-/]+/',
  6005. $value
  6006. ));
  6007. }
  6008. return $value;
  6009. },
  6010. null,
  6011. $autoload
  6012. );
  6013. $input->setOption('autoload', $autoload);
  6014. }
  6015. private function parseAuthorString(string $author): array
  6016. {
  6017. if (Preg::isMatch('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+)(?:\s+<(?P<email>.+?)>)?$/u', $author, $match)) {
  6018. if (null !== $match['email'] && !$this->isValidEmail($match['email'])) {
  6019. throw new \InvalidArgumentException('Invalid email "'.$match['email'].'"');
  6020. }
  6021. return [
  6022. 'name' => trim($match['name']),
  6023. 'email' => $match['email'],
  6024. ];
  6025. }
  6026. throw new \InvalidArgumentException(
  6027. 'Invalid author string. Must be in the formats: '.
  6028. 'Jane Doe or John Smith <john@example.com>'
  6029. );
  6030. }
  6031. protected function formatAuthors(string $author): array
  6032. {
  6033. $author = $this->parseAuthorString($author);
  6034. if (null === $author['email']) {
  6035. unset($author['email']);
  6036. }
  6037. return [$author];
  6038. }
  6039. public function namespaceFromPackageName(string $packageName): ?string
  6040. {
  6041. if (!$packageName || strpos($packageName, '/') === false) {
  6042. return null;
  6043. }
  6044. $namespace = array_map(
  6045. static function ($part): string {
  6046. $part = Preg::replace('/[^a-z0-9]/i', ' ', $part);
  6047. $part = ucwords($part);
  6048. return str_replace(' ', '', $part);
  6049. },
  6050. explode('/', $packageName)
  6051. );
  6052. return implode('\\', $namespace);
  6053. }
  6054. protected function getGitConfig(): array
  6055. {
  6056. if (null !== $this->gitConfig) {
  6057. return $this->gitConfig;
  6058. }
  6059. $process = new ProcessExecutor($this->getIO());
  6060. if (0 === $process->execute(['git', 'config', '-l'], $output)) {
  6061. $this->gitConfig = [];
  6062. Preg::matchAllStrictGroups('{^([^=]+)=(.*)$}m', $output, $matches);
  6063. foreach ($matches[1] as $key => $match) {
  6064. $this->gitConfig[$match] = $matches[2][$key];
  6065. }
  6066. return $this->gitConfig;
  6067. }
  6068. return $this->gitConfig = [];
  6069. }
  6070. protected function hasVendorIgnore(string $ignoreFile, string $vendor = 'vendor'): bool
  6071. {
  6072. if (!file_exists($ignoreFile)) {
  6073. return false;
  6074. }
  6075. $pattern = sprintf('{^/?%s(/\*?)?$}', preg_quote($vendor));
  6076. $lines = file($ignoreFile, FILE_IGNORE_NEW_LINES);
  6077. foreach ($lines as $line) {
  6078. if (Preg::isMatch($pattern, $line)) {
  6079. return true;
  6080. }
  6081. }
  6082. return false;
  6083. }
  6084. protected function addVendorIgnore(string $ignoreFile, string $vendor = '/vendor/'): void
  6085. {
  6086. $contents = "";
  6087. if (file_exists($ignoreFile)) {
  6088. $contents = file_get_contents($ignoreFile);
  6089. if (strpos($contents, "\n") !== 0) {
  6090. $contents .= "\n";
  6091. }
  6092. }
  6093. file_put_contents($ignoreFile, $contents . $vendor. "\n");
  6094. }
  6095. protected function isValidEmail(string $email): bool
  6096. {
  6097. if (!function_exists('filter_var')) {
  6098. return true;
  6099. }
  6100. return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
  6101. }
  6102. private function updateDependencies(OutputInterface $output): void
  6103. {
  6104. try {
  6105. $updateCommand = $this->getApplication()->find('update');
  6106. $this->getApplication()->resetComposer();
  6107. $updateCommand->run(new ArrayInput([]), $output);
  6108. } catch (\Exception $e) {
  6109. $this->getIO()->writeError('Could not update dependencies. Run `composer update` to see more information.');
  6110. }
  6111. }
  6112. private function runDumpAutoloadCommand(OutputInterface $output): void
  6113. {
  6114. try {
  6115. $command = $this->getApplication()->find('dump-autoload');
  6116. $this->getApplication()->resetComposer();
  6117. $command->run(new ArrayInput([]), $output);
  6118. } catch (\Exception $e) {
  6119. $this->getIO()->writeError('Could not run dump-autoload.');
  6120. }
  6121. }
  6122. private function hasDependencies(array $options): bool
  6123. {
  6124. $requires = (array) $options['require'];
  6125. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : [];
  6126. return !empty($requires) || !empty($devRequires);
  6127. }
  6128. private function sanitizePackageNameComponent(string $name): string
  6129. {
  6130. $name = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  6131. $name = strtolower($name);
  6132. $name = Preg::replace('{^[_.-]+|[_.-]+$|[^a-z0-9_.-]}u', '', $name);
  6133. $name = Preg::replace('{([_.-]){2,}}u', '$1', $name);
  6134. return $name;
  6135. }
  6136. }
  6137. <?php declare(strict_types=1);
  6138. namespace Composer\Command;
  6139. use Composer\Installer;
  6140. use Composer\Plugin\CommandEvent;
  6141. use Composer\Plugin\PluginEvents;
  6142. use Composer\Advisory\Auditor;
  6143. use Composer\Util\HttpDownloader;
  6144. use Symfony\Component\Console\Input\InputInterface;
  6145. use Composer\Console\Input\InputOption;
  6146. use Composer\Console\Input\InputArgument;
  6147. use Symfony\Component\Console\Output\OutputInterface;
  6148. class InstallCommand extends BaseCommand
  6149. {
  6150. use CompletionTrait;
  6151. protected function configure()
  6152. {
  6153. $this
  6154. ->setName('install')
  6155. ->setAliases(['i'])
  6156. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json')
  6157. ->setDefinition([
  6158. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  6159. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  6160. 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()),
  6161. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  6162. new InputOption('download-only', null, InputOption::VALUE_NONE, 'Download only, do not install packages.'),
  6163. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  6164. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  6165. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  6166. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  6167. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  6168. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
  6169. new InputOption('audit', null, InputOption::VALUE_NONE, 'Run an audit after installation is complete.'),
  6170. new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
  6171. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  6172. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  6173. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  6174. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  6175. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  6176. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  6177. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  6178. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  6179. ])
  6180. ->setHelp(
  6181. <<<EOT
  6182. The <info>install</info> command reads the composer.lock file from
  6183. the current directory, processes it, and downloads and installs all the
  6184. libraries and dependencies outlined in that file. If the file does not
  6185. exist it will look for composer.json and do the same.
  6186. <info>php composer.phar install</info>
  6187. Read more at https://getcomposer.org/doc/03-cli.md#install-i
  6188. EOT
  6189. )
  6190. ;
  6191. }
  6192. protected function execute(InputInterface $input, OutputInterface $output): int
  6193. {
  6194. $io = $this->getIO();
  6195. if ($input->getOption('dev')) {
  6196. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  6197. }
  6198. if ($input->getOption('no-suggest')) {
  6199. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  6200. }
  6201. $args = $input->getArgument('packages');
  6202. if (count($args) > 0) {
  6203. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  6204. return 1;
  6205. }
  6206. if ($input->getOption('no-install')) {
  6207. $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
  6208. return 1;
  6209. }
  6210. $composer = $this->requireComposer();
  6211. if (!$composer->getLocker()->isLocked() && !HttpDownloader::isCurlEnabled()) {
  6212. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  6213. }
  6214. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  6215. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6216. $install = Installer::create($io, $composer);
  6217. $config = $composer->getConfig();
  6218. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($config, $input);
  6219. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  6220. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  6221. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  6222. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  6223. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  6224. $install
  6225. ->setDryRun($input->getOption('dry-run'))
  6226. ->setDownloadOnly($input->getOption('download-only'))
  6227. ->setVerbose($input->getOption('verbose'))
  6228. ->setPreferSource($preferSource)
  6229. ->setPreferDist($preferDist)
  6230. ->setDevMode(!$input->getOption('no-dev'))
  6231. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  6232. ->setOptimizeAutoloader($optimize)
  6233. ->setClassMapAuthoritative($authoritative)
  6234. ->setApcuAutoloader($apcu, $apcuPrefix)
  6235. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  6236. ->setAudit($input->getOption('audit'))
  6237. ->setErrorOnAudit($input->getOption('audit'))
  6238. ->setAuditFormat($this->getAuditFormat($input))
  6239. ;
  6240. if ($input->getOption('no-plugins')) {
  6241. $install->disablePlugins();
  6242. }
  6243. return $install->run();
  6244. }
  6245. }
  6246. <?php declare(strict_types=1);
  6247. namespace Composer\Command;
  6248. use Composer\Console\Input\InputOption;
  6249. use Composer\Json\JsonFile;
  6250. use Composer\Package\CompletePackageInterface;
  6251. use Composer\Plugin\CommandEvent;
  6252. use Composer\Plugin\PluginEvents;
  6253. use Composer\Repository\RepositoryUtils;
  6254. use Composer\Util\PackageInfo;
  6255. use Composer\Util\PackageSorter;
  6256. use Symfony\Component\Console\Formatter\OutputFormatter;
  6257. use Symfony\Component\Console\Helper\Table;
  6258. use Symfony\Component\Console\Input\InputInterface;
  6259. use Symfony\Component\Console\Output\OutputInterface;
  6260. use Symfony\Component\Console\Style\SymfonyStyle;
  6261. class LicensesCommand extends BaseCommand
  6262. {
  6263. protected function configure(): void
  6264. {
  6265. $this
  6266. ->setName('licenses')
  6267. ->setDescription('Shows information about licenses of dependencies')
  6268. ->setDefinition([
  6269. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text', ['text', 'json', 'summary']),
  6270. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  6271. ])
  6272. ->setHelp(
  6273. <<<EOT
  6274. The license command displays detailed information about the licenses of
  6275. the installed dependencies.
  6276. Read more at https://getcomposer.org/doc/03-cli.md#licenses
  6277. EOT
  6278. )
  6279. ;
  6280. }
  6281. protected function execute(InputInterface $input, OutputInterface $output): int
  6282. {
  6283. $composer = $this->requireComposer();
  6284. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  6285. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6286. $root = $composer->getPackage();
  6287. $repo = $composer->getRepositoryManager()->getLocalRepository();
  6288. if ($input->getOption('no-dev')) {
  6289. $packages = RepositoryUtils::filterRequiredPackages($repo->getPackages(), $root);
  6290. } else {
  6291. $packages = $repo->getPackages();
  6292. }
  6293. $packages = PackageSorter::sortPackagesAlphabetically($packages);
  6294. $io = $this->getIO();
  6295. switch ($format = $input->getOption('format')) {
  6296. case 'text':
  6297. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  6298. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  6299. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  6300. $io->write('Dependencies:');
  6301. $io->write('');
  6302. $table = new Table($output);
  6303. $table->setStyle('compact');
  6304. $table->setHeaders(['Name', 'Version', 'Licenses']);
  6305. foreach ($packages as $package) {
  6306. $link = PackageInfo::getViewSourceOrHomepageUrl($package);
  6307. if ($link !== null) {
  6308. $name = '<href='.OutputFormatter::escape($link).'>'.$package->getPrettyName().'</>';
  6309. } else {
  6310. $name = $package->getPrettyName();
  6311. }
  6312. $table->addRow([
  6313. $name,
  6314. $package->getFullPrettyVersion(),
  6315. implode(', ', $package instanceof CompletePackageInterface ? $package->getLicense() : []) ?: 'none',
  6316. ]);
  6317. }
  6318. $table->render();
  6319. break;
  6320. case 'json':
  6321. $dependencies = [];
  6322. foreach ($packages as $package) {
  6323. $dependencies[$package->getPrettyName()] = [
  6324. 'version' => $package->getFullPrettyVersion(),
  6325. 'license' => $package instanceof CompletePackageInterface ? $package->getLicense() : [],
  6326. ];
  6327. }
  6328. $io->write(JsonFile::encode([
  6329. 'name' => $root->getPrettyName(),
  6330. 'version' => $root->getFullPrettyVersion(),
  6331. 'license' => $root->getLicense(),
  6332. 'dependencies' => $dependencies,
  6333. ]));
  6334. break;
  6335. case 'summary':
  6336. $usedLicenses = [];
  6337. foreach ($packages as $package) {
  6338. $licenses = $package instanceof CompletePackageInterface ? $package->getLicense() : [];
  6339. if (count($licenses) === 0) {
  6340. $licenses[] = 'none';
  6341. }
  6342. foreach ($licenses as $licenseName) {
  6343. if (!isset($usedLicenses[$licenseName])) {
  6344. $usedLicenses[$licenseName] = 0;
  6345. }
  6346. $usedLicenses[$licenseName]++;
  6347. }
  6348. }
  6349. arsort($usedLicenses, SORT_NUMERIC);
  6350. $rows = [];
  6351. foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
  6352. $rows[] = [$usedLicense, $numberOfDependencies];
  6353. }
  6354. $symfonyIo = new SymfonyStyle($input, $output);
  6355. $symfonyIo->table(
  6356. ['License', 'Number of dependencies'],
  6357. $rows
  6358. );
  6359. break;
  6360. default:
  6361. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6362. }
  6363. return 0;
  6364. }
  6365. }
  6366. <?php declare(strict_types=1);
  6367. namespace Composer\Command;
  6368. use Symfony\Component\Console\Input\InputInterface;
  6369. use Composer\Console\Input\InputArgument;
  6370. use Symfony\Component\Console\Input\ArrayInput;
  6371. use Composer\Console\Input\InputOption;
  6372. use Symfony\Component\Console\Output\OutputInterface;
  6373. class OutdatedCommand extends BaseCommand
  6374. {
  6375. use CompletionTrait;
  6376. protected function configure(): void
  6377. {
  6378. $this
  6379. ->setName('outdated')
  6380. ->setDescription('Shows a list of installed packages that have updates available, including their latest version')
  6381. ->setDefinition([
  6382. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.', null, $this->suggestInstalledPackage(false)),
  6383. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  6384. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  6385. new InputOption('locked', null, InputOption::VALUE_NONE, 'Shows updates for packages from the lock file, regardless of what is currently in vendor dir'),
  6386. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  6387. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  6388. new InputOption('major-only', 'M', InputOption::VALUE_NONE, 'Show only packages that have major SemVer-compatible updates.'),
  6389. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates.'),
  6390. new InputOption('patch-only', 'p', InputOption::VALUE_NONE, 'Show only packages that have patch SemVer-compatible updates.'),
  6391. new InputOption('sort-by-age', 'A', InputOption::VALUE_NONE, 'Displays the installed version\'s age, and sorts packages oldest first.'),
  6392. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['json', 'text']),
  6393. new InputOption('ignore', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore specified package(s). Can contain wildcards (*). Use it if you don\'t want to be informed about new versions of some packages.', null, $this->suggestInstalledPackage(false)),
  6394. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  6395. 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'),
  6396. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages). Use with the --outdated option'),
  6397. ])
  6398. ->setHelp(
  6399. <<<EOT
  6400. The outdated command is just a proxy for `composer show -l`
  6401. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  6402. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  6403. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  6404. compatibility breaks according to semver, so upgrade when you can but it
  6405. may involve work.
  6406. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  6407. Read more at https://getcomposer.org/doc/03-cli.md#outdated
  6408. EOT
  6409. )
  6410. ;
  6411. }
  6412. protected function execute(InputInterface $input, OutputInterface $output): int
  6413. {
  6414. $args = [
  6415. 'command' => 'show',
  6416. '--latest' => true,
  6417. ];
  6418. if ($input->getOption('no-interaction')) {
  6419. $args['--no-interaction'] = true;
  6420. }
  6421. if ($input->getOption('no-plugins')) {
  6422. $args['--no-plugins'] = true;
  6423. }
  6424. if ($input->getOption('no-scripts')) {
  6425. $args['--no-scripts'] = true;
  6426. }
  6427. if ($input->getOption('no-cache')) {
  6428. $args['--no-cache'] = true;
  6429. }
  6430. if (!$input->getOption('all')) {
  6431. $args['--outdated'] = true;
  6432. }
  6433. if ($input->getOption('direct')) {
  6434. $args['--direct'] = true;
  6435. }
  6436. if (null !== $input->getArgument('package')) {
  6437. $args['package'] = $input->getArgument('package');
  6438. }
  6439. if ($input->getOption('strict')) {
  6440. $args['--strict'] = true;
  6441. }
  6442. if ($input->getOption('major-only')) {
  6443. $args['--major-only'] = true;
  6444. }
  6445. if ($input->getOption('minor-only')) {
  6446. $args['--minor-only'] = true;
  6447. }
  6448. if ($input->getOption('patch-only')) {
  6449. $args['--patch-only'] = true;
  6450. }
  6451. if ($input->getOption('locked')) {
  6452. $args['--locked'] = true;
  6453. }
  6454. if ($input->getOption('no-dev')) {
  6455. $args['--no-dev'] = true;
  6456. }
  6457. if ($input->getOption('sort-by-age')) {
  6458. $args['--sort-by-age'] = true;
  6459. }
  6460. $args['--ignore-platform-req'] = $input->getOption('ignore-platform-req');
  6461. if ($input->getOption('ignore-platform-reqs')) {
  6462. $args['--ignore-platform-reqs'] = true;
  6463. }
  6464. $args['--format'] = $input->getOption('format');
  6465. $args['--ignore'] = $input->getOption('ignore');
  6466. $input = new ArrayInput($args);
  6467. return $this->getApplication()->run($input, $output);
  6468. }
  6469. public function isProxyCommand(): bool
  6470. {
  6471. return true;
  6472. }
  6473. }
  6474. <?php declare(strict_types=1);
  6475. namespace Composer\Command;
  6476. use Composer\Factory;
  6477. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  6478. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  6479. use Composer\IO\IOInterface;
  6480. use Composer\Package\BasePackage;
  6481. use Composer\Package\CompletePackageInterface;
  6482. use Composer\Package\PackageInterface;
  6483. use Composer\Package\Version\VersionParser;
  6484. use Composer\Package\Version\VersionSelector;
  6485. use Composer\Pcre\Preg;
  6486. use Composer\Repository\CompositeRepository;
  6487. use Composer\Repository\PlatformRepository;
  6488. use Composer\Repository\RepositoryFactory;
  6489. use Composer\Repository\RepositorySet;
  6490. use Composer\Semver\Constraint\Constraint;
  6491. use Composer\Util\Filesystem;
  6492. use Symfony\Component\Console\Input\InputInterface;
  6493. use Symfony\Component\Console\Output\OutputInterface;
  6494. trait PackageDiscoveryTrait
  6495. {
  6496. private $repos;
  6497. private $repositorySets;
  6498. protected function getRepos(): CompositeRepository
  6499. {
  6500. if (null === $this->repos) {
  6501. $this->repos = new CompositeRepository(array_merge(
  6502. [new PlatformRepository],
  6503. RepositoryFactory::defaultReposWithDefaultManager($this->getIO())
  6504. ));
  6505. }
  6506. return $this->repos;
  6507. }
  6508. private function getRepositorySet(InputInterface $input, ?string $minimumStability = null): RepositorySet
  6509. {
  6510. $key = $minimumStability ?? 'default';
  6511. if (!isset($this->repositorySets[$key])) {
  6512. $this->repositorySets[$key] = $repositorySet = new RepositorySet($minimumStability ?? $this->getMinimumStability($input));
  6513. $repositorySet->addRepository($this->getRepos());
  6514. }
  6515. return $this->repositorySets[$key];
  6516. }
  6517. private function getMinimumStability(InputInterface $input): string
  6518. {
  6519. if ($input->hasOption('stability')) {
  6520. return VersionParser::normalizeStability($input->getOption('stability') ?? 'stable');
  6521. }
  6522. $file = Factory::getComposerFile();
  6523. if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode((string) file_get_contents($file), true))) {
  6524. if (isset($composer['minimum-stability'])) {
  6525. return VersionParser::normalizeStability($composer['minimum-stability']);
  6526. }
  6527. }
  6528. return 'stable';
  6529. }
  6530. final protected function determineRequirements(InputInterface $input, OutputInterface $output, array $requires = [], ?PlatformRepository $platformRepo = null, string $preferredStability = 'stable', bool $useBestVersionConstraint = true, bool $fixed = false): array
  6531. {
  6532. if (count($requires) > 0) {
  6533. $requires = $this->normalizeRequirements($requires);
  6534. $result = [];
  6535. $io = $this->getIO();
  6536. foreach ($requires as $requirement) {
  6537. if (isset($requirement['version']) && Preg::isMatch('{^\d+(\.\d+)?$}', $requirement['version'])) {
  6538. $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</warning>');
  6539. }
  6540. if (!isset($requirement['version'])) {
  6541. [$name, $version] = $this->findBestVersionAndNameForPackage($this->getIO(), $input, $requirement['name'], $platformRepo, $preferredStability, $fixed);
  6542. $requirement['name'] = $name;
  6543. if ($useBestVersionConstraint) {
  6544. $requirement['version'] = $version;
  6545. $io->writeError(sprintf(
  6546. 'Using version <info>%s</info> for <info>%s</info>',
  6547. $requirement['version'],
  6548. $requirement['name']
  6549. ));
  6550. } else {
  6551. $requirement['version'] = 'guess';
  6552. }
  6553. }
  6554. $result[] = $requirement['name'] . ' ' . $requirement['version'];
  6555. }
  6556. return $result;
  6557. }
  6558. $versionParser = new VersionParser();
  6559. $composer = $this->tryComposer();
  6560. $installedRepo = null;
  6561. if (null !== $composer) {
  6562. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  6563. }
  6564. $existingPackages = [];
  6565. if (null !== $installedRepo) {
  6566. foreach ($installedRepo->getPackages() as $package) {
  6567. $existingPackages[] = $package->getName();
  6568. }
  6569. }
  6570. unset($composer, $installedRepo);
  6571. $io = $this->getIO();
  6572. while (null !== $package = $io->ask('Search for a package: ')) {
  6573. $matches = $this->getRepos()->search($package);
  6574. if (count($matches) > 0) {
  6575. foreach ($matches as $position => $foundPackage) {
  6576. if (in_array($foundPackage['name'], $existingPackages, true)) {
  6577. unset($matches[$position]);
  6578. }
  6579. }
  6580. $matches = array_values($matches);
  6581. $exactMatch = false;
  6582. foreach ($matches as $match) {
  6583. if ($match['name'] === $package) {
  6584. $exactMatch = true;
  6585. break;
  6586. }
  6587. }
  6588. if (!$exactMatch) {
  6589. $providers = $this->getRepos()->getProviders($package);
  6590. if (count($providers) > 0) {
  6591. array_unshift($matches, ['name' => $package, 'description' => '']);
  6592. }
  6593. $choices = [];
  6594. foreach ($matches as $position => $foundPackage) {
  6595. $abandoned = '';
  6596. if (isset($foundPackage['abandoned'])) {
  6597. if (is_string($foundPackage['abandoned'])) {
  6598. $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
  6599. } else {
  6600. $replacement = 'No replacement was suggested';
  6601. }
  6602. $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
  6603. }
  6604. $choices[] = sprintf(' <info>%5s</info> %s %s', "[$position]", $foundPackage['name'], $abandoned);
  6605. }
  6606. $io->writeError([
  6607. '',
  6608. sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
  6609. '',
  6610. ]);
  6611. $io->writeError($choices);
  6612. $io->writeError('');
  6613. $validator = static function (string $selection) use ($matches, $versionParser) {
  6614. if ('' === $selection) {
  6615. return false;
  6616. }
  6617. if (is_numeric($selection) && isset($matches[(int) $selection])) {
  6618. $package = $matches[(int) $selection];
  6619. return $package['name'];
  6620. }
  6621. if (Preg::isMatch('{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}', $selection, $packageMatches)) {
  6622. if (isset($packageMatches['version'])) {
  6623. $versionParser->parseConstraints($packageMatches['version']);
  6624. return $packageMatches['name'].' '.$packageMatches['version'];
  6625. }
  6626. return $packageMatches['name'];
  6627. }
  6628. throw new \Exception('Not a valid selection');
  6629. };
  6630. $package = $io->askAndValidate(
  6631. 'Enter package # to add, or the complete package name if it is not listed: ',
  6632. $validator,
  6633. 3,
  6634. ''
  6635. );
  6636. }
  6637. if (false !== $package && false === strpos($package, ' ')) {
  6638. $validator = static function (string $input) {
  6639. $input = trim($input);
  6640. return strlen($input) > 0 ? $input : false;
  6641. };
  6642. $constraint = $io->askAndValidate(
  6643. 'Enter the version constraint to require (or leave blank to use the latest version): ',
  6644. $validator,
  6645. 3,
  6646. ''
  6647. );
  6648. if (false === $constraint) {
  6649. [, $constraint] = $this->findBestVersionAndNameForPackage($this->getIO(), $input, $package, $platformRepo, $preferredStability);
  6650. $io->writeError(sprintf(
  6651. 'Using version <info>%s</info> for <info>%s</info>',
  6652. $constraint,
  6653. $package
  6654. ));
  6655. }
  6656. $package .= ' '.$constraint;
  6657. }
  6658. if (false !== $package) {
  6659. $requires[] = $package;
  6660. $existingPackages[] = explode(' ', $package)[0];
  6661. }
  6662. }
  6663. }
  6664. return $requires;
  6665. }
  6666. private function findBestVersionAndNameForPackage(IOInterface $io, InputInterface $input, string $name, ?PlatformRepository $platformRepo = null, string $preferredStability = 'stable', bool $fixed = false): array
  6667. {
  6668. if ($input->hasOption('ignore-platform-reqs') && $input->hasOption('ignore-platform-req')) {
  6669. $platformRequirementFilter = $this->getPlatformRequirementFilter($input);
  6670. } else {
  6671. $platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  6672. }
  6673. $repoSet = $this->getRepositorySet($input);
  6674. $versionSelector = new VersionSelector($repoSet, $platformRepo);
  6675. $effectiveMinimumStability = $this->getMinimumStability($input);
  6676. $package = $versionSelector->findBestCandidate($name, null, $preferredStability, $platformRequirementFilter, 0, $this->getIO());
  6677. if (false === $package) {
  6678. if ($platformRequirementFilter->isIgnored($name)) {
  6679. return [$name, '*'];
  6680. }
  6681. $providers = $repoSet->getProviders($name);
  6682. if (count($providers) > 0) {
  6683. $constraint = '*';
  6684. if ($input->isInteractive()) {
  6685. $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) {
  6686. $parser = new VersionParser();
  6687. $parser->parseConstraints($value);
  6688. return $value;
  6689. }, 3, '*');
  6690. }
  6691. return [$name, $constraint];
  6692. }
  6693. if (!($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter) && false !== ($candidate = $versionSelector->findBestCandidate($name, null, $preferredStability, PlatformRequirementFilterFactory::ignoreAll()))) {
  6694. throw new \InvalidArgumentException(sprintf(
  6695. 'Package %s has requirements incompatible with your PHP version, PHP extensions and Composer version' . $this->getPlatformExceptionDetails($candidate, $platformRepo),
  6696. $name
  6697. ));
  6698. }
  6699. if (false !== ($package = $versionSelector->findBestCandidate($name, null, $preferredStability, $platformRequirementFilter, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES))) {
  6700. if (false !== ($allReposPackage = $versionSelector->findBestCandidate($name, null, $preferredStability, $platformRequirementFilter, RepositorySet::ALLOW_SHADOWED_REPOSITORIES))) {
  6701. throw new \InvalidArgumentException(
  6702. '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.'
  6703. );
  6704. }
  6705. throw new \InvalidArgumentException(sprintf(
  6706. 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.',
  6707. $name,
  6708. $effectiveMinimumStability
  6709. ));
  6710. }
  6711. if (!$platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter && false !== ($candidate = $versionSelector->findBestCandidate($name, null, $preferredStability, PlatformRequirementFilterFactory::ignoreAll(), RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES))) {
  6712. $additional = '';
  6713. if (false === $versionSelector->findBestCandidate($name, null, $preferredStability, PlatformRequirementFilterFactory::ignoreAll())) {
  6714. $additional = PHP_EOL.PHP_EOL.'Additionally, the package was only found with a stability of "'.$candidate->getStability().'" while your minimum stability is "'.$effectiveMinimumStability.'".';
  6715. }
  6716. throw new \InvalidArgumentException(sprintf(
  6717. 'Could not find package %s in any version matching your PHP version, PHP extensions and Composer version' . $this->getPlatformExceptionDetails($candidate, $platformRepo) . '%s',
  6718. $name,
  6719. $additional
  6720. ));
  6721. }
  6722. $similar = $this->findSimilar($name);
  6723. if (count($similar) > 0) {
  6724. if (in_array($name, $similar, true)) {
  6725. throw new \InvalidArgumentException(sprintf(
  6726. "Could not find package %s. It was however found via repository search, which indicates a consistency issue with the repository.",
  6727. $name
  6728. ));
  6729. }
  6730. if ($input->isInteractive()) {
  6731. $result = $io->select("<error>Could not find package $name.</error>\nPick one of these or leave empty to abort:", $similar, false, 1);
  6732. if ($result !== false) {
  6733. return $this->findBestVersionAndNameForPackage($io, $input, $similar[$result], $platformRepo, $preferredStability, $fixed);
  6734. }
  6735. }
  6736. throw new \InvalidArgumentException(sprintf(
  6737. "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s",
  6738. $name,
  6739. implode("\n ", $similar)
  6740. ));
  6741. }
  6742. throw new \InvalidArgumentException(sprintf(
  6743. '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).',
  6744. $name,
  6745. $effectiveMinimumStability
  6746. ));
  6747. }
  6748. return [
  6749. $package->getPrettyName(),
  6750. $fixed ? $package->getPrettyVersion() : $versionSelector->findRecommendedRequireVersion($package),
  6751. ];
  6752. }
  6753. private function findSimilar(string $package): array
  6754. {
  6755. try {
  6756. if (null === $this->repos) {
  6757. throw new \LogicException('findSimilar was called before $this->repos was initialized');
  6758. }
  6759. $results = $this->repos->search($package);
  6760. } catch (\Throwable $e) {
  6761. if ($e instanceof \LogicException) {
  6762. throw $e;
  6763. }
  6764. return [];
  6765. }
  6766. $similarPackages = [];
  6767. $installedRepo = $this->requireComposer()->getRepositoryManager()->getLocalRepository();
  6768. foreach ($results as $result) {
  6769. if (null !== $installedRepo->findPackage($result['name'], '*')) {
  6770. continue;
  6771. }
  6772. $similarPackages[$result['name']] = levenshtein($package, $result['name']);
  6773. }
  6774. asort($similarPackages);
  6775. return array_keys(array_slice($similarPackages, 0, 5));
  6776. }
  6777. private function getPlatformExceptionDetails(PackageInterface $candidate, ?PlatformRepository $platformRepo = null): string
  6778. {
  6779. $details = [];
  6780. if (null === $platformRepo) {
  6781. return '';
  6782. }
  6783. foreach ($candidate->getRequires() as $link) {
  6784. if (!PlatformRepository::isPlatformPackage($link->getTarget())) {
  6785. continue;
  6786. }
  6787. $platformPkg = $platformRepo->findPackage($link->getTarget(), '*');
  6788. if (null === $platformPkg) {
  6789. if ($platformRepo->isPlatformPackageDisabled($link->getTarget())) {
  6790. $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".';
  6791. } else {
  6792. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' but it is not present.';
  6793. }
  6794. continue;
  6795. }
  6796. if (!$link->getConstraint()->matches(new Constraint('==', $platformPkg->getVersion()))) {
  6797. $platformPkgVersion = $platformPkg->getPrettyVersion();
  6798. $platformExtra = $platformPkg->getExtra();
  6799. if (isset($platformExtra['config.platform']) && $platformPkg instanceof CompletePackageInterface) {
  6800. $platformPkgVersion .= ' ('.$platformPkg->getDescription().')';
  6801. }
  6802. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' which does not match your installed version '.$platformPkgVersion.'.';
  6803. }
  6804. }
  6805. if (count($details) === 0) {
  6806. return '';
  6807. }
  6808. return ':'.PHP_EOL.' - ' . implode(PHP_EOL.' - ', $details);
  6809. }
  6810. }
  6811. <?php declare(strict_types=1);
  6812. namespace Composer\Command;
  6813. use Symfony\Component\Console\Input\InputInterface;
  6814. use Symfony\Component\Console\Output\OutputInterface;
  6815. use Composer\Console\Input\InputArgument;
  6816. use Composer\Console\Input\InputOption;
  6817. class ProhibitsCommand extends BaseDependencyCommand
  6818. {
  6819. use CompletionTrait;
  6820. protected function configure(): void
  6821. {
  6822. $this
  6823. ->setName('prohibits')
  6824. ->setAliases(['why-not'])
  6825. ->setDescription('Shows which packages prevent the given package from being installed')
  6826. ->setDefinition([
  6827. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect', null, $this->suggestAvailablePackage()),
  6828. new InputArgument(self::ARGUMENT_CONSTRAINT, InputArgument::REQUIRED, 'Version constraint, which version you expected to be installed'),
  6829. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  6830. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  6831. new InputOption('locked', null, InputOption::VALUE_NONE, 'Read dependency information from composer.lock'),
  6832. ])
  6833. ->setHelp(
  6834. <<<EOT
  6835. Displays detailed information about why a package cannot be installed.
  6836. <info>php composer.phar prohibits composer/composer</info>
  6837. Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not
  6838. EOT
  6839. )
  6840. ;
  6841. }
  6842. protected function execute(InputInterface $input, OutputInterface $output): int
  6843. {
  6844. return parent::doExecute($input, $output, true);
  6845. }
  6846. }
  6847. <?php declare(strict_types=1);
  6848. namespace Composer\Command;
  6849. use Composer\DependencyResolver\Operation\InstallOperation;
  6850. use Composer\DependencyResolver\Operation\UninstallOperation;
  6851. use Composer\DependencyResolver\Transaction;
  6852. use Composer\Package\AliasPackage;
  6853. use Composer\Package\BasePackage;
  6854. use Composer\Pcre\Preg;
  6855. use Composer\Plugin\CommandEvent;
  6856. use Composer\Plugin\PluginEvents;
  6857. use Composer\Script\ScriptEvents;
  6858. use Composer\Util\Platform;
  6859. use Symfony\Component\Console\Input\InputInterface;
  6860. use Composer\Console\Input\InputOption;
  6861. use Composer\Console\Input\InputArgument;
  6862. use Symfony\Component\Console\Output\OutputInterface;
  6863. class ReinstallCommand extends BaseCommand
  6864. {
  6865. use CompletionTrait;
  6866. protected function configure(): void
  6867. {
  6868. $this
  6869. ->setName('reinstall')
  6870. ->setDescription('Uninstalls and reinstalls the given package names')
  6871. ->setDefinition([
  6872. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  6873. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  6874. 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()),
  6875. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  6876. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  6877. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  6878. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  6879. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  6880. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  6881. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  6882. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  6883. new InputOption('type', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Filter packages to reinstall by type(s)', null, $this->suggestInstalledPackageTypes(false)),
  6884. new InputArgument('packages', InputArgument::IS_ARRAY, 'List of package names to reinstall, can include a wildcard (*) to match any substring.', null, $this->suggestInstalledPackage(false)),
  6885. ])
  6886. ->setHelp(
  6887. <<<EOT
  6888. The <info>reinstall</info> command looks up installed packages by name,
  6889. uninstalls them and reinstalls them. This lets you do a clean install
  6890. of a package if you messed with its files, or if you wish to change
  6891. the installation type using --prefer-install.
  6892. <info>php composer.phar reinstall acme/foo "acme/bar-*"</info>
  6893. Read more at https://getcomposer.org/doc/03-cli.md#reinstall
  6894. EOT
  6895. )
  6896. ;
  6897. }
  6898. protected function execute(InputInterface $input, OutputInterface $output): int
  6899. {
  6900. $io = $this->getIO();
  6901. $composer = $this->requireComposer();
  6902. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6903. $packagesToReinstall = [];
  6904. $packageNamesToReinstall = [];
  6905. if (\count($input->getOption('type')) > 0) {
  6906. if (\count($input->getArgument('packages')) > 0) {
  6907. throw new \InvalidArgumentException('You cannot specify package names and filter by type at the same time.');
  6908. }
  6909. foreach ($localRepo->getCanonicalPackages() as $package) {
  6910. if (in_array($package->getType(), $input->getOption('type'), true)) {
  6911. $packagesToReinstall[] = $package;
  6912. $packageNamesToReinstall[] = $package->getName();
  6913. }
  6914. }
  6915. } else {
  6916. if (\count($input->getArgument('packages')) === 0) {
  6917. throw new \InvalidArgumentException('You must pass one or more package names to be reinstalled.');
  6918. }
  6919. foreach ($input->getArgument('packages') as $pattern) {
  6920. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  6921. $matched = false;
  6922. foreach ($localRepo->getCanonicalPackages() as $package) {
  6923. if (Preg::isMatch($patternRegexp, $package->getName())) {
  6924. $matched = true;
  6925. $packagesToReinstall[] = $package;
  6926. $packageNamesToReinstall[] = $package->getName();
  6927. }
  6928. }
  6929. if (!$matched) {
  6930. $io->writeError('<warning>Pattern "' . $pattern . '" does not match any currently installed packages.</warning>');
  6931. }
  6932. }
  6933. }
  6934. if (0 === \count($packagesToReinstall)) {
  6935. $io->writeError('<warning>Found no packages to reinstall, aborting.</warning>');
  6936. return 1;
  6937. }
  6938. $uninstallOperations = [];
  6939. foreach ($packagesToReinstall as $package) {
  6940. $uninstallOperations[] = new UninstallOperation($package);
  6941. }
  6942. $presentPackages = $localRepo->getPackages();
  6943. $resultPackages = $presentPackages;
  6944. foreach ($presentPackages as $index => $package) {
  6945. if (in_array($package->getName(), $packageNamesToReinstall, true)) {
  6946. unset($presentPackages[$index]);
  6947. }
  6948. }
  6949. $transaction = new Transaction($presentPackages, $resultPackages);
  6950. $installOperations = $transaction->getOperations();
  6951. $installOrder = [];
  6952. foreach ($installOperations as $index => $op) {
  6953. if ($op instanceof InstallOperation && !$op->getPackage() instanceof AliasPackage) {
  6954. $installOrder[$op->getPackage()->getName()] = $index;
  6955. }
  6956. }
  6957. usort($uninstallOperations, static function ($a, $b) use ($installOrder): int {
  6958. return $installOrder[$b->getPackage()->getName()] - $installOrder[$a->getPackage()->getName()];
  6959. });
  6960. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'reinstall', $input, $output);
  6961. $eventDispatcher = $composer->getEventDispatcher();
  6962. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  6963. $config = $composer->getConfig();
  6964. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($config, $input);
  6965. $installationManager = $composer->getInstallationManager();
  6966. $downloadManager = $composer->getDownloadManager();
  6967. $package = $composer->getPackage();
  6968. $installationManager->setOutputProgress(!$input->getOption('no-progress'));
  6969. if ($input->getOption('no-plugins')) {
  6970. $installationManager->disablePlugins();
  6971. }
  6972. $downloadManager->setPreferSource($preferSource);
  6973. $downloadManager->setPreferDist($preferDist);
  6974. $devMode = $localRepo->getDevMode() !== null ? $localRepo->getDevMode() : true;
  6975. Platform::putEnv('COMPOSER_DEV_MODE', $devMode ? '1' : '0');
  6976. $eventDispatcher->dispatchScript(ScriptEvents::PRE_INSTALL_CMD, $devMode);
  6977. $installationManager->execute($localRepo, $uninstallOperations, $devMode);
  6978. $installationManager->execute($localRepo, $installOperations, $devMode);
  6979. if (!$input->getOption('no-autoloader')) {
  6980. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  6981. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  6982. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  6983. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  6984. $generator = $composer->getAutoloadGenerator();
  6985. $generator->setClassMapAuthoritative($authoritative);
  6986. $generator->setApcu($apcu, $apcuPrefix);
  6987. $generator->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input));
  6988. $generator->dump(
  6989. $config,
  6990. $localRepo,
  6991. $package,
  6992. $installationManager,
  6993. 'composer',
  6994. $optimize,
  6995. null,
  6996. $composer->getLocker()
  6997. );
  6998. }
  6999. $eventDispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, $devMode);
  7000. return 0;
  7001. }
  7002. }
  7003. <?php declare(strict_types=1);
  7004. namespace Composer\Command;
  7005. use Composer\Config\JsonConfigSource;
  7006. use Composer\DependencyResolver\Request;
  7007. use Composer\Installer;
  7008. use Composer\Pcre\Preg;
  7009. use Composer\Plugin\CommandEvent;
  7010. use Composer\Plugin\PluginEvents;
  7011. use Composer\Json\JsonFile;
  7012. use Composer\Factory;
  7013. use Symfony\Component\Console\Exception\InvalidArgumentException;
  7014. use Symfony\Component\Console\Input\InputInterface;
  7015. use Composer\Console\Input\InputOption;
  7016. use Composer\Console\Input\InputArgument;
  7017. use Symfony\Component\Console\Output\OutputInterface;
  7018. use Composer\Package\BasePackage;
  7019. use Composer\Advisory\Auditor;
  7020. class RemoveCommand extends BaseCommand
  7021. {
  7022. use CompletionTrait;
  7023. protected function configure()
  7024. {
  7025. $this
  7026. ->setName('remove')
  7027. ->setAliases(['rm', 'uninstall'])
  7028. ->setDescription('Removes a package from the require or require-dev')
  7029. ->setDefinition([
  7030. new InputArgument('packages', InputArgument::IS_ARRAY, 'Packages that should be removed.', null, $this->suggestRootRequirement()),
  7031. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  7032. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  7033. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  7034. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  7035. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  7036. 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).'),
  7037. new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
  7038. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  7039. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies (can also be set via the COMPOSER_WITH_DEPENDENCIES=1 env var). (Deprecated, is now default behavior)'),
  7040. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements (can also be set via the COMPOSER_WITH_ALL_DEPENDENCIES=1 env var).'),
  7041. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  7042. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  7043. new InputOption('minimal-changes', 'm', InputOption::VALUE_NONE, 'During an update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var).'),
  7044. new InputOption('unused', null, InputOption::VALUE_NONE, 'Remove all packages which are locked but not required by any other package.'),
  7045. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  7046. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  7047. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  7048. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  7049. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  7050. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  7051. ])
  7052. ->setHelp(
  7053. <<<EOT
  7054. The <info>remove</info> command removes a package from the current
  7055. list of installed packages
  7056. <info>php composer.phar remove</info>
  7057. Read more at https://getcomposer.org/doc/03-cli.md#remove-rm
  7058. EOT
  7059. )
  7060. ;
  7061. }
  7062. protected function execute(InputInterface $input, OutputInterface $output): int
  7063. {
  7064. if ($input->getArgument('packages') === [] && !$input->getOption('unused')) {
  7065. throw new InvalidArgumentException('Not enough arguments (missing: "packages").');
  7066. }
  7067. $packages = $input->getArgument('packages');
  7068. $packages = array_map('strtolower', $packages);
  7069. if ($input->getOption('unused')) {
  7070. $composer = $this->requireComposer();
  7071. $locker = $composer->getLocker();
  7072. if (!$locker->isLocked()) {
  7073. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --unused');
  7074. }
  7075. $lockedPackages = $locker->getLockedRepository()->getPackages();
  7076. $required = [];
  7077. foreach (array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()) as $link) {
  7078. $required[$link->getTarget()] = true;
  7079. }
  7080. do {
  7081. $found = false;
  7082. foreach ($lockedPackages as $index => $package) {
  7083. foreach ($package->getNames() as $name) {
  7084. if (isset($required[$name])) {
  7085. foreach ($package->getRequires() as $link) {
  7086. $required[$link->getTarget()] = true;
  7087. }
  7088. $found = true;
  7089. unset($lockedPackages[$index]);
  7090. break;
  7091. }
  7092. }
  7093. }
  7094. } while ($found);
  7095. $unused = [];
  7096. foreach ($lockedPackages as $package) {
  7097. $unused[] = $package->getName();
  7098. }
  7099. $packages = array_merge($packages, $unused);
  7100. if (count($packages) === 0) {
  7101. $this->getIO()->writeError('<info>No unused packages to remove</info>');
  7102. return 0;
  7103. }
  7104. }
  7105. $file = Factory::getComposerFile();
  7106. $jsonFile = new JsonFile($file);
  7107. $composer = $jsonFile->read();
  7108. $composerBackup = file_get_contents($jsonFile->getPath());
  7109. $json = new JsonConfigSource($jsonFile);
  7110. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  7111. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  7112. $io = $this->getIO();
  7113. if ($input->getOption('update-with-dependencies')) {
  7114. $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>');
  7115. }
  7116. foreach (['require', 'require-dev'] as $linkType) {
  7117. if (isset($composer[$linkType])) {
  7118. foreach ($composer[$linkType] as $name => $version) {
  7119. $composer[$linkType][strtolower($name)] = $name;
  7120. }
  7121. }
  7122. }
  7123. $dryRun = $input->getOption('dry-run');
  7124. $toRemove = [];
  7125. foreach ($packages as $package) {
  7126. if (isset($composer[$type][$package])) {
  7127. if ($dryRun) {
  7128. $toRemove[$type][] = $composer[$type][$package];
  7129. } else {
  7130. $json->removeLink($type, $composer[$type][$package]);
  7131. }
  7132. } elseif (isset($composer[$altType][$package])) {
  7133. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  7134. if ($io->isInteractive()) {
  7135. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  7136. if ($dryRun) {
  7137. $toRemove[$altType][] = $composer[$altType][$package];
  7138. } else {
  7139. $json->removeLink($altType, $composer[$altType][$package]);
  7140. }
  7141. }
  7142. }
  7143. } elseif (isset($composer[$type]) && count($matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) > 0) {
  7144. foreach ($matches as $matchedPackage) {
  7145. if ($dryRun) {
  7146. $toRemove[$type][] = $matchedPackage;
  7147. } else {
  7148. $json->removeLink($type, $matchedPackage);
  7149. }
  7150. }
  7151. } elseif (isset($composer[$altType]) && count($matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) > 0) {
  7152. foreach ($matches as $matchedPackage) {
  7153. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  7154. if ($io->isInteractive()) {
  7155. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  7156. if ($dryRun) {
  7157. $toRemove[$altType][] = $matchedPackage;
  7158. } else {
  7159. $json->removeLink($altType, $matchedPackage);
  7160. }
  7161. }
  7162. }
  7163. }
  7164. } else {
  7165. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  7166. }
  7167. }
  7168. $io->writeError('<info>'.$file.' has been updated</info>');
  7169. if ($input->getOption('no-update')) {
  7170. return 0;
  7171. }
  7172. if ($composer = $this->tryComposer()) {
  7173. $composer->getPluginManager()->deactivateInstalledPlugins();
  7174. }
  7175. $this->resetComposer();
  7176. $composer = $this->requireComposer();
  7177. if ($dryRun) {
  7178. $rootPackage = $composer->getPackage();
  7179. $links = [
  7180. 'require' => $rootPackage->getRequires(),
  7181. 'require-dev' => $rootPackage->getDevRequires(),
  7182. ];
  7183. foreach ($toRemove as $type => $names) {
  7184. foreach ($names as $name) {
  7185. unset($links[$type][$name]);
  7186. }
  7187. }
  7188. $rootPackage->setRequires($links['require']);
  7189. $rootPackage->setDevRequires($links['require-dev']);
  7190. }
  7191. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  7192. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7193. $allowPlugins = $composer->getConfig()->get('allow-plugins');
  7194. $removedPlugins = is_array($allowPlugins) ? array_intersect(array_keys($allowPlugins), $packages) : [];
  7195. if (!$dryRun && is_array($allowPlugins) && count($removedPlugins) > 0) {
  7196. if (count($allowPlugins) === count($removedPlugins)) {
  7197. $json->removeConfigSetting('allow-plugins');
  7198. } else {
  7199. foreach ($removedPlugins as $plugin) {
  7200. $json->removeConfigSetting('allow-plugins.'.$plugin);
  7201. }
  7202. }
  7203. }
  7204. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  7205. $install = Installer::create($io, $composer);
  7206. $updateDevMode = !$input->getOption('update-no-dev');
  7207. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  7208. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  7209. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  7210. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  7211. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  7212. $flags = '';
  7213. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  7214. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  7215. $flags .= ' --with-all-dependencies';
  7216. } elseif ($input->getOption('no-update-with-dependencies')) {
  7217. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  7218. $flags .= ' --with-dependencies';
  7219. }
  7220. $io->writeError('<info>Running composer update '.implode(' ', $packages).$flags.'</info>');
  7221. $install
  7222. ->setVerbose($input->getOption('verbose'))
  7223. ->setDevMode($updateDevMode)
  7224. ->setOptimizeAutoloader($optimize)
  7225. ->setClassMapAuthoritative($authoritative)
  7226. ->setApcuAutoloader($apcu, $apcuPrefix)
  7227. ->setUpdate(true)
  7228. ->setInstall(!$input->getOption('no-install'))
  7229. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  7230. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  7231. ->setDryRun($dryRun)
  7232. ->setAudit(!$input->getOption('no-audit'))
  7233. ->setAuditFormat($this->getAuditFormat($input))
  7234. ->setMinimalUpdate($input->getOption('minimal-changes'))
  7235. ;
  7236. if ($composer->getLocker()->isLocked()) {
  7237. $install->setUpdateAllowList($packages);
  7238. }
  7239. $status = $install->run();
  7240. if ($status !== 0) {
  7241. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  7242. file_put_contents($jsonFile->getPath(), $composerBackup);
  7243. }
  7244. if (!$dryRun) {
  7245. foreach ($packages as $package) {
  7246. if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
  7247. $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
  7248. return 2;
  7249. }
  7250. }
  7251. }
  7252. return $status;
  7253. }
  7254. }
  7255. <?php declare(strict_types=1);
  7256. namespace Composer\Command;
  7257. use Composer\DependencyResolver\Request;
  7258. use Composer\Package\AliasPackage;
  7259. use Composer\Package\CompletePackageInterface;
  7260. use Composer\Package\Loader\RootPackageLoader;
  7261. use Composer\Package\Locker;
  7262. use Composer\Package\PackageInterface;
  7263. use Composer\Package\Version\VersionBumper;
  7264. use Composer\Package\Version\VersionSelector;
  7265. use Composer\Pcre\Preg;
  7266. use Composer\Repository\RepositorySet;
  7267. use Composer\Util\Filesystem;
  7268. use Composer\Util\PackageSorter;
  7269. use Seld\Signal\SignalHandler;
  7270. use Symfony\Component\Console\Input\InputInterface;
  7271. use Composer\Console\Input\InputArgument;
  7272. use Composer\Console\Input\InputOption;
  7273. use Symfony\Component\Console\Output\OutputInterface;
  7274. use Composer\Factory;
  7275. use Composer\Installer;
  7276. use Composer\Installer\InstallerEvents;
  7277. use Composer\Json\JsonFile;
  7278. use Composer\Json\JsonManipulator;
  7279. use Composer\Package\Version\VersionParser;
  7280. use Composer\Package\Loader\ArrayLoader;
  7281. use Composer\Package\BasePackage;
  7282. use Composer\Plugin\CommandEvent;
  7283. use Composer\Plugin\PluginEvents;
  7284. use Composer\Repository\CompositeRepository;
  7285. use Composer\Repository\PlatformRepository;
  7286. use Composer\IO\IOInterface;
  7287. use Composer\Advisory\Auditor;
  7288. use Composer\Util\Silencer;
  7289. class RequireCommand extends BaseCommand
  7290. {
  7291. use CompletionTrait;
  7292. use PackageDiscoveryTrait;
  7293. private $newlyCreated;
  7294. private $firstRequire;
  7295. private $json;
  7296. private $file;
  7297. private $composerBackup;
  7298. private $lock;
  7299. private $lockBackup;
  7300. private $dependencyResolutionCompleted = false;
  7301. protected function configure()
  7302. {
  7303. $this
  7304. ->setName('require')
  7305. ->setAliases(['r'])
  7306. ->setDescription('Adds required packages to your composer.json and installs them')
  7307. ->setDefinition([
  7308. 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()),
  7309. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  7310. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  7311. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  7312. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  7313. 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()),
  7314. new InputOption('fixed', null, InputOption::VALUE_NONE, 'Write fixed version to the composer.json.'),
  7315. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  7316. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  7317. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  7318. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  7319. 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).'),
  7320. new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
  7321. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  7322. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements (can also be set via the COMPOSER_WITH_DEPENDENCIES=1 env var).'),
  7323. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements (can also be set via the COMPOSER_WITH_ALL_DEPENDENCIES=1 env var).'),
  7324. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-dependencies'),
  7325. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  7326. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  7327. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  7328. 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).'),
  7329. 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).'),
  7330. new InputOption('minimal-changes', 'm', InputOption::VALUE_NONE, 'During an update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var).'),
  7331. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  7332. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  7333. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  7334. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  7335. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  7336. ])
  7337. ->setHelp(
  7338. <<<EOT
  7339. The require command adds required packages to your composer.json and installs them.
  7340. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  7341. matches to require.
  7342. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  7343. If you do not want to install the new dependencies immediately you can call it with --no-update
  7344. Read more at https://getcomposer.org/doc/03-cli.md#require-r
  7345. EOT
  7346. )
  7347. ;
  7348. }
  7349. protected function execute(InputInterface $input, OutputInterface $output): int
  7350. {
  7351. $this->file = Factory::getComposerFile();
  7352. $io = $this->getIO();
  7353. if ($input->getOption('no-suggest')) {
  7354. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  7355. }
  7356. $this->newlyCreated = !file_exists($this->file);
  7357. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  7358. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  7359. return 1;
  7360. }
  7361. if (!Filesystem::isReadable($this->file)) {
  7362. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  7363. return 1;
  7364. }
  7365. if (filesize($this->file) === 0) {
  7366. file_put_contents($this->file, "{\n}\n");
  7367. }
  7368. $this->json = new JsonFile($this->file);
  7369. $this->lock = Factory::getLockFile($this->file);
  7370. $this->composerBackup = file_get_contents($this->json->getPath());
  7371. $this->lockBackup = file_exists($this->lock) ? file_get_contents($this->lock) : null;
  7372. $signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) {
  7373. $this->getIO()->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG);
  7374. $this->revertComposerFile();
  7375. $handler->exitWithLastSignal();
  7376. });
  7377. if (!is_writable($this->file) && false === Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
  7378. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  7379. return 1;
  7380. }
  7381. if ($input->getOption('fixed') === true) {
  7382. $config = $this->json->read();
  7383. $packageType = empty($config['type']) ? 'library' : $config['type'];
  7384. if ($packageType !== 'project' && !$input->getOption('dev')) {
  7385. $io->writeError('<error>The "--fixed" option is only allowed for packages with a "project" type or for dev dependencies to prevent possible misuses.</error>');
  7386. if (!isset($config['type'])) {
  7387. $io->writeError('<error>If your package is not a library, you can explicitly specify the "type" by using "composer config type project".</error>');
  7388. }
  7389. return 1;
  7390. }
  7391. }
  7392. $composer = $this->requireComposer();
  7393. $repos = $composer->getRepositoryManager()->getRepositories();
  7394. $platformOverrides = $composer->getConfig()->get('platform');
  7395. $this->repos = new CompositeRepository(array_merge(
  7396. [$platformRepo = new PlatformRepository([], $platformOverrides)],
  7397. $repos
  7398. ));
  7399. if ($composer->getPackage()->getPreferStable()) {
  7400. $preferredStability = 'stable';
  7401. } else {
  7402. $preferredStability = $composer->getPackage()->getMinimumStability();
  7403. }
  7404. try {
  7405. $requirements = $this->determineRequirements(
  7406. $input,
  7407. $output,
  7408. $input->getArgument('packages'),
  7409. $platformRepo,
  7410. $preferredStability,
  7411. $input->getOption('no-update'),
  7412. $input->getOption('fixed')
  7413. );
  7414. } catch (\Exception $e) {
  7415. if ($this->newlyCreated) {
  7416. $this->revertComposerFile();
  7417. throw new \RuntimeException('No composer.json present in the current directory ('.$this->file.'), this may be the cause of the following exception.', 0, $e);
  7418. }
  7419. throw $e;
  7420. }
  7421. $requirements = $this->formatRequirements($requirements);
  7422. if (!$input->getOption('dev') && $io->isInteractive() && !$composer->isGlobal()) {
  7423. $devPackages = [];
  7424. $devTags = ['dev', 'testing', 'static analysis'];
  7425. $currentRequiresByKey = $this->getPackagesByRequireKey();
  7426. foreach ($requirements as $name => $version) {
  7427. if (isset($currentRequiresByKey[$name])) {
  7428. continue;
  7429. }
  7430. $pkg = PackageSorter::getMostCurrentVersion($this->getRepos()->findPackages($name));
  7431. if ($pkg instanceof CompletePackageInterface) {
  7432. $pkgDevTags = array_intersect($devTags, array_map('strtolower', $pkg->getKeywords()));
  7433. if (count($pkgDevTags) > 0) {
  7434. $devPackages[] = $pkgDevTags;
  7435. }
  7436. }
  7437. }
  7438. if (count($devPackages) === count($requirements)) {
  7439. $plural = count($requirements) > 1 ? 's' : '';
  7440. $plural2 = count($requirements) > 1 ? 'are' : 'is';
  7441. $plural3 = count($requirements) > 1 ? 'they are' : 'it is';
  7442. $pkgDevTags = array_unique(array_merge(...$devPackages));
  7443. $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.');
  7444. if ($io->askConfirmation('<info>Do you want to re-run the command with --dev?</> [<comment>yes</>]? ')) {
  7445. $input->setOption('dev', true);
  7446. }
  7447. }
  7448. unset($devPackages, $pkgDevTags);
  7449. }
  7450. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  7451. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  7452. $requirementsToGuess = [];
  7453. foreach ($requirements as $package => $constraint) {
  7454. if ($constraint === 'guess') {
  7455. $requirements[$package] = '*';
  7456. $requirementsToGuess[] = $package;
  7457. }
  7458. }
  7459. $versionParser = new VersionParser();
  7460. foreach ($requirements as $package => $constraint) {
  7461. if (strtolower($package) === $composer->getPackage()->getName()) {
  7462. $io->writeError(sprintf('<error>Root package \'%s\' cannot require itself in its composer.json</error>', $package));
  7463. return 1;
  7464. }
  7465. if ($constraint === 'self.version') {
  7466. continue;
  7467. }
  7468. $versionParser->parseConstraints($constraint);
  7469. }
  7470. $inconsistentRequireKeys = $this->getInconsistentRequireKeys($requirements, $requireKey);
  7471. if (count($inconsistentRequireKeys) > 0) {
  7472. foreach ($inconsistentRequireKeys as $package) {
  7473. $io->warning(sprintf(
  7474. '%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.',
  7475. $package,
  7476. $removeKey,
  7477. $input->getOption('dev') ? 'with' : 'without',
  7478. $requireKey
  7479. ));
  7480. }
  7481. if ($io->isInteractive()) {
  7482. if (!$io->askConfirmation(sprintf('<info>Do you want to move %s?</info> [<comment>no</comment>]? ', count($inconsistentRequireKeys) > 1 ? 'these requirements' : 'this requirement'), false)) {
  7483. 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)) {
  7484. return 0;
  7485. }
  7486. $input->setOption('dev', true);
  7487. [$requireKey, $removeKey] = [$removeKey, $requireKey];
  7488. }
  7489. }
  7490. }
  7491. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  7492. $this->firstRequire = $this->newlyCreated;
  7493. if (!$this->firstRequire) {
  7494. $composerDefinition = $this->json->read();
  7495. if (count($composerDefinition['require'] ?? []) === 0 && count($composerDefinition['require-dev'] ?? []) === 0) {
  7496. $this->firstRequire = true;
  7497. }
  7498. }
  7499. if (!$input->getOption('dry-run')) {
  7500. $this->updateFile($this->json, $requirements, $requireKey, $removeKey, $sortPackages);
  7501. }
  7502. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  7503. if ($input->getOption('no-update')) {
  7504. return 0;
  7505. }
  7506. $composer->getPluginManager()->deactivateInstalledPlugins();
  7507. try {
  7508. $result = $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
  7509. if ($result === 0 && count($requirementsToGuess) > 0) {
  7510. $result = $this->updateRequirementsAfterResolution($requirementsToGuess, $requireKey, $removeKey, $sortPackages, $input->getOption('dry-run'), $input->getOption('fixed'));
  7511. }
  7512. return $result;
  7513. } catch (\Exception $e) {
  7514. if (!$this->dependencyResolutionCompleted) {
  7515. $this->revertComposerFile();
  7516. }
  7517. throw $e;
  7518. } finally {
  7519. if ($input->getOption('dry-run') && $this->newlyCreated) {
  7520. @unlink($this->json->getPath());
  7521. }
  7522. $signalHandler->unregister();
  7523. }
  7524. }
  7525. private function getInconsistentRequireKeys(array $newRequirements, string $requireKey): array
  7526. {
  7527. $requireKeys = $this->getPackagesByRequireKey();
  7528. $inconsistentRequirements = [];
  7529. foreach ($requireKeys as $package => $packageRequireKey) {
  7530. if (!isset($newRequirements[$package])) {
  7531. continue;
  7532. }
  7533. if ($requireKey !== $packageRequireKey) {
  7534. $inconsistentRequirements[] = $package;
  7535. }
  7536. }
  7537. return $inconsistentRequirements;
  7538. }
  7539. private function getPackagesByRequireKey(): array
  7540. {
  7541. $composerDefinition = $this->json->read();
  7542. $require = [];
  7543. $requireDev = [];
  7544. if (isset($composerDefinition['require'])) {
  7545. $require = $composerDefinition['require'];
  7546. }
  7547. if (isset($composerDefinition['require-dev'])) {
  7548. $requireDev = $composerDefinition['require-dev'];
  7549. }
  7550. return array_merge(
  7551. array_fill_keys(array_keys($require), 'require'),
  7552. array_fill_keys(array_keys($requireDev), 'require-dev')
  7553. );
  7554. }
  7555. private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, string $requireKey, string $removeKey): int
  7556. {
  7557. $this->resetComposer();
  7558. $composer = $this->requireComposer();
  7559. $this->dependencyResolutionCompleted = false;
  7560. $composer->getEventDispatcher()->addListener(InstallerEvents::PRE_OPERATIONS_EXEC, function (): void {
  7561. $this->dependencyResolutionCompleted = true;
  7562. }, 10000);
  7563. if ($input->getOption('dry-run')) {
  7564. $rootPackage = $composer->getPackage();
  7565. $links = [
  7566. 'require' => $rootPackage->getRequires(),
  7567. 'require-dev' => $rootPackage->getDevRequires(),
  7568. ];
  7569. $loader = new ArrayLoader();
  7570. $newLinks = $loader->parseLinks($rootPackage->getName(), $rootPackage->getPrettyVersion(), BasePackage::$supportedLinkTypes[$requireKey]['method'], $requirements);
  7571. $links[$requireKey] = array_merge($links[$requireKey], $newLinks);
  7572. foreach ($requirements as $package => $constraint) {
  7573. unset($links[$removeKey][$package]);
  7574. }
  7575. $rootPackage->setRequires($links['require']);
  7576. $rootPackage->setDevRequires($links['require-dev']);
  7577. $references = $rootPackage->getReferences();
  7578. $references = RootPackageLoader::extractReferences($requirements, $references);
  7579. $rootPackage->setReferences($references);
  7580. $stabilityFlags = $rootPackage->getStabilityFlags();
  7581. $stabilityFlags = RootPackageLoader::extractStabilityFlags($requirements, $rootPackage->getMinimumStability(), $stabilityFlags);
  7582. $rootPackage->setStabilityFlags($stabilityFlags);
  7583. unset($stabilityFlags, $references);
  7584. }
  7585. $updateDevMode = !$input->getOption('update-no-dev');
  7586. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  7587. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  7588. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  7589. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  7590. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  7591. $flags = '';
  7592. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  7593. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  7594. $flags .= ' --with-all-dependencies';
  7595. } elseif ($input->getOption('update-with-dependencies') || $input->getOption('with-dependencies')) {
  7596. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  7597. $flags .= ' --with-dependencies';
  7598. }
  7599. $io->writeError('<info>Running composer update '.implode(' ', array_keys($requirements)).$flags.'</info>');
  7600. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  7601. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7602. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  7603. $install = Installer::create($io, $composer);
  7604. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($composer->getConfig(), $input);
  7605. $install
  7606. ->setDryRun($input->getOption('dry-run'))
  7607. ->setVerbose($input->getOption('verbose'))
  7608. ->setPreferSource($preferSource)
  7609. ->setPreferDist($preferDist)
  7610. ->setDevMode($updateDevMode)
  7611. ->setOptimizeAutoloader($optimize)
  7612. ->setClassMapAuthoritative($authoritative)
  7613. ->setApcuAutoloader($apcu, $apcuPrefix)
  7614. ->setUpdate(true)
  7615. ->setInstall(!$input->getOption('no-install'))
  7616. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  7617. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  7618. ->setPreferStable($input->getOption('prefer-stable'))
  7619. ->setPreferLowest($input->getOption('prefer-lowest'))
  7620. ->setAudit(!$input->getOption('no-audit'))
  7621. ->setAuditFormat($this->getAuditFormat($input))
  7622. ->setMinimalUpdate($input->getOption('minimal-changes'))
  7623. ;
  7624. if (!$this->firstRequire && $composer->getLocker()->isLocked()) {
  7625. $install->setUpdateAllowList(array_keys($requirements));
  7626. }
  7627. $status = $install->run();
  7628. if ($status !== 0 && $status !== Installer::ERROR_AUDIT_FAILED) {
  7629. if ($status === Installer::ERROR_DEPENDENCY_RESOLUTION_FAILED) {
  7630. foreach ($this->normalizeRequirements($input->getArgument('packages')) as $req) {
  7631. if (!isset($req['version'])) {
  7632. $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.');
  7633. break;
  7634. }
  7635. }
  7636. }
  7637. $this->revertComposerFile();
  7638. }
  7639. return $status;
  7640. }
  7641. private function updateRequirementsAfterResolution(array $requirementsToUpdate, string $requireKey, string $removeKey, bool $sortPackages, bool $dryRun, bool $fixed): int
  7642. {
  7643. $composer = $this->requireComposer();
  7644. $locker = $composer->getLocker();
  7645. $requirements = [];
  7646. $versionSelector = new VersionSelector(new RepositorySet());
  7647. $repo = $locker->isLocked() ? $composer->getLocker()->getLockedRepository(true) : $composer->getRepositoryManager()->getLocalRepository();
  7648. foreach ($requirementsToUpdate as $packageName) {
  7649. $package = $repo->findPackage($packageName, '*');
  7650. while ($package instanceof AliasPackage) {
  7651. $package = $package->getAliasOf();
  7652. }
  7653. if (!$package instanceof PackageInterface) {
  7654. continue;
  7655. }
  7656. if ($fixed) {
  7657. $requirements[$packageName] = $package->getPrettyVersion();
  7658. } else {
  7659. $requirements[$packageName] = $versionSelector->findRecommendedRequireVersion($package);
  7660. }
  7661. $this->getIO()->writeError(sprintf(
  7662. 'Using version <info>%s</info> for <info>%s</info>',
  7663. $requirements[$packageName],
  7664. $packageName
  7665. ));
  7666. if (Preg::isMatch('{^dev-(?!main$|master$|trunk$|latest$)}', $requirements[$packageName])) {
  7667. $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');
  7668. 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>]? ')) {
  7669. $this->revertComposerFile();
  7670. return 1;
  7671. }
  7672. }
  7673. }
  7674. if (!$dryRun) {
  7675. $this->updateFile($this->json, $requirements, $requireKey, $removeKey, $sortPackages);
  7676. if ($locker->isLocked() && $composer->getConfig()->get('lock')) {
  7677. $stabilityFlags = RootPackageLoader::extractStabilityFlags($requirements, $composer->getPackage()->getMinimumStability(), []);
  7678. $locker->updateHash($this->json, function (array $lockData) use ($stabilityFlags) {
  7679. foreach ($stabilityFlags as $packageName => $flag) {
  7680. $lockData['stability-flags'][$packageName] = $flag;
  7681. }
  7682. return $lockData;
  7683. });
  7684. }
  7685. }
  7686. return 0;
  7687. }
  7688. private function updateFile(JsonFile $json, array $new, string $requireKey, string $removeKey, bool $sortPackages): void
  7689. {
  7690. if ($this->updateFileCleanly($json, $new, $requireKey, $removeKey, $sortPackages)) {
  7691. return;
  7692. }
  7693. $composerDefinition = $this->json->read();
  7694. foreach ($new as $package => $version) {
  7695. $composerDefinition[$requireKey][$package] = $version;
  7696. unset($composerDefinition[$removeKey][$package]);
  7697. if (isset($composerDefinition[$removeKey]) && count($composerDefinition[$removeKey]) === 0) {
  7698. unset($composerDefinition[$removeKey]);
  7699. }
  7700. }
  7701. $this->json->write($composerDefinition);
  7702. }
  7703. private function updateFileCleanly(JsonFile $json, array $new, string $requireKey, string $removeKey, bool $sortPackages): bool
  7704. {
  7705. $contents = file_get_contents($json->getPath());
  7706. $manipulator = new JsonManipulator($contents);
  7707. foreach ($new as $package => $constraint) {
  7708. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  7709. return false;
  7710. }
  7711. if (!$manipulator->removeSubNode($removeKey, $package)) {
  7712. return false;
  7713. }
  7714. }
  7715. $manipulator->removeMainKeyIfEmpty($removeKey);
  7716. file_put_contents($json->getPath(), $manipulator->getContents());
  7717. return true;
  7718. }
  7719. protected function interact(InputInterface $input, OutputInterface $output): void
  7720. {
  7721. }
  7722. private function revertComposerFile(): void
  7723. {
  7724. $io = $this->getIO();
  7725. if ($this->newlyCreated) {
  7726. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  7727. unlink($this->json->getPath());
  7728. if (file_exists($this->lock)) {
  7729. unlink($this->lock);
  7730. }
  7731. } else {
  7732. $msg = ' to its ';
  7733. if ($this->lockBackup) {
  7734. $msg = ' and '.$this->lock.' to their ';
  7735. }
  7736. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.$msg.'original content.</error>');
  7737. file_put_contents($this->json->getPath(), $this->composerBackup);
  7738. if ($this->lockBackup) {
  7739. file_put_contents($this->lock, $this->lockBackup);
  7740. }
  7741. }
  7742. }
  7743. }
  7744. <?php declare(strict_types=1);
  7745. namespace Composer\Command;
  7746. use Composer\Script\Event as ScriptEvent;
  7747. use Composer\Script\ScriptEvents;
  7748. use Composer\Util\ProcessExecutor;
  7749. use Composer\Util\Platform;
  7750. use Symfony\Component\Console\Input\InputInterface;
  7751. use Composer\Console\Input\InputOption;
  7752. use Composer\Console\Input\InputArgument;
  7753. use Symfony\Component\Console\Output\OutputInterface;
  7754. class RunScriptCommand extends BaseCommand
  7755. {
  7756. protected $scriptEvents = [
  7757. ScriptEvents::PRE_INSTALL_CMD,
  7758. ScriptEvents::POST_INSTALL_CMD,
  7759. ScriptEvents::PRE_UPDATE_CMD,
  7760. ScriptEvents::POST_UPDATE_CMD,
  7761. ScriptEvents::PRE_STATUS_CMD,
  7762. ScriptEvents::POST_STATUS_CMD,
  7763. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  7764. ScriptEvents::POST_CREATE_PROJECT_CMD,
  7765. ScriptEvents::PRE_ARCHIVE_CMD,
  7766. ScriptEvents::POST_ARCHIVE_CMD,
  7767. ScriptEvents::PRE_AUTOLOAD_DUMP,
  7768. ScriptEvents::POST_AUTOLOAD_DUMP,
  7769. ];
  7770. protected function configure(): void
  7771. {
  7772. $this
  7773. ->setName('run-script')
  7774. ->setAliases(['run'])
  7775. ->setDescription('Runs the scripts defined in composer.json')
  7776. ->setDefinition([
  7777. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.', null, function () {
  7778. return array_map(static function ($script) { return $script['name']; }, $this->getScripts());
  7779. }),
  7780. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  7781. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  7782. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  7783. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  7784. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  7785. ])
  7786. ->setHelp(
  7787. <<<EOT
  7788. The <info>run-script</info> command runs scripts defined in composer.json:
  7789. <info>php composer.phar run-script post-update-cmd</info>
  7790. Read more at https://getcomposer.org/doc/03-cli.md#run-script-run
  7791. EOT
  7792. )
  7793. ;
  7794. }
  7795. protected function interact(InputInterface $input, OutputInterface $output): void
  7796. {
  7797. $scripts = $this->getScripts();
  7798. if (count($scripts) === 0) {
  7799. return;
  7800. }
  7801. if ($input->getArgument('script') !== null || $input->getOption('list')) {
  7802. return;
  7803. }
  7804. $options = [];
  7805. foreach ($scripts as $script) {
  7806. $options[$script['name']] = $script['description'];
  7807. }
  7808. $io = $this->getIO();
  7809. $script = $io->select(
  7810. 'Script to run: ',
  7811. $options,
  7812. '',
  7813. 1,
  7814. 'Invalid script name "%s"'
  7815. );
  7816. $input->setArgument('script', $script);
  7817. }
  7818. protected function execute(InputInterface $input, OutputInterface $output): int
  7819. {
  7820. if ($input->getOption('list')) {
  7821. return $this->listScripts($output);
  7822. }
  7823. $script = $input->getArgument('script');
  7824. if ($script === null) {
  7825. throw new \RuntimeException('Missing required argument "script"');
  7826. }
  7827. if (!in_array($script, $this->scriptEvents)) {
  7828. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  7829. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  7830. }
  7831. }
  7832. $composer = $this->requireComposer();
  7833. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  7834. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  7835. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  7836. if (!$hasListeners) {
  7837. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  7838. }
  7839. $args = $input->getArgument('args');
  7840. if (null !== $timeout = $input->getOption('timeout')) {
  7841. if (!ctype_digit($timeout)) {
  7842. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  7843. }
  7844. ProcessExecutor::setTimeout((int) $timeout);
  7845. }
  7846. Platform::putEnv('COMPOSER_DEV_MODE', $devMode ? '1' : '0');
  7847. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  7848. }
  7849. protected function listScripts(OutputInterface $output): int
  7850. {
  7851. $scripts = $this->getScripts();
  7852. if (count($scripts) === 0) {
  7853. return 0;
  7854. }
  7855. $io = $this->getIO();
  7856. $io->writeError('<info>scripts:</info>');
  7857. $table = [];
  7858. foreach ($scripts as $script) {
  7859. $table[] = [' '.$script['name'], $script['description']];
  7860. }
  7861. $this->renderTable($table, $output);
  7862. return 0;
  7863. }
  7864. private function getScripts(): array
  7865. {
  7866. $scripts = $this->requireComposer()->getPackage()->getScripts();
  7867. if (count($scripts) === 0) {
  7868. return [];
  7869. }
  7870. $result = [];
  7871. foreach ($scripts as $name => $script) {
  7872. $description = '';
  7873. try {
  7874. $cmd = $this->getApplication()->find($name);
  7875. if ($cmd instanceof ScriptAliasCommand) {
  7876. $description = $cmd->getDescription();
  7877. }
  7878. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  7879. }
  7880. $result[] = ['name' => $name, 'description' => $description];
  7881. }
  7882. return $result;
  7883. }
  7884. }
  7885. <?php declare(strict_types=1);
  7886. namespace Composer\Command;
  7887. use Composer\Pcre\Preg;
  7888. use Symfony\Component\Console\Input\InputInterface;
  7889. use Composer\Console\Input\InputOption;
  7890. use Composer\Console\Input\InputArgument;
  7891. use Symfony\Component\Console\Output\OutputInterface;
  7892. class ScriptAliasCommand extends BaseCommand
  7893. {
  7894. private $script;
  7895. private $description;
  7896. private $aliases;
  7897. public function __construct(string $script, ?string $description, array $aliases = [])
  7898. {
  7899. $this->script = $script;
  7900. $this->description = $description ?? 'Runs the '.$script.' script as defined in composer.json';
  7901. $this->aliases = $aliases;
  7902. foreach ($this->aliases as $alias) {
  7903. if (!is_string($alias)) {
  7904. throw new \InvalidArgumentException('"scripts-aliases" element array values should contain only strings');
  7905. }
  7906. }
  7907. $this->ignoreValidationErrors();
  7908. parent::__construct();
  7909. }
  7910. protected function configure(): void
  7911. {
  7912. $this
  7913. ->setName($this->script)
  7914. ->setDescription($this->description)
  7915. ->setAliases($this->aliases)
  7916. ->setDefinition([
  7917. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  7918. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  7919. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  7920. ])
  7921. ->setHelp(
  7922. <<<EOT
  7923. The <info>run-script</info> command runs scripts defined in composer.json:
  7924. <info>php composer.phar run-script post-update-cmd</info>
  7925. Read more at https://getcomposer.org/doc/03-cli.md#run-script-run
  7926. EOT
  7927. )
  7928. ;
  7929. }
  7930. protected function execute(InputInterface $input, OutputInterface $output): int
  7931. {
  7932. $composer = $this->requireComposer();
  7933. $args = $input->getArguments();
  7934. if (!method_exists($input, '__toString')) {
  7935. throw new \LogicException('Expected an Input instance that is stringable, got '.get_class($input));
  7936. }
  7937. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args'], ['script-alias-input' => Preg::replace('{^\S+ ?}', '', $input->__toString(), 1)]);
  7938. }
  7939. }
  7940. <?php declare(strict_types=1);
  7941. namespace Composer\Command;
  7942. use Composer\Factory;
  7943. use Composer\Json\JsonFile;
  7944. use Symfony\Component\Console\Formatter\OutputFormatter;
  7945. use Symfony\Component\Console\Input\InputInterface;
  7946. use Composer\Console\Input\InputArgument;
  7947. use Composer\Console\Input\InputOption;
  7948. use Symfony\Component\Console\Output\OutputInterface;
  7949. use Composer\Repository\CompositeRepository;
  7950. use Composer\Repository\PlatformRepository;
  7951. use Composer\Repository\RepositoryInterface;
  7952. use Composer\Plugin\CommandEvent;
  7953. use Composer\Plugin\PluginEvents;
  7954. class SearchCommand extends BaseCommand
  7955. {
  7956. protected function configure(): void
  7957. {
  7958. $this
  7959. ->setName('search')
  7960. ->setDescription('Searches for packages')
  7961. ->setDefinition([
  7962. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in package names'),
  7963. new InputOption('only-vendor', 'O', InputOption::VALUE_NONE, 'Search only for vendor / organization names, returns only "vendor" as result'),
  7964. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  7965. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['json', 'text']),
  7966. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  7967. ])
  7968. ->setHelp(
  7969. <<<EOT
  7970. The search command searches for packages by its name
  7971. <info>php composer.phar search symfony composer</info>
  7972. Read more at https://getcomposer.org/doc/03-cli.md#search
  7973. EOT
  7974. )
  7975. ;
  7976. }
  7977. protected function execute(InputInterface $input, OutputInterface $output): int
  7978. {
  7979. $platformRepo = new PlatformRepository;
  7980. $io = $this->getIO();
  7981. $format = $input->getOption('format');
  7982. if (!in_array($format, ['text', 'json'])) {
  7983. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  7984. return 1;
  7985. }
  7986. if (!($composer = $this->tryComposer())) {
  7987. $composer = $this->createComposerInstance($input, $this->getIO(), []);
  7988. }
  7989. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  7990. $installedRepo = new CompositeRepository([$localRepo, $platformRepo]);
  7991. $repos = new CompositeRepository(array_merge([$installedRepo], $composer->getRepositoryManager()->getRepositories()));
  7992. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  7993. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7994. $mode = RepositoryInterface::SEARCH_FULLTEXT;
  7995. if ($input->getOption('only-name') === true) {
  7996. if ($input->getOption('only-vendor') === true) {
  7997. throw new \InvalidArgumentException('--only-name and --only-vendor cannot be used together');
  7998. }
  7999. $mode = RepositoryInterface::SEARCH_NAME;
  8000. } elseif ($input->getOption('only-vendor') === true) {
  8001. $mode = RepositoryInterface::SEARCH_VENDOR;
  8002. }
  8003. $type = $input->getOption('type');
  8004. $query = implode(' ', $input->getArgument('tokens'));
  8005. if ($mode !== RepositoryInterface::SEARCH_FULLTEXT) {
  8006. $query = preg_quote($query);
  8007. }
  8008. $results = $repos->search($query, $mode, $type);
  8009. if (\count($results) > 0 && $format === 'text') {
  8010. $width = $this->getTerminalWidth();
  8011. $nameLength = 0;
  8012. foreach ($results as $result) {
  8013. $nameLength = max(strlen($result['name']), $nameLength);
  8014. }
  8015. $nameLength += 1;
  8016. foreach ($results as $result) {
  8017. $description = $result['description'] ?? '';
  8018. $warning = !empty($result['abandoned']) ? '<warning>! Abandoned !</warning> ' : '';
  8019. $remaining = $width - $nameLength - strlen($warning) - 2;
  8020. if (strlen($description) > $remaining) {
  8021. $description = substr($description, 0, $remaining - 3) . '...';
  8022. }
  8023. $link = $result['url'] ?? null;
  8024. if ($link !== null) {
  8025. $io->write('<href='.OutputFormatter::escape($link).'>'.$result['name'].'</>'. str_repeat(' ', $nameLength - strlen($result['name'])) . $warning . $description);
  8026. } else {
  8027. $io->write(str_pad($result['name'], $nameLength, ' ') . $warning . $description);
  8028. }
  8029. }
  8030. } elseif ($format === 'json') {
  8031. $io->write(JsonFile::encode($results));
  8032. }
  8033. return 0;
  8034. }
  8035. }
  8036. <?php declare(strict_types=1);
  8037. namespace Composer\Command;
  8038. use Composer\Composer;
  8039. use Composer\Factory;
  8040. use Composer\Config;
  8041. use Composer\Pcre\Preg;
  8042. use Composer\Util\Filesystem;
  8043. use Composer\Util\Platform;
  8044. use Composer\SelfUpdate\Keys;
  8045. use Composer\SelfUpdate\Versions;
  8046. use Composer\IO\IOInterface;
  8047. use Composer\Downloader\FilesystemException;
  8048. use Composer\Downloader\TransportException;
  8049. use Phar;
  8050. use Symfony\Component\Console\Input\InputInterface;
  8051. use Composer\Console\Input\InputOption;
  8052. use Composer\Console\Input\InputArgument;
  8053. use Symfony\Component\Console\Output\OutputInterface;
  8054. use Symfony\Component\Finder\Finder;
  8055. class SelfUpdateCommand extends BaseCommand
  8056. {
  8057. private const HOMEPAGE = 'getcomposer.org';
  8058. private const OLD_INSTALL_EXT = '-old.phar';
  8059. protected function configure(): void
  8060. {
  8061. $this
  8062. ->setName('self-update')
  8063. ->setAliases(['selfupdate'])
  8064. ->setDescription('Updates composer.phar to the latest version')
  8065. ->setDefinition([
  8066. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  8067. 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'),
  8068. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  8069. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  8070. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  8071. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  8072. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  8073. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  8074. new InputOption('1', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 1.x versions'),
  8075. new InputOption('2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.x versions'),
  8076. new InputOption('2.2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.2.x LTS versions'),
  8077. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  8078. ])
  8079. ->setHelp(
  8080. <<<EOT
  8081. The <info>self-update</info> command checks getcomposer.org for newer
  8082. versions of composer and if found, installs the latest.
  8083. <info>php composer.phar self-update</info>
  8084. Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate
  8085. EOT
  8086. )
  8087. ;
  8088. }
  8089. protected function execute(InputInterface $input, OutputInterface $output): int
  8090. {
  8091. if ($_SERVER['argv'][0] === 'Standard input code') {
  8092. return 1;
  8093. }
  8094. class_exists('Composer\Util\Platform');
  8095. class_exists('Composer\Downloader\FilesystemException');
  8096. $config = Factory::createConfig();
  8097. if ($config->get('disable-tls') === true) {
  8098. $baseUrl = 'http://' . self::HOMEPAGE;
  8099. } else {
  8100. $baseUrl = 'https://' . self::HOMEPAGE;
  8101. }
  8102. $io = $this->getIO();
  8103. $httpDownloader = Factory::createHttpDownloader($io, $config);
  8104. $versionsUtil = new Versions($config, $httpDownloader);
  8105. $requestedChannel = null;
  8106. foreach (Versions::CHANNELS as $channel) {
  8107. if ($input->getOption($channel)) {
  8108. $requestedChannel = $channel;
  8109. $versionsUtil->setChannel($channel, $io);
  8110. break;
  8111. }
  8112. }
  8113. if ($input->getOption('set-channel-only')) {
  8114. return 0;
  8115. }
  8116. $cacheDir = $config->get('cache-dir');
  8117. $rollbackDir = $config->get('data-dir');
  8118. $home = $config->get('home');
  8119. $localFilename = Phar::running(false);
  8120. if ('' === $localFilename) {
  8121. throw new \RuntimeException('Could not determine the location of the composer.phar file as it appears you are not running this code from a phar archive.');
  8122. }
  8123. if ($input->getOption('update-keys')) {
  8124. $this->fetchKeys($io, $config);
  8125. return 0;
  8126. }
  8127. if (!file_exists($localFilename)) {
  8128. throw new FilesystemException('Composer update failed: the "'.$localFilename.'" is not accessible');
  8129. }
  8130. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  8131. if (!is_writable($tmpDir)) {
  8132. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  8133. }
  8134. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  8135. $composerUser = posix_getpwuid(posix_geteuid());
  8136. $homeDirOwnerId = fileowner($home);
  8137. if (is_array($composerUser) && $homeDirOwnerId !== false) {
  8138. $homeOwner = posix_getpwuid($homeDirOwnerId);
  8139. if (is_array($homeOwner) && $composerUser['name'] !== $homeOwner['name']) {
  8140. $io->writeError('<warning>You are running Composer as "'.$composerUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  8141. }
  8142. }
  8143. }
  8144. if ($input->getOption('rollback')) {
  8145. return $this->rollback($output, $rollbackDir, $localFilename);
  8146. }
  8147. if ($input->getArgument('command') === 'self' && $input->getArgument('version') === 'update') {
  8148. $input->setArgument('version', null);
  8149. }
  8150. $latest = $versionsUtil->getLatest();
  8151. $latestStable = $versionsUtil->getLatest('stable');
  8152. try {
  8153. $latestPreview = $versionsUtil->getLatest('preview');
  8154. } catch (\UnexpectedValueException $e) {
  8155. $latestPreview = $latestStable;
  8156. }
  8157. $latestVersion = $latest['version'];
  8158. $updateVersion = $input->getArgument('version') ?? $latestVersion;
  8159. $currentMajorVersion = Preg::replace('{^(\d+).*}', '$1', Composer::getVersion());
  8160. $updateMajorVersion = Preg::replace('{^(\d+).*}', '$1', $updateVersion);
  8161. $previewMajorVersion = Preg::replace('{^(\d+).*}', '$1', $latestPreview['version']);
  8162. if ($versionsUtil->getChannel() === 'stable' && null === $input->getArgument('version')) {
  8163. if ($currentMajorVersion < $updateMajorVersion) {
  8164. $skippedVersion = $updateVersion;
  8165. $versionsUtil->setChannel($currentMajorVersion);
  8166. $latest = $versionsUtil->getLatest();
  8167. $latestStable = $versionsUtil->getLatest('stable');
  8168. $latestVersion = $latest['version'];
  8169. $updateVersion = $latestVersion;
  8170. $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>');
  8171. } elseif ($currentMajorVersion < $previewMajorVersion) {
  8172. $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>');
  8173. }
  8174. }
  8175. $effectiveChannel = $requestedChannel === null ? $versionsUtil->getChannel() : $requestedChannel;
  8176. if (is_numeric($effectiveChannel) && strpos($latestStable['version'], $effectiveChannel) !== 0) {
  8177. $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>');
  8178. }
  8179. if (isset($latest['eol'])) {
  8180. $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>');
  8181. }
  8182. if (Preg::isMatch('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  8183. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  8184. return 1;
  8185. }
  8186. $channelString = $versionsUtil->getChannel();
  8187. if (is_numeric($channelString)) {
  8188. $channelString .= '.x';
  8189. }
  8190. if (Composer::VERSION === $updateVersion) {
  8191. $io->writeError(
  8192. sprintf(
  8193. '<info>You are already using the latest available Composer version %s (%s channel).</info>',
  8194. $updateVersion,
  8195. $channelString
  8196. )
  8197. );
  8198. if ($input->getOption('clean-backups')) {
  8199. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  8200. }
  8201. return 0;
  8202. }
  8203. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp'.random_int(0, 10000000).'.phar';
  8204. $backupFile = sprintf(
  8205. '%s/%s-%s%s',
  8206. $rollbackDir,
  8207. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  8208. Preg::replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  8209. self::OLD_INSTALL_EXT
  8210. );
  8211. $updatingToTag = !Preg::isMatch('{^[0-9a-f]{40}$}', $updateVersion);
  8212. $io->write(sprintf("Upgrading to version <info>%s</info> (%s channel).", $updateVersion, $channelString));
  8213. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  8214. try {
  8215. $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody();
  8216. } catch (TransportException $e) {
  8217. if ($e->getStatusCode() === 404) {
  8218. throw new \InvalidArgumentException('Version "'.$updateVersion.'" could not be found.', 0, $e);
  8219. }
  8220. throw $e;
  8221. }
  8222. $io->writeError(' ', false);
  8223. $httpDownloader->copy($remoteFilename, $tempFilename);
  8224. $io->writeError('');
  8225. if (!file_exists($tempFilename) || null === $signature || '' === $signature) {
  8226. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  8227. return 1;
  8228. }
  8229. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  8230. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  8231. } else {
  8232. if (!extension_loaded('openssl')) {
  8233. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  8234. . '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.');
  8235. }
  8236. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  8237. if (!file_exists($sigFile)) {
  8238. file_put_contents(
  8239. $home.'/keys.dev.pub',
  8240. <<<DEVPUBKEY
  8241. -----BEGIN PUBLIC KEY-----
  8242. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  8243. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  8244. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  8245. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  8246. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  8247. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  8248. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  8249. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  8250. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  8251. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  8252. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  8253. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  8254. -----END PUBLIC KEY-----
  8255. DEVPUBKEY
  8256. );
  8257. file_put_contents(
  8258. $home.'/keys.tags.pub',
  8259. <<<TAGSPUBKEY
  8260. -----BEGIN PUBLIC KEY-----
  8261. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  8262. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  8263. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  8264. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  8265. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  8266. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  8267. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  8268. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  8269. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  8270. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  8271. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  8272. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  8273. -----END PUBLIC KEY-----
  8274. TAGSPUBKEY
  8275. );
  8276. }
  8277. $pubkeyid = openssl_pkey_get_public($sigFile);
  8278. if (false === $pubkeyid) {
  8279. throw new \RuntimeException('Failed loading the public key from '.$sigFile);
  8280. }
  8281. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  8282. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()), true)) {
  8283. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  8284. }
  8285. $signatureData = json_decode($signature, true);
  8286. $signatureSha384 = base64_decode($signatureData['sha384'], true);
  8287. if (false === $signatureSha384) {
  8288. throw new \RuntimeException('Failed loading the phar signature from '.$remoteFilename.'.sig, got '.$signature);
  8289. }
  8290. $verified = 1 === openssl_verify((string) file_get_contents($tempFilename), $signatureSha384, $pubkeyid, $algo);
  8291. if (\PHP_VERSION_ID < 80000) {
  8292. openssl_free_key($pubkeyid);
  8293. }
  8294. if (!$verified) {
  8295. 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');
  8296. }
  8297. }
  8298. if ($input->getOption('clean-backups')) {
  8299. $this->cleanBackups($rollbackDir);
  8300. }
  8301. if (!$this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  8302. @unlink($tempFilename);
  8303. return 1;
  8304. }
  8305. if (file_exists($backupFile)) {
  8306. $io->writeError(sprintf(
  8307. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  8308. Composer::VERSION
  8309. ));
  8310. } else {
  8311. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  8312. }
  8313. return 0;
  8314. }
  8315. protected function fetchKeys(IOInterface $io, Config $config): void
  8316. {
  8317. if (!$io->isInteractive()) {
  8318. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  8319. }
  8320. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  8321. $validator = static function ($value): string {
  8322. $value = (string) $value;
  8323. if (!Preg::isMatch('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  8324. throw new \UnexpectedValueException('Invalid input');
  8325. }
  8326. return trim($value)."\n";
  8327. };
  8328. $devKey = '';
  8329. while (!Preg::isMatch('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  8330. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  8331. while ($line = $io->ask('', '')) {
  8332. $devKey .= trim($line)."\n";
  8333. if (trim($line) === '-----END PUBLIC KEY-----') {
  8334. break;
  8335. }
  8336. }
  8337. }
  8338. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  8339. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  8340. $tagsKey = '';
  8341. while (!Preg::isMatch('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  8342. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  8343. while ($line = $io->ask('', '')) {
  8344. $tagsKey .= trim($line)."\n";
  8345. if (trim($line) === '-----END PUBLIC KEY-----') {
  8346. break;
  8347. }
  8348. }
  8349. }
  8350. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  8351. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  8352. $io->write('Public keys stored in '.$config->get('home'));
  8353. }
  8354. protected function rollback(OutputInterface $output, string $rollbackDir, string $localFilename): int
  8355. {
  8356. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  8357. if (null === $rollbackVersion) {
  8358. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  8359. }
  8360. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  8361. if (!is_file($oldFile)) {
  8362. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  8363. }
  8364. if (!Filesystem::isReadable($oldFile)) {
  8365. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  8366. }
  8367. $io = $this->getIO();
  8368. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  8369. if (!$this->setLocalPhar($localFilename, $oldFile)) {
  8370. return 1;
  8371. }
  8372. return 0;
  8373. }
  8374. protected function setLocalPhar(string $localFilename, string $newFilename, ?string $backupTarget = null): bool
  8375. {
  8376. $io = $this->getIO();
  8377. $perms = @fileperms($localFilename);
  8378. if ($perms !== false) {
  8379. @chmod($newFilename, $perms);
  8380. }
  8381. if (!$this->validatePhar($newFilename, $error)) {
  8382. $io->writeError('<error>The '.($backupTarget !== null ? 'update' : 'backup').' file is corrupted ('.$error.')</error>');
  8383. if ($backupTarget !== null) {
  8384. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  8385. }
  8386. return false;
  8387. }
  8388. if ($backupTarget !== null) {
  8389. @copy($localFilename, $backupTarget);
  8390. }
  8391. try {
  8392. if (Platform::isWindows()) {
  8393. copy($newFilename, $localFilename);
  8394. @unlink($newFilename);
  8395. } else {
  8396. rename($newFilename, $localFilename);
  8397. }
  8398. return true;
  8399. } catch (\Exception $e) {
  8400. if (!is_writable(dirname($localFilename))
  8401. && $io->isInteractive()
  8402. && $this->isWindowsNonAdminUser()) {
  8403. return $this->tryAsWindowsAdmin($localFilename, $newFilename);
  8404. }
  8405. @unlink($newFilename);
  8406. $action = 'Composer '.($backupTarget !== null ? 'update' : 'rollback');
  8407. throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
  8408. }
  8409. }
  8410. protected function cleanBackups(string $rollbackDir, ?string $except = null): void
  8411. {
  8412. $finder = $this->getOldInstallationFinder($rollbackDir);
  8413. $io = $this->getIO();
  8414. $fs = new Filesystem;
  8415. foreach ($finder as $file) {
  8416. if ($file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  8417. continue;
  8418. }
  8419. $file = (string) $file;
  8420. $io->writeError('<info>Removing: '.$file.'</info>');
  8421. $fs->remove($file);
  8422. }
  8423. }
  8424. protected function getLastBackupVersion(string $rollbackDir): ?string
  8425. {
  8426. $finder = $this->getOldInstallationFinder($rollbackDir);
  8427. $finder->sortByName();
  8428. $files = iterator_to_array($finder);
  8429. if (count($files) > 0) {
  8430. return end($files)->getBasename(self::OLD_INSTALL_EXT);
  8431. }
  8432. return null;
  8433. }
  8434. protected function getOldInstallationFinder(string $rollbackDir): Finder
  8435. {
  8436. return Finder::create()
  8437. ->depth(0)
  8438. ->files()
  8439. ->name('*' . self::OLD_INSTALL_EXT)
  8440. ->in($rollbackDir);
  8441. }
  8442. protected function validatePhar(string $pharFile, ?string &$error): bool
  8443. {
  8444. if ((bool) ini_get('phar.readonly')) {
  8445. return true;
  8446. }
  8447. try {
  8448. $phar = new \Phar($pharFile);
  8449. unset($phar);
  8450. $result = true;
  8451. } catch (\Exception $e) {
  8452. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  8453. throw $e;
  8454. }
  8455. $error = $e->getMessage();
  8456. $result = false;
  8457. }
  8458. return $result;
  8459. }
  8460. protected function isWindowsNonAdminUser(): bool
  8461. {
  8462. if (!Platform::isWindows()) {
  8463. return false;
  8464. }
  8465. exec('fltmc.exe filters', $output, $exitCode);
  8466. return $exitCode !== 0;
  8467. }
  8468. protected function tryAsWindowsAdmin(string $localFilename, string $newFilename): bool
  8469. {
  8470. $io = $this->getIO();
  8471. $io->writeError('<error>Unable to write "'.$localFilename.'". Access is denied.</error>');
  8472. $helpMessage = 'Please run the self-update command as an Administrator.';
  8473. $question = 'Complete this operation with Administrator privileges [<comment>Y,n</comment>]? ';
  8474. if (!$io->askConfirmation($question, true)) {
  8475. $io->writeError('<warning>Operation cancelled. '.$helpMessage.'</warning>');
  8476. return false;
  8477. }
  8478. $tmpFile = tempnam(sys_get_temp_dir(), '');
  8479. if (false === $tmpFile) {
  8480. $io->writeError('<error>Operation failed.'.$helpMessage.'</error>');
  8481. return false;
  8482. }
  8483. $script = $tmpFile.'.vbs';
  8484. rename($tmpFile, $script);
  8485. $checksum = hash_file('sha256', $newFilename);
  8486. $source = str_replace('/', '\\', $newFilename);
  8487. $destination = str_replace('/', '\\', $localFilename);
  8488. $vbs = <<<EOT
  8489. Set UAC = CreateObject("Shell.Application")
  8490. UAC.ShellExecute "cmd.exe", "/c copy /b /y ""$source"" ""$destination""", "", "runas", 0
  8491. Wscript.Sleep(300)
  8492. EOT;
  8493. file_put_contents($script, $vbs);
  8494. exec('"'.$script.'"');
  8495. @unlink($script);
  8496. if ($result = Filesystem::isReadable($localFilename) && (hash_file('sha256', $localFilename) === $checksum)) {
  8497. $io->writeError('<info>Operation succeeded.</info>');
  8498. @unlink($newFilename);
  8499. } else {
  8500. $io->writeError('<error>Operation failed.'.$helpMessage.'</error>');
  8501. }
  8502. return $result;
  8503. }
  8504. }
  8505. <?php declare(strict_types=1);
  8506. namespace Composer\Command;
  8507. use Composer\Composer;
  8508. use Composer\DependencyResolver\DefaultPolicy;
  8509. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  8510. use Composer\IO\IOInterface;
  8511. use Composer\Json\JsonFile;
  8512. use Composer\Package\BasePackage;
  8513. use Composer\Package\CompletePackageInterface;
  8514. use Composer\Package\Link;
  8515. use Composer\Package\AliasPackage;
  8516. use Composer\Package\PackageInterface;
  8517. use Composer\Package\Version\VersionParser;
  8518. use Composer\Package\Version\VersionSelector;
  8519. use Composer\Pcre\Preg;
  8520. use Composer\Plugin\CommandEvent;
  8521. use Composer\Plugin\PluginEvents;
  8522. use Composer\Repository\ArrayRepository;
  8523. use Composer\Repository\InstalledArrayRepository;
  8524. use Composer\Repository\ComposerRepository;
  8525. use Composer\Repository\CompositeRepository;
  8526. use Composer\Repository\FilterRepository;
  8527. use Composer\Repository\PlatformRepository;
  8528. use Composer\Repository\RepositoryFactory;
  8529. use Composer\Repository\InstalledRepository;
  8530. use Composer\Repository\RepositoryInterface;
  8531. use Composer\Repository\RepositorySet;
  8532. use Composer\Repository\RepositoryUtils;
  8533. use Composer\Repository\RootPackageRepository;
  8534. use Composer\Semver\Constraint\ConstraintInterface;
  8535. use Composer\Semver\Semver;
  8536. use Composer\Spdx\SpdxLicenses;
  8537. use Composer\Util\PackageInfo;
  8538. use DateTimeInterface;
  8539. use Symfony\Component\Console\Completion\CompletionInput;
  8540. use Symfony\Component\Console\Formatter\OutputFormatter;
  8541. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  8542. use Composer\Console\Input\InputArgument;
  8543. use Symfony\Component\Console\Input\InputInterface;
  8544. use Composer\Console\Input\InputOption;
  8545. use Symfony\Component\Console\Output\OutputInterface;
  8546. class ShowCommand extends BaseCommand
  8547. {
  8548. use CompletionTrait;
  8549. protected $versionParser;
  8550. protected $colors;
  8551. private $repositorySet;
  8552. protected function configure()
  8553. {
  8554. $this
  8555. ->setName('show')
  8556. ->setAliases(['info'])
  8557. ->setDescription('Shows information about packages')
  8558. ->setDefinition([
  8559. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.', null, $this->suggestPackageBasedOnMode()),
  8560. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  8561. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  8562. new InputOption('locked', null, InputOption::VALUE_NONE, 'List all locked packages'),
  8563. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  8564. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  8565. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  8566. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  8567. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  8568. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  8569. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  8570. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  8571. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  8572. new InputOption('ignore', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore specified package(s). Can contain wildcards (*). Use it with the --outdated option if you don\'t want to be informed about new versions of some packages.', null, $this->suggestInstalledPackage(false)),
  8573. new InputOption('major-only', 'M', InputOption::VALUE_NONE, 'Show only packages that have major SemVer-compatible updates. Use with the --latest or --outdated option.'),
  8574. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --latest or --outdated option.'),
  8575. new InputOption('patch-only', null, InputOption::VALUE_NONE, 'Show only packages that have patch SemVer-compatible updates. Use with the --latest or --outdated option.'),
  8576. new InputOption('sort-by-age', 'A', InputOption::VALUE_NONE, 'Displays the installed version\'s age, and sorts packages oldest first. Use with the --latest or --outdated option.'),
  8577. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  8578. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  8579. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text', ['json', 'text']),
  8580. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  8581. 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'),
  8582. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages). Use with the --outdated option'),
  8583. ])
  8584. ->setHelp(
  8585. <<<EOT
  8586. The show command displays detailed information about a package, or
  8587. lists all packages available.
  8588. Read more at https://getcomposer.org/doc/03-cli.md#show-info
  8589. EOT
  8590. )
  8591. ;
  8592. }
  8593. protected function suggestPackageBasedOnMode(): \Closure
  8594. {
  8595. return function (CompletionInput $input) {
  8596. if ($input->getOption('available') || $input->getOption('all')) {
  8597. return $this->suggestAvailablePackageInclPlatform()($input);
  8598. }
  8599. if ($input->getOption('platform')) {
  8600. return $this->suggestPlatformPackage()($input);
  8601. }
  8602. return $this->suggestInstalledPackage(false)($input);
  8603. };
  8604. }
  8605. protected function execute(InputInterface $input, OutputInterface $output): int
  8606. {
  8607. $this->versionParser = new VersionParser;
  8608. if ($input->getOption('tree')) {
  8609. $this->initStyles($output);
  8610. }
  8611. $composer = $this->tryComposer();
  8612. $io = $this->getIO();
  8613. if ($input->getOption('installed') && !$input->getOption('self')) {
  8614. $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>');
  8615. }
  8616. if ($input->getOption('outdated')) {
  8617. $input->setOption('latest', true);
  8618. } elseif (count($input->getOption('ignore')) > 0) {
  8619. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  8620. }
  8621. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  8622. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  8623. return 1;
  8624. }
  8625. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  8626. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  8627. return 1;
  8628. }
  8629. if (count(array_filter([$input->getOption('patch-only'), $input->getOption('minor-only'), $input->getOption('major-only')])) > 1) {
  8630. $io->writeError('Only one of --major-only, --minor-only or --patch-only can be used at once');
  8631. return 1;
  8632. }
  8633. if ($input->getOption('tree') && $input->getOption('latest')) {
  8634. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  8635. return 1;
  8636. }
  8637. if ($input->getOption('tree') && $input->getOption('path')) {
  8638. $io->writeError('The --tree (-t) option is not usable in combination with --path (-P)');
  8639. return 1;
  8640. }
  8641. $format = $input->getOption('format');
  8642. if (!in_array($format, ['text', 'json'])) {
  8643. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  8644. return 1;
  8645. }
  8646. $platformReqFilter = $this->getPlatformRequirementFilter($input);
  8647. $platformOverrides = [];
  8648. if ($composer) {
  8649. $platformOverrides = $composer->getConfig()->get('platform');
  8650. }
  8651. $platformRepo = new PlatformRepository([], $platformOverrides);
  8652. $lockedRepo = null;
  8653. if ($input->getOption('self') && !$input->getOption('installed') && !$input->getOption('locked')) {
  8654. $package = clone $this->requireComposer()->getPackage();
  8655. if ($input->getOption('name-only')) {
  8656. $io->write($package->getName());
  8657. return 0;
  8658. }
  8659. if ($input->getArgument('package')) {
  8660. throw new \InvalidArgumentException('You cannot use --self together with a package name');
  8661. }
  8662. $repos = $installedRepo = new InstalledRepository([new RootPackageRepository($package)]);
  8663. } elseif ($input->getOption('platform')) {
  8664. $repos = $installedRepo = new InstalledRepository([$platformRepo]);
  8665. } elseif ($input->getOption('available')) {
  8666. $installedRepo = new InstalledRepository([$platformRepo]);
  8667. if ($composer) {
  8668. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  8669. $installedRepo->addRepository($composer->getRepositoryManager()->getLocalRepository());
  8670. } else {
  8671. $defaultRepos = RepositoryFactory::defaultReposWithDefaultManager($io);
  8672. $repos = new CompositeRepository($defaultRepos);
  8673. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  8674. }
  8675. } elseif ($input->getOption('all') && $composer) {
  8676. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  8677. $locker = $composer->getLocker();
  8678. if ($locker->isLocked()) {
  8679. $lockedRepo = $locker->getLockedRepository(true);
  8680. $installedRepo = new InstalledRepository([$lockedRepo, $localRepo, $platformRepo]);
  8681. } else {
  8682. $installedRepo = new InstalledRepository([$localRepo, $platformRepo]);
  8683. }
  8684. $repos = new CompositeRepository(array_merge([new FilterRepository($installedRepo, ['canonical' => false])], $composer->getRepositoryManager()->getRepositories()));
  8685. } elseif ($input->getOption('all')) {
  8686. $defaultRepos = RepositoryFactory::defaultReposWithDefaultManager($io);
  8687. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  8688. $installedRepo = new InstalledRepository([$platformRepo]);
  8689. $repos = new CompositeRepository(array_merge([$installedRepo], $defaultRepos));
  8690. } elseif ($input->getOption('locked')) {
  8691. if (!$composer || !$composer->getLocker()->isLocked()) {
  8692. throw new \UnexpectedValueException('A valid composer.json and composer.lock files is required to run this command with --locked');
  8693. }
  8694. $locker = $composer->getLocker();
  8695. $lockedRepo = $locker->getLockedRepository(!$input->getOption('no-dev'));
  8696. if ($input->getOption('self')) {
  8697. $lockedRepo->addPackage(clone $composer->getPackage());
  8698. }
  8699. $repos = $installedRepo = new InstalledRepository([$lockedRepo]);
  8700. } else {
  8701. if (!$composer) {
  8702. $composer = $this->requireComposer();
  8703. }
  8704. $rootPkg = $composer->getPackage();
  8705. $rootRepo = new InstalledArrayRepository();
  8706. if ($input->getOption('self')) {
  8707. $rootRepo = new RootPackageRepository(clone $rootPkg);
  8708. }
  8709. if ($input->getOption('no-dev')) {
  8710. $packages = RepositoryUtils::filterRequiredPackages($composer->getRepositoryManager()->getLocalRepository()->getPackages(), $rootPkg);
  8711. $repos = $installedRepo = new InstalledRepository([$rootRepo, new InstalledArrayRepository(array_map(static function ($pkg): PackageInterface {
  8712. return clone $pkg;
  8713. }, $packages))]);
  8714. } else {
  8715. $repos = $installedRepo = new InstalledRepository([$rootRepo, $composer->getRepositoryManager()->getLocalRepository()]);
  8716. }
  8717. if (!$installedRepo->getPackages()) {
  8718. $hasNonPlatformReqs = static function (array $reqs): bool {
  8719. return (bool) array_filter(array_keys($reqs), function (string $name) {
  8720. return !PlatformRepository::isPlatformPackage($name);
  8721. });
  8722. };
  8723. if ($hasNonPlatformReqs($rootPkg->getRequires()) || $hasNonPlatformReqs($rootPkg->getDevRequires())) {
  8724. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  8725. }
  8726. }
  8727. }
  8728. if ($composer) {
  8729. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  8730. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  8731. }
  8732. if ($input->getOption('latest') && null === $composer) {
  8733. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  8734. $input->setOption('latest', false);
  8735. }
  8736. $packageFilter = $input->getArgument('package');
  8737. if (isset($package)) {
  8738. $versions = [$package->getPrettyVersion() => $package->getVersion()];
  8739. } elseif (null !== $packageFilter && !str_contains($packageFilter, '*')) {
  8740. [$package, $versions] = $this->getPackage($installedRepo, $repos, $packageFilter, $input->getArgument('version'));
  8741. if (isset($package) && $input->getOption('direct')) {
  8742. if (!in_array($package->getName(), $this->getRootRequires(), true)) {
  8743. throw new \InvalidArgumentException('Package "' . $package->getName() . '" is installed but not a direct dependent of the root package.');
  8744. }
  8745. }
  8746. if (!isset($package)) {
  8747. $options = $input->getOptions();
  8748. $hint = '';
  8749. if ($input->getOption('locked')) {
  8750. $hint .= ' in lock file';
  8751. }
  8752. if (isset($options['working-dir'])) {
  8753. $hint .= ' in ' . $options['working-dir'] . '/composer.json';
  8754. }
  8755. if (PlatformRepository::isPlatformPackage($packageFilter) && !$input->getOption('platform')) {
  8756. $hint .= ', try using --platform (-p) to show platform packages';
  8757. }
  8758. if (!$input->getOption('all') && !$input->getOption('available')) {
  8759. $hint .= ', try using --available (-a) to show all available packages';
  8760. }
  8761. throw new \InvalidArgumentException('Package "' . $packageFilter . '" not found'.$hint.'.');
  8762. }
  8763. }
  8764. if (isset($package)) {
  8765. assert(isset($versions));
  8766. $exitCode = 0;
  8767. if ($input->getOption('tree')) {
  8768. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  8769. if ('json' === $format) {
  8770. $io->write(JsonFile::encode(['installed' => [$arrayTree]]));
  8771. } else {
  8772. $this->displayPackageTree([$arrayTree]);
  8773. }
  8774. return $exitCode;
  8775. }
  8776. $latestPackage = null;
  8777. if ($input->getOption('latest')) {
  8778. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $input->getOption('major-only'), $input->getOption('minor-only'), $input->getOption('patch-only'), $platformReqFilter);
  8779. }
  8780. if (
  8781. $input->getOption('outdated')
  8782. && $input->getOption('strict')
  8783. && null !== $latestPackage
  8784. && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion()
  8785. && (!$latestPackage instanceof CompletePackageInterface || !$latestPackage->isAbandoned())
  8786. ) {
  8787. $exitCode = 1;
  8788. }
  8789. if ($input->getOption('path')) {
  8790. $io->write($package->getName(), false);
  8791. $path = $composer->getInstallationManager()->getInstallPath($package);
  8792. if (is_string($path)) {
  8793. $io->write(' ' . strtok(realpath($path), "\r\n"));
  8794. } else {
  8795. $io->write(' null');
  8796. }
  8797. return $exitCode;
  8798. }
  8799. if ('json' === $format) {
  8800. $this->printPackageInfoAsJson($package, $versions, $installedRepo, $latestPackage ?: null);
  8801. } else {
  8802. $this->printPackageInfo($package, $versions, $installedRepo, $latestPackage ?: null);
  8803. }
  8804. return $exitCode;
  8805. }
  8806. if ($input->getOption('tree')) {
  8807. $rootRequires = $this->getRootRequires();
  8808. $packages = $installedRepo->getPackages();
  8809. usort($packages, static function (BasePackage $a, BasePackage $b): int {
  8810. return strcmp((string) $a, (string) $b);
  8811. });
  8812. $arrayTree = [];
  8813. foreach ($packages as $package) {
  8814. if (in_array($package->getName(), $rootRequires, true)) {
  8815. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  8816. }
  8817. }
  8818. if ('json' === $format) {
  8819. $io->write(JsonFile::encode(['installed' => $arrayTree]));
  8820. } else {
  8821. $this->displayPackageTree($arrayTree);
  8822. }
  8823. return 0;
  8824. }
  8825. $packages = [];
  8826. $packageFilterRegex = null;
  8827. if (null !== $packageFilter) {
  8828. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  8829. }
  8830. $packageListFilter = null;
  8831. if ($input->getOption('direct')) {
  8832. $packageListFilter = $this->getRootRequires();
  8833. }
  8834. if ($input->getOption('path') && null === $composer) {
  8835. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  8836. $input->setOption('path', false);
  8837. }
  8838. foreach (RepositoryUtils::flattenRepositories($repos) as $repo) {
  8839. if ($repo === $platformRepo) {
  8840. $type = 'platform';
  8841. } elseif ($lockedRepo !== null && $repo === $lockedRepo) {
  8842. $type = 'locked';
  8843. } elseif ($repo === $installedRepo || in_array($repo, $installedRepo->getRepositories(), true)) {
  8844. $type = 'installed';
  8845. } else {
  8846. $type = 'available';
  8847. }
  8848. if ($repo instanceof ComposerRepository) {
  8849. foreach ($repo->getPackageNames($packageFilter) as $name) {
  8850. $packages[$type][$name] = $name;
  8851. }
  8852. } else {
  8853. foreach ($repo->getPackages() as $package) {
  8854. if (!isset($packages[$type][$package->getName()])
  8855. || !is_object($packages[$type][$package->getName()])
  8856. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  8857. ) {
  8858. while ($package instanceof AliasPackage) {
  8859. $package = $package->getAliasOf();
  8860. }
  8861. if (!$packageFilterRegex || Preg::isMatch($packageFilterRegex, $package->getName())) {
  8862. if (null === $packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  8863. $packages[$type][$package->getName()] = $package;
  8864. }
  8865. }
  8866. }
  8867. }
  8868. if ($repo === $platformRepo) {
  8869. foreach ($platformRepo->getDisabledPackages() as $name => $package) {
  8870. $packages[$type][$name] = $package;
  8871. }
  8872. }
  8873. }
  8874. }
  8875. $showAllTypes = $input->getOption('all');
  8876. $showLatest = $input->getOption('latest');
  8877. $showMajorOnly = $input->getOption('major-only');
  8878. $showMinorOnly = $input->getOption('minor-only');
  8879. $showPatchOnly = $input->getOption('patch-only');
  8880. $ignoredPackagesRegex = BasePackage::packageNamesToRegexp(array_map('strtolower', $input->getOption('ignore')));
  8881. $indent = $showAllTypes ? ' ' : '';
  8882. $latestPackages = [];
  8883. $exitCode = 0;
  8884. $viewData = [];
  8885. $viewMetaData = [];
  8886. $writeVersion = false;
  8887. $writeDescription = false;
  8888. foreach (['platform' => true, 'locked' => true, 'available' => false, 'installed' => true] as $type => $showVersion) {
  8889. if (isset($packages[$type])) {
  8890. ksort($packages[$type]);
  8891. $nameLength = $versionLength = $latestLength = $releaseDateLength = 0;
  8892. if ($showLatest && $showVersion) {
  8893. foreach ($packages[$type] as $package) {
  8894. if (is_object($package) && !Preg::isMatch($ignoredPackagesRegex, $package->getPrettyName())) {
  8895. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $showMajorOnly, $showMinorOnly, $showPatchOnly, $platformReqFilter);
  8896. if ($latestPackage === null) {
  8897. continue;
  8898. }
  8899. $latestPackages[$package->getPrettyName()] = $latestPackage;
  8900. }
  8901. }
  8902. }
  8903. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  8904. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  8905. $writeLatest = $writeVersion && $showLatest;
  8906. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  8907. $writeReleaseDate = $writeLatest && ($input->getOption('sort-by-age') || $format === 'json');
  8908. $hasOutdatedPackages = false;
  8909. if ($input->getOption('sort-by-age')) {
  8910. usort($packages[$type], function ($a, $b) {
  8911. if (is_object($a) && is_object($b)) {
  8912. return $a->getReleaseDate() <=> $b->getReleaseDate();
  8913. }
  8914. return 0;
  8915. });
  8916. }
  8917. $viewData[$type] = [];
  8918. foreach ($packages[$type] as $package) {
  8919. $packageViewData = [];
  8920. if (is_object($package)) {
  8921. $latestPackage = null;
  8922. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  8923. $latestPackage = $latestPackages[$package->getPrettyName()];
  8924. }
  8925. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && (!$latestPackage instanceof CompletePackageInterface || !$latestPackage->isAbandoned());
  8926. $packageIsUpToDate = $packageIsUpToDate || ($latestPackage === null && $showMajorOnly);
  8927. $packageIsIgnored = Preg::isMatch($ignoredPackagesRegex, $package->getPrettyName());
  8928. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  8929. continue;
  8930. }
  8931. if ($input->getOption('outdated') || $input->getOption('strict')) {
  8932. $hasOutdatedPackages = true;
  8933. }
  8934. $packageViewData['name'] = $package->getPrettyName();
  8935. $packageViewData['direct-dependency'] = in_array($package->getName(), $this->getRootRequires(), true);
  8936. if ($format !== 'json' || true !== $input->getOption('name-only')) {
  8937. $packageViewData['homepage'] = $package instanceof CompletePackageInterface ? $package->getHomepage() : null;
  8938. $packageViewData['source'] = PackageInfo::getViewSourceUrl($package);
  8939. }
  8940. $nameLength = max($nameLength, strlen($packageViewData['name']));
  8941. if ($writeVersion) {
  8942. $packageViewData['version'] = $package->getFullPrettyVersion();
  8943. if ($format === 'text') {
  8944. $packageViewData['version'] = ltrim($packageViewData['version'], 'v');
  8945. }
  8946. $versionLength = max($versionLength, strlen($packageViewData['version']));
  8947. }
  8948. if ($writeReleaseDate) {
  8949. if ($package->getReleaseDate() !== null) {
  8950. $packageViewData['release-age'] = str_replace(' ago', ' old', $this->getRelativeTime($package->getReleaseDate()));
  8951. if (!str_contains($packageViewData['release-age'], ' old')) {
  8952. $packageViewData['release-age'] = 'from '.$packageViewData['release-age'];
  8953. }
  8954. $releaseDateLength = max($releaseDateLength, strlen($packageViewData['release-age']));
  8955. $packageViewData['release-date'] = $package->getReleaseDate()->format(DateTimeInterface::ATOM);
  8956. } else {
  8957. $packageViewData['release-age'] = '';
  8958. $packageViewData['release-date'] = '';
  8959. }
  8960. }
  8961. if ($writeLatest && $latestPackage) {
  8962. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  8963. if ($format === 'text') {
  8964. $packageViewData['latest'] = ltrim($packageViewData['latest'], 'v');
  8965. }
  8966. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  8967. $latestLength = max($latestLength, strlen($packageViewData['latest']));
  8968. if ($latestPackage->getReleaseDate() !== null) {
  8969. $packageViewData['latest-release-date'] = $latestPackage->getReleaseDate()->format(DateTimeInterface::ATOM);
  8970. } else {
  8971. $packageViewData['latest-release-date'] = '';
  8972. }
  8973. } elseif ($writeLatest) {
  8974. $packageViewData['latest'] = '[none matched]';
  8975. $packageViewData['latest-status'] = 'up-to-date';
  8976. $latestLength = max($latestLength, strlen($packageViewData['latest']));
  8977. }
  8978. if ($writeDescription && $package instanceof CompletePackageInterface) {
  8979. $packageViewData['description'] = $package->getDescription();
  8980. }
  8981. if ($writePath) {
  8982. $path = $composer->getInstallationManager()->getInstallPath($package);
  8983. if (is_string($path)) {
  8984. $packageViewData['path'] = strtok(realpath($path), "\r\n");
  8985. } else {
  8986. $packageViewData['path'] = null;
  8987. }
  8988. }
  8989. $packageIsAbandoned = false;
  8990. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  8991. $replacementPackageName = $latestPackage->getReplacementPackage();
  8992. $replacement = $replacementPackageName !== null
  8993. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  8994. : 'No replacement was suggested';
  8995. $packageWarning = sprintf(
  8996. 'Package %s is abandoned, you should avoid using it. %s.',
  8997. $package->getPrettyName(),
  8998. $replacement
  8999. );
  9000. $packageViewData['warning'] = $packageWarning;
  9001. $packageIsAbandoned = $replacementPackageName ?? true;
  9002. }
  9003. $packageViewData['abandoned'] = $packageIsAbandoned;
  9004. } else {
  9005. $packageViewData['name'] = $package;
  9006. $nameLength = max($nameLength, strlen($package));
  9007. }
  9008. $viewData[$type][] = $packageViewData;
  9009. }
  9010. $viewMetaData[$type] = [
  9011. 'nameLength' => $nameLength,
  9012. 'versionLength' => $versionLength,
  9013. 'latestLength' => $latestLength,
  9014. 'releaseDateLength' => $releaseDateLength,
  9015. 'writeLatest' => $writeLatest,
  9016. 'writeReleaseDate' => $writeReleaseDate,
  9017. ];
  9018. if ($input->getOption('strict') && $hasOutdatedPackages) {
  9019. $exitCode = 1;
  9020. break;
  9021. }
  9022. }
  9023. }
  9024. if ('json' === $format) {
  9025. $io->write(JsonFile::encode($viewData));
  9026. } else {
  9027. if ($input->getOption('latest') && array_filter($viewData)) {
  9028. if (!$io->isDecorated()) {
  9029. $io->writeError('Legend:');
  9030. $io->writeError('! patch or minor release available - update recommended');
  9031. $io->writeError('~ major release available - update possible');
  9032. if (!$input->getOption('outdated')) {
  9033. $io->writeError('= up to date version');
  9034. }
  9035. } else {
  9036. $io->writeError('<info>Color legend:</info>');
  9037. $io->writeError('- <highlight>patch or minor</highlight> release available - update recommended');
  9038. $io->writeError('- <comment>major</comment> release available - update possible');
  9039. if (!$input->getOption('outdated')) {
  9040. $io->writeError('- <info>up to date</info> version');
  9041. }
  9042. }
  9043. }
  9044. $width = $this->getTerminalWidth();
  9045. foreach ($viewData as $type => $packages) {
  9046. $nameLength = $viewMetaData[$type]['nameLength'];
  9047. $versionLength = $viewMetaData[$type]['versionLength'];
  9048. $latestLength = $viewMetaData[$type]['latestLength'];
  9049. $releaseDateLength = $viewMetaData[$type]['releaseDateLength'];
  9050. $writeLatest = $viewMetaData[$type]['writeLatest'];
  9051. $writeReleaseDate = $viewMetaData[$type]['writeReleaseDate'];
  9052. $versionFits = $nameLength + $versionLength + 3 <= $width;
  9053. $latestFits = $nameLength + $versionLength + $latestLength + 3 <= $width;
  9054. $releaseDateFits = $nameLength + $versionLength + $latestLength + $releaseDateLength + 3 <= $width;
  9055. $descriptionFits = $nameLength + $versionLength + $latestLength + $releaseDateLength + 24 <= $width;
  9056. if ($latestFits && !$io->isDecorated()) {
  9057. $latestLength += 2;
  9058. }
  9059. if ($showAllTypes) {
  9060. if ('available' === $type) {
  9061. $io->write('<comment>' . $type . '</comment>:');
  9062. } else {
  9063. $io->write('<info>' . $type . '</info>:');
  9064. }
  9065. }
  9066. if ($writeLatest && !$input->getOption('direct')) {
  9067. $directDeps = [];
  9068. $transitiveDeps = [];
  9069. foreach ($packages as $pkg) {
  9070. if ($pkg['direct-dependency'] ?? false) {
  9071. $directDeps[] = $pkg;
  9072. } else {
  9073. $transitiveDeps[] = $pkg;
  9074. }
  9075. }
  9076. $io->writeError('');
  9077. $io->writeError('<info>Direct dependencies required in composer.json:</>');
  9078. if (\count($directDeps) > 0) {
  9079. $this->printPackages($io, $directDeps, $indent, $writeVersion && $versionFits, $latestFits, $writeDescription && $descriptionFits, $width, $versionLength, $nameLength, $latestLength, $writeReleaseDate && $releaseDateFits, $releaseDateLength);
  9080. } else {
  9081. $io->writeError('Everything up to date');
  9082. }
  9083. $io->writeError('');
  9084. $io->writeError('<info>Transitive dependencies not required in composer.json:</>');
  9085. if (\count($transitiveDeps) > 0) {
  9086. $this->printPackages($io, $transitiveDeps, $indent, $writeVersion && $versionFits, $latestFits, $writeDescription && $descriptionFits, $width, $versionLength, $nameLength, $latestLength, $writeReleaseDate && $releaseDateFits, $releaseDateLength);
  9087. } else {
  9088. $io->writeError('Everything up to date');
  9089. }
  9090. } else {
  9091. if ($writeLatest && \count($packages) === 0) {
  9092. $io->writeError('All your direct dependencies are up to date');
  9093. } else {
  9094. $this->printPackages($io, $packages, $indent, $writeVersion && $versionFits, $writeLatest && $latestFits, $writeDescription && $descriptionFits, $width, $versionLength, $nameLength, $latestLength, $writeReleaseDate && $releaseDateFits, $releaseDateLength);
  9095. }
  9096. }
  9097. if ($showAllTypes) {
  9098. $io->write('');
  9099. }
  9100. }
  9101. }
  9102. return $exitCode;
  9103. }
  9104. private function printPackages(IOInterface $io, array $packages, string $indent, bool $writeVersion, bool $writeLatest, bool $writeDescription, int $width, int $versionLength, int $nameLength, int $latestLength, bool $writeReleaseDate, int $releaseDateLength): void
  9105. {
  9106. $padName = $writeVersion || $writeLatest || $writeReleaseDate || $writeDescription;
  9107. $padVersion = $writeLatest || $writeReleaseDate || $writeDescription;
  9108. $padLatest = $writeDescription || $writeReleaseDate;
  9109. $padReleaseDate = $writeDescription;
  9110. foreach ($packages as $package) {
  9111. $link = $package['source'] ?? $package['homepage'] ?? '';
  9112. if ($link !== '') {
  9113. $io->write($indent . '<href='.OutputFormatter::escape($link).'>'.$package['name'].'</>'. str_repeat(' ', ($padName ? $nameLength - strlen($package['name']) : 0)), false);
  9114. } else {
  9115. $io->write($indent . str_pad($package['name'], ($padName ? $nameLength : 0), ' '), false);
  9116. }
  9117. if (isset($package['version']) && $writeVersion) {
  9118. $io->write(' ' . str_pad($package['version'], ($padVersion ? $versionLength : 0), ' '), false);
  9119. }
  9120. if (isset($package['latest']) && isset($package['latest-status']) && $writeLatest) {
  9121. $latestVersion = $package['latest'];
  9122. $updateStatus = $package['latest-status'];
  9123. $style = $this->updateStatusToVersionStyle($updateStatus);
  9124. if (!$io->isDecorated()) {
  9125. $latestVersion = str_replace(['up-to-date', 'semver-safe-update', 'update-possible'], ['=', '!', '~'], $updateStatus) . ' ' . $latestVersion;
  9126. }
  9127. $io->write(' <' . $style . '>' . str_pad($latestVersion, ($padLatest ? $latestLength : 0), ' ') . '</' . $style . '>', false);
  9128. if ($writeReleaseDate && isset($package['release-age'])) {
  9129. $io->write(' '.str_pad($package['release-age'], ($padReleaseDate ? $releaseDateLength : 0), ' '), false);
  9130. }
  9131. }
  9132. if (isset($package['description']) && $writeDescription) {
  9133. $description = strtok($package['description'], "\r\n");
  9134. $remaining = $width - $nameLength - $versionLength - $releaseDateLength - 4;
  9135. if ($writeLatest) {
  9136. $remaining -= $latestLength;
  9137. }
  9138. if (strlen($description) > $remaining) {
  9139. $description = substr($description, 0, $remaining - 3) . '...';
  9140. }
  9141. $io->write(' ' . $description, false);
  9142. }
  9143. if (array_key_exists('path', $package)) {
  9144. $io->write(' '.(is_string($package['path']) ? $package['path'] : 'null'), false);
  9145. }
  9146. $io->write('');
  9147. if (isset($package['warning'])) {
  9148. $io->write('<warning>' . $package['warning'] . '</warning>');
  9149. }
  9150. }
  9151. }
  9152. protected function getRootRequires(): array
  9153. {
  9154. $composer = $this->tryComposer();
  9155. if ($composer === null) {
  9156. return [];
  9157. }
  9158. $rootPackage = $composer->getPackage();
  9159. return array_map(
  9160. 'strtolower',
  9161. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  9162. );
  9163. }
  9164. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  9165. {
  9166. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  9167. }
  9168. protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, string $name, $version = null): array
  9169. {
  9170. $name = strtolower($name);
  9171. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  9172. $policy = new DefaultPolicy();
  9173. $repositorySet = new RepositorySet('dev');
  9174. $repositorySet->allowInstalledRepositories();
  9175. $repositorySet->addRepository($repos);
  9176. $matchedPackage = null;
  9177. $versions = [];
  9178. if (PlatformRepository::isPlatformPackage($name)) {
  9179. $pool = $repositorySet->createPoolWithAllPackages();
  9180. } else {
  9181. $pool = $repositorySet->createPoolForPackage($name);
  9182. }
  9183. $matches = $pool->whatProvides($name, $constraint);
  9184. $literals = [];
  9185. foreach ($matches as $package) {
  9186. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  9187. $package = $package->getAliasOf();
  9188. }
  9189. if (null === $version && $installedRepo->hasPackage($package)) {
  9190. $matchedPackage = $package;
  9191. }
  9192. $versions[$package->getPrettyVersion()] = $package->getVersion();
  9193. $literals[] = $package->getId();
  9194. }
  9195. if (null === $matchedPackage && \count($literals) > 0) {
  9196. $preferred = $policy->selectPreferredPackages($pool, $literals);
  9197. $matchedPackage = $pool->literalToPackage($preferred[0]);
  9198. }
  9199. if ($matchedPackage !== null && !$matchedPackage instanceof CompletePackageInterface) {
  9200. throw new \LogicException('ShowCommand::getPackage can only work with CompletePackageInterface, but got '.get_class($matchedPackage));
  9201. }
  9202. return [$matchedPackage, $versions];
  9203. }
  9204. protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, ?PackageInterface $latestPackage = null): void
  9205. {
  9206. $io = $this->getIO();
  9207. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  9208. $this->printLinks($package, Link::TYPE_REQUIRE);
  9209. $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
  9210. if ($package->getSuggests()) {
  9211. $io->write("\n<info>suggests</info>");
  9212. foreach ($package->getSuggests() as $suggested => $reason) {
  9213. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  9214. }
  9215. }
  9216. $this->printLinks($package, Link::TYPE_PROVIDE);
  9217. $this->printLinks($package, Link::TYPE_CONFLICT);
  9218. $this->printLinks($package, Link::TYPE_REPLACE);
  9219. }
  9220. protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, ?PackageInterface $latestPackage = null): void
  9221. {
  9222. $isInstalledPackage = !PlatformRepository::isPlatformPackage($package->getName()) && $installedRepo->hasPackage($package);
  9223. $io = $this->getIO();
  9224. $io->write('<info>name</info> : ' . $package->getPrettyName());
  9225. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  9226. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: []));
  9227. $this->printVersions($package, $versions, $installedRepo);
  9228. if ($isInstalledPackage && $package->getReleaseDate() !== null) {
  9229. $io->write('<info>released</info> : ' . $package->getReleaseDate()->format('Y-m-d') . ', ' . $this->getRelativeTime($package->getReleaseDate()));
  9230. }
  9231. if ($latestPackage) {
  9232. $style = $this->getVersionStyle($latestPackage, $package);
  9233. $releasedTime = $latestPackage->getReleaseDate() === null ? '' : ' released ' . $latestPackage->getReleaseDate()->format('Y-m-d') . ', ' . $this->getRelativeTime($latestPackage->getReleaseDate());
  9234. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>' . $releasedTime);
  9235. } else {
  9236. $latestPackage = $package;
  9237. }
  9238. $io->write('<info>type</info> : ' . $package->getType());
  9239. $this->printLicenses($package);
  9240. $io->write('<info>homepage</info> : ' . $package->getHomepage());
  9241. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  9242. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  9243. if ($isInstalledPackage) {
  9244. $path = $this->requireComposer()->getInstallationManager()->getInstallPath($package);
  9245. if (is_string($path)) {
  9246. $io->write('<info>path</info> : ' . realpath($path));
  9247. } else {
  9248. $io->write('<info>path</info> : null');
  9249. }
  9250. }
  9251. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  9252. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  9253. $replacement = ($latestPackage->getReplacementPackage() !== null)
  9254. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  9255. : null;
  9256. $io->writeError(
  9257. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  9258. );
  9259. }
  9260. if ($package->getSupport()) {
  9261. $io->write("\n<info>support</info>");
  9262. foreach ($package->getSupport() as $type => $value) {
  9263. $io->write('<comment>' . $type . '</comment> : '.$value);
  9264. }
  9265. }
  9266. if (\count($package->getAutoload()) > 0) {
  9267. $io->write("\n<info>autoload</info>");
  9268. $autoloadConfig = $package->getAutoload();
  9269. foreach ($autoloadConfig as $type => $autoloads) {
  9270. $io->write('<comment>' . $type . '</comment>');
  9271. if ($type === 'psr-0' || $type === 'psr-4') {
  9272. foreach ($autoloads as $name => $path) {
  9273. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  9274. }
  9275. } elseif ($type === 'classmap') {
  9276. $io->write(implode(', ', $autoloadConfig[$type]));
  9277. }
  9278. }
  9279. if ($package->getIncludePaths()) {
  9280. $io->write('<comment>include-path</comment>');
  9281. $io->write(implode(', ', $package->getIncludePaths()));
  9282. }
  9283. }
  9284. }
  9285. protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo): void
  9286. {
  9287. $versions = array_keys($versions);
  9288. $versions = Semver::rsort($versions);
  9289. if ($installedPackages = $installedRepo->findPackages($package->getName())) {
  9290. foreach ($installedPackages as $installedPackage) {
  9291. $installedVersion = $installedPackage->getPrettyVersion();
  9292. $key = array_search($installedVersion, $versions);
  9293. if (false !== $key) {
  9294. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  9295. }
  9296. }
  9297. }
  9298. $versions = implode(', ', $versions);
  9299. $this->getIO()->write('<info>versions</info> : ' . $versions);
  9300. }
  9301. protected function printLinks(CompletePackageInterface $package, string $linkType, ?string $title = null): void
  9302. {
  9303. $title = $title ?: $linkType;
  9304. $io = $this->getIO();
  9305. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  9306. $io->write("\n<info>" . $title . "</info>");
  9307. foreach ($links as $link) {
  9308. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  9309. }
  9310. }
  9311. }
  9312. protected function printLicenses(CompletePackageInterface $package): void
  9313. {
  9314. $spdxLicenses = new SpdxLicenses();
  9315. $licenses = $package->getLicense();
  9316. $io = $this->getIO();
  9317. foreach ($licenses as $licenseId) {
  9318. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  9319. if (!$license) {
  9320. $out = $licenseId;
  9321. } else {
  9322. if ($license[1] === true) {
  9323. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  9324. } else {
  9325. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  9326. }
  9327. }
  9328. $io->write('<info>license</info> : ' . $out);
  9329. }
  9330. }
  9331. protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, ?PackageInterface $latestPackage = null): void
  9332. {
  9333. $json = [
  9334. 'name' => $package->getPrettyName(),
  9335. 'description' => $package->getDescription(),
  9336. 'keywords' => $package->getKeywords() ?: [],
  9337. 'type' => $package->getType(),
  9338. 'homepage' => $package->getHomepage(),
  9339. 'names' => $package->getNames(),
  9340. ];
  9341. $json = $this->appendVersions($json, $versions);
  9342. $json = $this->appendLicenses($json, $package);
  9343. if ($latestPackage) {
  9344. $json['latest'] = $latestPackage->getPrettyVersion();
  9345. } else {
  9346. $latestPackage = $package;
  9347. }
  9348. if (null !== $package->getSourceType()) {
  9349. $json['source'] = [
  9350. 'type' => $package->getSourceType(),
  9351. 'url' => $package->getSourceUrl(),
  9352. 'reference' => $package->getSourceReference(),
  9353. ];
  9354. }
  9355. if (null !== $package->getDistType()) {
  9356. $json['dist'] = [
  9357. 'type' => $package->getDistType(),
  9358. 'url' => $package->getDistUrl(),
  9359. 'reference' => $package->getDistReference(),
  9360. ];
  9361. }
  9362. if (!PlatformRepository::isPlatformPackage($package->getName()) && $installedRepo->hasPackage($package)) {
  9363. $path = $this->requireComposer()->getInstallationManager()->getInstallPath($package);
  9364. if (is_string($path)) {
  9365. $path = realpath($path);
  9366. if ($path !== false) {
  9367. $json['path'] = $path;
  9368. }
  9369. } else {
  9370. $json['path'] = null;
  9371. }
  9372. if ($package->getReleaseDate() !== null) {
  9373. $json['released'] = $package->getReleaseDate()->format(DATE_ATOM);
  9374. }
  9375. }
  9376. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  9377. $json['replacement'] = $latestPackage->getReplacementPackage();
  9378. }
  9379. if ($package->getSuggests()) {
  9380. $json['suggests'] = $package->getSuggests();
  9381. }
  9382. if ($package->getSupport()) {
  9383. $json['support'] = $package->getSupport();
  9384. }
  9385. $json = $this->appendAutoload($json, $package);
  9386. if ($package->getIncludePaths()) {
  9387. $json['include_path'] = $package->getIncludePaths();
  9388. }
  9389. $json = $this->appendLinks($json, $package);
  9390. $this->getIO()->write(JsonFile::encode($json));
  9391. }
  9392. private function appendVersions(array $json, array $versions): array
  9393. {
  9394. uasort($versions, 'version_compare');
  9395. $versions = array_keys(array_reverse($versions));
  9396. $json['versions'] = $versions;
  9397. return $json;
  9398. }
  9399. private function appendLicenses(array $json, CompletePackageInterface $package): array
  9400. {
  9401. if ($licenses = $package->getLicense()) {
  9402. $spdxLicenses = new SpdxLicenses();
  9403. $json['licenses'] = array_map(static function ($licenseId) use ($spdxLicenses) {
  9404. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  9405. if (!$license) {
  9406. return $licenseId;
  9407. }
  9408. return [
  9409. 'name' => $license[0],
  9410. 'osi' => $licenseId,
  9411. 'url' => $license[2],
  9412. ];
  9413. }, $licenses);
  9414. }
  9415. return $json;
  9416. }
  9417. private function appendAutoload(array $json, CompletePackageInterface $package): array
  9418. {
  9419. if (\count($package->getAutoload()) > 0) {
  9420. $autoload = [];
  9421. foreach ($package->getAutoload() as $type => $autoloads) {
  9422. if ($type === 'psr-0' || $type === 'psr-4') {
  9423. $psr = [];
  9424. foreach ($autoloads as $name => $path) {
  9425. if (!$path) {
  9426. $path = '.';
  9427. }
  9428. $psr[$name ?: '*'] = $path;
  9429. }
  9430. $autoload[$type] = $psr;
  9431. } elseif ($type === 'classmap') {
  9432. $autoload['classmap'] = $autoloads;
  9433. }
  9434. }
  9435. $json['autoload'] = $autoload;
  9436. }
  9437. return $json;
  9438. }
  9439. private function appendLinks(array $json, CompletePackageInterface $package): array
  9440. {
  9441. foreach (Link::$TYPES as $linkType) {
  9442. $json = $this->appendLink($json, $package, $linkType);
  9443. }
  9444. return $json;
  9445. }
  9446. private function appendLink(array $json, CompletePackageInterface $package, string $linkType): array
  9447. {
  9448. $links = $package->{'get' . ucfirst($linkType)}();
  9449. if ($links) {
  9450. $json[$linkType] = [];
  9451. foreach ($links as $link) {
  9452. $json[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
  9453. }
  9454. }
  9455. return $json;
  9456. }
  9457. protected function initStyles(OutputInterface $output): void
  9458. {
  9459. $this->colors = [
  9460. 'green',
  9461. 'yellow',
  9462. 'cyan',
  9463. 'magenta',
  9464. 'blue',
  9465. ];
  9466. foreach ($this->colors as $color) {
  9467. $style = new OutputFormatterStyle($color);
  9468. $output->getFormatter()->setStyle($color, $style);
  9469. }
  9470. }
  9471. protected function displayPackageTree(array $arrayTree): void
  9472. {
  9473. $io = $this->getIO();
  9474. foreach ($arrayTree as $package) {
  9475. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  9476. $io->write(' ' . $package['version'], false);
  9477. if (isset($package['description'])) {
  9478. $io->write(' ' . strtok($package['description'], "\r\n"));
  9479. } else {
  9480. $io->write('');
  9481. }
  9482. if (isset($package['requires'])) {
  9483. $requires = $package['requires'];
  9484. $treeBar = '├';
  9485. $j = 0;
  9486. $total = count($requires);
  9487. foreach ($requires as $require) {
  9488. $requireName = $require['name'];
  9489. $j++;
  9490. if ($j === $total) {
  9491. $treeBar = 'â””';
  9492. }
  9493. $level = 1;
  9494. $color = $this->colors[$level];
  9495. $info = sprintf(
  9496. '%s──<%s>%s</%s> %s',
  9497. $treeBar,
  9498. $color,
  9499. $requireName,
  9500. $color,
  9501. $require['version']
  9502. );
  9503. $this->writeTreeLine($info);
  9504. $treeBar = str_replace('â””', ' ', $treeBar);
  9505. $packagesInTree = [$package['name'], $requireName];
  9506. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  9507. }
  9508. }
  9509. }
  9510. }
  9511. protected function generatePackageTree(
  9512. PackageInterface $package,
  9513. InstalledRepository $installedRepo,
  9514. RepositoryInterface $remoteRepos
  9515. ): array {
  9516. $requires = $package->getRequires();
  9517. ksort($requires);
  9518. $children = [];
  9519. foreach ($requires as $requireName => $require) {
  9520. $packagesInTree = [$package->getName(), $requireName];
  9521. $treeChildDesc = [
  9522. 'name' => $requireName,
  9523. 'version' => $require->getPrettyConstraint(),
  9524. ];
  9525. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
  9526. if ($deepChildren) {
  9527. $treeChildDesc['requires'] = $deepChildren;
  9528. }
  9529. $children[] = $treeChildDesc;
  9530. }
  9531. $tree = [
  9532. 'name' => $package->getPrettyName(),
  9533. 'version' => $package->getPrettyVersion(),
  9534. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : '',
  9535. ];
  9536. if ($children) {
  9537. $tree['requires'] = $children;
  9538. }
  9539. return $tree;
  9540. }
  9541. protected function displayTree(
  9542. $package,
  9543. array $packagesInTree,
  9544. string $previousTreeBar = '├',
  9545. int $level = 1
  9546. ): void {
  9547. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  9548. if (is_array($package) && isset($package['requires'])) {
  9549. $requires = $package['requires'];
  9550. $treeBar = $previousTreeBar . ' ├';
  9551. $i = 0;
  9552. $total = count($requires);
  9553. foreach ($requires as $require) {
  9554. $currentTree = $packagesInTree;
  9555. $i++;
  9556. if ($i === $total) {
  9557. $treeBar = $previousTreeBar . ' â””';
  9558. }
  9559. $colorIdent = $level % count($this->colors);
  9560. $color = $this->colors[$colorIdent];
  9561. assert(is_string($require['name']));
  9562. assert(is_string($require['version']));
  9563. $circularWarn = in_array(
  9564. $require['name'],
  9565. $currentTree,
  9566. true
  9567. ) ? '(circular dependency aborted here)' : '';
  9568. $info = rtrim(sprintf(
  9569. '%s──<%s>%s</%s> %s %s',
  9570. $treeBar,
  9571. $color,
  9572. $require['name'],
  9573. $color,
  9574. $require['version'],
  9575. $circularWarn
  9576. ));
  9577. $this->writeTreeLine($info);
  9578. $treeBar = str_replace('â””', ' ', $treeBar);
  9579. $currentTree[] = $require['name'];
  9580. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  9581. }
  9582. }
  9583. }
  9584. protected function addTree(
  9585. string $name,
  9586. Link $link,
  9587. InstalledRepository $installedRepo,
  9588. RepositoryInterface $remoteRepos,
  9589. array $packagesInTree
  9590. ): array {
  9591. $children = [];
  9592. [$package] = $this->getPackage(
  9593. $installedRepo,
  9594. $remoteRepos,
  9595. $name,
  9596. $link->getPrettyConstraint() === 'self.version' ? $link->getConstraint() : $link->getPrettyConstraint()
  9597. );
  9598. if (is_object($package)) {
  9599. $requires = $package->getRequires();
  9600. ksort($requires);
  9601. foreach ($requires as $requireName => $require) {
  9602. $currentTree = $packagesInTree;
  9603. $treeChildDesc = [
  9604. 'name' => $requireName,
  9605. 'version' => $require->getPrettyConstraint(),
  9606. ];
  9607. if (!in_array($requireName, $currentTree, true)) {
  9608. $currentTree[] = $requireName;
  9609. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
  9610. if ($deepChildren) {
  9611. $treeChildDesc['requires'] = $deepChildren;
  9612. }
  9613. }
  9614. $children[] = $treeChildDesc;
  9615. }
  9616. }
  9617. return $children;
  9618. }
  9619. private function updateStatusToVersionStyle(string $updateStatus): string
  9620. {
  9621. return str_replace(['up-to-date', 'semver-safe-update', 'update-possible'], ['info', 'highlight', 'comment'], $updateStatus);
  9622. }
  9623. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package): string
  9624. {
  9625. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  9626. return 'up-to-date';
  9627. }
  9628. $constraint = $package->getVersion();
  9629. if (0 !== strpos($constraint, 'dev-')) {
  9630. $constraint = '^'.$constraint;
  9631. }
  9632. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  9633. return 'semver-safe-update';
  9634. }
  9635. return 'update-possible';
  9636. }
  9637. private function writeTreeLine(string $line): void
  9638. {
  9639. $io = $this->getIO();
  9640. if (!$io->isDecorated()) {
  9641. $line = str_replace(['└', '├', '──', '│'], ['`-', '|-', '-', '|'], $line);
  9642. }
  9643. $io->write($line);
  9644. }
  9645. private function findLatestPackage(PackageInterface $package, Composer $composer, PlatformRepository $platformRepo, bool $majorOnly, bool $minorOnly, bool $patchOnly, PlatformRequirementFilterInterface $platformReqFilter): ?PackageInterface
  9646. {
  9647. $name = $package->getName();
  9648. $versionSelector = new VersionSelector($this->getRepositorySet($composer), $platformRepo);
  9649. $stability = $composer->getPackage()->getMinimumStability();
  9650. $flags = $composer->getPackage()->getStabilityFlags();
  9651. if (isset($flags[$name])) {
  9652. $stability = array_search($flags[$name], BasePackage::STABILITIES, true);
  9653. }
  9654. $bestStability = $stability;
  9655. if ($composer->getPackage()->getPreferStable()) {
  9656. $bestStability = $package->getStability();
  9657. }
  9658. $targetVersion = null;
  9659. if (0 === strpos($package->getVersion(), 'dev-')) {
  9660. $targetVersion = $package->getVersion();
  9661. if ($majorOnly) {
  9662. return null;
  9663. }
  9664. }
  9665. if ($targetVersion === null) {
  9666. if ($majorOnly && Preg::isMatch('{^(?P<zero_major>(?:0\.)+)?(?P<first_meaningful>\d+)\.}', $package->getVersion(), $match)) {
  9667. $targetVersion = '>='.$match['zero_major'].(((int) $match['first_meaningful']) + 1).',<9999999-dev';
  9668. }
  9669. if ($minorOnly) {
  9670. $targetVersion = '^'.$package->getVersion();
  9671. }
  9672. if ($patchOnly) {
  9673. $trimmedVersion = Preg::replace('{(\.0)+$}D', '', $package->getVersion());
  9674. $partsNeeded = substr($trimmedVersion, 0, 1) === '0' ? 4 : 3;
  9675. while (substr_count($trimmedVersion, '.') + 1 < $partsNeeded) {
  9676. $trimmedVersion .= '.0';
  9677. }
  9678. $targetVersion = '~'.$trimmedVersion;
  9679. }
  9680. }
  9681. if ($this->getIO()->isVerbose()) {
  9682. $showWarnings = true;
  9683. } else {
  9684. $showWarnings = static function (PackageInterface $candidate) use ($package): bool {
  9685. if (str_starts_with($candidate->getVersion(), 'dev-') || str_starts_with($package->getVersion(), 'dev-')) {
  9686. return false;
  9687. }
  9688. return version_compare($candidate->getVersion(), $package->getVersion(), '<=');
  9689. };
  9690. }
  9691. $candidate = $versionSelector->findBestCandidate($name, $targetVersion, $bestStability, $platformReqFilter, 0, $this->getIO(), $showWarnings);
  9692. while ($candidate instanceof AliasPackage) {
  9693. $candidate = $candidate->getAliasOf();
  9694. }
  9695. return $candidate !== false ? $candidate : null;
  9696. }
  9697. private function getRepositorySet(Composer $composer): RepositorySet
  9698. {
  9699. if (!$this->repositorySet) {
  9700. $this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  9701. $this->repositorySet->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  9702. }
  9703. return $this->repositorySet;
  9704. }
  9705. private function getRelativeTime(\DateTimeInterface $releaseDate): string
  9706. {
  9707. if ($releaseDate->format('Ymd') === date('Ymd')) {
  9708. return 'today';
  9709. }
  9710. $diff = $releaseDate->diff(new \DateTimeImmutable());
  9711. if ($diff->days < 7) {
  9712. return 'this week';
  9713. }
  9714. if ($diff->days < 14) {
  9715. return 'last week';
  9716. }
  9717. if ($diff->m < 1 && $diff->days < 31) {
  9718. return floor($diff->days / 7) . ' weeks ago';
  9719. }
  9720. if ($diff->y < 1) {
  9721. return $diff->m . ' month' . ($diff->m > 1 ? 's' : '') . ' ago';
  9722. }
  9723. return $diff->y . ' year' . ($diff->y > 1 ? 's' : '') . ' ago';
  9724. }
  9725. }
  9726. <?php declare(strict_types=1);
  9727. namespace Composer\Command;
  9728. use Symfony\Component\Console\Input\InputInterface;
  9729. use Composer\Console\Input\InputOption;
  9730. use Symfony\Component\Console\Output\OutputInterface;
  9731. use Composer\Downloader\ChangeReportInterface;
  9732. use Composer\Downloader\DvcsDownloaderInterface;
  9733. use Composer\Downloader\VcsCapableDownloaderInterface;
  9734. use Composer\Package\Dumper\ArrayDumper;
  9735. use Composer\Package\Version\VersionGuesser;
  9736. use Composer\Package\Version\VersionParser;
  9737. use Composer\Plugin\CommandEvent;
  9738. use Composer\Plugin\PluginEvents;
  9739. use Composer\Script\ScriptEvents;
  9740. use Composer\Util\ProcessExecutor;
  9741. class StatusCommand extends BaseCommand
  9742. {
  9743. private const EXIT_CODE_ERRORS = 1;
  9744. private const EXIT_CODE_UNPUSHED_CHANGES = 2;
  9745. private const EXIT_CODE_VERSION_CHANGES = 4;
  9746. protected function configure(): void
  9747. {
  9748. $this
  9749. ->setName('status')
  9750. ->setDescription('Shows a list of locally modified packages')
  9751. ->setDefinition([
  9752. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  9753. ])
  9754. ->setHelp(
  9755. <<<EOT
  9756. The status command displays a list of dependencies that have
  9757. been modified locally.
  9758. Read more at https://getcomposer.org/doc/03-cli.md#status
  9759. EOT
  9760. )
  9761. ;
  9762. }
  9763. protected function execute(InputInterface $input, OutputInterface $output): int
  9764. {
  9765. $composer = $this->requireComposer();
  9766. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  9767. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  9768. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  9769. $exitCode = $this->doExecute($input);
  9770. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  9771. return $exitCode;
  9772. }
  9773. private function doExecute(InputInterface $input): int
  9774. {
  9775. $composer = $this->requireComposer();
  9776. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  9777. $dm = $composer->getDownloadManager();
  9778. $im = $composer->getInstallationManager();
  9779. $errors = [];
  9780. $io = $this->getIO();
  9781. $unpushedChanges = [];
  9782. $vcsVersionChanges = [];
  9783. $parser = new VersionParser;
  9784. $guesser = new VersionGuesser($composer->getConfig(), $composer->getLoop()->getProcessExecutor() ?? new ProcessExecutor($io), $parser, $io);
  9785. $dumper = new ArrayDumper;
  9786. foreach ($installedRepo->getCanonicalPackages() as $package) {
  9787. $downloader = $dm->getDownloaderForPackage($package);
  9788. $targetDir = $im->getInstallPath($package);
  9789. if ($targetDir === null) {
  9790. continue;
  9791. }
  9792. if ($downloader instanceof ChangeReportInterface) {
  9793. if (is_link($targetDir)) {
  9794. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  9795. }
  9796. if (null !== ($changes = $downloader->getLocalChanges($package, $targetDir))) {
  9797. $errors[$targetDir] = $changes;
  9798. }
  9799. }
  9800. if ($downloader instanceof VcsCapableDownloaderInterface) {
  9801. if ($downloader->getVcsReference($package, $targetDir)) {
  9802. switch ($package->getInstallationSource()) {
  9803. case 'source':
  9804. $previousRef = $package->getSourceReference();
  9805. break;
  9806. case 'dist':
  9807. $previousRef = $package->getDistReference();
  9808. break;
  9809. default:
  9810. $previousRef = null;
  9811. }
  9812. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  9813. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef && $currentVersion['pretty_version'] !== $previousRef) {
  9814. $vcsVersionChanges[$targetDir] = [
  9815. 'previous' => [
  9816. 'version' => $package->getPrettyVersion(),
  9817. 'ref' => $previousRef,
  9818. ],
  9819. 'current' => [
  9820. 'version' => $currentVersion['pretty_version'],
  9821. 'ref' => $currentVersion['commit'],
  9822. ],
  9823. ];
  9824. }
  9825. }
  9826. }
  9827. if ($downloader instanceof DvcsDownloaderInterface) {
  9828. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  9829. $unpushedChanges[$targetDir] = $unpushed;
  9830. }
  9831. }
  9832. }
  9833. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  9834. $io->writeError('<info>No local changes</info>');
  9835. return 0;
  9836. }
  9837. if ($errors) {
  9838. $io->writeError('<error>You have changes in the following dependencies:</error>');
  9839. foreach ($errors as $path => $changes) {
  9840. if ($input->getOption('verbose')) {
  9841. $indentedChanges = implode("\n", array_map(static function ($line): string {
  9842. return ' ' . ltrim($line);
  9843. }, explode("\n", $changes)));
  9844. $io->write('<info>'.$path.'</info>:');
  9845. $io->write($indentedChanges);
  9846. } else {
  9847. $io->write($path);
  9848. }
  9849. }
  9850. }
  9851. if ($unpushedChanges) {
  9852. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  9853. foreach ($unpushedChanges as $path => $changes) {
  9854. if ($input->getOption('verbose')) {
  9855. $indentedChanges = implode("\n", array_map(static function ($line): string {
  9856. return ' ' . ltrim($line);
  9857. }, explode("\n", $changes)));
  9858. $io->write('<info>'.$path.'</info>:');
  9859. $io->write($indentedChanges);
  9860. } else {
  9861. $io->write($path);
  9862. }
  9863. }
  9864. }
  9865. if ($vcsVersionChanges) {
  9866. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  9867. foreach ($vcsVersionChanges as $path => $changes) {
  9868. if ($input->getOption('verbose')) {
  9869. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  9870. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  9871. if ($io->isVeryVerbose()) {
  9872. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  9873. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  9874. }
  9875. $io->write('<info>'.$path.'</info>:');
  9876. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  9877. } else {
  9878. $io->write($path);
  9879. }
  9880. }
  9881. }
  9882. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  9883. $io->writeError('Use --verbose (-v) to see a list of files');
  9884. }
  9885. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  9886. }
  9887. }
  9888. <?php declare(strict_types=1);
  9889. namespace Composer\Command;
  9890. use Composer\Repository\PlatformRepository;
  9891. use Composer\Repository\RootPackageRepository;
  9892. use Composer\Repository\InstalledRepository;
  9893. use Composer\Installer\SuggestedPackagesReporter;
  9894. use Composer\Console\Input\InputArgument;
  9895. use Symfony\Component\Console\Input\InputInterface;
  9896. use Composer\Console\Input\InputOption;
  9897. use Symfony\Component\Console\Output\OutputInterface;
  9898. class SuggestsCommand extends BaseCommand
  9899. {
  9900. use CompletionTrait;
  9901. protected function configure(): void
  9902. {
  9903. $this
  9904. ->setName('suggests')
  9905. ->setDescription('Shows package suggestions')
  9906. ->setDefinition([
  9907. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
  9908. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  9909. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
  9910. new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
  9911. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  9912. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.', null, $this->suggestInstalledPackage()),
  9913. ])
  9914. ->setHelp(
  9915. <<<EOT
  9916. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  9917. Read more at https://getcomposer.org/doc/03-cli.md#suggests
  9918. EOT
  9919. )
  9920. ;
  9921. }
  9922. protected function execute(InputInterface $input, OutputInterface $output): int
  9923. {
  9924. $composer = $this->requireComposer();
  9925. $installedRepos = [
  9926. new RootPackageRepository(clone $composer->getPackage()),
  9927. ];
  9928. $locker = $composer->getLocker();
  9929. if ($locker->isLocked()) {
  9930. $installedRepos[] = new PlatformRepository([], $locker->getPlatformOverrides());
  9931. $installedRepos[] = $locker->getLockedRepository(!$input->getOption('no-dev'));
  9932. } else {
  9933. $installedRepos[] = new PlatformRepository([], $composer->getConfig()->get('platform'));
  9934. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  9935. }
  9936. $installedRepo = new InstalledRepository($installedRepos);
  9937. $reporter = new SuggestedPackagesReporter($this->getIO());
  9938. $filter = $input->getArgument('packages');
  9939. $packages = $installedRepo->getPackages();
  9940. $packages[] = $composer->getPackage();
  9941. foreach ($packages as $package) {
  9942. if (!empty($filter) && !in_array($package->getName(), $filter)) {
  9943. continue;
  9944. }
  9945. $reporter->addSuggestionsFromPackage($package);
  9946. }
  9947. $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE;
  9948. if ($input->getOption('by-suggestion')) {
  9949. $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION;
  9950. }
  9951. if ($input->getOption('by-package')) {
  9952. $mode |= SuggestedPackagesReporter::MODE_BY_PACKAGE;
  9953. }
  9954. if ($input->getOption('list')) {
  9955. $mode = SuggestedPackagesReporter::MODE_LIST;
  9956. }
  9957. $reporter->output($mode, $installedRepo, empty($filter) && !$input->getOption('all') ? $composer->getPackage() : null);
  9958. return 0;
  9959. }
  9960. }
  9961. <?php declare(strict_types=1);
  9962. namespace Composer\Command;
  9963. use Composer\Composer;
  9964. use Composer\DependencyResolver\Request;
  9965. use Composer\Installer;
  9966. use Composer\IO\IOInterface;
  9967. use Composer\Package\BasePackage;
  9968. use Composer\Package\Loader\RootPackageLoader;
  9969. use Composer\Package\PackageInterface;
  9970. use Composer\Package\Version\VersionSelector;
  9971. use Composer\Pcre\Preg;
  9972. use Composer\Plugin\CommandEvent;
  9973. use Composer\Plugin\PluginEvents;
  9974. use Composer\Package\Version\VersionParser;
  9975. use Composer\Repository\CompositeRepository;
  9976. use Composer\Repository\PlatformRepository;
  9977. use Composer\Repository\RepositoryInterface;
  9978. use Composer\Repository\RepositorySet;
  9979. use Composer\Semver\Constraint\MultiConstraint;
  9980. use Composer\Semver\Intervals;
  9981. use Composer\Util\HttpDownloader;
  9982. use Composer\Advisory\Auditor;
  9983. use Composer\Util\Platform;
  9984. use Symfony\Component\Console\Helper\Table;
  9985. use Symfony\Component\Console\Input\InputInterface;
  9986. use Composer\Console\Input\InputOption;
  9987. use Composer\Console\Input\InputArgument;
  9988. use Symfony\Component\Console\Output\OutputInterface;
  9989. class UpdateCommand extends BaseCommand
  9990. {
  9991. use CompletionTrait;
  9992. protected function configure()
  9993. {
  9994. $this
  9995. ->setName('update')
  9996. ->setAliases(['u', 'upgrade'])
  9997. ->setDescription('Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file')
  9998. ->setDefinition([
  9999. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.', null, $this->suggestInstalledPackage(false)),
  10000. 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'),
  10001. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  10002. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  10003. 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()),
  10004. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  10005. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  10006. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  10007. 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.'),
  10008. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  10009. 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).'),
  10010. new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
  10011. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  10012. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  10013. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  10014. new InputOption('with-dependencies', 'w', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, except those which are root requirements (can also be set via the COMPOSER_WITH_DEPENDENCIES=1 env var).'),
  10015. new InputOption('with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, including those which are root requirements (can also be set via the COMPOSER_WITH_ALL_DEPENDENCIES=1 env var).'),
  10016. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  10017. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  10018. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  10019. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  10020. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  10021. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  10022. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  10023. 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).'),
  10024. 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).'),
  10025. new InputOption('minimal-changes', 'm', InputOption::VALUE_NONE, 'During a partial update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var).'),
  10026. new InputOption('patch-only', null, InputOption::VALUE_NONE, 'Only allow patch version updates for currently installed dependencies.'),
  10027. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  10028. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  10029. new InputOption('bump-after-update', null, InputOption::VALUE_OPTIONAL, 'Runs bump after performing the update.', false, ['dev', 'no-dev', 'all']),
  10030. ])
  10031. ->setHelp(
  10032. <<<EOT
  10033. The <info>update</info> command reads the composer.json file from the
  10034. current directory, processes it, and updates, removes or installs all the
  10035. dependencies.
  10036. <info>php composer.phar update</info>
  10037. To limit the update operation to a few packages, you can list the package(s)
  10038. you want to update as such:
  10039. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  10040. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  10041. from a specific vendor:
  10042. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  10043. To run an update with more restrictive constraints you can use:
  10044. <info>php composer.phar update --with vendor/package:1.0.*</info>
  10045. To run a partial update with more restrictive constraints you can use the shorthand:
  10046. <info>php composer.phar update vendor/package:1.0.*</info>
  10047. To select packages names interactively with auto-completion use <info>-i</info>.
  10048. Read more at https://getcomposer.org/doc/03-cli.md#update-u-upgrade
  10049. EOT
  10050. )
  10051. ;
  10052. }
  10053. protected function execute(InputInterface $input, OutputInterface $output): int
  10054. {
  10055. $io = $this->getIO();
  10056. if ($input->getOption('dev')) {
  10057. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  10058. }
  10059. if ($input->getOption('no-suggest')) {
  10060. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  10061. }
  10062. $composer = $this->requireComposer();
  10063. if (!HttpDownloader::isCurlEnabled()) {
  10064. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  10065. }
  10066. $packages = $input->getArgument('packages');
  10067. $reqs = $this->formatRequirements($input->getOption('with'));
  10068. if (count($packages) > 0) {
  10069. $allowlistPackagesWithRequirements = array_filter($packages, static function ($pkg): bool {
  10070. return Preg::isMatch('{\S+[ =:]\S+}', $pkg);
  10071. });
  10072. foreach ($this->formatRequirements($allowlistPackagesWithRequirements) as $package => $constraint) {
  10073. $reqs[$package] = $constraint;
  10074. }
  10075. foreach ($allowlistPackagesWithRequirements as $package) {
  10076. $packageName = Preg::replace('{^([^ =:]+)[ =:].*$}', '$1', $package);
  10077. $index = array_search($package, $packages);
  10078. $packages[$index] = $packageName;
  10079. }
  10080. }
  10081. $rootPackage = $composer->getPackage();
  10082. $rootPackage->setReferences(RootPackageLoader::extractReferences($reqs, $rootPackage->getReferences()));
  10083. $rootPackage->setStabilityFlags(RootPackageLoader::extractStabilityFlags($reqs, $rootPackage->getMinimumStability(), $rootPackage->getStabilityFlags()));
  10084. $parser = new VersionParser;
  10085. $temporaryConstraints = [];
  10086. $rootRequirements = array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires());
  10087. foreach ($reqs as $package => $constraint) {
  10088. $package = strtolower($package);
  10089. $parsedConstraint = $parser->parseConstraints($constraint);
  10090. $temporaryConstraints[$package] = $parsedConstraint;
  10091. if (isset($rootRequirements[$package]) && !Intervals::haveIntersections($parsedConstraint, $rootRequirements[$package]->getConstraint())) {
  10092. $io->writeError('<error>The temporary constraint "'.$constraint.'" for "'.$package.'" must be a subset of the constraint in your composer.json ('.$rootRequirements[$package]->getPrettyConstraint().')</error>');
  10093. $io->write('<info>Run `composer require '.$package.'` or `composer require '.$package.':'.$constraint.'` instead to replace the constraint</info>');
  10094. return self::FAILURE;
  10095. }
  10096. }
  10097. if ($input->getOption('patch-only')) {
  10098. if (!$composer->getLocker()->isLocked()) {
  10099. throw new \InvalidArgumentException('patch-only can only be used with a lock file present');
  10100. }
  10101. foreach ($composer->getLocker()->getLockedRepository(true)->getCanonicalPackages() as $package) {
  10102. if ($package->isDev()) {
  10103. continue;
  10104. }
  10105. if (!Preg::isMatch('{^(\d+\.\d+\.\d+)}', $package->getVersion(), $match)) {
  10106. continue;
  10107. }
  10108. $constraint = $parser->parseConstraints('~'.$match[1]);
  10109. if (isset($temporaryConstraints[$package->getName()])) {
  10110. $temporaryConstraints[$package->getName()] = MultiConstraint::create([$temporaryConstraints[$package->getName()], $constraint], true);
  10111. } else {
  10112. $temporaryConstraints[$package->getName()] = $constraint;
  10113. }
  10114. }
  10115. }
  10116. if ($input->getOption('interactive')) {
  10117. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  10118. }
  10119. if ($input->getOption('root-reqs')) {
  10120. $requires = array_keys($rootPackage->getRequires());
  10121. if (!$input->getOption('no-dev')) {
  10122. $requires = array_merge($requires, array_keys($rootPackage->getDevRequires()));
  10123. }
  10124. if (!empty($packages)) {
  10125. $packages = array_intersect($packages, $requires);
  10126. } else {
  10127. $packages = $requires;
  10128. }
  10129. }
  10130. $filteredPackages = array_filter($packages, static function ($package): bool {
  10131. return !in_array($package, ['lock', 'nothing', 'mirrors'], true);
  10132. });
  10133. $updateMirrors = $input->getOption('lock') || count($filteredPackages) !== count($packages);
  10134. $packages = $filteredPackages;
  10135. if ($updateMirrors && !empty($packages)) {
  10136. $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
  10137. return -1;
  10138. }
  10139. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  10140. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  10141. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  10142. $install = Installer::create($io, $composer);
  10143. $config = $composer->getConfig();
  10144. [$preferSource, $preferDist] = $this->getPreferredInstallOptions($config, $input);
  10145. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  10146. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  10147. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  10148. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  10149. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  10150. if ($input->getOption('with-all-dependencies')) {
  10151. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  10152. } elseif ($input->getOption('with-dependencies')) {
  10153. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  10154. }
  10155. $install
  10156. ->setDryRun($input->getOption('dry-run'))
  10157. ->setVerbose($input->getOption('verbose'))
  10158. ->setPreferSource($preferSource)
  10159. ->setPreferDist($preferDist)
  10160. ->setDevMode(!$input->getOption('no-dev'))
  10161. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  10162. ->setOptimizeAutoloader($optimize)
  10163. ->setClassMapAuthoritative($authoritative)
  10164. ->setApcuAutoloader($apcu, $apcuPrefix)
  10165. ->setUpdate(true)
  10166. ->setInstall(!$input->getOption('no-install'))
  10167. ->setUpdateMirrors($updateMirrors)
  10168. ->setUpdateAllowList($packages)
  10169. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  10170. ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
  10171. ->setPreferStable($input->getOption('prefer-stable'))
  10172. ->setPreferLowest($input->getOption('prefer-lowest'))
  10173. ->setTemporaryConstraints($temporaryConstraints)
  10174. ->setAudit(!$input->getOption('no-audit'))
  10175. ->setAuditFormat($this->getAuditFormat($input))
  10176. ->setMinimalUpdate($input->getOption('minimal-changes'))
  10177. ;
  10178. if ($input->getOption('no-plugins')) {
  10179. $install->disablePlugins();
  10180. }
  10181. $result = $install->run();
  10182. if ($result === 0) {
  10183. $bumpAfterUpdate = $input->getOption('bump-after-update');
  10184. if (false === $bumpAfterUpdate) {
  10185. $bumpAfterUpdate = $composer->getConfig()->get('bump-after-update');
  10186. }
  10187. if (false !== $bumpAfterUpdate) {
  10188. $io->writeError('<info>Bumping dependencies</info>');
  10189. $bumpCommand = new BumpCommand();
  10190. $bumpCommand->setComposer($composer);
  10191. $result = $bumpCommand->doBump(
  10192. $io,
  10193. $bumpAfterUpdate === 'dev',
  10194. $bumpAfterUpdate === 'no-dev',
  10195. $input->getOption('dry-run'),
  10196. $input->getArgument('packages')
  10197. );
  10198. }
  10199. }
  10200. return $result;
  10201. }
  10202. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages): array
  10203. {
  10204. if (!$input->isInteractive()) {
  10205. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  10206. }
  10207. $platformReqFilter = $this->getPlatformRequirementFilter($input);
  10208. $stabilityFlags = $composer->getPackage()->getStabilityFlags();
  10209. $requires = array_merge(
  10210. $composer->getPackage()->getRequires(),
  10211. $composer->getPackage()->getDevRequires()
  10212. );
  10213. $filter = \count($packages) > 0 ? BasePackage::packageNamesToRegexp($packages) : null;
  10214. $io->writeError('<info>Loading packages that can be updated...</info>');
  10215. $autocompleterValues = [];
  10216. $installedPackages = $composer->getLocker()->isLocked() ? $composer->getLocker()->getLockedRepository(true)->getPackages() : $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  10217. $versionSelector = $this->createVersionSelector($composer);
  10218. foreach ($installedPackages as $package) {
  10219. if ($filter !== null && !Preg::isMatch($filter, $package->getName())) {
  10220. continue;
  10221. }
  10222. $currentVersion = $package->getPrettyVersion();
  10223. $constraint = isset($requires[$package->getName()]) ? $requires[$package->getName()]->getPrettyConstraint() : null;
  10224. $stability = isset($stabilityFlags[$package->getName()]) ? (string) array_search($stabilityFlags[$package->getName()], BasePackage::STABILITIES, true) : $composer->getPackage()->getMinimumStability();
  10225. $latestVersion = $versionSelector->findBestCandidate($package->getName(), $constraint, $stability, $platformReqFilter);
  10226. if ($latestVersion !== false && ($package->getVersion() !== $latestVersion->getVersion() || $latestVersion->isDev())) {
  10227. $autocompleterValues[$package->getName()] = '<comment>' . $currentVersion . '</comment> => <comment>' . $latestVersion->getPrettyVersion() . '</comment>';
  10228. }
  10229. }
  10230. if (0 === \count($installedPackages)) {
  10231. foreach ($requires as $req => $constraint) {
  10232. if (PlatformRepository::isPlatformPackage($req)) {
  10233. continue;
  10234. }
  10235. $autocompleterValues[$req] = '';
  10236. }
  10237. }
  10238. if (0 === \count($autocompleterValues)) {
  10239. throw new \RuntimeException('Could not find any package with new versions available');
  10240. }
  10241. $packages = $io->select(
  10242. 'Select packages: (Select more than one value separated by comma) ',
  10243. $autocompleterValues,
  10244. false,
  10245. 1,
  10246. 'No package named "%s" is installed.',
  10247. true
  10248. );
  10249. $table = new Table($output);
  10250. $table->setHeaders(['Selected packages']);
  10251. foreach ($packages as $package) {
  10252. $table->addRow([$package]);
  10253. }
  10254. $table->render();
  10255. if ($io->askConfirmation(sprintf(
  10256. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  10257. 1 === count($packages) ? '' : 's'
  10258. ))) {
  10259. return $packages;
  10260. }
  10261. throw new \RuntimeException('Installation aborted.');
  10262. }
  10263. private function createVersionSelector(Composer $composer): VersionSelector
  10264. {
  10265. $repositorySet = new RepositorySet();
  10266. $repositorySet->addRepository(new CompositeRepository(array_filter($composer->getRepositoryManager()->getRepositories(), function (RepositoryInterface $repository) {
  10267. return !$repository instanceof PlatformRepository;
  10268. })));
  10269. return new VersionSelector($repositorySet);
  10270. }
  10271. }
  10272. <?php declare(strict_types=1);
  10273. namespace Composer\Command;
  10274. use Composer\Factory;
  10275. use Composer\IO\IOInterface;
  10276. use Composer\Package\Loader\ValidatingArrayLoader;
  10277. use Composer\Plugin\CommandEvent;
  10278. use Composer\Plugin\PluginEvents;
  10279. use Composer\Repository\InstalledRepository;
  10280. use Composer\Repository\PlatformRepository;
  10281. use Composer\Util\ConfigValidator;
  10282. use Composer\Util\Filesystem;
  10283. use Symfony\Component\Console\Input\InputArgument;
  10284. use Symfony\Component\Console\Input\InputInterface;
  10285. use Symfony\Component\Console\Input\InputOption;
  10286. use Symfony\Component\Console\Output\OutputInterface;
  10287. class ValidateCommand extends BaseCommand
  10288. {
  10289. protected function configure(): void
  10290. {
  10291. $this
  10292. ->setName('validate')
  10293. ->setDescription('Validates a composer.json and composer.lock')
  10294. ->setDefinition([
  10295. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
  10296. new InputOption('check-lock', null, InputOption::VALUE_NONE, 'Check if lock file is up to date (even when config.lock is false)'),
  10297. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  10298. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  10299. new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
  10300. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  10301. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  10302. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  10303. ])
  10304. ->setHelp(
  10305. <<<EOT
  10306. The validate command validates a given composer.json and composer.lock
  10307. Exit codes in case of errors are:
  10308. 1 validation warning(s), only when --strict is given
  10309. 2 validation error(s)
  10310. 3 file unreadable or missing
  10311. Read more at https://getcomposer.org/doc/03-cli.md#validate
  10312. EOT
  10313. );
  10314. }
  10315. protected function execute(InputInterface $input, OutputInterface $output): int
  10316. {
  10317. $file = $input->getArgument('file') ?? Factory::getComposerFile();
  10318. $io = $this->getIO();
  10319. if (!file_exists($file)) {
  10320. $io->writeError('<error>' . $file . ' not found.</error>');
  10321. return 3;
  10322. }
  10323. if (!Filesystem::isReadable($file)) {
  10324. $io->writeError('<error>' . $file . ' is not readable.</error>');
  10325. return 3;
  10326. }
  10327. $validator = new ConfigValidator($io);
  10328. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  10329. $checkPublish = !$input->getOption('no-check-publish');
  10330. $checkLock = !$input->getOption('no-check-lock');
  10331. $checkVersion = $input->getOption('no-check-version') ? 0 : ConfigValidator::CHECK_VERSION;
  10332. $isStrict = $input->getOption('strict');
  10333. [$errors, $publishErrors, $warnings] = $validator->validate($file, $checkAll, $checkVersion);
  10334. $lockErrors = [];
  10335. $composer = $this->createComposerInstance($input, $io, $file);
  10336. $checkLock = ($checkLock && $composer->getConfig()->get('lock')) || $input->getOption('check-lock');
  10337. $locker = $composer->getLocker();
  10338. if ($locker->isLocked() && !$locker->isFresh()) {
  10339. $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>`.';
  10340. }
  10341. if ($locker->isLocked()) {
  10342. $lockErrors = array_merge($lockErrors, $locker->getMissingRequirementInfo($composer->getPackage(), true));
  10343. }
  10344. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true);
  10345. $exitCode = count($errors) > 0 ? 2 : (($isStrict && count($warnings) > 0) ? 1 : 0);
  10346. if ($input->getOption('with-dependencies')) {
  10347. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  10348. foreach ($localRepo->getPackages() as $package) {
  10349. $path = $composer->getInstallationManager()->getInstallPath($package);
  10350. if (null === $path) {
  10351. continue;
  10352. }
  10353. $file = $path . '/composer.json';
  10354. if (is_dir($path) && file_exists($file)) {
  10355. [$errors, $publishErrors, $warnings] = $validator->validate($file, $checkAll, $checkVersion);
  10356. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  10357. $depCode = count($errors) > 0 ? 2 : (($isStrict && count($warnings) > 0) ? 1 : 0);
  10358. $exitCode = max($depCode, $exitCode);
  10359. }
  10360. }
  10361. }
  10362. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  10363. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  10364. return max($eventCode, $exitCode);
  10365. }
  10366. 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
  10367. {
  10368. $doPrintSchemaUrl = false;
  10369. if (\count($errors) > 0) {
  10370. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  10371. } elseif (\count($publishErrors) > 0 && $checkPublish) {
  10372. $io->writeError('<info>' . $name . ' is valid for simple usage with Composer but has</info>');
  10373. $io->writeError('<info>strict errors that make it unable to be published as a package</info>');
  10374. $doPrintSchemaUrl = $printSchemaUrl;
  10375. } elseif (\count($warnings) > 0) {
  10376. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  10377. $doPrintSchemaUrl = $printSchemaUrl;
  10378. } elseif (\count($lockErrors) > 0) {
  10379. $io->write('<info>' . $name . ' is valid but your composer.lock has some '.($checkLock ? 'errors' : 'warnings').'</info>');
  10380. } else {
  10381. $io->write('<info>' . $name . ' is valid</info>');
  10382. }
  10383. if ($doPrintSchemaUrl) {
  10384. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  10385. }
  10386. if (\count($errors) > 0) {
  10387. $errors = array_map(static function ($err): string {
  10388. return '- ' . $err;
  10389. }, $errors);
  10390. array_unshift($errors, '# General errors');
  10391. }
  10392. if (\count($warnings) > 0) {
  10393. $warnings = array_map(static function ($err): string {
  10394. return '- ' . $err;
  10395. }, $warnings);
  10396. array_unshift($warnings, '# General warnings');
  10397. }
  10398. $extraWarnings = [];
  10399. if (\count($publishErrors) > 0 && $checkPublish) {
  10400. $publishErrors = array_map(static function ($err): string {
  10401. return '- ' . $err;
  10402. }, $publishErrors);
  10403. array_unshift($publishErrors, '# Publish errors');
  10404. $errors = array_merge($errors, $publishErrors);
  10405. }
  10406. if (\count($lockErrors) > 0) {
  10407. if ($checkLock) {
  10408. array_unshift($lockErrors, '# Lock file errors');
  10409. $errors = array_merge($errors, $lockErrors);
  10410. } else {
  10411. array_unshift($lockErrors, '# Lock file warnings');
  10412. $extraWarnings = array_merge($extraWarnings, $lockErrors);
  10413. }
  10414. }
  10415. $messages = [
  10416. 'error' => $errors,
  10417. 'warning' => array_merge($warnings, $extraWarnings),
  10418. ];
  10419. foreach ($messages as $style => $msgs) {
  10420. foreach ($msgs as $msg) {
  10421. if (strpos($msg, '#') === 0) {
  10422. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  10423. } else {
  10424. $io->writeError($msg);
  10425. }
  10426. }
  10427. }
  10428. }
  10429. }
  10430. <?php declare(strict_types=1);
  10431. namespace Composer;
  10432. use Composer\Package\Locker;
  10433. use Composer\Pcre\Preg;
  10434. use Composer\Plugin\PluginManager;
  10435. use Composer\Downloader\DownloadManager;
  10436. use Composer\Autoload\AutoloadGenerator;
  10437. use Composer\Package\Archiver\ArchiveManager;
  10438. class Composer extends PartialComposer
  10439. {
  10440. public const VERSION = '2.8.8';
  10441. public const BRANCH_ALIAS_VERSION = '';
  10442. public const RELEASE_DATE = '2025-04-04 16:56:46';
  10443. public const SOURCE_VERSION = '';
  10444. public const RUNTIME_API_VERSION = '2.2.2';
  10445. public static function getVersion(): string
  10446. {
  10447. if (self::VERSION === '@package_version'.'@') {
  10448. return self::SOURCE_VERSION;
  10449. }
  10450. if (self::BRANCH_ALIAS_VERSION !== '' && Preg::isMatch('{^[a-f0-9]{40}$}', self::VERSION)) {
  10451. return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
  10452. }
  10453. return self::VERSION;
  10454. }
  10455. private $locker;
  10456. private $downloadManager;
  10457. private $pluginManager;
  10458. private $autoloadGenerator;
  10459. private $archiveManager;
  10460. public function setLocker(Locker $locker): void
  10461. {
  10462. $this->locker = $locker;
  10463. }
  10464. public function getLocker(): Locker
  10465. {
  10466. return $this->locker;
  10467. }
  10468. public function setDownloadManager(DownloadManager $manager): void
  10469. {
  10470. $this->downloadManager = $manager;
  10471. }
  10472. public function getDownloadManager(): DownloadManager
  10473. {
  10474. return $this->downloadManager;
  10475. }
  10476. public function setArchiveManager(ArchiveManager $manager): void
  10477. {
  10478. $this->archiveManager = $manager;
  10479. }
  10480. public function getArchiveManager(): ArchiveManager
  10481. {
  10482. return $this->archiveManager;
  10483. }
  10484. public function setPluginManager(PluginManager $manager): void
  10485. {
  10486. $this->pluginManager = $manager;
  10487. }
  10488. public function getPluginManager(): PluginManager
  10489. {
  10490. return $this->pluginManager;
  10491. }
  10492. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator): void
  10493. {
  10494. $this->autoloadGenerator = $autoloadGenerator;
  10495. }
  10496. public function getAutoloadGenerator(): AutoloadGenerator
  10497. {
  10498. return $this->autoloadGenerator;
  10499. }
  10500. }
  10501. <?php declare(strict_types=1);
  10502. namespace Composer;
  10503. use Composer\Advisory\Auditor;
  10504. use Composer\Config\ConfigSourceInterface;
  10505. use Composer\Downloader\TransportException;
  10506. use Composer\IO\IOInterface;
  10507. use Composer\Pcre\Preg;
  10508. use Composer\Util\Platform;
  10509. use Composer\Util\ProcessExecutor;
  10510. class Config
  10511. {
  10512. public const SOURCE_DEFAULT = 'default';
  10513. public const SOURCE_COMMAND = 'command';
  10514. public const SOURCE_UNKNOWN = 'unknown';
  10515. public const RELATIVE_PATHS = 1;
  10516. public static $defaultConfig = [
  10517. 'process-timeout' => 300,
  10518. 'use-include-path' => false,
  10519. 'allow-plugins' => [],
  10520. 'use-parent-dir' => 'prompt',
  10521. 'preferred-install' => 'dist',
  10522. 'audit' => ['ignore' => [], 'abandoned' => Auditor::ABANDONED_FAIL],
  10523. 'notify-on-install' => true,
  10524. 'github-protocols' => ['https', 'ssh', 'git'],
  10525. 'gitlab-protocol' => null,
  10526. 'vendor-dir' => 'vendor',
  10527. 'bin-dir' => '{$vendor-dir}/bin',
  10528. 'cache-dir' => '{$home}/cache',
  10529. 'data-dir' => '{$home}',
  10530. 'cache-files-dir' => '{$cache-dir}/files',
  10531. 'cache-repo-dir' => '{$cache-dir}/repo',
  10532. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  10533. 'cache-ttl' => 15552000,
  10534. 'cache-files-ttl' => null,
  10535. 'cache-files-maxsize' => '300MiB',
  10536. 'cache-read-only' => false,
  10537. 'bin-compat' => 'auto',
  10538. 'discard-changes' => false,
  10539. 'autoloader-suffix' => null,
  10540. 'sort-packages' => false,
  10541. 'optimize-autoloader' => false,
  10542. 'classmap-authoritative' => false,
  10543. 'apcu-autoloader' => false,
  10544. 'prepend-autoloader' => true,
  10545. 'github-domains' => ['github.com'],
  10546. 'bitbucket-expose-hostname' => true,
  10547. 'disable-tls' => false,
  10548. 'secure-http' => true,
  10549. 'secure-svn-domains' => [],
  10550. 'cafile' => null,
  10551. 'capath' => null,
  10552. 'github-expose-hostname' => true,
  10553. 'gitlab-domains' => ['gitlab.com'],
  10554. 'store-auths' => 'prompt',
  10555. 'platform' => [],
  10556. 'archive-format' => 'tar',
  10557. 'archive-dir' => '.',
  10558. 'htaccess-protect' => true,
  10559. 'use-github-api' => true,
  10560. 'lock' => true,
  10561. 'platform-check' => 'php-only',
  10562. 'bitbucket-oauth' => [],
  10563. 'github-oauth' => [],
  10564. 'gitlab-oauth' => [],
  10565. 'gitlab-token' => [],
  10566. 'http-basic' => [],
  10567. 'bearer' => [],
  10568. 'bump-after-update' => false,
  10569. 'allow-missing-requirements' => false,
  10570. ];
  10571. public static $defaultRepositories = [
  10572. 'packagist.org' => [
  10573. 'type' => 'composer',
  10574. 'url' => 'https://repo.packagist.org',
  10575. ],
  10576. ];
  10577. private $config;
  10578. private $baseDir;
  10579. private $repositories;
  10580. private $configSource;
  10581. private $authConfigSource;
  10582. private $localAuthConfigSource = null;
  10583. private $useEnvironment;
  10584. private $warnedHosts = [];
  10585. private $sslVerifyWarnedHosts = [];
  10586. private $sourceOfConfigValue = [];
  10587. public function __construct(bool $useEnvironment = true, ?string $baseDir = null)
  10588. {
  10589. $this->config = static::$defaultConfig;
  10590. $this->repositories = static::$defaultRepositories;
  10591. $this->useEnvironment = $useEnvironment;
  10592. $this->baseDir = is_string($baseDir) && '' !== $baseDir ? $baseDir : null;
  10593. foreach ($this->config as $configKey => $configValue) {
  10594. $this->setSourceOfConfigValue($configValue, $configKey, self::SOURCE_DEFAULT);
  10595. }
  10596. foreach ($this->repositories as $configKey => $configValue) {
  10597. $this->setSourceOfConfigValue($configValue, 'repositories.' . $configKey, self::SOURCE_DEFAULT);
  10598. }
  10599. }
  10600. public function setBaseDir(?string $baseDir): void
  10601. {
  10602. $this->baseDir = $baseDir;
  10603. }
  10604. public function setConfigSource(ConfigSourceInterface $source): void
  10605. {
  10606. $this->configSource = $source;
  10607. }
  10608. public function getConfigSource(): ConfigSourceInterface
  10609. {
  10610. return $this->configSource;
  10611. }
  10612. public function setAuthConfigSource(ConfigSourceInterface $source): void
  10613. {
  10614. $this->authConfigSource = $source;
  10615. }
  10616. public function getAuthConfigSource(): ConfigSourceInterface
  10617. {
  10618. return $this->authConfigSource;
  10619. }
  10620. public function setLocalAuthConfigSource(ConfigSourceInterface $source): void
  10621. {
  10622. $this->localAuthConfigSource = $source;
  10623. }
  10624. public function getLocalAuthConfigSource(): ?ConfigSourceInterface
  10625. {
  10626. return $this->localAuthConfigSource;
  10627. }
  10628. public function merge(array $config, string $source = self::SOURCE_UNKNOWN): void
  10629. {
  10630. if (!empty($config['config']) && is_array($config['config'])) {
  10631. foreach ($config['config'] as $key => $val) {
  10632. if (in_array($key, ['bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer'], true) && isset($this->config[$key])) {
  10633. $this->config[$key] = array_merge($this->config[$key], $val);
  10634. $this->setSourceOfConfigValue($val, $key, $source);
  10635. } elseif (in_array($key, ['allow-plugins'], true) && isset($this->config[$key]) && is_array($this->config[$key]) && is_array($val)) {
  10636. $this->config[$key] = array_merge($val, $this->config[$key], $val);
  10637. $this->setSourceOfConfigValue($val, $key, $source);
  10638. } elseif (in_array($key, ['gitlab-domains', 'github-domains'], true) && isset($this->config[$key])) {
  10639. $this->config[$key] = array_unique(array_merge($this->config[$key], $val));
  10640. $this->setSourceOfConfigValue($val, $key, $source);
  10641. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  10642. if (is_array($val) || is_array($this->config[$key])) {
  10643. if (is_string($val)) {
  10644. $val = ['*' => $val];
  10645. }
  10646. if (is_string($this->config[$key])) {
  10647. $this->config[$key] = ['*' => $this->config[$key]];
  10648. $this->sourceOfConfigValue[$key . '*'] = $source;
  10649. }
  10650. $this->config[$key] = array_merge($this->config[$key], $val);
  10651. $this->setSourceOfConfigValue($val, $key, $source);
  10652. if (isset($this->config[$key]['*'])) {
  10653. $wildcard = $this->config[$key]['*'];
  10654. unset($this->config[$key]['*']);
  10655. $this->config[$key]['*'] = $wildcard;
  10656. }
  10657. } else {
  10658. $this->config[$key] = $val;
  10659. $this->setSourceOfConfigValue($val, $key, $source);
  10660. }
  10661. } elseif ('audit' === $key) {
  10662. $currentIgnores = $this->config['audit']['ignore'];
  10663. $this->config[$key] = array_merge($this->config['audit'], $val);
  10664. $this->setSourceOfConfigValue($val, $key, $source);
  10665. $this->config['audit']['ignore'] = array_merge($currentIgnores, $val['ignore'] ?? []);
  10666. } else {
  10667. $this->config[$key] = $val;
  10668. $this->setSourceOfConfigValue($val, $key, $source);
  10669. }
  10670. }
  10671. }
  10672. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  10673. $this->repositories = array_reverse($this->repositories, true);
  10674. $newRepos = array_reverse($config['repositories'], true);
  10675. foreach ($newRepos as $name => $repository) {
  10676. if (false === $repository) {
  10677. $this->disableRepoByName((string) $name);
  10678. continue;
  10679. }
  10680. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  10681. $this->disableRepoByName((string) key($repository));
  10682. continue;
  10683. }
  10684. if (isset($repository['type'], $repository['url']) && $repository['type'] === 'composer' && Preg::isMatch('{^https?://(?:[a-z0-9-.]+\.)?packagist.org(/|$)}', $repository['url'])) {
  10685. $this->disableRepoByName('packagist.org');
  10686. }
  10687. if (is_int($name)) {
  10688. $this->repositories[] = $repository;
  10689. $this->setSourceOfConfigValue($repository, 'repositories.' . array_search($repository, $this->repositories, true), $source);
  10690. } else {
  10691. if ($name === 'packagist') {
  10692. $this->repositories[$name . '.org'] = $repository;
  10693. $this->setSourceOfConfigValue($repository, 'repositories.' . $name . '.org', $source);
  10694. } else {
  10695. $this->repositories[$name] = $repository;
  10696. $this->setSourceOfConfigValue($repository, 'repositories.' . $name, $source);
  10697. }
  10698. }
  10699. }
  10700. $this->repositories = array_reverse($this->repositories, true);
  10701. }
  10702. }
  10703. public function getRepositories(): array
  10704. {
  10705. return $this->repositories;
  10706. }
  10707. public function get(string $key, int $flags = 0)
  10708. {
  10709. switch ($key) {
  10710. case 'vendor-dir':
  10711. case 'bin-dir':
  10712. case 'process-timeout':
  10713. case 'data-dir':
  10714. case 'cache-dir':
  10715. case 'cache-files-dir':
  10716. case 'cache-repo-dir':
  10717. case 'cache-vcs-dir':
  10718. case 'cafile':
  10719. case 'capath':
  10720. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  10721. $val = $this->getComposerEnv($env);
  10722. if ($val !== false) {
  10723. $this->setSourceOfConfigValue($val, $key, $env);
  10724. }
  10725. if ($key === 'process-timeout') {
  10726. return max(0, false !== $val ? (int) $val : $this->config[$key]);
  10727. }
  10728. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  10729. $val = Platform::expandPath($val);
  10730. if (substr($key, -4) !== '-dir') {
  10731. return $val;
  10732. }
  10733. return (($flags & self::RELATIVE_PATHS) === self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  10734. case 'cache-read-only':
  10735. case 'htaccess-protect':
  10736. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  10737. $val = $this->getComposerEnv($env);
  10738. if (false === $val) {
  10739. $val = $this->config[$key];
  10740. } else {
  10741. $this->setSourceOfConfigValue($val, $key, $env);
  10742. }
  10743. return $val !== 'false' && (bool) $val;
  10744. case 'disable-tls':
  10745. case 'secure-http':
  10746. case 'use-github-api':
  10747. case 'lock':
  10748. if ($key === 'secure-http' && $this->get('disable-tls') === true) {
  10749. return false;
  10750. }
  10751. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  10752. case 'cache-ttl':
  10753. return max(0, (int) $this->config[$key]);
  10754. case 'cache-files-maxsize':
  10755. if (!Preg::isMatch('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', (string) $this->config[$key], $matches)) {
  10756. throw new \RuntimeException(
  10757. "Could not parse the value of '$key': {$this->config[$key]}"
  10758. );
  10759. }
  10760. $size = (float) $matches[1];
  10761. if (isset($matches[2])) {
  10762. switch (strtolower($matches[2])) {
  10763. case 'g':
  10764. $size *= 1024;
  10765. case 'm':
  10766. $size *= 1024;
  10767. case 'k':
  10768. $size *= 1024;
  10769. break;
  10770. }
  10771. }
  10772. return max(0, (int) $size);
  10773. case 'cache-files-ttl':
  10774. if (isset($this->config[$key])) {
  10775. return max(0, (int) $this->config[$key]);
  10776. }
  10777. return $this->get('cache-ttl');
  10778. case 'home':
  10779. return rtrim($this->process(Platform::expandPath($this->config[$key]), $flags), '/\\');
  10780. case 'bin-compat':
  10781. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  10782. if (!in_array($value, ['auto', 'full', 'proxy', 'symlink'])) {
  10783. throw new \RuntimeException(
  10784. "Invalid value for 'bin-compat': {$value}. Expected auto, full or proxy"
  10785. );
  10786. }
  10787. if ($value === 'symlink') {
  10788. trigger_error('config.bin-compat "symlink" is deprecated since Composer 2.2, use auto, full (for Windows compatibility) or proxy instead.', E_USER_DEPRECATED);
  10789. }
  10790. return $value;
  10791. case 'discard-changes':
  10792. $env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES');
  10793. if ($env !== false) {
  10794. if (!in_array($env, ['stash', 'true', 'false', '1', '0'], true)) {
  10795. throw new \RuntimeException(
  10796. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  10797. );
  10798. }
  10799. if ('stash' === $env) {
  10800. return 'stash';
  10801. }
  10802. return $env !== 'false' && (bool) $env;
  10803. }
  10804. if (!in_array($this->config[$key], [true, false, 'stash'], true)) {
  10805. throw new \RuntimeException(
  10806. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  10807. );
  10808. }
  10809. return $this->config[$key];
  10810. case 'github-protocols':
  10811. $protos = $this->config['github-protocols'];
  10812. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  10813. unset($protos[$index]);
  10814. }
  10815. if (reset($protos) === 'http') {
  10816. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  10817. }
  10818. return $protos;
  10819. case 'autoloader-suffix':
  10820. if ($this->config[$key] === '') {
  10821. return null;
  10822. }
  10823. return $this->process($this->config[$key], $flags);
  10824. case 'audit':
  10825. $result = $this->config[$key];
  10826. $abandonedEnv = $this->getComposerEnv('COMPOSER_AUDIT_ABANDONED');
  10827. if (false !== $abandonedEnv) {
  10828. if (!in_array($abandonedEnv, $validChoices = Auditor::ABANDONEDS, true)) {
  10829. throw new \RuntimeException(
  10830. "Invalid value for COMPOSER_AUDIT_ABANDONED: {$abandonedEnv}. Expected one of ".implode(', ', Auditor::ABANDONEDS)."."
  10831. );
  10832. }
  10833. $result['abandoned'] = $abandonedEnv;
  10834. }
  10835. return $result;
  10836. default:
  10837. if (!isset($this->config[$key])) {
  10838. return null;
  10839. }
  10840. return $this->process($this->config[$key], $flags);
  10841. }
  10842. }
  10843. public function all(int $flags = 0): array
  10844. {
  10845. $all = [
  10846. 'repositories' => $this->getRepositories(),
  10847. ];
  10848. foreach (array_keys($this->config) as $key) {
  10849. $all['config'][$key] = $this->get($key, $flags);
  10850. }
  10851. return $all;
  10852. }
  10853. public function getSourceOfValue(string $key): string
  10854. {
  10855. $this->get($key);
  10856. return $this->sourceOfConfigValue[$key] ?? self::SOURCE_UNKNOWN;
  10857. }
  10858. private function setSourceOfConfigValue($configValue, string $path, string $source): void
  10859. {
  10860. $this->sourceOfConfigValue[$path] = $source;
  10861. if (is_array($configValue)) {
  10862. foreach ($configValue as $key => $value) {
  10863. $this->setSourceOfConfigValue($value, $path . '.' . $key, $source);
  10864. }
  10865. }
  10866. }
  10867. public function raw(): array
  10868. {
  10869. return [
  10870. 'repositories' => $this->getRepositories(),
  10871. 'config' => $this->config,
  10872. ];
  10873. }
  10874. public function has(string $key): bool
  10875. {
  10876. return array_key_exists($key, $this->config);
  10877. }
  10878. private function process($value, int $flags)
  10879. {
  10880. if (!is_string($value)) {
  10881. return $value;
  10882. }
  10883. return Preg::replaceCallback('#\{\$(.+)\}#', function ($match) use ($flags) {
  10884. return $this->get($match[1], $flags);
  10885. }, $value);
  10886. }
  10887. private function realpath(string $path): string
  10888. {
  10889. if (Preg::isMatch('{^(?:/|[a-z]:|[a-z0-9.]+://|\\\\\\\\)}i', $path)) {
  10890. return $path;
  10891. }
  10892. return $this->baseDir !== null ? $this->baseDir . '/' . $path : $path;
  10893. }
  10894. private function getComposerEnv(string $var)
  10895. {
  10896. if ($this->useEnvironment) {
  10897. return Platform::getEnv($var);
  10898. }
  10899. return false;
  10900. }
  10901. private function disableRepoByName(string $name): void
  10902. {
  10903. if (isset($this->repositories[$name])) {
  10904. unset($this->repositories[$name]);
  10905. } elseif ($name === 'packagist') {
  10906. unset($this->repositories['packagist.org']);
  10907. }
  10908. }
  10909. public function prohibitUrlByConfig(string $url, ?IOInterface $io = null, array $repoOptions = []): void
  10910. {
  10911. if (false === filter_var($url, FILTER_VALIDATE_URL) && !Preg::isMatch('{^https?://}', $url)) {
  10912. return;
  10913. }
  10914. $scheme = parse_url($url, PHP_URL_SCHEME);
  10915. $hostname = parse_url($url, PHP_URL_HOST);
  10916. if (in_array($scheme, ['http', 'git', 'ftp', 'svn'])) {
  10917. if ($this->get('secure-http')) {
  10918. if ($scheme === 'svn') {
  10919. if (in_array($hostname, $this->get('secure-svn-domains'), true)) {
  10920. return;
  10921. }
  10922. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-svn-domains for details.");
  10923. }
  10924. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  10925. }
  10926. if ($io !== null) {
  10927. if (is_string($hostname)) {
  10928. if (!isset($this->warnedHosts[$hostname])) {
  10929. $io->writeError("<warning>Warning: Accessing $hostname over $scheme which is an insecure protocol.</warning>");
  10930. }
  10931. $this->warnedHosts[$hostname] = true;
  10932. }
  10933. }
  10934. }
  10935. if ($io !== null && is_string($hostname) && !isset($this->sslVerifyWarnedHosts[$hostname])) {
  10936. $warning = null;
  10937. if (isset($repoOptions['ssl']['verify_peer']) && !(bool) $repoOptions['ssl']['verify_peer']) {
  10938. $warning = 'verify_peer';
  10939. }
  10940. if (isset($repoOptions['ssl']['verify_peer_name']) && !(bool) $repoOptions['ssl']['verify_peer_name']) {
  10941. $warning = $warning === null ? 'verify_peer_name' : $warning . ' and verify_peer_name';
  10942. }
  10943. if ($warning !== null) {
  10944. $io->writeError("<warning>Warning: Accessing $hostname with $warning disabled.</warning>");
  10945. $this->sslVerifyWarnedHosts[$hostname] = true;
  10946. }
  10947. }
  10948. }
  10949. public static function disableProcessTimeout(): void
  10950. {
  10951. ProcessExecutor::setTimeout(0);
  10952. }
  10953. }
  10954. <?php declare(strict_types=1);
  10955. namespace Composer\Config;
  10956. interface ConfigSourceInterface
  10957. {
  10958. public function addRepository(string $name, $config, bool $append = true): void;
  10959. public function removeRepository(string $name): void;
  10960. public function addConfigSetting(string $name, $value): void;
  10961. public function removeConfigSetting(string $name): void;
  10962. public function addProperty(string $name, $value): void;
  10963. public function removeProperty(string $name): void;
  10964. public function addLink(string $type, string $name, string $value): void;
  10965. public function removeLink(string $type, string $name): void;
  10966. public function getName(): string;
  10967. }
  10968. <?php declare(strict_types=1);
  10969. namespace Composer\Config;
  10970. use Composer\Json\JsonFile;
  10971. use Composer\Json\JsonManipulator;
  10972. use Composer\Json\JsonValidationException;
  10973. use Composer\Pcre\Preg;
  10974. use Composer\Util\Filesystem;
  10975. use Composer\Util\Silencer;
  10976. class JsonConfigSource implements ConfigSourceInterface
  10977. {
  10978. private $file;
  10979. private $authConfig;
  10980. public function __construct(JsonFile $file, bool $authConfig = false)
  10981. {
  10982. $this->file = $file;
  10983. $this->authConfig = $authConfig;
  10984. }
  10985. public function getName(): string
  10986. {
  10987. return $this->file->getPath();
  10988. }
  10989. public function addRepository(string $name, $config, bool $append = true): void
  10990. {
  10991. $this->manipulateJson('addRepository', static function (&$config, $repo, $repoConfig) use ($append): void {
  10992. if (isset($config['repositories'])) {
  10993. foreach ($config['repositories'] as $index => $val) {
  10994. if ($index === $repo) {
  10995. continue;
  10996. }
  10997. if (is_numeric($index) && ($val === ['packagist' => false] || $val === ['packagist.org' => false])) {
  10998. unset($config['repositories'][$index]);
  10999. $config['repositories']['packagist.org'] = false;
  11000. break;
  11001. }
  11002. }
  11003. }
  11004. if ($append) {
  11005. $config['repositories'][$repo] = $repoConfig;
  11006. } else {
  11007. $config['repositories'] = [$repo => $repoConfig] + $config['repositories'];
  11008. }
  11009. }, $name, $config, $append);
  11010. }
  11011. public function removeRepository(string $name): void
  11012. {
  11013. $this->manipulateJson('removeRepository', static function (&$config, $repo): void {
  11014. unset($config['repositories'][$repo]);
  11015. }, $name);
  11016. }
  11017. public function addConfigSetting(string $name, $value): void
  11018. {
  11019. $authConfig = $this->authConfig;
  11020. $this->manipulateJson('addConfigSetting', static function (&$config, $key, $val) use ($authConfig): void {
  11021. if (Preg::isMatch('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  11022. [$key, $host] = explode('.', $key, 2);
  11023. if ($authConfig) {
  11024. $config[$key][$host] = $val;
  11025. } else {
  11026. $config['config'][$key][$host] = $val;
  11027. }
  11028. } else {
  11029. $config['config'][$key] = $val;
  11030. }
  11031. }, $name, $value);
  11032. }
  11033. public function removeConfigSetting(string $name): void
  11034. {
  11035. $authConfig = $this->authConfig;
  11036. $this->manipulateJson('removeConfigSetting', static function (&$config, $key) use ($authConfig): void {
  11037. if (Preg::isMatch('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  11038. [$key, $host] = explode('.', $key, 2);
  11039. if ($authConfig) {
  11040. unset($config[$key][$host]);
  11041. } else {
  11042. unset($config['config'][$key][$host]);
  11043. }
  11044. } else {
  11045. unset($config['config'][$key]);
  11046. }
  11047. }, $name);
  11048. }
  11049. public function addProperty(string $name, $value): void
  11050. {
  11051. $this->manipulateJson('addProperty', static function (&$config, $key, $val): void {
  11052. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  11053. $bits = explode('.', $key);
  11054. $last = array_pop($bits);
  11055. $arr = &$config[reset($bits)];
  11056. foreach ($bits as $bit) {
  11057. if (!isset($arr[$bit])) {
  11058. $arr[$bit] = [];
  11059. }
  11060. $arr = &$arr[$bit];
  11061. }
  11062. $arr[$last] = $val;
  11063. } else {
  11064. $config[$key] = $val;
  11065. }
  11066. }, $name, $value);
  11067. }
  11068. public function removeProperty(string $name): void
  11069. {
  11070. $this->manipulateJson('removeProperty', static function (&$config, $key): void {
  11071. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0 || stripos($key, 'autoload.') === 0 || stripos($key, 'autoload-dev.') === 0) {
  11072. $bits = explode('.', $key);
  11073. $last = array_pop($bits);
  11074. $arr = &$config[reset($bits)];
  11075. foreach ($bits as $bit) {
  11076. if (!isset($arr[$bit])) {
  11077. return;
  11078. }
  11079. $arr = &$arr[$bit];
  11080. }
  11081. unset($arr[$last]);
  11082. } else {
  11083. unset($config[$key]);
  11084. }
  11085. }, $name);
  11086. }
  11087. public function addLink(string $type, string $name, string $value): void
  11088. {
  11089. $this->manipulateJson('addLink', static function (&$config, $type, $name, $value): void {
  11090. $config[$type][$name] = $value;
  11091. }, $type, $name, $value);
  11092. }
  11093. public function removeLink(string $type, string $name): void
  11094. {
  11095. $this->manipulateJson('removeSubNode', static function (&$config, $type, $name): void {
  11096. unset($config[$type][$name]);
  11097. }, $type, $name);
  11098. $this->manipulateJson('removeMainKeyIfEmpty', static function (&$config, $type): void {
  11099. if (0 === count($config[$type])) {
  11100. unset($config[$type]);
  11101. }
  11102. }, $type);
  11103. }
  11104. private function manipulateJson(string $method, callable $fallback, ...$args): void
  11105. {
  11106. if ($this->file->exists()) {
  11107. if (!is_writable($this->file->getPath())) {
  11108. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  11109. }
  11110. if (!Filesystem::isReadable($this->file->getPath())) {
  11111. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  11112. }
  11113. $contents = file_get_contents($this->file->getPath());
  11114. } elseif ($this->authConfig) {
  11115. $contents = "{\n}\n";
  11116. } else {
  11117. $contents = "{\n \"config\": {\n }\n}\n";
  11118. }
  11119. $manipulator = new JsonManipulator($contents);
  11120. $newFile = !$this->file->exists();
  11121. if ($this->authConfig && $method === 'addConfigSetting') {
  11122. $method = 'addSubNode';
  11123. [$mainNode, $name] = explode('.', $args[0], 2);
  11124. $args = [$mainNode, $name, $args[1]];
  11125. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  11126. $method = 'removeSubNode';
  11127. [$mainNode, $name] = explode('.', $args[0], 2);
  11128. $args = [$mainNode, $name];
  11129. }
  11130. if (call_user_func_array([$manipulator, $method], $args)) {
  11131. file_put_contents($this->file->getPath(), $manipulator->getContents());
  11132. } else {
  11133. $config = $this->file->read();
  11134. $this->arrayUnshiftRef($args, $config);
  11135. $fallback(...$args);
  11136. foreach (['require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev', 'scripts', 'scripts-descriptions', 'scripts-aliases', 'support'] as $prop) {
  11137. if (isset($config[$prop]) && $config[$prop] === []) {
  11138. $config[$prop] = new \stdClass;
  11139. }
  11140. }
  11141. foreach (['psr-0', 'psr-4'] as $prop) {
  11142. if (isset($config['autoload'][$prop]) && $config['autoload'][$prop] === []) {
  11143. $config['autoload'][$prop] = new \stdClass;
  11144. }
  11145. if (isset($config['autoload-dev'][$prop]) && $config['autoload-dev'][$prop] === []) {
  11146. $config['autoload-dev'][$prop] = new \stdClass;
  11147. }
  11148. }
  11149. foreach (['platform', 'http-basic', 'bearer', 'gitlab-token', 'gitlab-oauth', 'github-oauth', 'preferred-install'] as $prop) {
  11150. if (isset($config['config'][$prop]) && $config['config'][$prop] === []) {
  11151. $config['config'][$prop] = new \stdClass;
  11152. }
  11153. }
  11154. $this->file->write($config);
  11155. }
  11156. try {
  11157. $this->file->validateSchema(JsonFile::LAX_SCHEMA);
  11158. } catch (JsonValidationException $e) {
  11159. file_put_contents($this->file->getPath(), $contents);
  11160. 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);
  11161. }
  11162. if ($newFile) {
  11163. Silencer::call('chmod', $this->file->getPath(), 0600);
  11164. }
  11165. }
  11166. private function arrayUnshiftRef(array &$array, &$value): int
  11167. {
  11168. $return = array_unshift($array, '');
  11169. $array[0] = &$value;
  11170. return $return;
  11171. }
  11172. }
  11173. <?php declare(strict_types=1);
  11174. namespace Composer\Console;
  11175. use Composer\Installer;
  11176. use Composer\IO\NullIO;
  11177. use Composer\Util\Filesystem;
  11178. use Composer\Util\Platform;
  11179. use Composer\Util\Silencer;
  11180. use LogicException;
  11181. use RuntimeException;
  11182. use Symfony\Component\Console\Application as BaseApplication;
  11183. use Symfony\Component\Console\Exception\CommandNotFoundException;
  11184. use Symfony\Component\Console\Exception\ExceptionInterface;
  11185. use Symfony\Component\Console\Helper\HelperSet;
  11186. use Symfony\Component\Console\Helper\QuestionHelper;
  11187. use Symfony\Component\Console\Input\InputDefinition;
  11188. use Symfony\Component\Console\Input\InputInterface;
  11189. use Symfony\Component\Console\Input\InputOption;
  11190. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  11191. use Symfony\Component\Console\Output\OutputInterface;
  11192. use Seld\JsonLint\ParsingException;
  11193. use Composer\Command;
  11194. use Composer\Composer;
  11195. use Composer\Factory;
  11196. use Composer\Downloader\TransportException;
  11197. use Composer\IO\IOInterface;
  11198. use Composer\IO\ConsoleIO;
  11199. use Composer\Json\JsonValidationException;
  11200. use Composer\Util\ErrorHandler;
  11201. use Composer\Util\HttpDownloader;
  11202. use Composer\EventDispatcher\ScriptExecutionException;
  11203. use Composer\Exception\NoSslException;
  11204. use Composer\XdebugHandler\XdebugHandler;
  11205. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  11206. class Application extends BaseApplication
  11207. {
  11208. protected $composer;
  11209. protected $io;
  11210. private static $logo = ' ______
  11211. / ____/___ ____ ___ ____ ____ ________ _____
  11212. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  11213. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  11214. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  11215. /_/
  11216. ';
  11217. private $hasPluginCommands = false;
  11218. private $disablePluginsByDefault = false;
  11219. private $disableScriptsByDefault = false;
  11220. private $initialWorkingDirectory;
  11221. public function __construct(string $name = 'Composer', string $version = '')
  11222. {
  11223. if (method_exists($this, 'setCatchErrors')) {
  11224. $this->setCatchErrors(true);
  11225. }
  11226. static $shutdownRegistered = false;
  11227. if ($version === '') {
  11228. $version = Composer::getVersion();
  11229. }
  11230. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  11231. ini_set('xdebug.show_exception_trace', '0');
  11232. ini_set('xdebug.scream', '0');
  11233. }
  11234. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  11235. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  11236. }
  11237. $this->io = new NullIO();
  11238. if (!$shutdownRegistered) {
  11239. $shutdownRegistered = true;
  11240. register_shutdown_function(static function (): void {
  11241. $lastError = error_get_last();
  11242. if ($lastError && $lastError['message'] &&
  11243. (strpos($lastError['message'], 'Allowed memory') !== false ||
  11244. strpos($lastError['message'], 'exceeded memory') !== false )) {
  11245. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  11246. }
  11247. });
  11248. }
  11249. $this->initialWorkingDirectory = getcwd();
  11250. parent::__construct($name, $version);
  11251. }
  11252. public function __destruct()
  11253. {
  11254. }
  11255. public function run(?InputInterface $input = null, ?OutputInterface $output = null): int
  11256. {
  11257. if (null === $output) {
  11258. $output = Factory::createOutput();
  11259. }
  11260. return parent::run($input, $output);
  11261. }
  11262. public function doRun(InputInterface $input, OutputInterface $output): int
  11263. {
  11264. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  11265. $this->disableScriptsByDefault = $input->hasParameterOption('--no-scripts');
  11266. static $stdin = null;
  11267. if (null === $stdin) {
  11268. $stdin = defined('STDIN') ? STDIN : fopen('php://stdin', 'r');
  11269. }
  11270. if (Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING') !== '1' && (Platform::getEnv('COMPOSER_NO_INTERACTION') || $stdin === false || !Platform::isTty($stdin))) {
  11271. $input->setInteractive(false);
  11272. }
  11273. $io = $this->io = new ConsoleIO($input, $output, new HelperSet([
  11274. new QuestionHelper(),
  11275. ]));
  11276. ErrorHandler::register($io);
  11277. if ($input->hasParameterOption('--no-cache')) {
  11278. $io->writeError('Disabling cache usage', true, IOInterface::DEBUG);
  11279. Platform::putEnv('COMPOSER_CACHE_DIR', Platform::isWindows() ? 'nul' : '/dev/null');
  11280. }
  11281. $newWorkDir = $this->getNewWorkingDir($input);
  11282. if (null !== $newWorkDir) {
  11283. $oldWorkingDir = Platform::getCwd(true);
  11284. chdir($newWorkDir);
  11285. $this->initialWorkingDirectory = $newWorkDir;
  11286. $cwd = Platform::getCwd(true);
  11287. $io->writeError('Changed CWD to ' . ($cwd !== '' ? $cwd : $newWorkDir), true, IOInterface::DEBUG);
  11288. }
  11289. $commandName = '';
  11290. if ($name = $this->getCommandNameBeforeBinding($input)) {
  11291. try {
  11292. $commandName = $this->find($name)->getName();
  11293. } catch (CommandNotFoundException $e) {
  11294. $commandName = false;
  11295. } catch (\InvalidArgumentException $e) {
  11296. }
  11297. }
  11298. if (
  11299. null === $newWorkDir
  11300. && !in_array($commandName, ['', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'], true)
  11301. && !file_exists(Factory::getComposerFile())
  11302. && ($useParentDirIfNoJsonAvailable = $this->getUseParentDirConfigValue()) !== false
  11303. && ($commandName !== 'config' || ($input->hasParameterOption('--file', true) === false && $input->hasParameterOption('-f', true) === false))
  11304. && $input->hasParameterOption('--help', true) === false
  11305. && $input->hasParameterOption('-h', true) === false
  11306. ) {
  11307. $dir = dirname(Platform::getCwd(true));
  11308. $home = realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/');
  11309. while (dirname($dir) !== $dir && $dir !== $home) {
  11310. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  11311. if ($useParentDirIfNoJsonAvailable !== true && !$io->isInteractive()) {
  11312. $io->writeError('<info>No composer.json in current directory, to use the one at '.$dir.' run interactively or set config.use-parent-dir to true</info>');
  11313. break;
  11314. }
  11315. 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>]? ')) {
  11316. if ($useParentDirIfNoJsonAvailable === true) {
  11317. $io->writeError('<info>No composer.json in current directory, changing working directory to '.$dir.'</info>');
  11318. } else {
  11319. $io->writeError('<info>Always want to use the parent dir? Use "composer config --global use-parent-dir true" to change the default.</info>');
  11320. }
  11321. $oldWorkingDir = Platform::getCwd(true);
  11322. chdir($dir);
  11323. }
  11324. break;
  11325. }
  11326. $dir = dirname($dir);
  11327. }
  11328. unset($dir, $home);
  11329. }
  11330. $needsSudoCheck = !Platform::isWindows()
  11331. && function_exists('exec')
  11332. && !Platform::getEnv('COMPOSER_ALLOW_SUPERUSER')
  11333. && !Platform::isDocker();
  11334. $isNonAllowedRoot = false;
  11335. if ($needsSudoCheck) {
  11336. $isNonAllowedRoot = $this->isRunningAsRoot();
  11337. if ($isNonAllowedRoot) {
  11338. if ($uid = (int) Platform::getEnv('SUDO_UID')) {
  11339. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  11340. }
  11341. }
  11342. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  11343. }
  11344. $mayNeedPluginCommand = false === $input->hasParameterOption(['--version', '-V'])
  11345. && (
  11346. false === $commandName
  11347. || in_array($commandName, ['', 'list', 'help'], true)
  11348. || ($commandName === '_complete' && !$isNonAllowedRoot)
  11349. );
  11350. if ($mayNeedPluginCommand && !$this->disablePluginsByDefault && !$this->hasPluginCommands) {
  11351. if ($isNonAllowedRoot) {
  11352. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  11353. if ($io->isInteractive() && $io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  11354. $isNonAllowedRoot = false;
  11355. } else {
  11356. $io->writeError('<warning>Aborting as no plugin should be loaded if running as super user is not explicitly allowed</warning>');
  11357. return 1;
  11358. }
  11359. }
  11360. try {
  11361. foreach ($this->getPluginCommands() as $command) {
  11362. if ($this->has($command->getName())) {
  11363. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  11364. } else {
  11365. $this->add($command);
  11366. }
  11367. }
  11368. } catch (NoSslException $e) {
  11369. } catch (ParsingException $e) {
  11370. $details = $e->getDetails();
  11371. $file = realpath(Factory::getComposerFile());
  11372. $line = null;
  11373. if ($details && isset($details['line'])) {
  11374. $line = $details['line'];
  11375. }
  11376. $ghe = new GithubActionError($this->io);
  11377. $ghe->emit($e->getMessage(), $file, $line);
  11378. throw $e;
  11379. }
  11380. $this->hasPluginCommands = true;
  11381. }
  11382. if (!$this->disablePluginsByDefault && $isNonAllowedRoot && !$io->isInteractive()) {
  11383. $io->writeError('<error>Composer plugins have been disabled for safety in this non-interactive session.</error>');
  11384. $io->writeError('<error>Set COMPOSER_ALLOW_SUPERUSER=1 if you want to allow plugins to run as root/super user.</error>');
  11385. $this->disablePluginsByDefault = true;
  11386. }
  11387. $isProxyCommand = false;
  11388. if ($name = $this->getCommandNameBeforeBinding($input)) {
  11389. try {
  11390. $command = $this->find($name);
  11391. $commandName = $command->getName();
  11392. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  11393. } catch (\InvalidArgumentException $e) {
  11394. }
  11395. }
  11396. if (!$isProxyCommand) {
  11397. $io->writeError(sprintf(
  11398. 'Running %s (%s) with %s on %s',
  11399. Composer::getVersion(),
  11400. Composer::RELEASE_DATE,
  11401. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  11402. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  11403. ), true, IOInterface::DEBUG);
  11404. if (\PHP_VERSION_ID < 70205) {
  11405. $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>');
  11406. }
  11407. if (XdebugHandler::isXdebugActive() && !Platform::getEnv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  11408. $io->writeError('<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>');
  11409. }
  11410. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  11411. $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']));
  11412. }
  11413. if ($isNonAllowedRoot) {
  11414. if ($commandName !== 'self-update' && $commandName !== 'selfupdate' && $commandName !== '_complete') {
  11415. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  11416. if ($io->isInteractive()) {
  11417. if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  11418. return 1;
  11419. }
  11420. }
  11421. }
  11422. }
  11423. Silencer::call(static function () use ($io): void {
  11424. $pid = function_exists('getmypid') ? getmypid() . '-' : '';
  11425. $tempfile = sys_get_temp_dir() . '/temp-' . $pid . bin2hex(random_bytes(5));
  11426. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) === __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  11427. $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()));
  11428. }
  11429. });
  11430. $file = Factory::getComposerFile();
  11431. if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  11432. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  11433. foreach ($composer['scripts'] as $script => $dummy) {
  11434. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  11435. if ($this->has($script)) {
  11436. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  11437. } else {
  11438. $description = null;
  11439. if (isset($composer['scripts-descriptions'][$script])) {
  11440. $description = $composer['scripts-descriptions'][$script];
  11441. }
  11442. $aliases = $composer['scripts-aliases'][$script] ?? [];
  11443. $this->add(new Command\ScriptAliasCommand($script, $description, $aliases));
  11444. }
  11445. }
  11446. }
  11447. }
  11448. }
  11449. }
  11450. try {
  11451. if ($input->hasParameterOption('--profile')) {
  11452. $startTime = microtime(true);
  11453. $this->io->enableDebugging($startTime);
  11454. }
  11455. $result = parent::doRun($input, $output);
  11456. if (true === $input->hasParameterOption(['--version', '-V'], true)) {
  11457. $io->writeError(sprintf('<info>PHP</info> version <comment>%s</comment> (%s)', \PHP_VERSION, \PHP_BINARY));
  11458. $io->writeError('Run the "diagnose" command to get more detailed diagnostics output.');
  11459. }
  11460. if (isset($oldWorkingDir) && '' !== $oldWorkingDir) {
  11461. Silencer::call('chdir', $oldWorkingDir);
  11462. }
  11463. if (isset($startTime)) {
  11464. $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</info>');
  11465. }
  11466. return $result;
  11467. } catch (ScriptExecutionException $e) {
  11468. if ($this->getDisablePluginsByDefault() && $this->isRunningAsRoot() && !$this->io->isInteractive()) {
  11469. $io->writeError('<error>Plugins have been disabled automatically as you are running as root, this may be the cause of the script failure.</error>', true, IOInterface::QUIET);
  11470. $io->writeError('<error>See also https://getcomposer.org/root</error>', true, IOInterface::QUIET);
  11471. }
  11472. return $e->getCode();
  11473. } catch (\Throwable $e) {
  11474. $ghe = new GithubActionError($this->io);
  11475. $ghe->emit($e->getMessage());
  11476. $this->hintCommonErrors($e, $output);
  11477. if (!method_exists($this, 'setCatchErrors') && !$e instanceof \Exception) {
  11478. if ($output instanceof ConsoleOutputInterface) {
  11479. $this->renderThrowable($e, $output->getErrorOutput());
  11480. } else {
  11481. $this->renderThrowable($e, $output);
  11482. }
  11483. return max(1, $e->getCode());
  11484. }
  11485. if ($e instanceof TransportException) {
  11486. $reflProp = new \ReflectionProperty($e, 'code');
  11487. $reflProp->setAccessible(true);
  11488. $reflProp->setValue($e, Installer::ERROR_TRANSPORT_EXCEPTION);
  11489. }
  11490. throw $e;
  11491. } finally {
  11492. restore_error_handler();
  11493. }
  11494. }
  11495. private function getNewWorkingDir(InputInterface $input): ?string
  11496. {
  11497. $workingDir = $input->getParameterOption(['--working-dir', '-d'], null, true);
  11498. if (null !== $workingDir && !is_dir($workingDir)) {
  11499. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  11500. }
  11501. return $workingDir;
  11502. }
  11503. private function hintCommonErrors(\Throwable $exception, OutputInterface $output): void
  11504. {
  11505. $io = $this->getIO();
  11506. if ((get_class($exception) === LogicException::class || $exception instanceof \Error) && $output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
  11507. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  11508. }
  11509. Silencer::suppress();
  11510. try {
  11511. $composer = $this->getComposer(false, true);
  11512. if (null !== $composer && function_exists('disk_free_space')) {
  11513. $config = $composer->getConfig();
  11514. $minSpaceFree = 100 * 1024 * 1024;
  11515. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  11516. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  11517. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  11518. ) {
  11519. $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);
  11520. }
  11521. }
  11522. } catch (\Exception $e) {
  11523. }
  11524. Silencer::restore();
  11525. if ($exception instanceof TransportException && str_contains($exception->getMessage(), 'Unable to use a proxy')) {
  11526. $io->writeError('<error>The following exception indicates your proxy is misconfigured</error>', true, IOInterface::QUIET);
  11527. $io->writeError('<error>Check https://getcomposer.org/doc/faqs/how-to-use-composer-behind-a-proxy.md for details</error>', true, IOInterface::QUIET);
  11528. }
  11529. if (Platform::isWindows() && $exception instanceof TransportException && str_contains($exception->getMessage(), 'unable to get local issuer certificate')) {
  11530. $avastDetect = glob('C:\Program Files\Avast*');
  11531. if (is_array($avastDetect) && count($avastDetect) !== 0) {
  11532. $io->writeError('<error>The following exception indicates a possible issue with the Avast Firewall</error>', true, IOInterface::QUIET);
  11533. $io->writeError('<error>Check https://getcomposer.org/local-issuer for details</error>', true, IOInterface::QUIET);
  11534. } else {
  11535. $io->writeError('<error>The following exception indicates a possible issue with a Firewall/Antivirus</error>', true, IOInterface::QUIET);
  11536. $io->writeError('<error>Check https://getcomposer.org/local-issuer for details</error>', true, IOInterface::QUIET);
  11537. }
  11538. }
  11539. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  11540. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  11541. $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);
  11542. }
  11543. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  11544. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  11545. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  11546. }
  11547. if ($exception instanceof ProcessTimedOutException) {
  11548. $io->writeError('<error>The following exception is caused by a process timeout</error>', true, IOInterface::QUIET);
  11549. $io->writeError('<error>Check https://getcomposer.org/doc/06-config.md#process-timeout for details</error>', true, IOInterface::QUIET);
  11550. }
  11551. if ($this->getDisablePluginsByDefault() && $this->isRunningAsRoot() && !$this->io->isInteractive()) {
  11552. $io->writeError('<error>Plugins have been disabled automatically as you are running as root, this may be the cause of the following exception. See also https://getcomposer.org/root</error>', true, IOInterface::QUIET);
  11553. } elseif ($exception instanceof CommandNotFoundException && $this->getDisablePluginsByDefault()) {
  11554. $io->writeError('<error>Plugins have been disabled, which may be why some commands are missing, unless you made a typo</error>', true, IOInterface::QUIET);
  11555. }
  11556. $hints = HttpDownloader::getExceptionHints($exception);
  11557. if (null !== $hints && count($hints) > 0) {
  11558. foreach ($hints as $hint) {
  11559. $io->writeError($hint, true, IOInterface::QUIET);
  11560. }
  11561. }
  11562. }
  11563. public function getComposer(bool $required = true, ?bool $disablePlugins = null, ?bool $disableScripts = null): ?Composer
  11564. {
  11565. if (null === $disablePlugins) {
  11566. $disablePlugins = $this->disablePluginsByDefault;
  11567. }
  11568. if (null === $disableScripts) {
  11569. $disableScripts = $this->disableScriptsByDefault;
  11570. }
  11571. if (null === $this->composer) {
  11572. try {
  11573. $this->composer = Factory::create(Platform::isInputCompletionProcess() ? new NullIO() : $this->io, null, $disablePlugins, $disableScripts);
  11574. } catch (\InvalidArgumentException $e) {
  11575. if ($required) {
  11576. $this->io->writeError($e->getMessage());
  11577. if ($this->areExceptionsCaught()) {
  11578. exit(1);
  11579. }
  11580. throw $e;
  11581. }
  11582. } catch (JsonValidationException $e) {
  11583. if ($required) {
  11584. throw $e;
  11585. }
  11586. } catch (RuntimeException $e) {
  11587. if ($required) {
  11588. throw $e;
  11589. }
  11590. }
  11591. }
  11592. return $this->composer;
  11593. }
  11594. public function resetComposer(): void
  11595. {
  11596. $this->composer = null;
  11597. if (method_exists($this->getIO(), 'resetAuthentications')) {
  11598. $this->getIO()->resetAuthentications();
  11599. }
  11600. }
  11601. public function getIO(): IOInterface
  11602. {
  11603. return $this->io;
  11604. }
  11605. public function getHelp(): string
  11606. {
  11607. return self::$logo . parent::getHelp();
  11608. }
  11609. protected function getDefaultCommands(): array
  11610. {
  11611. $commands = array_merge(parent::getDefaultCommands(), [
  11612. new Command\AboutCommand(),
  11613. new Command\ConfigCommand(),
  11614. new Command\DependsCommand(),
  11615. new Command\ProhibitsCommand(),
  11616. new Command\InitCommand(),
  11617. new Command\InstallCommand(),
  11618. new Command\CreateProjectCommand(),
  11619. new Command\UpdateCommand(),
  11620. new Command\SearchCommand(),
  11621. new Command\ValidateCommand(),
  11622. new Command\AuditCommand(),
  11623. new Command\ShowCommand(),
  11624. new Command\SuggestsCommand(),
  11625. new Command\RequireCommand(),
  11626. new Command\DumpAutoloadCommand(),
  11627. new Command\StatusCommand(),
  11628. new Command\ArchiveCommand(),
  11629. new Command\DiagnoseCommand(),
  11630. new Command\RunScriptCommand(),
  11631. new Command\LicensesCommand(),
  11632. new Command\GlobalCommand(),
  11633. new Command\ClearCacheCommand(),
  11634. new Command\RemoveCommand(),
  11635. new Command\HomeCommand(),
  11636. new Command\ExecCommand(),
  11637. new Command\OutdatedCommand(),
  11638. new Command\CheckPlatformReqsCommand(),
  11639. new Command\FundCommand(),
  11640. new Command\ReinstallCommand(),
  11641. new Command\BumpCommand(),
  11642. ]);
  11643. if (strpos(__FILE__, 'phar:') === 0 || '1' === Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING')) {
  11644. $commands[] = new Command\SelfUpdateCommand();
  11645. }
  11646. return $commands;
  11647. }
  11648. private function getCommandNameBeforeBinding(InputInterface $input): ?string
  11649. {
  11650. $input = clone $input;
  11651. try {
  11652. $input->bind($this->getDefinition());
  11653. } catch (ExceptionInterface $e) {
  11654. }
  11655. return $input->getFirstArgument();
  11656. }
  11657. public function getLongVersion(): string
  11658. {
  11659. $branchAliasString = '';
  11660. if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
  11661. $branchAliasString = sprintf(' (%s)', Composer::BRANCH_ALIAS_VERSION);
  11662. }
  11663. return sprintf(
  11664. '<info>%s</info> version <comment>%s%s</comment> %s',
  11665. $this->getName(),
  11666. $this->getVersion(),
  11667. $branchAliasString,
  11668. Composer::RELEASE_DATE
  11669. );
  11670. }
  11671. protected function getDefaultInputDefinition(): InputDefinition
  11672. {
  11673. $definition = parent::getDefaultInputDefinition();
  11674. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  11675. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  11676. $definition->addOption(new InputOption('--no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'));
  11677. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  11678. $definition->addOption(new InputOption('--no-cache', null, InputOption::VALUE_NONE, 'Prevent use of the cache'));
  11679. return $definition;
  11680. }
  11681. private function getPluginCommands(): array
  11682. {
  11683. $commands = [];
  11684. $composer = $this->getComposer(false, false);
  11685. if (null === $composer) {
  11686. $composer = Factory::createGlobal($this->io, $this->disablePluginsByDefault, $this->disableScriptsByDefault);
  11687. }
  11688. if (null !== $composer) {
  11689. $pm = $composer->getPluginManager();
  11690. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', ['composer' => $composer, 'io' => $this->io]) as $capability) {
  11691. $newCommands = $capability->getCommands();
  11692. if (!is_array($newCommands)) {
  11693. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  11694. }
  11695. foreach ($newCommands as $command) {
  11696. if (!$command instanceof Command\BaseCommand) {
  11697. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  11698. }
  11699. }
  11700. $commands = array_merge($commands, $newCommands);
  11701. }
  11702. }
  11703. return $commands;
  11704. }
  11705. public function getInitialWorkingDirectory()
  11706. {
  11707. return $this->initialWorkingDirectory;
  11708. }
  11709. public function getDisablePluginsByDefault(): bool
  11710. {
  11711. return $this->disablePluginsByDefault;
  11712. }
  11713. public function getDisableScriptsByDefault(): bool
  11714. {
  11715. return $this->disableScriptsByDefault;
  11716. }
  11717. private function getUseParentDirConfigValue()
  11718. {
  11719. $config = Factory::createConfig($this->io);
  11720. return $config->get('use-parent-dir');
  11721. }
  11722. private function isRunningAsRoot(): bool
  11723. {
  11724. return function_exists('posix_getuid') && posix_getuid() === 0;
  11725. }
  11726. }
  11727. <?php declare(strict_types=1);
  11728. namespace Composer\Console;
  11729. use Composer\IO\IOInterface;
  11730. use Composer\Util\Platform;
  11731. final class GithubActionError
  11732. {
  11733. protected $io;
  11734. public function __construct(IOInterface $io)
  11735. {
  11736. $this->io = $io;
  11737. }
  11738. public function emit(string $message, ?string $file = null, ?int $line = null): void
  11739. {
  11740. if (Platform::getEnv('GITHUB_ACTIONS') && !Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING')) {
  11741. $message = $this->escapeData($message);
  11742. if ($file && $line) {
  11743. $file = $this->escapeProperty($file);
  11744. $this->io->write("::error file=". $file .",line=". $line ."::". $message);
  11745. } elseif ($file) {
  11746. $file = $this->escapeProperty($file);
  11747. $this->io->write("::error file=". $file ."::". $message);
  11748. } else {
  11749. $this->io->write("::error ::". $message);
  11750. }
  11751. }
  11752. }
  11753. private function escapeData(string $data): string
  11754. {
  11755. $data = str_replace("%", '%25', $data);
  11756. $data = str_replace("\r", '%0D', $data);
  11757. $data = str_replace("\n", '%0A', $data);
  11758. return $data;
  11759. }
  11760. private function escapeProperty(string $property): string
  11761. {
  11762. $property = str_replace("%", '%25', $property);
  11763. $property = str_replace("\r", '%0D', $property);
  11764. $property = str_replace("\n", '%0A', $property);
  11765. $property = str_replace(":", '%3A', $property);
  11766. $property = str_replace(",", '%2C', $property);
  11767. return $property;
  11768. }
  11769. }
  11770. <?php declare(strict_types=1);
  11771. namespace Composer\Console;
  11772. use Closure;
  11773. use Composer\Pcre\Preg;
  11774. use Symfony\Component\Console\Formatter\OutputFormatter;
  11775. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  11776. class HtmlOutputFormatter extends OutputFormatter
  11777. {
  11778. private static $availableForegroundColors = [
  11779. 30 => 'black',
  11780. 31 => 'red',
  11781. 32 => 'green',
  11782. 33 => 'yellow',
  11783. 34 => 'blue',
  11784. 35 => 'magenta',
  11785. 36 => 'cyan',
  11786. 37 => 'white',
  11787. ];
  11788. private static $availableBackgroundColors = [
  11789. 40 => 'black',
  11790. 41 => 'red',
  11791. 42 => 'green',
  11792. 43 => 'yellow',
  11793. 44 => 'blue',
  11794. 45 => 'magenta',
  11795. 46 => 'cyan',
  11796. 47 => 'white',
  11797. ];
  11798. private static $availableOptions = [
  11799. 1 => 'bold',
  11800. 4 => 'underscore',
  11801. ];
  11802. public function __construct(array $styles = [])
  11803. {
  11804. parent::__construct(true, $styles);
  11805. }
  11806. public function format(?string $message): ?string
  11807. {
  11808. $formatted = parent::format($message);
  11809. if ($formatted === null) {
  11810. return null;
  11811. }
  11812. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  11813. return Preg::replaceCallback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", Closure::fromCallable([$this, 'formatHtml']), $formatted);
  11814. }
  11815. private function formatHtml(array $matches): string
  11816. {
  11817. assert(is_string($matches[1]));
  11818. $out = '<span style="';
  11819. foreach (explode(';', $matches[1]) as $code) {
  11820. if (isset(self::$availableForegroundColors[(int) $code])) {
  11821. $out .= 'color:'.self::$availableForegroundColors[(int) $code].';';
  11822. } elseif (isset(self::$availableBackgroundColors[(int) $code])) {
  11823. $out .= 'background-color:'.self::$availableBackgroundColors[(int) $code].';';
  11824. } elseif (isset(self::$availableOptions[(int) $code])) {
  11825. switch (self::$availableOptions[(int) $code]) {
  11826. case 'bold':
  11827. $out .= 'font-weight:bold;';
  11828. break;
  11829. case 'underscore':
  11830. $out .= 'text-decoration:underline;';
  11831. break;
  11832. }
  11833. }
  11834. }
  11835. return $out.'">'.$matches[2].'</span>';
  11836. }
  11837. }
  11838. <?php declare(strict_types=1);
  11839. namespace Composer\Console\Input;
  11840. use Symfony\Component\Console\Completion\CompletionInput;
  11841. use Symfony\Component\Console\Completion\CompletionSuggestions;
  11842. use Symfony\Component\Console\Completion\Suggestion;
  11843. use Symfony\Component\Console\Exception\InvalidArgumentException;
  11844. use Symfony\Component\Console\Exception\LogicException;
  11845. use Symfony\Component\Console\Input\InputArgument as BaseInputArgument;
  11846. class InputArgument extends BaseInputArgument
  11847. {
  11848. private $suggestedValues;
  11849. public function __construct(string $name, ?int $mode = null, string $description = '', $default = null, $suggestedValues = [])
  11850. {
  11851. parent::__construct($name, $mode, $description, $default);
  11852. $this->suggestedValues = $suggestedValues;
  11853. }
  11854. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  11855. {
  11856. $values = $this->suggestedValues;
  11857. if ($values instanceof \Closure && !\is_array($values = $values($input, $suggestions))) {
  11858. throw new LogicException(sprintf('Closure for option "%s" must return an array. Got "%s".', $this->getName(), get_debug_type($values)));
  11859. }
  11860. if ([] !== $values) {
  11861. $suggestions->suggestValues($values);
  11862. }
  11863. }
  11864. }
  11865. <?php declare(strict_types=1);
  11866. namespace Composer\Console\Input;
  11867. use Symfony\Component\Console\Completion\CompletionInput;
  11868. use Symfony\Component\Console\Completion\CompletionSuggestions;
  11869. use Symfony\Component\Console\Completion\Suggestion;
  11870. use Symfony\Component\Console\Exception\InvalidArgumentException;
  11871. use Symfony\Component\Console\Exception\LogicException;
  11872. use Symfony\Component\Console\Input\InputOption as BaseInputOption;
  11873. class InputOption extends BaseInputOption
  11874. {
  11875. private $suggestedValues;
  11876. public function __construct(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null, $suggestedValues = [])
  11877. {
  11878. parent::__construct($name, $shortcut, $mode, $description, $default);
  11879. $this->suggestedValues = $suggestedValues;
  11880. if ([] !== $suggestedValues && !$this->acceptValue()) {
  11881. throw new LogicException('Cannot set suggested values if the option does not accept a value.');
  11882. }
  11883. }
  11884. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  11885. {
  11886. $values = $this->suggestedValues;
  11887. if ($values instanceof \Closure && !\is_array($values = $values($input, $suggestions))) {
  11888. throw new LogicException(sprintf('Closure for argument "%s" must return an array. Got "%s".', $this->getName(), get_debug_type($values)));
  11889. }
  11890. if ([] !== $values) {
  11891. $suggestions->suggestValues($values);
  11892. }
  11893. }
  11894. }
  11895. <?php declare(strict_types=1);
  11896. namespace Composer\DependencyResolver;
  11897. class Decisions implements \Iterator, \Countable
  11898. {
  11899. public const DECISION_LITERAL = 0;
  11900. public const DECISION_REASON = 1;
  11901. protected $pool;
  11902. protected $decisionMap;
  11903. protected $decisionQueue = [];
  11904. public function __construct(Pool $pool)
  11905. {
  11906. $this->pool = $pool;
  11907. $this->decisionMap = [];
  11908. }
  11909. public function decide(int $literal, int $level, Rule $why): void
  11910. {
  11911. $this->addDecision($literal, $level);
  11912. $this->decisionQueue[] = [
  11913. self::DECISION_LITERAL => $literal,
  11914. self::DECISION_REASON => $why,
  11915. ];
  11916. }
  11917. public function satisfy(int $literal): bool
  11918. {
  11919. $packageId = abs($literal);
  11920. return (
  11921. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  11922. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  11923. );
  11924. }
  11925. public function conflict(int $literal): bool
  11926. {
  11927. $packageId = abs($literal);
  11928. return (
  11929. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  11930. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  11931. );
  11932. }
  11933. public function decided(int $literalOrPackageId): bool
  11934. {
  11935. return ($this->decisionMap[abs($literalOrPackageId)] ?? 0) !== 0;
  11936. }
  11937. public function undecided(int $literalOrPackageId): bool
  11938. {
  11939. return ($this->decisionMap[abs($literalOrPackageId)] ?? 0) === 0;
  11940. }
  11941. public function decidedInstall(int $literalOrPackageId): bool
  11942. {
  11943. $packageId = abs($literalOrPackageId);
  11944. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  11945. }
  11946. public function decisionLevel(int $literalOrPackageId): int
  11947. {
  11948. $packageId = abs($literalOrPackageId);
  11949. if (isset($this->decisionMap[$packageId])) {
  11950. return abs($this->decisionMap[$packageId]);
  11951. }
  11952. return 0;
  11953. }
  11954. public function decisionRule(int $literalOrPackageId): Rule
  11955. {
  11956. $packageId = abs($literalOrPackageId);
  11957. foreach ($this->decisionQueue as $decision) {
  11958. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  11959. return $decision[self::DECISION_REASON];
  11960. }
  11961. }
  11962. throw new \LogicException('Did not find a decision rule using '.$literalOrPackageId);
  11963. }
  11964. public function atOffset(int $queueOffset): array
  11965. {
  11966. return $this->decisionQueue[$queueOffset];
  11967. }
  11968. public function validOffset(int $queueOffset): bool
  11969. {
  11970. return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
  11971. }
  11972. public function lastReason(): Rule
  11973. {
  11974. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
  11975. }
  11976. public function lastLiteral(): int
  11977. {
  11978. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  11979. }
  11980. public function reset(): void
  11981. {
  11982. while ($decision = array_pop($this->decisionQueue)) {
  11983. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  11984. }
  11985. }
  11986. public function resetToOffset(int $offset): void
  11987. {
  11988. while (\count($this->decisionQueue) > $offset + 1) {
  11989. $decision = array_pop($this->decisionQueue);
  11990. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  11991. }
  11992. }
  11993. public function revertLast(): void
  11994. {
  11995. $this->decisionMap[abs($this->lastLiteral())] = 0;
  11996. array_pop($this->decisionQueue);
  11997. }
  11998. public function count(): int
  11999. {
  12000. return \count($this->decisionQueue);
  12001. }
  12002. public function rewind(): void
  12003. {
  12004. end($this->decisionQueue);
  12005. }
  12006. #[\ReturnTypeWillChange]
  12007. public function current()
  12008. {
  12009. return current($this->decisionQueue);
  12010. }
  12011. public function key(): ?int
  12012. {
  12013. return key($this->decisionQueue);
  12014. }
  12015. public function next(): void
  12016. {
  12017. prev($this->decisionQueue);
  12018. }
  12019. public function valid(): bool
  12020. {
  12021. return false !== current($this->decisionQueue);
  12022. }
  12023. public function isEmpty(): bool
  12024. {
  12025. return \count($this->decisionQueue) === 0;
  12026. }
  12027. protected function addDecision(int $literal, int $level): void
  12028. {
  12029. $packageId = abs($literal);
  12030. $previousDecision = $this->decisionMap[$packageId] ?? 0;
  12031. if ($previousDecision !== 0) {
  12032. $literalString = $this->pool->literalToPrettyString($literal, []);
  12033. $package = $this->pool->literalToPackage($literal);
  12034. throw new SolverBugException(
  12035. "Trying to decide $literalString on level $level, even though $package was previously decided as ".$previousDecision."."
  12036. );
  12037. }
  12038. if ($literal > 0) {
  12039. $this->decisionMap[$packageId] = $level;
  12040. } else {
  12041. $this->decisionMap[$packageId] = -$level;
  12042. }
  12043. }
  12044. public function toString(?Pool $pool = null): string
  12045. {
  12046. $decisionMap = $this->decisionMap;
  12047. ksort($decisionMap);
  12048. $str = '[';
  12049. foreach ($decisionMap as $packageId => $level) {
  12050. $str .= ($pool !== null ? $pool->literalToPackage($packageId) : $packageId).':'.$level.',';
  12051. }
  12052. $str .= ']';
  12053. return $str;
  12054. }
  12055. public function __toString(): string
  12056. {
  12057. return $this->toString();
  12058. }
  12059. }
  12060. <?php declare(strict_types=1);
  12061. namespace Composer\DependencyResolver;
  12062. use Composer\Package\AliasPackage;
  12063. use Composer\Package\BasePackage;
  12064. use Composer\Package\PackageInterface;
  12065. use Composer\Semver\CompilingMatcher;
  12066. use Composer\Semver\Constraint\Constraint;
  12067. class DefaultPolicy implements PolicyInterface
  12068. {
  12069. private $preferStable;
  12070. private $preferLowest;
  12071. private $preferredVersions;
  12072. private $preferredPackageResultCachePerPool;
  12073. private $sortingCachePerPool;
  12074. public function __construct(bool $preferStable = false, bool $preferLowest = false, ?array $preferredVersions = null)
  12075. {
  12076. $this->preferStable = $preferStable;
  12077. $this->preferLowest = $preferLowest;
  12078. $this->preferredVersions = $preferredVersions;
  12079. }
  12080. public function versionCompare(PackageInterface $a, PackageInterface $b, string $operator): bool
  12081. {
  12082. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  12083. return BasePackage::STABILITIES[$stabA] < BasePackage::STABILITIES[$stabB];
  12084. }
  12085. if (($a->isDev() && str_starts_with($a->getVersion(), 'dev-')) || ($b->isDev() && str_starts_with($b->getVersion(), 'dev-'))) {
  12086. $constraint = new Constraint($operator, $b->getVersion());
  12087. $version = new Constraint('==', $a->getVersion());
  12088. return $constraint->matchSpecific($version, true);
  12089. }
  12090. return CompilingMatcher::match(new Constraint($operator, $b->getVersion()), Constraint::OP_EQ, $a->getVersion());
  12091. }
  12092. public function selectPreferredPackages(Pool $pool, array $literals, ?string $requiredPackage = null): array
  12093. {
  12094. sort($literals);
  12095. $resultCacheKey = implode(',', $literals).$requiredPackage;
  12096. $poolId = spl_object_id($pool);
  12097. if (isset($this->preferredPackageResultCachePerPool[$poolId][$resultCacheKey])) {
  12098. return $this->preferredPackageResultCachePerPool[$poolId][$resultCacheKey];
  12099. }
  12100. $packages = $this->groupLiteralsByName($pool, $literals);
  12101. foreach ($packages as &$nameLiterals) {
  12102. usort($nameLiterals, function ($a, $b) use ($pool, $requiredPackage, $poolId): int {
  12103. $cacheKey = 'i'.$a.'.'.$b.$requiredPackage;
  12104. if (isset($this->sortingCachePerPool[$poolId][$cacheKey])) {
  12105. return $this->sortingCachePerPool[$poolId][$cacheKey];
  12106. }
  12107. return $this->sortingCachePerPool[$poolId][$cacheKey] = $this->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  12108. });
  12109. }
  12110. foreach ($packages as &$sortedLiterals) {
  12111. $sortedLiterals = $this->pruneToBestVersion($pool, $sortedLiterals);
  12112. $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
  12113. }
  12114. $selected = array_merge(...array_values($packages));
  12115. usort($selected, function ($a, $b) use ($pool, $requiredPackage, $poolId): int {
  12116. $cacheKey = $a.'.'.$b.$requiredPackage;
  12117. if (isset($this->sortingCachePerPool[$poolId][$cacheKey])) {
  12118. return $this->sortingCachePerPool[$poolId][$cacheKey];
  12119. }
  12120. return $this->sortingCachePerPool[$poolId][$cacheKey] = $this->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  12121. });
  12122. return $this->preferredPackageResultCachePerPool[$poolId][$resultCacheKey] = $selected;
  12123. }
  12124. protected function groupLiteralsByName(Pool $pool, array $literals): array
  12125. {
  12126. $packages = [];
  12127. foreach ($literals as $literal) {
  12128. $packageName = $pool->literalToPackage($literal)->getName();
  12129. if (!isset($packages[$packageName])) {
  12130. $packages[$packageName] = [];
  12131. }
  12132. $packages[$packageName][] = $literal;
  12133. }
  12134. return $packages;
  12135. }
  12136. public function compareByPriority(Pool $pool, BasePackage $a, BasePackage $b, ?string $requiredPackage = null, bool $ignoreReplace = false): int
  12137. {
  12138. if ($a->getName() === $b->getName()) {
  12139. $aAliased = $a instanceof AliasPackage;
  12140. $bAliased = $b instanceof AliasPackage;
  12141. if ($aAliased && !$bAliased) {
  12142. return -1;
  12143. }
  12144. if (!$aAliased && $bAliased) {
  12145. return 1;
  12146. }
  12147. }
  12148. if (!$ignoreReplace) {
  12149. if ($this->replaces($a, $b)) {
  12150. return 1;
  12151. }
  12152. if ($this->replaces($b, $a)) {
  12153. return -1;
  12154. }
  12155. if ($requiredPackage !== null && false !== ($pos = strpos($requiredPackage, '/'))) {
  12156. $requiredVendor = substr($requiredPackage, 0, $pos);
  12157. $aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
  12158. $bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
  12159. if ($bIsSameVendor !== $aIsSameVendor) {
  12160. return $aIsSameVendor ? -1 : 1;
  12161. }
  12162. }
  12163. }
  12164. if ($a->id === $b->id) {
  12165. return 0;
  12166. }
  12167. return ($a->id < $b->id) ? -1 : 1;
  12168. }
  12169. protected function replaces(BasePackage $source, BasePackage $target): bool
  12170. {
  12171. foreach ($source->getReplaces() as $link) {
  12172. if ($link->getTarget() === $target->getName()
  12173. ) {
  12174. return true;
  12175. }
  12176. }
  12177. return false;
  12178. }
  12179. protected function pruneToBestVersion(Pool $pool, array $literals): array
  12180. {
  12181. if ($this->preferredVersions !== null) {
  12182. $name = $pool->literalToPackage($literals[0])->getName();
  12183. if (isset($this->preferredVersions[$name])) {
  12184. $preferredVersion = $this->preferredVersions[$name];
  12185. $bestLiterals = [];
  12186. foreach ($literals as $literal) {
  12187. if ($pool->literalToPackage($literal)->getVersion() === $preferredVersion) {
  12188. $bestLiterals[] = $literal;
  12189. }
  12190. }
  12191. if (\count($bestLiterals) > 0) {
  12192. return $bestLiterals;
  12193. }
  12194. }
  12195. }
  12196. $operator = $this->preferLowest ? '<' : '>';
  12197. $bestLiterals = [$literals[0]];
  12198. $bestPackage = $pool->literalToPackage($literals[0]);
  12199. foreach ($literals as $i => $literal) {
  12200. if (0 === $i) {
  12201. continue;
  12202. }
  12203. $package = $pool->literalToPackage($literal);
  12204. if ($this->versionCompare($package, $bestPackage, $operator)) {
  12205. $bestPackage = $package;
  12206. $bestLiterals = [$literal];
  12207. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  12208. $bestLiterals[] = $literal;
  12209. }
  12210. }
  12211. return $bestLiterals;
  12212. }
  12213. protected function pruneRemoteAliases(Pool $pool, array $literals): array
  12214. {
  12215. $hasLocalAlias = false;
  12216. foreach ($literals as $literal) {
  12217. $package = $pool->literalToPackage($literal);
  12218. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  12219. $hasLocalAlias = true;
  12220. break;
  12221. }
  12222. }
  12223. if (!$hasLocalAlias) {
  12224. return $literals;
  12225. }
  12226. $selected = [];
  12227. foreach ($literals as $literal) {
  12228. $package = $pool->literalToPackage($literal);
  12229. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  12230. $selected[] = $literal;
  12231. }
  12232. }
  12233. return $selected;
  12234. }
  12235. }
  12236. <?php declare(strict_types=1);
  12237. namespace Composer\DependencyResolver;
  12238. class GenericRule extends Rule
  12239. {
  12240. protected $literals;
  12241. public function __construct(array $literals, $reason, $reasonData)
  12242. {
  12243. parent::__construct($reason, $reasonData);
  12244. sort($literals);
  12245. $this->literals = $literals;
  12246. }
  12247. public function getLiterals(): array
  12248. {
  12249. return $this->literals;
  12250. }
  12251. public function getHash()
  12252. {
  12253. $data = unpack('ihash', (string) hash(\PHP_VERSION_ID > 80100 ? 'xxh3' : 'sha1', implode(',', $this->literals), true));
  12254. if (false === $data) {
  12255. throw new \RuntimeException('Failed unpacking: '.implode(', ', $this->literals));
  12256. }
  12257. return $data['hash'];
  12258. }
  12259. public function equals(Rule $rule): bool
  12260. {
  12261. return $this->literals === $rule->getLiterals();
  12262. }
  12263. public function isAssertion(): bool
  12264. {
  12265. return 1 === \count($this->literals);
  12266. }
  12267. public function __toString(): string
  12268. {
  12269. $result = $this->isDisabled() ? 'disabled(' : '(';
  12270. foreach ($this->literals as $i => $literal) {
  12271. if ($i !== 0) {
  12272. $result .= '|';
  12273. }
  12274. $result .= $literal;
  12275. }
  12276. $result .= ')';
  12277. return $result;
  12278. }
  12279. }
  12280. <?php declare(strict_types=1);
  12281. namespace Composer\DependencyResolver;
  12282. use Composer\Repository\InstalledRepositoryInterface;
  12283. use Composer\Repository\RepositoryInterface;
  12284. class LocalRepoTransaction extends Transaction
  12285. {
  12286. public function __construct(RepositoryInterface $lockedRepository, InstalledRepositoryInterface $localRepository)
  12287. {
  12288. parent::__construct(
  12289. $localRepository->getPackages(),
  12290. $lockedRepository->getPackages()
  12291. );
  12292. }
  12293. }
  12294. <?php declare(strict_types=1);
  12295. namespace Composer\DependencyResolver;
  12296. use Composer\Package\AliasPackage;
  12297. use Composer\Package\BasePackage;
  12298. use Composer\Package\Package;
  12299. use Composer\Pcre\Preg;
  12300. class LockTransaction extends Transaction
  12301. {
  12302. protected $presentMap;
  12303. protected $unlockableMap;
  12304. protected $resultPackages;
  12305. public function __construct(Pool $pool, array $presentMap, array $unlockableMap, Decisions $decisions)
  12306. {
  12307. $this->presentMap = $presentMap;
  12308. $this->unlockableMap = $unlockableMap;
  12309. $this->setResultPackages($pool, $decisions);
  12310. parent::__construct($this->presentMap, $this->resultPackages['all']);
  12311. }
  12312. public function setResultPackages(Pool $pool, Decisions $decisions): void
  12313. {
  12314. $this->resultPackages = ['all' => [], 'non-dev' => [], 'dev' => []];
  12315. foreach ($decisions as $i => $decision) {
  12316. $literal = $decision[Decisions::DECISION_LITERAL];
  12317. if ($literal > 0) {
  12318. $package = $pool->literalToPackage($literal);
  12319. $this->resultPackages['all'][] = $package;
  12320. if (!isset($this->unlockableMap[$package->id])) {
  12321. $this->resultPackages['non-dev'][] = $package;
  12322. }
  12323. }
  12324. }
  12325. }
  12326. public function setNonDevPackages(LockTransaction $extractionResult): void
  12327. {
  12328. $packages = $extractionResult->getNewLockPackages(false);
  12329. $this->resultPackages['dev'] = $this->resultPackages['non-dev'];
  12330. $this->resultPackages['non-dev'] = [];
  12331. foreach ($packages as $package) {
  12332. foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
  12333. if ($package->getName() === $resultPackage->getName()) {
  12334. $this->resultPackages['non-dev'][] = $resultPackage;
  12335. unset($this->resultPackages['dev'][$i]);
  12336. }
  12337. }
  12338. }
  12339. }
  12340. public function getNewLockPackages(bool $devMode, bool $updateMirrors = false): array
  12341. {
  12342. $packages = [];
  12343. foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
  12344. if ($package instanceof AliasPackage) {
  12345. continue;
  12346. }
  12347. if ($updateMirrors === true && !array_key_exists(spl_object_hash($package), $this->presentMap)) {
  12348. $package = $this->updateMirrorAndUrls($package);
  12349. }
  12350. $packages[] = $package;
  12351. }
  12352. return $packages;
  12353. }
  12354. private function updateMirrorAndUrls(BasePackage $package): BasePackage
  12355. {
  12356. foreach ($this->presentMap as $presentPackage) {
  12357. if ($package->getName() !== $presentPackage->getName()) {
  12358. continue;
  12359. }
  12360. if ($package->getVersion() !== $presentPackage->getVersion()) {
  12361. continue;
  12362. }
  12363. if ($presentPackage->getSourceReference() === null) {
  12364. continue;
  12365. }
  12366. if ($presentPackage->getSourceType() !== $package->getSourceType()) {
  12367. continue;
  12368. }
  12369. if ($presentPackage instanceof Package) {
  12370. $presentPackage->setSourceUrl($package->getSourceUrl());
  12371. $presentPackage->setSourceMirrors($package->getSourceMirrors());
  12372. }
  12373. if ($presentPackage->getDistType() !== $package->getDistType()) {
  12374. return $presentPackage;
  12375. }
  12376. if (
  12377. $package->getDistUrl() !== null
  12378. && $presentPackage->getDistReference() !== null
  12379. && Preg::isMatch('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $package->getDistUrl())
  12380. ) {
  12381. $presentPackage->setDistUrl(Preg::replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $presentPackage->getDistReference(), $package->getDistUrl()));
  12382. }
  12383. $presentPackage->setDistMirrors($package->getDistMirrors());
  12384. return $presentPackage;
  12385. }
  12386. return $package;
  12387. }
  12388. public function getAliases(array $aliases): array
  12389. {
  12390. $usedAliases = [];
  12391. foreach ($this->resultPackages['all'] as $package) {
  12392. if ($package instanceof AliasPackage) {
  12393. foreach ($aliases as $index => $alias) {
  12394. if ($alias['package'] === $package->getName()) {
  12395. $usedAliases[] = $alias;
  12396. unset($aliases[$index]);
  12397. }
  12398. }
  12399. }
  12400. }
  12401. usort($usedAliases, static function ($a, $b): int {
  12402. return strcmp($a['package'], $b['package']);
  12403. });
  12404. return $usedAliases;
  12405. }
  12406. }
  12407. <?php declare(strict_types=1);
  12408. namespace Composer\DependencyResolver;
  12409. class MultiConflictRule extends Rule
  12410. {
  12411. protected $literals;
  12412. public function __construct(array $literals, $reason, $reasonData)
  12413. {
  12414. parent::__construct($reason, $reasonData);
  12415. if (\count($literals) < 3) {
  12416. throw new \RuntimeException("multi conflict rule requires at least 3 literals");
  12417. }
  12418. sort($literals);
  12419. $this->literals = $literals;
  12420. }
  12421. public function getLiterals(): array
  12422. {
  12423. return $this->literals;
  12424. }
  12425. public function getHash()
  12426. {
  12427. $data = unpack('ihash', (string) hash(\PHP_VERSION_ID > 80100 ? 'xxh3' : 'sha1', 'c:'.implode(',', $this->literals), true));
  12428. if (false === $data) {
  12429. throw new \RuntimeException('Failed unpacking: '.implode(', ', $this->literals));
  12430. }
  12431. return $data['hash'];
  12432. }
  12433. public function equals(Rule $rule): bool
  12434. {
  12435. if ($rule instanceof MultiConflictRule) {
  12436. return $this->literals === $rule->getLiterals();
  12437. }
  12438. return false;
  12439. }
  12440. public function isAssertion(): bool
  12441. {
  12442. return false;
  12443. }
  12444. public function disable(): void
  12445. {
  12446. 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.");
  12447. }
  12448. public function __toString(): string
  12449. {
  12450. $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
  12451. foreach ($this->literals as $i => $literal) {
  12452. if ($i !== 0) {
  12453. $result .= '|';
  12454. }
  12455. $result .= $literal;
  12456. }
  12457. $result .= '))';
  12458. return $result;
  12459. }
  12460. }
  12461. <?php declare(strict_types=1);
  12462. namespace Composer\DependencyResolver\Operation;
  12463. use Composer\Package\PackageInterface;
  12464. class InstallOperation extends SolverOperation implements OperationInterface
  12465. {
  12466. protected const TYPE = 'install';
  12467. protected $package;
  12468. public function __construct(PackageInterface $package)
  12469. {
  12470. $this->package = $package;
  12471. }
  12472. public function getPackage(): PackageInterface
  12473. {
  12474. return $this->package;
  12475. }
  12476. public function show($lock): string
  12477. {
  12478. return self::format($this->package, $lock);
  12479. }
  12480. public static function format(PackageInterface $package, bool $lock = false): string
  12481. {
  12482. return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  12483. }
  12484. }
  12485. <?php declare(strict_types=1);
  12486. namespace Composer\DependencyResolver\Operation;
  12487. use Composer\Package\AliasPackage;
  12488. class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
  12489. {
  12490. protected const TYPE = 'markAliasInstalled';
  12491. protected $package;
  12492. public function __construct(AliasPackage $package)
  12493. {
  12494. $this->package = $package;
  12495. }
  12496. public function getPackage(): AliasPackage
  12497. {
  12498. return $this->package;
  12499. }
  12500. public function show($lock): string
  12501. {
  12502. 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>)';
  12503. }
  12504. }
  12505. <?php declare(strict_types=1);
  12506. namespace Composer\DependencyResolver\Operation;
  12507. use Composer\Package\AliasPackage;
  12508. class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
  12509. {
  12510. protected const TYPE = 'markAliasUninstalled';
  12511. protected $package;
  12512. public function __construct(AliasPackage $package)
  12513. {
  12514. $this->package = $package;
  12515. }
  12516. public function getPackage(): AliasPackage
  12517. {
  12518. return $this->package;
  12519. }
  12520. public function show($lock): string
  12521. {
  12522. 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>)';
  12523. }
  12524. }
  12525. <?php declare(strict_types=1);
  12526. namespace Composer\DependencyResolver\Operation;
  12527. interface OperationInterface
  12528. {
  12529. public function getOperationType();
  12530. public function show(bool $lock);
  12531. public function __toString();
  12532. }
  12533. <?php declare(strict_types=1);
  12534. namespace Composer\DependencyResolver\Operation;
  12535. abstract class SolverOperation implements OperationInterface
  12536. {
  12537. protected const TYPE = '';
  12538. public function getOperationType(): string
  12539. {
  12540. return static::TYPE;
  12541. }
  12542. public function __toString()
  12543. {
  12544. return $this->show(false);
  12545. }
  12546. }
  12547. <?php declare(strict_types=1);
  12548. namespace Composer\DependencyResolver\Operation;
  12549. use Composer\Package\PackageInterface;
  12550. class UninstallOperation extends SolverOperation implements OperationInterface
  12551. {
  12552. protected const TYPE = 'uninstall';
  12553. protected $package;
  12554. public function __construct(PackageInterface $package)
  12555. {
  12556. $this->package = $package;
  12557. }
  12558. public function getPackage(): PackageInterface
  12559. {
  12560. return $this->package;
  12561. }
  12562. public function show($lock): string
  12563. {
  12564. return self::format($this->package, $lock);
  12565. }
  12566. public static function format(PackageInterface $package, bool $lock = false): string
  12567. {
  12568. return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  12569. }
  12570. }
  12571. <?php declare(strict_types=1);
  12572. namespace Composer\DependencyResolver\Operation;
  12573. use Composer\Package\PackageInterface;
  12574. use Composer\Package\Version\VersionParser;
  12575. class UpdateOperation extends SolverOperation implements OperationInterface
  12576. {
  12577. protected const TYPE = 'update';
  12578. protected $initialPackage;
  12579. protected $targetPackage;
  12580. public function __construct(PackageInterface $initial, PackageInterface $target)
  12581. {
  12582. $this->initialPackage = $initial;
  12583. $this->targetPackage = $target;
  12584. }
  12585. public function getInitialPackage(): PackageInterface
  12586. {
  12587. return $this->initialPackage;
  12588. }
  12589. public function getTargetPackage(): PackageInterface
  12590. {
  12591. return $this->targetPackage;
  12592. }
  12593. public function show($lock): string
  12594. {
  12595. return self::format($this->initialPackage, $this->targetPackage, $lock);
  12596. }
  12597. public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, bool $lock = false): string
  12598. {
  12599. $fromVersion = $initialPackage->getFullPrettyVersion();
  12600. $toVersion = $targetPackage->getFullPrettyVersion();
  12601. if ($fromVersion === $toVersion && $initialPackage->getSourceReference() !== $targetPackage->getSourceReference()) {
  12602. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  12603. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  12604. } elseif ($fromVersion === $toVersion && $initialPackage->getDistReference() !== $targetPackage->getDistReference()) {
  12605. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  12606. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  12607. }
  12608. $actionName = VersionParser::isUpgrade($initialPackage->getVersion(), $targetPackage->getVersion()) ? 'Upgrading' : 'Downgrading';
  12609. return $actionName.' <info>'.$initialPackage->getPrettyName().'</info> (<comment>'.$fromVersion.'</comment> => <comment>'.$toVersion.'</comment>)';
  12610. }
  12611. }
  12612. <?php declare(strict_types=1);
  12613. namespace Composer\DependencyResolver;
  12614. use Composer\Package\PackageInterface;
  12615. use Composer\Semver\Constraint\Constraint;
  12616. interface PolicyInterface
  12617. {
  12618. public function versionCompare(PackageInterface $a, PackageInterface $b, string $operator): bool;
  12619. public function selectPreferredPackages(Pool $pool, array $literals, ?string $requiredPackage = null): array;
  12620. }
  12621. <?php declare(strict_types=1);
  12622. namespace Composer\DependencyResolver;
  12623. use Composer\Package\BasePackage;
  12624. use Composer\Package\Version\VersionParser;
  12625. use Composer\Semver\CompilingMatcher;
  12626. use Composer\Semver\Constraint\ConstraintInterface;
  12627. use Composer\Semver\Constraint\Constraint;
  12628. class Pool implements \Countable
  12629. {
  12630. protected $packages = [];
  12631. protected $packageByName = [];
  12632. protected $versionParser;
  12633. protected $providerCache = [];
  12634. protected $unacceptableFixedOrLockedPackages;
  12635. protected $removedVersions = [];
  12636. protected $removedVersionsByPackage = [];
  12637. public function __construct(array $packages = [], array $unacceptableFixedOrLockedPackages = [], array $removedVersions = [], array $removedVersionsByPackage = [])
  12638. {
  12639. $this->versionParser = new VersionParser;
  12640. $this->setPackages($packages);
  12641. $this->unacceptableFixedOrLockedPackages = $unacceptableFixedOrLockedPackages;
  12642. $this->removedVersions = $removedVersions;
  12643. $this->removedVersionsByPackage = $removedVersionsByPackage;
  12644. }
  12645. public function getRemovedVersions(string $name, ConstraintInterface $constraint): array
  12646. {
  12647. if (!isset($this->removedVersions[$name])) {
  12648. return [];
  12649. }
  12650. $result = [];
  12651. foreach ($this->removedVersions[$name] as $version => $prettyVersion) {
  12652. if ($constraint->matches(new Constraint('==', $version))) {
  12653. $result[$version] = $prettyVersion;
  12654. }
  12655. }
  12656. return $result;
  12657. }
  12658. public function getRemovedVersionsByPackage(string $objectHash): array
  12659. {
  12660. if (!isset($this->removedVersionsByPackage[$objectHash])) {
  12661. return [];
  12662. }
  12663. return $this->removedVersionsByPackage[$objectHash];
  12664. }
  12665. private function setPackages(array $packages): void
  12666. {
  12667. $id = 1;
  12668. foreach ($packages as $package) {
  12669. $this->packages[] = $package;
  12670. $package->id = $id++;
  12671. foreach ($package->getNames() as $provided) {
  12672. $this->packageByName[$provided][] = $package;
  12673. }
  12674. }
  12675. }
  12676. public function getPackages(): array
  12677. {
  12678. return $this->packages;
  12679. }
  12680. public function packageById(int $id): BasePackage
  12681. {
  12682. return $this->packages[$id - 1];
  12683. }
  12684. public function count(): int
  12685. {
  12686. return \count($this->packages);
  12687. }
  12688. public function whatProvides(string $name, ?ConstraintInterface $constraint = null): array
  12689. {
  12690. $key = (string) $constraint;
  12691. if (isset($this->providerCache[$name][$key])) {
  12692. return $this->providerCache[$name][$key];
  12693. }
  12694. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint);
  12695. }
  12696. private function computeWhatProvides(string $name, ?ConstraintInterface $constraint = null): array
  12697. {
  12698. if (!isset($this->packageByName[$name])) {
  12699. return [];
  12700. }
  12701. $matches = [];
  12702. foreach ($this->packageByName[$name] as $candidate) {
  12703. if ($this->match($candidate, $name, $constraint)) {
  12704. $matches[] = $candidate;
  12705. }
  12706. }
  12707. return $matches;
  12708. }
  12709. public function literalToPackage(int $literal): BasePackage
  12710. {
  12711. $packageId = abs($literal);
  12712. return $this->packageById($packageId);
  12713. }
  12714. public function literalToPrettyString(int $literal, array $installedMap): string
  12715. {
  12716. $package = $this->literalToPackage($literal);
  12717. if (isset($installedMap[$package->id])) {
  12718. $prefix = ($literal > 0 ? 'keep' : 'remove');
  12719. } else {
  12720. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  12721. }
  12722. return $prefix.' '.$package->getPrettyString();
  12723. }
  12724. public function match(BasePackage $candidate, string $name, ?ConstraintInterface $constraint = null): bool
  12725. {
  12726. $candidateName = $candidate->getName();
  12727. $candidateVersion = $candidate->getVersion();
  12728. if ($candidateName === $name) {
  12729. return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
  12730. }
  12731. $provides = $candidate->getProvides();
  12732. $replaces = $candidate->getReplaces();
  12733. if (isset($replaces[0]) || isset($provides[0])) {
  12734. foreach ($provides as $link) {
  12735. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  12736. return true;
  12737. }
  12738. }
  12739. foreach ($replaces as $link) {
  12740. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  12741. return true;
  12742. }
  12743. }
  12744. return false;
  12745. }
  12746. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  12747. return true;
  12748. }
  12749. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  12750. return true;
  12751. }
  12752. return false;
  12753. }
  12754. public function isUnacceptableFixedOrLockedPackage(BasePackage $package): bool
  12755. {
  12756. return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
  12757. }
  12758. public function getUnacceptableFixedOrLockedPackages(): array
  12759. {
  12760. return $this->unacceptableFixedOrLockedPackages;
  12761. }
  12762. public function __toString(): string
  12763. {
  12764. $str = "Pool:\n";
  12765. foreach ($this->packages as $package) {
  12766. $str .= '- '.str_pad((string) $package->id, 6, ' ', STR_PAD_LEFT).': '.$package->getName()."\n";
  12767. }
  12768. return $str;
  12769. }
  12770. }
  12771. <?php declare(strict_types=1);
  12772. namespace Composer\DependencyResolver;
  12773. use Composer\EventDispatcher\EventDispatcher;
  12774. use Composer\IO\IOInterface;
  12775. use Composer\Package\AliasPackage;
  12776. use Composer\Package\BasePackage;
  12777. use Composer\Package\CompleteAliasPackage;
  12778. use Composer\Package\CompletePackage;
  12779. use Composer\Package\PackageInterface;
  12780. use Composer\Package\Version\StabilityFilter;
  12781. use Composer\Pcre\Preg;
  12782. use Composer\Plugin\PluginEvents;
  12783. use Composer\Plugin\PrePoolCreateEvent;
  12784. use Composer\Repository\PlatformRepository;
  12785. use Composer\Repository\RepositoryInterface;
  12786. use Composer\Repository\RootPackageRepository;
  12787. use Composer\Semver\CompilingMatcher;
  12788. use Composer\Semver\Constraint\Constraint;
  12789. use Composer\Semver\Constraint\ConstraintInterface;
  12790. use Composer\Semver\Constraint\MatchAllConstraint;
  12791. use Composer\Semver\Constraint\MultiConstraint;
  12792. use Composer\Semver\Intervals;
  12793. class PoolBuilder
  12794. {
  12795. private $acceptableStabilities;
  12796. private $stabilityFlags;
  12797. private $rootAliases;
  12798. private $rootReferences;
  12799. private $temporaryConstraints;
  12800. private $eventDispatcher;
  12801. private $poolOptimizer;
  12802. private $io;
  12803. private $aliasMap = [];
  12804. private $packagesToLoad = [];
  12805. private $loadedPackages = [];
  12806. private $loadedPerRepo = [];
  12807. private $packages = [];
  12808. private $unacceptableFixedOrLockedPackages = [];
  12809. private $updateAllowList = [];
  12810. private $skippedLoad = [];
  12811. private $ignoredTypes = [];
  12812. private $allowedTypes = null;
  12813. private $restrictedPackagesList = null;
  12814. private $pathRepoUnlocked = [];
  12815. private $maxExtendedReqs = [];
  12816. private $updateAllowWarned = [];
  12817. private $indexCounter = 0;
  12818. public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, ?EventDispatcher $eventDispatcher = null, ?PoolOptimizer $poolOptimizer = null, array $temporaryConstraints = [])
  12819. {
  12820. $this->acceptableStabilities = $acceptableStabilities;
  12821. $this->stabilityFlags = $stabilityFlags;
  12822. $this->rootAliases = $rootAliases;
  12823. $this->rootReferences = $rootReferences;
  12824. $this->eventDispatcher = $eventDispatcher;
  12825. $this->poolOptimizer = $poolOptimizer;
  12826. $this->io = $io;
  12827. $this->temporaryConstraints = $temporaryConstraints;
  12828. }
  12829. public function setIgnoredTypes(array $types): void
  12830. {
  12831. $this->ignoredTypes = $types;
  12832. }
  12833. public function setAllowedTypes(?array $types): void
  12834. {
  12835. $this->allowedTypes = $types;
  12836. }
  12837. public function buildPool(array $repositories, Request $request): Pool
  12838. {
  12839. $this->restrictedPackagesList = $request->getRestrictedPackages() !== null ? array_flip($request->getRestrictedPackages()) : null;
  12840. if (\count($request->getUpdateAllowList()) > 0) {
  12841. $this->updateAllowList = $request->getUpdateAllowList();
  12842. $this->warnAboutNonMatchingUpdateAllowList($request);
  12843. if (null === $request->getLockedRepository()) {
  12844. throw new \LogicException('No lock repo present and yet a partial update was requested.');
  12845. }
  12846. foreach ($request->getLockedRepository()->getPackages() as $lockedPackage) {
  12847. if (!$this->isUpdateAllowed($lockedPackage)) {
  12848. $this->skippedLoad[$lockedPackage->getName()][] = $lockedPackage;
  12849. foreach ($lockedPackage->getReplaces() as $link) {
  12850. $this->skippedLoad[$link->getTarget()][] = $lockedPackage;
  12851. }
  12852. if ($lockedPackage->getDistType() === 'path') {
  12853. $transportOptions = $lockedPackage->getTransportOptions();
  12854. if (!isset($transportOptions['symlink']) || $transportOptions['symlink'] !== false) {
  12855. $this->pathRepoUnlocked[$lockedPackage->getName()] = true;
  12856. continue;
  12857. }
  12858. }
  12859. $request->lockPackage($lockedPackage);
  12860. }
  12861. }
  12862. }
  12863. foreach ($request->getFixedOrLockedPackages() as $package) {
  12864. $this->loadedPackages[$package->getName()] = new MatchAllConstraint();
  12865. foreach ($package->getReplaces() as $link) {
  12866. $this->loadedPackages[$link->getTarget()] = new MatchAllConstraint();
  12867. }
  12868. if (
  12869. $package->getRepository() instanceof RootPackageRepository
  12870. || $package->getRepository() instanceof PlatformRepository
  12871. || StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $package->getNames(), $package->getStability())
  12872. ) {
  12873. $this->loadPackage($request, $repositories, $package, false);
  12874. } else {
  12875. $this->unacceptableFixedOrLockedPackages[] = $package;
  12876. }
  12877. }
  12878. foreach ($request->getRequires() as $packageName => $constraint) {
  12879. if (isset($this->loadedPackages[$packageName])) {
  12880. continue;
  12881. }
  12882. $this->packagesToLoad[$packageName] = $constraint;
  12883. $this->maxExtendedReqs[$packageName] = true;
  12884. }
  12885. foreach ($this->packagesToLoad as $name => $constraint) {
  12886. if (isset($this->loadedPackages[$name])) {
  12887. unset($this->packagesToLoad[$name]);
  12888. }
  12889. }
  12890. while (\count($this->packagesToLoad) > 0) {
  12891. $this->loadPackagesMarkedForLoading($request, $repositories);
  12892. }
  12893. if (\count($this->temporaryConstraints) > 0) {
  12894. foreach ($this->packages as $i => $package) {
  12895. if ($package instanceof AliasPackage) {
  12896. continue;
  12897. }
  12898. foreach ($package->getNames() as $packageName) {
  12899. if (!isset($this->temporaryConstraints[$packageName])) {
  12900. continue;
  12901. }
  12902. $constraint = $this->temporaryConstraints[$packageName];
  12903. $packageAndAliases = [$i => $package];
  12904. if (isset($this->aliasMap[spl_object_hash($package)])) {
  12905. $packageAndAliases += $this->aliasMap[spl_object_hash($package)];
  12906. }
  12907. $found = false;
  12908. foreach ($packageAndAliases as $packageOrAlias) {
  12909. if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) {
  12910. $found = true;
  12911. }
  12912. }
  12913. if (!$found) {
  12914. foreach ($packageAndAliases as $index => $packageOrAlias) {
  12915. unset($this->packages[$index]);
  12916. }
  12917. }
  12918. }
  12919. }
  12920. }
  12921. if ($this->eventDispatcher !== null) {
  12922. $prePoolCreateEvent = new PrePoolCreateEvent(
  12923. PluginEvents::PRE_POOL_CREATE,
  12924. $repositories,
  12925. $request,
  12926. $this->acceptableStabilities,
  12927. $this->stabilityFlags,
  12928. $this->rootAliases,
  12929. $this->rootReferences,
  12930. $this->packages,
  12931. $this->unacceptableFixedOrLockedPackages
  12932. );
  12933. $this->eventDispatcher->dispatch($prePoolCreateEvent->getName(), $prePoolCreateEvent);
  12934. $this->packages = $prePoolCreateEvent->getPackages();
  12935. $this->unacceptableFixedOrLockedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
  12936. }
  12937. $pool = new Pool($this->packages, $this->unacceptableFixedOrLockedPackages);
  12938. $this->aliasMap = [];
  12939. $this->packagesToLoad = [];
  12940. $this->loadedPackages = [];
  12941. $this->loadedPerRepo = [];
  12942. $this->packages = [];
  12943. $this->unacceptableFixedOrLockedPackages = [];
  12944. $this->maxExtendedReqs = [];
  12945. $this->skippedLoad = [];
  12946. $this->indexCounter = 0;
  12947. $this->io->debug('Built pool.');
  12948. $pool = $this->runOptimizer($request, $pool);
  12949. Intervals::clear();
  12950. return $pool;
  12951. }
  12952. private function markPackageNameForLoading(Request $request, string $name, ConstraintInterface $constraint): void
  12953. {
  12954. if (PlatformRepository::isPlatformPackage($name)) {
  12955. return;
  12956. }
  12957. if (isset($this->maxExtendedReqs[$name])) {
  12958. return;
  12959. }
  12960. $rootRequires = $request->getRequires();
  12961. if (isset($rootRequires[$name]) && !Intervals::isSubsetOf($constraint, $rootRequires[$name])) {
  12962. $constraint = $rootRequires[$name];
  12963. }
  12964. if (!isset($this->loadedPackages[$name])) {
  12965. if (isset($this->packagesToLoad[$name])) {
  12966. if (Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
  12967. return;
  12968. }
  12969. $constraint = Intervals::compactConstraint(MultiConstraint::create([$this->packagesToLoad[$name], $constraint], false));
  12970. }
  12971. $this->packagesToLoad[$name] = $constraint;
  12972. return;
  12973. }
  12974. if (Intervals::isSubsetOf($constraint, $this->loadedPackages[$name])) {
  12975. return;
  12976. }
  12977. $this->packagesToLoad[$name] = Intervals::compactConstraint(MultiConstraint::create([$this->loadedPackages[$name], $constraint], false));
  12978. unset($this->loadedPackages[$name]);
  12979. }
  12980. private function loadPackagesMarkedForLoading(Request $request, array $repositories): void
  12981. {
  12982. foreach ($this->packagesToLoad as $name => $constraint) {
  12983. if ($this->restrictedPackagesList !== null && !isset($this->restrictedPackagesList[$name])) {
  12984. unset($this->packagesToLoad[$name]);
  12985. continue;
  12986. }
  12987. $this->loadedPackages[$name] = $constraint;
  12988. }
  12989. $packageBatch = $this->packagesToLoad;
  12990. $this->packagesToLoad = [];
  12991. foreach ($repositories as $repoIndex => $repository) {
  12992. if (0 === \count($packageBatch)) {
  12993. break;
  12994. }
  12995. if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
  12996. continue;
  12997. }
  12998. $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, $this->loadedPerRepo[$repoIndex] ?? []);
  12999. foreach ($result['namesFound'] as $name) {
  13000. unset($packageBatch[$name]);
  13001. }
  13002. foreach ($result['packages'] as $package) {
  13003. $this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()] = $package;
  13004. if (in_array($package->getType(), $this->ignoredTypes, true) || ($this->allowedTypes !== null && !in_array($package->getType(), $this->allowedTypes, true))) {
  13005. continue;
  13006. }
  13007. $this->loadPackage($request, $repositories, $package, !isset($this->pathRepoUnlocked[$package->getName()]));
  13008. }
  13009. }
  13010. }
  13011. private function loadPackage(Request $request, array $repositories, BasePackage $package, bool $propagateUpdate): void
  13012. {
  13013. $index = $this->indexCounter++;
  13014. $this->packages[$index] = $package;
  13015. if ($package instanceof AliasPackage) {
  13016. $this->aliasMap[spl_object_hash($package->getAliasOf())][$index] = $package;
  13017. }
  13018. $name = $package->getName();
  13019. if (isset($this->rootReferences[$name])) {
  13020. if (!$request->isLockedPackage($package) && !$request->isFixedPackage($package)) {
  13021. $package->setSourceDistReferences($this->rootReferences[$name]);
  13022. }
  13023. }
  13024. if (($propagateUpdate || isset($this->pathRepoUnlocked[$package->getName()])) && isset($this->rootAliases[$name][$package->getVersion()])) {
  13025. $alias = $this->rootAliases[$name][$package->getVersion()];
  13026. if ($package instanceof AliasPackage) {
  13027. $basePackage = $package->getAliasOf();
  13028. } else {
  13029. $basePackage = $package;
  13030. }
  13031. if ($basePackage instanceof CompletePackage) {
  13032. $aliasPackage = new CompleteAliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  13033. } else {
  13034. $aliasPackage = new AliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  13035. }
  13036. $aliasPackage->setRootPackageAlias(true);
  13037. $newIndex = $this->indexCounter++;
  13038. $this->packages[$newIndex] = $aliasPackage;
  13039. $this->aliasMap[spl_object_hash($aliasPackage->getAliasOf())][$newIndex] = $aliasPackage;
  13040. }
  13041. foreach ($package->getRequires() as $link) {
  13042. $require = $link->getTarget();
  13043. $linkConstraint = $link->getConstraint();
  13044. if (isset($this->skippedLoad[$require])) {
  13045. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  13046. $skippedRootRequires = $this->getSkippedRootRequires($request, $require);
  13047. if ($request->getUpdateAllowTransitiveRootDependencies() || 0 === \count($skippedRootRequires)) {
  13048. $this->unlockPackage($request, $repositories, $require);
  13049. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  13050. } else {
  13051. foreach ($skippedRootRequires as $rootRequire) {
  13052. if (!isset($this->updateAllowWarned[$rootRequire])) {
  13053. $this->updateAllowWarned[$rootRequire] = true;
  13054. $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>');
  13055. }
  13056. }
  13057. }
  13058. } elseif (isset($this->pathRepoUnlocked[$require]) && !isset($this->loadedPackages[$require])) {
  13059. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  13060. }
  13061. } else {
  13062. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  13063. }
  13064. }
  13065. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  13066. foreach ($package->getReplaces() as $link) {
  13067. $replace = $link->getTarget();
  13068. if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
  13069. $skippedRootRequires = $this->getSkippedRootRequires($request, $replace);
  13070. if ($request->getUpdateAllowTransitiveRootDependencies() || 0 === \count($skippedRootRequires)) {
  13071. $this->unlockPackage($request, $repositories, $replace);
  13072. $this->markPackageNameForLoadingIfRequired($request, $replace);
  13073. } else {
  13074. foreach ($skippedRootRequires as $rootRequire) {
  13075. if (!isset($this->updateAllowWarned[$rootRequire])) {
  13076. $this->updateAllowWarned[$rootRequire] = true;
  13077. $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>');
  13078. }
  13079. }
  13080. }
  13081. }
  13082. }
  13083. }
  13084. }
  13085. private function isRootRequire(Request $request, string $name): bool
  13086. {
  13087. $rootRequires = $request->getRequires();
  13088. return isset($rootRequires[$name]);
  13089. }
  13090. private function getSkippedRootRequires(Request $request, string $name): array
  13091. {
  13092. if (!isset($this->skippedLoad[$name])) {
  13093. return [];
  13094. }
  13095. $rootRequires = $request->getRequires();
  13096. $matches = [];
  13097. if (isset($rootRequires[$name])) {
  13098. return array_map(static function (PackageInterface $package) use ($name): string {
  13099. if ($name !== $package->getName()) {
  13100. return $package->getName() .' (via replace of '.$name.')';
  13101. }
  13102. return $package->getName();
  13103. }, $this->skippedLoad[$name]);
  13104. }
  13105. foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
  13106. if (isset($rootRequires[$packageOrReplacer->getName()])) {
  13107. $matches[] = $packageOrReplacer->getName();
  13108. }
  13109. foreach ($packageOrReplacer->getReplaces() as $link) {
  13110. if (isset($rootRequires[$link->getTarget()])) {
  13111. if ($name !== $packageOrReplacer->getName()) {
  13112. $matches[] = $packageOrReplacer->getName() .' (via replace of '.$name.')';
  13113. } else {
  13114. $matches[] = $packageOrReplacer->getName();
  13115. }
  13116. break;
  13117. }
  13118. }
  13119. }
  13120. return $matches;
  13121. }
  13122. private function isUpdateAllowed(BasePackage $package): bool
  13123. {
  13124. foreach ($this->updateAllowList as $pattern) {
  13125. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  13126. if (Preg::isMatch($patternRegexp, $package->getName())) {
  13127. return true;
  13128. }
  13129. }
  13130. return false;
  13131. }
  13132. private function warnAboutNonMatchingUpdateAllowList(Request $request): void
  13133. {
  13134. if (null === $request->getLockedRepository()) {
  13135. throw new \LogicException('No lock repo present and yet a partial update was requested.');
  13136. }
  13137. foreach ($this->updateAllowList as $pattern) {
  13138. $matchedPlatformPackage = false;
  13139. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  13140. foreach ($request->getLockedRepository()->getPackages() as $package) {
  13141. if (Preg::isMatch($patternRegexp, $package->getName())) {
  13142. continue 2;
  13143. }
  13144. }
  13145. foreach ($request->getRequires() as $packageName => $constraint) {
  13146. if (Preg::isMatch($patternRegexp, $packageName)) {
  13147. if (PlatformRepository::isPlatformPackage($packageName)) {
  13148. $matchedPlatformPackage = true;
  13149. continue;
  13150. }
  13151. continue 2;
  13152. }
  13153. }
  13154. if ($matchedPlatformPackage) {
  13155. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update matches platform packages, but these cannot be updated by Composer.</warning>');
  13156. } elseif (strpos($pattern, '*') !== false) {
  13157. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update does not match any locked packages.</warning>');
  13158. } else {
  13159. $this->io->writeError('<warning>Package "' . $pattern . '" listed for update is not locked.</warning>');
  13160. }
  13161. }
  13162. }
  13163. private function unlockPackage(Request $request, array $repositories, string $name): void
  13164. {
  13165. foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
  13166. if ($packageOrReplacer->getName() !== $name && isset($this->skippedLoad[$packageOrReplacer->getName()])) {
  13167. $replacerName = $packageOrReplacer->getName();
  13168. if ($request->getUpdateAllowTransitiveRootDependencies() || (!$this->isRootRequire($request, $name) && !$this->isRootRequire($request, $replacerName))) {
  13169. $this->unlockPackage($request, $repositories, $replacerName);
  13170. if ($this->isRootRequire($request, $replacerName)) {
  13171. $this->markPackageNameForLoading($request, $replacerName, new MatchAllConstraint);
  13172. } else {
  13173. foreach ($this->packages as $loadedPackage) {
  13174. $requires = $loadedPackage->getRequires();
  13175. if (isset($requires[$replacerName])) {
  13176. $this->markPackageNameForLoading($request, $replacerName, $requires[$replacerName]->getConstraint());
  13177. }
  13178. }
  13179. }
  13180. }
  13181. }
  13182. }
  13183. if (isset($this->pathRepoUnlocked[$name])) {
  13184. foreach ($this->packages as $index => $package) {
  13185. if ($package->getName() === $name) {
  13186. $this->removeLoadedPackage($request, $repositories, $package, $index);
  13187. }
  13188. }
  13189. }
  13190. unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name], $this->pathRepoUnlocked[$name]);
  13191. foreach ($request->getLockedPackages() as $lockedPackage) {
  13192. if (!($lockedPackage instanceof AliasPackage) && $lockedPackage->getName() === $name) {
  13193. if (false !== $index = array_search($lockedPackage, $this->packages, true)) {
  13194. $request->unlockPackage($lockedPackage);
  13195. $this->removeLoadedPackage($request, $repositories, $lockedPackage, $index);
  13196. foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
  13197. if ($fixedOrLockedPackage === $lockedPackage) {
  13198. continue;
  13199. }
  13200. if (isset($this->skippedLoad[$fixedOrLockedPackage->getName()])) {
  13201. $requires = $fixedOrLockedPackage->getRequires();
  13202. if (isset($requires[$lockedPackage->getName()])) {
  13203. $this->markPackageNameForLoading($request, $lockedPackage->getName(), $requires[$lockedPackage->getName()]->getConstraint());
  13204. }
  13205. foreach ($lockedPackage->getReplaces() as $replace) {
  13206. if (isset($requires[$replace->getTarget()], $this->skippedLoad[$replace->getTarget()])) {
  13207. $this->unlockPackage($request, $repositories, $replace->getTarget());
  13208. $this->markPackageNameForLoading($request, $replace->getTarget(), $replace->getConstraint());
  13209. }
  13210. }
  13211. }
  13212. }
  13213. }
  13214. }
  13215. }
  13216. }
  13217. private function markPackageNameForLoadingIfRequired(Request $request, string $name): void
  13218. {
  13219. if ($this->isRootRequire($request, $name)) {
  13220. $this->markPackageNameForLoading($request, $name, $request->getRequires()[$name]);
  13221. }
  13222. foreach ($this->packages as $package) {
  13223. foreach ($package->getRequires() as $link) {
  13224. if ($name === $link->getTarget()) {
  13225. $this->markPackageNameForLoading($request, $link->getTarget(), $link->getConstraint());
  13226. }
  13227. }
  13228. }
  13229. }
  13230. private function removeLoadedPackage(Request $request, array $repositories, BasePackage $package, int $index): void
  13231. {
  13232. $repoIndex = array_search($package->getRepository(), $repositories, true);
  13233. unset($this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()]);
  13234. unset($this->packages[$index]);
  13235. if (isset($this->aliasMap[spl_object_hash($package)])) {
  13236. foreach ($this->aliasMap[spl_object_hash($package)] as $aliasIndex => $aliasPackage) {
  13237. unset($this->loadedPerRepo[$repoIndex][$aliasPackage->getName()][$aliasPackage->getVersion()]);
  13238. unset($this->packages[$aliasIndex]);
  13239. }
  13240. unset($this->aliasMap[spl_object_hash($package)]);
  13241. }
  13242. }
  13243. private function runOptimizer(Request $request, Pool $pool): Pool
  13244. {
  13245. if (null === $this->poolOptimizer) {
  13246. return $pool;
  13247. }
  13248. $this->io->debug('Running pool optimizer.');
  13249. $before = microtime(true);
  13250. $total = \count($pool->getPackages());
  13251. $pool = $this->poolOptimizer->optimize($request, $pool);
  13252. $filtered = $total - \count($pool->getPackages());
  13253. if (0 === $filtered) {
  13254. return $pool;
  13255. }
  13256. $this->io->write(sprintf('Pool optimizer completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERY_VERBOSE);
  13257. $this->io->write(sprintf(
  13258. '<info>Found %s package versions referenced in your dependency graph. %s (%d%%) were optimized away.</info>',
  13259. number_format($total),
  13260. number_format($filtered),
  13261. round(100 / $total * $filtered)
  13262. ), true, IOInterface::VERY_VERBOSE);
  13263. return $pool;
  13264. }
  13265. }
  13266. <?php declare(strict_types=1);
  13267. namespace Composer\DependencyResolver;
  13268. use Composer\Package\AliasPackage;
  13269. use Composer\Package\BasePackage;
  13270. use Composer\Package\Version\VersionParser;
  13271. use Composer\Semver\CompilingMatcher;
  13272. use Composer\Semver\Constraint\ConstraintInterface;
  13273. use Composer\Semver\Constraint\Constraint;
  13274. use Composer\Semver\Constraint\MultiConstraint;
  13275. use Composer\Semver\Intervals;
  13276. class PoolOptimizer
  13277. {
  13278. private $policy;
  13279. private $irremovablePackages = [];
  13280. private $requireConstraintsPerPackage = [];
  13281. private $conflictConstraintsPerPackage = [];
  13282. private $packagesToRemove = [];
  13283. private $aliasesPerPackage = [];
  13284. private $removedVersionsByPackage = [];
  13285. public function __construct(PolicyInterface $policy)
  13286. {
  13287. $this->policy = $policy;
  13288. }
  13289. public function optimize(Request $request, Pool $pool): Pool
  13290. {
  13291. $this->prepare($request, $pool);
  13292. $this->optimizeByIdenticalDependencies($request, $pool);
  13293. $this->optimizeImpossiblePackagesAway($request, $pool);
  13294. $optimizedPool = $this->applyRemovalsToPool($pool);
  13295. $this->irremovablePackages = [];
  13296. $this->requireConstraintsPerPackage = [];
  13297. $this->conflictConstraintsPerPackage = [];
  13298. $this->packagesToRemove = [];
  13299. $this->aliasesPerPackage = [];
  13300. $this->removedVersionsByPackage = [];
  13301. return $optimizedPool;
  13302. }
  13303. private function prepare(Request $request, Pool $pool): void
  13304. {
  13305. $irremovablePackageConstraintGroups = [];
  13306. foreach ($request->getFixedOrLockedPackages() as $package) {
  13307. $irremovablePackageConstraintGroups[$package->getName()][] = new Constraint('==', $package->getVersion());
  13308. }
  13309. foreach ($request->getRequires() as $require => $constraint) {
  13310. $this->extractRequireConstraintsPerPackage($require, $constraint);
  13311. }
  13312. foreach ($pool->getPackages() as $package) {
  13313. foreach ($package->getRequires() as $link) {
  13314. $this->extractRequireConstraintsPerPackage($link->getTarget(), $link->getConstraint());
  13315. }
  13316. foreach ($package->getConflicts() as $link) {
  13317. $this->extractConflictConstraintsPerPackage($link->getTarget(), $link->getConstraint());
  13318. }
  13319. if ($package instanceof AliasPackage) {
  13320. $this->aliasesPerPackage[$package->getAliasOf()->id][] = $package;
  13321. }
  13322. }
  13323. $irremovablePackageConstraints = [];
  13324. foreach ($irremovablePackageConstraintGroups as $packageName => $constraints) {
  13325. $irremovablePackageConstraints[$packageName] = 1 === \count($constraints) ? $constraints[0] : new MultiConstraint($constraints, false);
  13326. }
  13327. unset($irremovablePackageConstraintGroups);
  13328. foreach ($pool->getPackages() as $package) {
  13329. if (!isset($irremovablePackageConstraints[$package->getName()])) {
  13330. continue;
  13331. }
  13332. if (CompilingMatcher::match($irremovablePackageConstraints[$package->getName()], Constraint::OP_EQ, $package->getVersion())) {
  13333. $this->markPackageIrremovable($package);
  13334. }
  13335. }
  13336. }
  13337. private function markPackageIrremovable(BasePackage $package): void
  13338. {
  13339. $this->irremovablePackages[$package->id] = true;
  13340. if ($package instanceof AliasPackage) {
  13341. $this->markPackageIrremovable($package->getAliasOf());
  13342. }
  13343. if (isset($this->aliasesPerPackage[$package->id])) {
  13344. foreach ($this->aliasesPerPackage[$package->id] as $aliasPackage) {
  13345. $this->irremovablePackages[$aliasPackage->id] = true;
  13346. }
  13347. }
  13348. }
  13349. private function applyRemovalsToPool(Pool $pool): Pool
  13350. {
  13351. $packages = [];
  13352. $removedVersions = [];
  13353. foreach ($pool->getPackages() as $package) {
  13354. if (!isset($this->packagesToRemove[$package->id])) {
  13355. $packages[] = $package;
  13356. } else {
  13357. $removedVersions[$package->getName()][$package->getVersion()] = $package->getPrettyVersion();
  13358. }
  13359. }
  13360. $optimizedPool = new Pool($packages, $pool->getUnacceptableFixedOrLockedPackages(), $removedVersions, $this->removedVersionsByPackage);
  13361. return $optimizedPool;
  13362. }
  13363. private function optimizeByIdenticalDependencies(Request $request, Pool $pool): void
  13364. {
  13365. $identicalDefinitionsPerPackage = [];
  13366. $packageIdenticalDefinitionLookup = [];
  13367. foreach ($pool->getPackages() as $package) {
  13368. if (isset($this->irremovablePackages[$package->id])) {
  13369. continue;
  13370. }
  13371. $this->markPackageForRemoval($package->id);
  13372. $dependencyHash = $this->calculateDependencyHash($package);
  13373. foreach ($package->getNames(false) as $packageName) {
  13374. if (!isset($this->requireConstraintsPerPackage[$packageName])) {
  13375. continue;
  13376. }
  13377. foreach ($this->requireConstraintsPerPackage[$packageName] as $requireConstraint) {
  13378. $groupHashParts = [];
  13379. if (CompilingMatcher::match($requireConstraint, Constraint::OP_EQ, $package->getVersion())) {
  13380. $groupHashParts[] = 'require:' . (string) $requireConstraint;
  13381. }
  13382. if (\count($package->getReplaces()) > 0) {
  13383. foreach ($package->getReplaces() as $link) {
  13384. if (CompilingMatcher::match($link->getConstraint(), Constraint::OP_EQ, $package->getVersion())) {
  13385. $groupHashParts[] = 'require:' . (string) $link->getConstraint();
  13386. }
  13387. }
  13388. }
  13389. if (isset($this->conflictConstraintsPerPackage[$packageName])) {
  13390. foreach ($this->conflictConstraintsPerPackage[$packageName] as $conflictConstraint) {
  13391. if (CompilingMatcher::match($conflictConstraint, Constraint::OP_EQ, $package->getVersion())) {
  13392. $groupHashParts[] = 'conflict:' . (string) $conflictConstraint;
  13393. }
  13394. }
  13395. }
  13396. if (0 === \count($groupHashParts)) {
  13397. continue;
  13398. }
  13399. $groupHash = implode('', $groupHashParts);
  13400. $identicalDefinitionsPerPackage[$packageName][$groupHash][$dependencyHash][] = $package;
  13401. $packageIdenticalDefinitionLookup[$package->id][$packageName] = ['groupHash' => $groupHash, 'dependencyHash' => $dependencyHash];
  13402. }
  13403. }
  13404. }
  13405. foreach ($identicalDefinitionsPerPackage as $constraintGroups) {
  13406. foreach ($constraintGroups as $constraintGroup) {
  13407. foreach ($constraintGroup as $packages) {
  13408. if (1 === \count($packages)) {
  13409. $this->keepPackage($packages[0], $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  13410. continue;
  13411. }
  13412. $literals = [];
  13413. foreach ($packages as $package) {
  13414. $literals[] = $package->id;
  13415. }
  13416. foreach ($this->policy->selectPreferredPackages($pool, $literals) as $preferredLiteral) {
  13417. $this->keepPackage($pool->literalToPackage($preferredLiteral), $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  13418. }
  13419. }
  13420. }
  13421. }
  13422. }
  13423. private function calculateDependencyHash(BasePackage $package): string
  13424. {
  13425. $hash = '';
  13426. $hashRelevantLinks = [
  13427. 'requires' => $package->getRequires(),
  13428. 'conflicts' => $package->getConflicts(),
  13429. 'replaces' => $package->getReplaces(),
  13430. 'provides' => $package->getProvides(),
  13431. ];
  13432. foreach ($hashRelevantLinks as $key => $links) {
  13433. if (0 === \count($links)) {
  13434. continue;
  13435. }
  13436. $hash .= $key . ':';
  13437. $subhash = [];
  13438. foreach ($links as $link) {
  13439. $subhash[$link->getTarget()] = (string) $link->getConstraint();
  13440. }
  13441. ksort($subhash);
  13442. foreach ($subhash as $target => $constraint) {
  13443. $hash .= $target . '@' . $constraint;
  13444. }
  13445. }
  13446. return $hash;
  13447. }
  13448. private function markPackageForRemoval(int $id): void
  13449. {
  13450. if (isset($this->irremovablePackages[$id])) {
  13451. throw new \LogicException('Attempted removing a package which was previously marked irremovable');
  13452. }
  13453. $this->packagesToRemove[$id] = true;
  13454. }
  13455. private function keepPackage(BasePackage $package, array $identicalDefinitionsPerPackage, array $packageIdenticalDefinitionLookup): void
  13456. {
  13457. if (!isset($this->packagesToRemove[$package->id])) {
  13458. return;
  13459. }
  13460. unset($this->packagesToRemove[$package->id]);
  13461. if ($package instanceof AliasPackage) {
  13462. $this->keepPackage($package->getAliasOf(), $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  13463. }
  13464. foreach ($package->getNames(false) as $name) {
  13465. if (isset($packageIdenticalDefinitionLookup[$package->id][$name])) {
  13466. $packageGroupPointers = $packageIdenticalDefinitionLookup[$package->id][$name];
  13467. $packageGroup = $identicalDefinitionsPerPackage[$name][$packageGroupPointers['groupHash']][$packageGroupPointers['dependencyHash']];
  13468. foreach ($packageGroup as $pkg) {
  13469. if ($pkg instanceof AliasPackage && $pkg->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  13470. $pkg = $pkg->getAliasOf();
  13471. }
  13472. $this->removedVersionsByPackage[spl_object_hash($package)][$pkg->getVersion()] = $pkg->getPrettyVersion();
  13473. }
  13474. }
  13475. }
  13476. if (isset($this->aliasesPerPackage[$package->id])) {
  13477. foreach ($this->aliasesPerPackage[$package->id] as $aliasPackage) {
  13478. unset($this->packagesToRemove[$aliasPackage->id]);
  13479. foreach ($aliasPackage->getNames(false) as $name) {
  13480. if (isset($packageIdenticalDefinitionLookup[$aliasPackage->id][$name])) {
  13481. $packageGroupPointers = $packageIdenticalDefinitionLookup[$aliasPackage->id][$name];
  13482. $packageGroup = $identicalDefinitionsPerPackage[$name][$packageGroupPointers['groupHash']][$packageGroupPointers['dependencyHash']];
  13483. foreach ($packageGroup as $pkg) {
  13484. if ($pkg instanceof AliasPackage && $pkg->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  13485. $pkg = $pkg->getAliasOf();
  13486. }
  13487. $this->removedVersionsByPackage[spl_object_hash($aliasPackage)][$pkg->getVersion()] = $pkg->getPrettyVersion();
  13488. }
  13489. }
  13490. }
  13491. }
  13492. }
  13493. }
  13494. private function optimizeImpossiblePackagesAway(Request $request, Pool $pool): void
  13495. {
  13496. if (\count($request->getLockedPackages()) === 0) {
  13497. return;
  13498. }
  13499. $packageIndex = [];
  13500. foreach ($pool->getPackages() as $package) {
  13501. $id = $package->id;
  13502. if (isset($this->irremovablePackages[$id])) {
  13503. continue;
  13504. }
  13505. if (isset($this->aliasesPerPackage[$id]) || $package instanceof AliasPackage) {
  13506. continue;
  13507. }
  13508. if ($request->isFixedPackage($package) || $request->isLockedPackage($package)) {
  13509. continue;
  13510. }
  13511. $packageIndex[$package->getName()][$package->id] = $package;
  13512. }
  13513. foreach ($request->getLockedPackages() as $package) {
  13514. $isUnusedPackage = true;
  13515. foreach ($package->getNames(false) as $packageName) {
  13516. if (isset($this->requireConstraintsPerPackage[$packageName])) {
  13517. $isUnusedPackage = false;
  13518. break;
  13519. }
  13520. }
  13521. if ($isUnusedPackage) {
  13522. continue;
  13523. }
  13524. foreach ($package->getRequires() as $link) {
  13525. $require = $link->getTarget();
  13526. if (!isset($packageIndex[$require])) {
  13527. continue;
  13528. }
  13529. $linkConstraint = $link->getConstraint();
  13530. foreach ($packageIndex[$require] as $id => $requiredPkg) {
  13531. if (false === CompilingMatcher::match($linkConstraint, Constraint::OP_EQ, $requiredPkg->getVersion())) {
  13532. $this->markPackageForRemoval($id);
  13533. unset($packageIndex[$require][$id]);
  13534. }
  13535. }
  13536. }
  13537. }
  13538. }
  13539. private function extractRequireConstraintsPerPackage(string $package, ConstraintInterface $constraint)
  13540. {
  13541. foreach ($this->expandDisjunctiveMultiConstraints($constraint) as $expanded) {
  13542. $this->requireConstraintsPerPackage[$package][(string) $expanded] = $expanded;
  13543. }
  13544. }
  13545. private function extractConflictConstraintsPerPackage(string $package, ConstraintInterface $constraint)
  13546. {
  13547. foreach ($this->expandDisjunctiveMultiConstraints($constraint) as $expanded) {
  13548. $this->conflictConstraintsPerPackage[$package][(string) $expanded] = $expanded;
  13549. }
  13550. }
  13551. private function expandDisjunctiveMultiConstraints(ConstraintInterface $constraint)
  13552. {
  13553. $constraint = Intervals::compactConstraint($constraint);
  13554. if ($constraint instanceof MultiConstraint && $constraint->isDisjunctive()) {
  13555. return $constraint->getConstraints();
  13556. }
  13557. return [$constraint];
  13558. }
  13559. }
  13560. <?php declare(strict_types=1);
  13561. namespace Composer\DependencyResolver;
  13562. use Composer\Package\CompletePackageInterface;
  13563. use Composer\Package\AliasPackage;
  13564. use Composer\Package\BasePackage;
  13565. use Composer\Package\Link;
  13566. use Composer\Package\PackageInterface;
  13567. use Composer\Package\RootPackageInterface;
  13568. use Composer\Pcre\Preg;
  13569. use Composer\Repository\RepositorySet;
  13570. use Composer\Repository\LockArrayRepository;
  13571. use Composer\Semver\Constraint\Constraint;
  13572. use Composer\Semver\Constraint\ConstraintInterface;
  13573. use Composer\Package\Version\VersionParser;
  13574. use Composer\Repository\PlatformRepository;
  13575. use Composer\Semver\Constraint\MultiConstraint;
  13576. class Problem
  13577. {
  13578. protected $reasonSeen;
  13579. protected $reasons = [];
  13580. protected $section = 0;
  13581. public function addRule(Rule $rule): void
  13582. {
  13583. $this->addReason(spl_object_hash($rule), $rule);
  13584. }
  13585. public function getReasons(): array
  13586. {
  13587. return $this->reasons;
  13588. }
  13589. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = [], array $learnedPool = []): string
  13590. {
  13591. $reasons = array_merge(...array_reverse($this->reasons));
  13592. if (\count($reasons) === 1) {
  13593. reset($reasons);
  13594. $rule = current($reasons);
  13595. if ($rule->getReason() !== Rule::RULE_ROOT_REQUIRE) {
  13596. throw new \LogicException("Single reason problems must contain a root require rule.");
  13597. }
  13598. $reasonData = $rule->getReasonData();
  13599. $packageName = $reasonData['packageName'];
  13600. $constraint = $reasonData['constraint'];
  13601. $packages = $pool->whatProvides($packageName, $constraint);
  13602. if (\count($packages) === 0) {
  13603. return "\n ".implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
  13604. }
  13605. }
  13606. usort($reasons, function (Rule $rule1, Rule $rule2) use ($pool) {
  13607. $rule1Prio = $this->getRulePriority($rule1);
  13608. $rule2Prio = $this->getRulePriority($rule2);
  13609. if ($rule1Prio !== $rule2Prio) {
  13610. return $rule2Prio - $rule1Prio;
  13611. }
  13612. return $this->getSortableString($pool, $rule1) <=> $this->getSortableString($pool, $rule2);
  13613. });
  13614. return self::formatDeduplicatedRules($reasons, ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  13615. }
  13616. private function getSortableString(Pool $pool, Rule $rule): string
  13617. {
  13618. switch ($rule->getReason()) {
  13619. case Rule::RULE_ROOT_REQUIRE:
  13620. return $rule->getReasonData()['packageName'];
  13621. case Rule::RULE_FIXED:
  13622. return (string) $rule->getReasonData()['package'];
  13623. case Rule::RULE_PACKAGE_CONFLICT:
  13624. case Rule::RULE_PACKAGE_REQUIRES:
  13625. return $rule->getSourcePackage($pool) . '//' . $rule->getReasonData()->getPrettyString($rule->getSourcePackage($pool));
  13626. case Rule::RULE_PACKAGE_SAME_NAME:
  13627. case Rule::RULE_PACKAGE_ALIAS:
  13628. case Rule::RULE_PACKAGE_INVERSE_ALIAS:
  13629. return (string) $rule->getReasonData();
  13630. case Rule::RULE_LEARNED:
  13631. return implode('-', $rule->getLiterals());
  13632. }
  13633. throw new \LogicException('Unknown rule type: '.$rule->getReason());
  13634. }
  13635. private function getRulePriority(Rule $rule): int
  13636. {
  13637. switch ($rule->getReason()) {
  13638. case Rule::RULE_FIXED:
  13639. return 3;
  13640. case Rule::RULE_ROOT_REQUIRE:
  13641. return 2;
  13642. case Rule::RULE_PACKAGE_CONFLICT:
  13643. case Rule::RULE_PACKAGE_REQUIRES:
  13644. return 1;
  13645. case Rule::RULE_PACKAGE_SAME_NAME:
  13646. case Rule::RULE_LEARNED:
  13647. case Rule::RULE_PACKAGE_ALIAS:
  13648. case Rule::RULE_PACKAGE_INVERSE_ALIAS:
  13649. return 0;
  13650. }
  13651. throw new \LogicException('Unknown rule type: '.$rule->getReason());
  13652. }
  13653. public static function formatDeduplicatedRules(array $rules, string $indent, RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = [], array $learnedPool = []): string
  13654. {
  13655. $messages = [];
  13656. $templates = [];
  13657. $parser = new VersionParser;
  13658. $deduplicatableRuleTypes = [Rule::RULE_PACKAGE_REQUIRES, Rule::RULE_PACKAGE_CONFLICT];
  13659. foreach ($rules as $rule) {
  13660. $message = $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  13661. if (in_array($rule->getReason(), $deduplicatableRuleTypes, true) && Preg::isMatchStrictGroups('{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}', $message, $m)) {
  13662. $message = str_replace('%', '%%', $message);
  13663. $template = Preg::replace('{^\S+ \S+ }', '%s%s ', $message);
  13664. $messages[] = $template;
  13665. $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2];
  13666. $sourcePackage = $rule->getSourcePackage($pool);
  13667. foreach ($pool->getRemovedVersionsByPackage(spl_object_hash($sourcePackage)) as $version => $prettyVersion) {
  13668. $templates[$template][$m[1]][$version] = $prettyVersion;
  13669. }
  13670. } elseif ($message !== '') {
  13671. $messages[] = $message;
  13672. }
  13673. }
  13674. $result = [];
  13675. foreach (array_unique($messages) as $message) {
  13676. if (isset($templates[$message])) {
  13677. foreach ($templates[$message] as $package => $versions) {
  13678. uksort($versions, 'version_compare');
  13679. if (!$isVerbose) {
  13680. $versions = self::condenseVersionList($versions, 1);
  13681. }
  13682. if (\count($versions) > 1) {
  13683. $message = Preg::replace('{^(%s%s (?:require|conflict))s}', '$1', $message);
  13684. $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');
  13685. } else {
  13686. $result[] = sprintf($message, $package, ' '.reset($versions));
  13687. }
  13688. }
  13689. } else {
  13690. $result[] = $message;
  13691. }
  13692. }
  13693. return "\n$indent- ".implode("\n$indent- ", $result);
  13694. }
  13695. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool): bool
  13696. {
  13697. foreach ($this->reasons as $sectionRules) {
  13698. foreach ($sectionRules as $rule) {
  13699. if ($rule->isCausedByLock($repositorySet, $request, $pool)) {
  13700. return true;
  13701. }
  13702. }
  13703. }
  13704. return false;
  13705. }
  13706. protected function addReason(string $id, Rule $reason): void
  13707. {
  13708. if (!isset($this->reasonSeen[$id])) {
  13709. $this->reasonSeen[$id] = true;
  13710. $this->reasons[$this->section][] = $reason;
  13711. }
  13712. }
  13713. public function nextSection(): void
  13714. {
  13715. $this->section++;
  13716. }
  13717. public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, string $packageName, ?ConstraintInterface $constraint = null): array
  13718. {
  13719. if (PlatformRepository::isPlatformPackage($packageName)) {
  13720. if (0 === stripos($packageName, 'php') || $packageName === 'hhvm') {
  13721. $version = self::getPlatformPackageVersion($pool, $packageName, phpversion());
  13722. $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
  13723. if (defined('HHVM_VERSION') || ($packageName === 'hhvm' && count($pool->whatProvides($packageName)) > 0)) {
  13724. return [$msg, 'your HHVM version does not satisfy that requirement.'];
  13725. }
  13726. if ($packageName === 'hhvm') {
  13727. return [$msg, 'HHVM was not detected on this machine, make sure it is in your PATH.'];
  13728. }
  13729. if (null === $version) {
  13730. return [$msg, 'the '.$packageName.' package is disabled by your platform config. Enable it again with "composer config platform.'.$packageName.' --unset".'];
  13731. }
  13732. return [$msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.'];
  13733. }
  13734. if (0 === stripos($packageName, 'ext-')) {
  13735. if (false !== strpos($packageName, ' ')) {
  13736. return ['- ', "PHP extension ".$packageName.' should be required as '.str_replace(' ', '-', $packageName).'.'];
  13737. }
  13738. $ext = substr($packageName, 4);
  13739. $msg = "- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ';
  13740. $version = self::getPlatformPackageVersion($pool, $packageName, phpversion($ext) === false ? '0' : phpversion($ext));
  13741. if (null === $version) {
  13742. $providersStr = self::getProvidersList($repositorySet, $packageName, 5);
  13743. if ($providersStr !== null) {
  13744. $providersStr = "\n\n Alternatively you can require one of these packages that provide the extension (or parts of it):\n".
  13745. " <warning>Keep in mind that the suggestions are automated and may not be valid or safe to use</warning>\n$providersStr";
  13746. }
  13747. if (extension_loaded($ext)) {
  13748. return [
  13749. $msg,
  13750. 'the '.$packageName.' package is disabled by your platform config. Enable it again with "composer config platform.'.$packageName.' --unset".' . $providersStr,
  13751. ];
  13752. }
  13753. return [$msg, 'it is missing from your system. Install or enable PHP\'s '.$ext.' extension.' . $providersStr];
  13754. }
  13755. return [$msg, 'it has the wrong version installed ('.$version.').'];
  13756. }
  13757. if (0 === stripos($packageName, 'lib-')) {
  13758. if (strtolower($packageName) === 'lib-icu') {
  13759. $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.';
  13760. return ["- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', $error];
  13761. }
  13762. $providersStr = self::getProvidersList($repositorySet, $packageName, 5);
  13763. if ($providersStr !== null) {
  13764. $providersStr = "\n\n Alternatively you can require one of these packages that provide the library (or parts of it):\n".
  13765. " <warning>Keep in mind that the suggestions are automated and may not be valid or safe to use</warning>\n$providersStr";
  13766. }
  13767. 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.'.$providersStr];
  13768. }
  13769. }
  13770. $lockedPackage = null;
  13771. foreach ($request->getLockedPackages() as $package) {
  13772. if ($package->getName() === $packageName) {
  13773. $lockedPackage = $package;
  13774. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  13775. 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.'];
  13776. }
  13777. break;
  13778. }
  13779. }
  13780. if ($constraint instanceof Constraint && $constraint->getOperator() === Constraint::STR_OP_EQ && Preg::isMatch('{^dev-.*#.*}', $constraint->getPrettyString())) {
  13781. $newConstraint = Preg::replace('{ +as +([^,\s|]+)$}', '', $constraint->getPrettyString());
  13782. $packages = $repositorySet->findPackages($packageName, new MultiConstraint([
  13783. new Constraint(Constraint::STR_OP_EQ, $newConstraint),
  13784. new Constraint(Constraint::STR_OP_EQ, str_replace('#', '+', $newConstraint))
  13785. ], false));
  13786. if (\count($packages) > 0) {
  13787. return ["- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).'. The # character in branch names is replaced by a + character. Make sure to require it as "'.str_replace('#', '+', $constraint->getPrettyString()).'".'];
  13788. }
  13789. }
  13790. $packages = $repositorySet->findPackages($packageName, $constraint);
  13791. if (\count($packages) > 0) {
  13792. $rootReqs = $repositorySet->getRootRequires();
  13793. if (isset($rootReqs[$packageName])) {
  13794. $filtered = array_filter($packages, static function ($p) use ($rootReqs, $packageName): bool {
  13795. return $rootReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  13796. });
  13797. if (0 === count($filtered)) {
  13798. 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().').'];
  13799. }
  13800. }
  13801. $tempReqs = $repositorySet->getTemporaryConstraints();
  13802. foreach (reset($packages)->getNames() as $name) {
  13803. if (isset($tempReqs[$name])) {
  13804. $filtered = array_filter($packages, static function ($p) use ($tempReqs, $name): bool {
  13805. return $tempReqs[$name]->matches(new Constraint('==', $p->getVersion()));
  13806. });
  13807. if (0 === count($filtered)) {
  13808. return ["- Root composer.json requires $name".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but '.(self::hasMultipleNames($packages) ? 'these conflict' : 'it conflicts').' with your temporary update constraint ('.$name.':'.$tempReqs[$name]->getPrettyString().').'];
  13809. }
  13810. }
  13811. }
  13812. if ($lockedPackage !== null) {
  13813. $fixedConstraint = new Constraint('==', $lockedPackage->getVersion());
  13814. $filtered = array_filter($packages, static function ($p) use ($fixedConstraint): bool {
  13815. return $fixedConstraint->matches(new Constraint('==', $p->getVersion()));
  13816. });
  13817. if (0 === count($filtered)) {
  13818. 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.'];
  13819. }
  13820. }
  13821. $nonLockedPackages = array_filter($packages, static function ($p): bool {
  13822. return !$p->getRepository() instanceof LockArrayRepository;
  13823. });
  13824. if (0 === \count($nonLockedPackages)) {
  13825. 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.'];
  13826. }
  13827. 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.'];
  13828. }
  13829. $packages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES);
  13830. if (\count($packages) > 0) {
  13831. $allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES);
  13832. if (\count($allReposPackages) > 0) {
  13833. return self::computeCheckForLowerPrioRepo($pool, $isVerbose, $packageName, $packages, $allReposPackages, 'minimum-stability', $constraint);
  13834. }
  13835. 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.'];
  13836. }
  13837. $packages = $repositorySet->findPackages($packageName, null, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES);
  13838. if (\count($packages) > 0) {
  13839. $allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES);
  13840. if (\count($allReposPackages) > 0) {
  13841. return self::computeCheckForLowerPrioRepo($pool, $isVerbose, $packageName, $packages, $allReposPackages, 'constraint', $constraint);
  13842. }
  13843. $suffix = '';
  13844. if ($constraint instanceof Constraint && $constraint->getVersion() === 'dev-master') {
  13845. foreach ($packages as $candidate) {
  13846. if (in_array($candidate->getVersion(), ['dev-default', 'dev-main'], true)) {
  13847. $suffix = ' Perhaps dev-master was renamed to '.$candidate->getPrettyVersion().'?';
  13848. break;
  13849. }
  13850. }
  13851. }
  13852. $allReposPackages = $packages;
  13853. $topPackage = reset($allReposPackages);
  13854. if ($topPackage instanceof RootPackageInterface) {
  13855. $suffix = ' See https://getcomposer.org/dep-on-root for details and assistance.';
  13856. }
  13857. 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];
  13858. }
  13859. if (!Preg::isMatch('{^[A-Za-z0-9_./-]+$}', $packageName)) {
  13860. $illegalChars = Preg::replace('{[A-Za-z0-9_./-]+}', '', $packageName);
  13861. 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.'];
  13862. }
  13863. $providersStr = self::getProvidersList($repositorySet, $packageName, 15);
  13864. if ($providersStr !== null) {
  13865. 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."];
  13866. }
  13867. return ["- Root composer.json requires $packageName, it ", "could not be found in any version, there may be a typo in the package name."];
  13868. }
  13869. public static function getPackageList(array $packages, bool $isVerbose, ?Pool $pool = null, ?ConstraintInterface $constraint = null, bool $useRemovedVersionGroup = false): string
  13870. {
  13871. $prepared = [];
  13872. $hasDefaultBranch = [];
  13873. foreach ($packages as $package) {
  13874. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  13875. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
  13876. if ($pool !== null && $constraint !== null) {
  13877. foreach ($pool->getRemovedVersions($package->getName(), $constraint) as $version => $prettyVersion) {
  13878. $prepared[$package->getName()]['versions'][$version] = $prettyVersion;
  13879. }
  13880. }
  13881. if ($pool !== null && $useRemovedVersionGroup) {
  13882. foreach ($pool->getRemovedVersionsByPackage(spl_object_hash($package)) as $version => $prettyVersion) {
  13883. $prepared[$package->getName()]['versions'][$version] = $prettyVersion;
  13884. }
  13885. }
  13886. if ($package->isDefaultBranch()) {
  13887. $hasDefaultBranch[$package->getName()] = true;
  13888. }
  13889. }
  13890. $preparedStrings = [];
  13891. foreach ($prepared as $name => $package) {
  13892. if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
  13893. unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
  13894. }
  13895. uksort($package['versions'], 'version_compare');
  13896. if (!$isVerbose) {
  13897. $package['versions'] = self::condenseVersionList($package['versions'], 4);
  13898. }
  13899. $preparedStrings[] = $package['name'].'['.implode(', ', $package['versions']).']';
  13900. }
  13901. return implode(', ', $preparedStrings);
  13902. }
  13903. private static function getPlatformPackageVersion(Pool $pool, string $packageName, string $version): ?string
  13904. {
  13905. $available = $pool->whatProvides($packageName);
  13906. if (\count($available) > 0) {
  13907. $selected = null;
  13908. foreach ($available as $pkg) {
  13909. if ($pkg->getRepository() instanceof PlatformRepository) {
  13910. $selected = $pkg;
  13911. break;
  13912. }
  13913. }
  13914. if ($selected === null) {
  13915. $selected = reset($available);
  13916. }
  13917. if ($selected->getName() !== $packageName) {
  13918. foreach (array_merge(array_values($selected->getProvides()), array_values($selected->getReplaces())) as $link) {
  13919. if ($link->getTarget() === $packageName) {
  13920. return $link->getPrettyConstraint().' '.substr($link->getDescription(), 0, -1).'d by '.$selected->getPrettyString();
  13921. }
  13922. }
  13923. }
  13924. $version = $selected->getPrettyVersion();
  13925. $extra = $selected->getExtra();
  13926. if ($selected instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  13927. $version .= '; ' . str_replace('Package ', '', (string) $selected->getDescription());
  13928. }
  13929. } else {
  13930. return null;
  13931. }
  13932. return $version;
  13933. }
  13934. private static function condenseVersionList(array $versions, int $max, int $maxDev = 16): array
  13935. {
  13936. if (count($versions) <= $max) {
  13937. return array_values($versions);
  13938. }
  13939. $filtered = [];
  13940. $byMajor = [];
  13941. foreach ($versions as $version => $pretty) {
  13942. if (0 === stripos((string) $version, 'dev-')) {
  13943. $byMajor['dev'][] = $pretty;
  13944. } else {
  13945. $byMajor[Preg::replace('{^(\d+)\..*}', '$1', (string) $version)][] = $pretty;
  13946. }
  13947. }
  13948. foreach ($byMajor as $majorVersion => $versionsForMajor) {
  13949. $maxVersions = $majorVersion === 'dev' ? $maxDev : $max;
  13950. if (count($versionsForMajor) > $maxVersions) {
  13951. $filtered[] = $versionsForMajor[0];
  13952. $filtered[] = '...';
  13953. $filtered[] = $versionsForMajor[count($versionsForMajor) - 1];
  13954. } else {
  13955. $filtered = array_merge($filtered, $versionsForMajor);
  13956. }
  13957. }
  13958. return $filtered;
  13959. }
  13960. private static function hasMultipleNames(array $packages): bool
  13961. {
  13962. $name = null;
  13963. foreach ($packages as $package) {
  13964. if ($name === null || $name === $package->getName()) {
  13965. $name = $package->getName();
  13966. } else {
  13967. return true;
  13968. }
  13969. }
  13970. return false;
  13971. }
  13972. private static function computeCheckForLowerPrioRepo(Pool $pool, bool $isVerbose, string $packageName, array $higherRepoPackages, array $allReposPackages, string $reason, ?ConstraintInterface $constraint = null): array
  13973. {
  13974. $nextRepoPackages = [];
  13975. $nextRepo = null;
  13976. foreach ($allReposPackages as $package) {
  13977. if ($nextRepo === null || $nextRepo === $package->getRepository()) {
  13978. $nextRepoPackages[] = $package;
  13979. $nextRepo = $package->getRepository();
  13980. } else {
  13981. break;
  13982. }
  13983. }
  13984. assert(null !== $nextRepo);
  13985. if (\count($higherRepoPackages) > 0) {
  13986. $topPackage = reset($higherRepoPackages);
  13987. if ($topPackage instanceof RootPackageInterface) {
  13988. return [
  13989. "- Root composer.json requires $packageName".self::constraintToText($constraint).', it is ',
  13990. 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' from '.$nextRepo->getRepoName().' but '.$topPackage->getPrettyName().' '.$topPackage->getPrettyVersion().' is the root package and cannot be modified. See https://getcomposer.org/dep-on-root for details and assistance.',
  13991. ];
  13992. }
  13993. }
  13994. if ($nextRepo instanceof LockArrayRepository) {
  13995. $singular = count($higherRepoPackages) === 1;
  13996. $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).').';
  13997. if ($nextRepoPackages[0]->getDistType() === 'path') {
  13998. $transportOptions = $nextRepoPackages[0]->getTransportOptions();
  13999. if (!isset($transportOptions['symlink']) || $transportOptions['symlink'] !== false) {
  14000. $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.';
  14001. }
  14002. }
  14003. return ["- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ',
  14004. '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,
  14005. ];
  14006. }
  14007. 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.'];
  14008. }
  14009. protected static function constraintToText(?ConstraintInterface $constraint = null): string
  14010. {
  14011. if ($constraint instanceof Constraint && $constraint->getOperator() === Constraint::STR_OP_EQ && !str_starts_with($constraint->getVersion(), 'dev-')) {
  14012. if (!Preg::isMatch('{^\d+(?:\.\d+)*$}', $constraint->getPrettyString())) {
  14013. return ' '.$constraint->getPrettyString() .' (exact version match)';
  14014. }
  14015. $versions = [$constraint->getPrettyString()];
  14016. for ($i = 3 - substr_count($versions[0], '.'); $i > 0; $i--) {
  14017. $versions[] = end($versions) . '.0';
  14018. }
  14019. return ' ' . $constraint->getPrettyString() . ' (exact version match: ' . (count($versions) > 1 ? implode(', ', array_slice($versions, 0, -1)) . ' or ' . end($versions) : $versions[0]) . ')';
  14020. }
  14021. return $constraint !== null ? ' '.$constraint->getPrettyString() : '';
  14022. }
  14023. private static function getProvidersList(RepositorySet $repositorySet, string $packageName, int $maxProviders): ?string
  14024. {
  14025. $providers = $repositorySet->getProviders($packageName);
  14026. if (\count($providers) > 0) {
  14027. $providersStr = implode(array_map(static function ($p): string {
  14028. $description = $p['description'] !== '' && $p['description'] !== null ? ' '.substr($p['description'], 0, 100) : '';
  14029. return ' - '.$p['name'].$description."\n";
  14030. }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers));
  14031. if (count($providers) > $maxProviders + 1) {
  14032. $providersStr .= ' ... and '.(count($providers) - $maxProviders).' more.'."\n";
  14033. }
  14034. return $providersStr;
  14035. }
  14036. return null;
  14037. }
  14038. }
  14039. <?php declare(strict_types=1);
  14040. namespace Composer\DependencyResolver;
  14041. use Composer\Package\BasePackage;
  14042. use Composer\Package\PackageInterface;
  14043. use Composer\Repository\LockArrayRepository;
  14044. use Composer\Semver\Constraint\ConstraintInterface;
  14045. use Composer\Semver\Constraint\MatchAllConstraint;
  14046. class Request
  14047. {
  14048. public const UPDATE_ONLY_LISTED = 0;
  14049. public const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
  14050. public const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
  14051. protected $lockedRepository;
  14052. protected $requires = [];
  14053. protected $fixedPackages = [];
  14054. protected $lockedPackages = [];
  14055. protected $fixedLockedPackages = [];
  14056. protected $updateAllowList = [];
  14057. protected $updateAllowTransitiveDependencies = false;
  14058. private $restrictedPackages = null;
  14059. public function __construct(?LockArrayRepository $lockedRepository = null)
  14060. {
  14061. $this->lockedRepository = $lockedRepository;
  14062. }
  14063. public function requireName(string $packageName, ?ConstraintInterface $constraint = null): void
  14064. {
  14065. $packageName = strtolower($packageName);
  14066. if ($constraint === null) {
  14067. $constraint = new MatchAllConstraint();
  14068. }
  14069. if (isset($this->requires[$packageName])) {
  14070. 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');
  14071. }
  14072. $this->requires[$packageName] = $constraint;
  14073. }
  14074. public function fixPackage(BasePackage $package): void
  14075. {
  14076. $this->fixedPackages[spl_object_hash($package)] = $package;
  14077. }
  14078. public function lockPackage(BasePackage $package): void
  14079. {
  14080. $this->lockedPackages[spl_object_hash($package)] = $package;
  14081. }
  14082. public function fixLockedPackage(BasePackage $package): void
  14083. {
  14084. $this->fixedPackages[spl_object_hash($package)] = $package;
  14085. $this->fixedLockedPackages[spl_object_hash($package)] = $package;
  14086. }
  14087. public function unlockPackage(BasePackage $package): void
  14088. {
  14089. unset($this->lockedPackages[spl_object_hash($package)]);
  14090. }
  14091. public function setUpdateAllowList(array $updateAllowList, $updateAllowTransitiveDependencies): void
  14092. {
  14093. $this->updateAllowList = $updateAllowList;
  14094. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  14095. }
  14096. public function getUpdateAllowList(): array
  14097. {
  14098. return $this->updateAllowList;
  14099. }
  14100. public function getUpdateAllowTransitiveDependencies(): bool
  14101. {
  14102. return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
  14103. }
  14104. public function getUpdateAllowTransitiveRootDependencies(): bool
  14105. {
  14106. return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  14107. }
  14108. public function getRequires(): array
  14109. {
  14110. return $this->requires;
  14111. }
  14112. public function getFixedPackages(): array
  14113. {
  14114. return $this->fixedPackages;
  14115. }
  14116. public function isFixedPackage(BasePackage $package): bool
  14117. {
  14118. return isset($this->fixedPackages[spl_object_hash($package)]);
  14119. }
  14120. public function getLockedPackages(): array
  14121. {
  14122. return $this->lockedPackages;
  14123. }
  14124. public function isLockedPackage(PackageInterface $package): bool
  14125. {
  14126. return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
  14127. }
  14128. public function getFixedOrLockedPackages(): array
  14129. {
  14130. return array_merge($this->fixedPackages, $this->lockedPackages);
  14131. }
  14132. public function getPresentMap(bool $packageIds = false): array
  14133. {
  14134. $presentMap = [];
  14135. if ($this->lockedRepository !== null) {
  14136. foreach ($this->lockedRepository->getPackages() as $package) {
  14137. $presentMap[$packageIds ? $package->getId() : spl_object_hash($package)] = $package;
  14138. }
  14139. }
  14140. foreach ($this->fixedPackages as $package) {
  14141. $presentMap[$packageIds ? $package->getId() : spl_object_hash($package)] = $package;
  14142. }
  14143. return $presentMap;
  14144. }
  14145. public function getFixedPackagesMap(): array
  14146. {
  14147. $fixedPackagesMap = [];
  14148. foreach ($this->fixedPackages as $package) {
  14149. $fixedPackagesMap[$package->getId()] = $package;
  14150. }
  14151. return $fixedPackagesMap;
  14152. }
  14153. public function getLockedRepository(): ?LockArrayRepository
  14154. {
  14155. return $this->lockedRepository;
  14156. }
  14157. public function restrictPackages(array $names): void
  14158. {
  14159. $this->restrictedPackages = $names;
  14160. }
  14161. public function getRestrictedPackages(): ?array
  14162. {
  14163. return $this->restrictedPackages;
  14164. }
  14165. }
  14166. <?php declare(strict_types=1);
  14167. namespace Composer\DependencyResolver;
  14168. use Composer\Package\AliasPackage;
  14169. use Composer\Package\BasePackage;
  14170. use Composer\Package\Link;
  14171. use Composer\Repository\PlatformRepository;
  14172. use Composer\Repository\RepositorySet;
  14173. use Composer\Package\Version\VersionParser;
  14174. use Composer\Semver\Constraint\Constraint;
  14175. use Composer\Semver\Constraint\ConstraintInterface;
  14176. abstract class Rule
  14177. {
  14178. public const RULE_ROOT_REQUIRE = 2;
  14179. public const RULE_FIXED = 3;
  14180. public const RULE_PACKAGE_CONFLICT = 6;
  14181. public const RULE_PACKAGE_REQUIRES = 7;
  14182. public const RULE_PACKAGE_SAME_NAME = 10;
  14183. public const RULE_LEARNED = 12;
  14184. public const RULE_PACKAGE_ALIAS = 13;
  14185. public const RULE_PACKAGE_INVERSE_ALIAS = 14;
  14186. private const BITFIELD_TYPE = 0;
  14187. private const BITFIELD_REASON = 8;
  14188. private const BITFIELD_DISABLED = 16;
  14189. protected $bitfield;
  14190. protected $request;
  14191. protected $reasonData;
  14192. public function __construct($reason, $reasonData)
  14193. {
  14194. $this->reasonData = $reasonData;
  14195. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  14196. ($reason << self::BITFIELD_REASON) |
  14197. (255 << self::BITFIELD_TYPE);
  14198. }
  14199. abstract public function getLiterals(): array;
  14200. abstract public function getHash();
  14201. abstract public function __toString(): string;
  14202. abstract public function equals(Rule $rule): bool;
  14203. public function getReason(): int
  14204. {
  14205. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  14206. }
  14207. public function getReasonData()
  14208. {
  14209. return $this->reasonData;
  14210. }
  14211. public function getRequiredPackage(): ?string
  14212. {
  14213. switch ($this->getReason()) {
  14214. case self::RULE_ROOT_REQUIRE:
  14215. return $this->getReasonData()['packageName'];
  14216. case self::RULE_FIXED:
  14217. return $this->getReasonData()['package']->getName();
  14218. case self::RULE_PACKAGE_REQUIRES:
  14219. return $this->getReasonData()->getTarget();
  14220. }
  14221. return null;
  14222. }
  14223. public function setType($type): void
  14224. {
  14225. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  14226. }
  14227. public function getType(): int
  14228. {
  14229. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  14230. }
  14231. public function disable(): void
  14232. {
  14233. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  14234. }
  14235. public function enable(): void
  14236. {
  14237. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  14238. }
  14239. public function isDisabled(): bool
  14240. {
  14241. return 0 !== (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  14242. }
  14243. public function isEnabled(): bool
  14244. {
  14245. return 0 === (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  14246. }
  14247. abstract public function isAssertion(): bool;
  14248. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool): bool
  14249. {
  14250. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  14251. if (PlatformRepository::isPlatformPackage($this->getReasonData()->getTarget())) {
  14252. return false;
  14253. }
  14254. if ($request->getLockedRepository() !== null) {
  14255. foreach ($request->getLockedRepository()->getPackages() as $package) {
  14256. if ($package->getName() === $this->getReasonData()->getTarget()) {
  14257. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  14258. return true;
  14259. }
  14260. if (!$this->getReasonData()->getConstraint()->matches(new Constraint('=', $package->getVersion()))) {
  14261. return true;
  14262. }
  14263. if (!$request->isLockedPackage($package)) {
  14264. return true;
  14265. }
  14266. break;
  14267. }
  14268. }
  14269. }
  14270. }
  14271. if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
  14272. if (PlatformRepository::isPlatformPackage($this->getReasonData()['packageName'])) {
  14273. return false;
  14274. }
  14275. if ($request->getLockedRepository() !== null) {
  14276. foreach ($request->getLockedRepository()->getPackages() as $package) {
  14277. if ($package->getName() === $this->getReasonData()['packageName']) {
  14278. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  14279. return true;
  14280. }
  14281. if (!$this->getReasonData()['constraint']->matches(new Constraint('=', $package->getVersion()))) {
  14282. return true;
  14283. }
  14284. break;
  14285. }
  14286. }
  14287. }
  14288. }
  14289. return false;
  14290. }
  14291. public function getSourcePackage(Pool $pool): BasePackage
  14292. {
  14293. $literals = $this->getLiterals();
  14294. switch ($this->getReason()) {
  14295. case self::RULE_PACKAGE_CONFLICT:
  14296. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  14297. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  14298. $reasonData = $this->getReasonData();
  14299. if ($reasonData->getSource() === $package1->getName()) {
  14300. [$package2, $package1] = [$package1, $package2];
  14301. }
  14302. return $package2;
  14303. case self::RULE_PACKAGE_REQUIRES:
  14304. $sourceLiteral = $literals[0];
  14305. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  14306. return $sourcePackage;
  14307. default:
  14308. throw new \LogicException('Not implemented');
  14309. }
  14310. }
  14311. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, array $installedMap = [], array $learnedPool = []): string
  14312. {
  14313. $literals = $this->getLiterals();
  14314. switch ($this->getReason()) {
  14315. case self::RULE_ROOT_REQUIRE:
  14316. $reasonData = $this->getReasonData();
  14317. $packageName = $reasonData['packageName'];
  14318. $constraint = $reasonData['constraint'];
  14319. $packages = $pool->whatProvides($packageName, $constraint);
  14320. if (0 === \count($packages)) {
  14321. return 'No package found to satisfy root composer.json require '.$packageName.' '.$constraint->getPrettyString();
  14322. }
  14323. $packagesNonAlias = array_values(array_filter($packages, static function ($p): bool {
  14324. return !($p instanceof AliasPackage);
  14325. }));
  14326. if (\count($packagesNonAlias) === 1) {
  14327. $package = $packagesNonAlias[0];
  14328. if ($request->isLockedPackage($package)) {
  14329. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion()." and an update of this package was not requested.";
  14330. }
  14331. }
  14332. return 'Root composer.json requires '.$packageName.' '.$constraint->getPrettyString().' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose, $constraint).'.';
  14333. case self::RULE_FIXED:
  14334. $package = $this->deduplicateDefaultBranchAlias($this->getReasonData()['package']);
  14335. if ($request->isLockedPackage($package)) {
  14336. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
  14337. }
  14338. return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
  14339. case self::RULE_PACKAGE_CONFLICT:
  14340. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  14341. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  14342. $conflictTarget = $package1->getPrettyString();
  14343. $reasonData = $this->getReasonData();
  14344. if ($reasonData->getSource() === $package1->getName()) {
  14345. [$package2, $package1] = [$package1, $package2];
  14346. $conflictTarget = $package1->getPrettyName().' '.$reasonData->getPrettyConstraint();
  14347. }
  14348. if ($reasonData->getTarget() !== $package1->getName()) {
  14349. $provideType = null;
  14350. $provided = null;
  14351. foreach ($package1->getProvides() as $provide) {
  14352. if ($provide->getTarget() === $reasonData->getTarget()) {
  14353. $provideType = 'provides';
  14354. $provided = $provide->getPrettyConstraint();
  14355. break;
  14356. }
  14357. }
  14358. foreach ($package1->getReplaces() as $replace) {
  14359. if ($replace->getTarget() === $reasonData->getTarget()) {
  14360. $provideType = 'replaces';
  14361. $provided = $replace->getPrettyConstraint();
  14362. break;
  14363. }
  14364. }
  14365. if (null !== $provideType) {
  14366. $conflictTarget = $reasonData->getTarget().' '.$reasonData->getPrettyConstraint().' ('.$package1->getPrettyString().' '.$provideType.' '.$reasonData->getTarget().' '.$provided.')';
  14367. }
  14368. }
  14369. return $package2->getPrettyString().' conflicts with '.$conflictTarget.'.';
  14370. case self::RULE_PACKAGE_REQUIRES:
  14371. assert(\count($literals) > 0);
  14372. $sourceLiteral = array_shift($literals);
  14373. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  14374. $reasonData = $this->getReasonData();
  14375. $requires = [];
  14376. foreach ($literals as $literal) {
  14377. $requires[] = $pool->literalToPackage($literal);
  14378. }
  14379. $text = $reasonData->getPrettyString($sourcePackage);
  14380. if (\count($requires) > 0) {
  14381. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires, $isVerbose, $reasonData->getConstraint()) . '.';
  14382. } else {
  14383. $targetName = $reasonData->getTarget();
  14384. $reason = Problem::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $targetName, $reasonData->getConstraint());
  14385. return $text . ' -> ' . $reason[1];
  14386. }
  14387. return $text;
  14388. case self::RULE_PACKAGE_SAME_NAME:
  14389. $packageNames = [];
  14390. foreach ($literals as $literal) {
  14391. $package = $pool->literalToPackage($literal);
  14392. $packageNames[$package->getName()] = true;
  14393. }
  14394. unset($literal);
  14395. $replacedName = $this->getReasonData();
  14396. if (\count($packageNames) > 1) {
  14397. if (!isset($packageNames[$replacedName])) {
  14398. $reason = 'They '.(\count($literals) === 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.';
  14399. } else {
  14400. $replacerNames = $packageNames;
  14401. unset($replacerNames[$replacedName]);
  14402. $replacerNames = array_keys($replacerNames);
  14403. if (\count($replacerNames) === 1) {
  14404. $reason = $replacerNames[0] . ' replaces ';
  14405. } else {
  14406. $reason = '['.implode(', ', $replacerNames).'] replace ';
  14407. }
  14408. $reason .= $replacedName.' and thus cannot coexist with it.';
  14409. }
  14410. $installedPackages = [];
  14411. $removablePackages = [];
  14412. foreach ($literals as $literal) {
  14413. if (isset($installedMap[abs($literal)])) {
  14414. $installedPackages[] = $pool->literalToPackage($literal);
  14415. } else {
  14416. $removablePackages[] = $pool->literalToPackage($literal);
  14417. }
  14418. }
  14419. if (\count($installedPackages) > 0 && \count($removablePackages) > 0) {
  14420. return $this->formatPackagesUnique($pool, $removablePackages, $isVerbose, null, true).' cannot be installed as that would require removing '.$this->formatPackagesUnique($pool, $installedPackages, $isVerbose, null, true).'. '.$reason;
  14421. }
  14422. return 'Only one of these can be installed: '.$this->formatPackagesUnique($pool, $literals, $isVerbose, null, true).'. '.$reason;
  14423. }
  14424. 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) . '.';
  14425. case self::RULE_LEARNED:
  14426. $learnedString = ' (conflict analysis result)';
  14427. if (\count($literals) === 1) {
  14428. $ruleText = $pool->literalToPrettyString($literals[0], $installedMap);
  14429. } else {
  14430. $groups = [];
  14431. foreach ($literals as $literal) {
  14432. $package = $pool->literalToPackage($literal);
  14433. if (isset($installedMap[$package->id])) {
  14434. $group = $literal > 0 ? 'keep' : 'remove';
  14435. } else {
  14436. $group = $literal > 0 ? 'install' : 'don\'t install';
  14437. }
  14438. $groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
  14439. }
  14440. $ruleTexts = [];
  14441. foreach ($groups as $group => $packages) {
  14442. $ruleTexts[] = $group . (\count($packages) > 1 ? ' one of' : '').' ' . $this->formatPackagesUnique($pool, $packages, $isVerbose);
  14443. }
  14444. $ruleText = implode(' | ', $ruleTexts);
  14445. }
  14446. return 'Conclusion: '.$ruleText.$learnedString;
  14447. case self::RULE_PACKAGE_ALIAS:
  14448. $aliasPackage = $pool->literalToPackage($literals[0]);
  14449. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  14450. return '';
  14451. }
  14452. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  14453. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
  14454. case self::RULE_PACKAGE_INVERSE_ALIAS:
  14455. $aliasPackage = $pool->literalToPackage($literals[1]);
  14456. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  14457. return '';
  14458. }
  14459. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  14460. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and must be installed with it.';
  14461. default:
  14462. $ruleText = '';
  14463. foreach ($literals as $i => $literal) {
  14464. if ($i !== 0) {
  14465. $ruleText .= '|';
  14466. }
  14467. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  14468. }
  14469. return '('.$ruleText.')';
  14470. }
  14471. }
  14472. protected function formatPackagesUnique(Pool $pool, array $literalsOrPackages, bool $isVerbose, ?ConstraintInterface $constraint = null, bool $useRemovedVersionGroup = false): string
  14473. {
  14474. $packages = [];
  14475. foreach ($literalsOrPackages as $package) {
  14476. $packages[] = \is_object($package) ? $package : $pool->literalToPackage($package);
  14477. }
  14478. return Problem::getPackageList($packages, $isVerbose, $pool, $constraint, $useRemovedVersionGroup);
  14479. }
  14480. private function deduplicateDefaultBranchAlias(BasePackage $package): BasePackage
  14481. {
  14482. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  14483. $package = $package->getAliasOf();
  14484. }
  14485. return $package;
  14486. }
  14487. }
  14488. <?php declare(strict_types=1);
  14489. namespace Composer\DependencyResolver;
  14490. class Rule2Literals extends Rule
  14491. {
  14492. protected $literal1;
  14493. protected $literal2;
  14494. public function __construct(int $literal1, int $literal2, $reason, $reasonData)
  14495. {
  14496. parent::__construct($reason, $reasonData);
  14497. if ($literal1 < $literal2) {
  14498. $this->literal1 = $literal1;
  14499. $this->literal2 = $literal2;
  14500. } else {
  14501. $this->literal1 = $literal2;
  14502. $this->literal2 = $literal1;
  14503. }
  14504. }
  14505. public function getLiterals(): array
  14506. {
  14507. return [$this->literal1, $this->literal2];
  14508. }
  14509. public function getHash()
  14510. {
  14511. return $this->literal1.','.$this->literal2;
  14512. }
  14513. public function equals(Rule $rule): bool
  14514. {
  14515. if ($rule instanceof self) {
  14516. if ($this->literal1 !== $rule->literal1) {
  14517. return false;
  14518. }
  14519. if ($this->literal2 !== $rule->literal2) {
  14520. return false;
  14521. }
  14522. return true;
  14523. }
  14524. $literals = $rule->getLiterals();
  14525. if (2 !== \count($literals)) {
  14526. return false;
  14527. }
  14528. if ($this->literal1 !== $literals[0]) {
  14529. return false;
  14530. }
  14531. if ($this->literal2 !== $literals[1]) {
  14532. return false;
  14533. }
  14534. return true;
  14535. }
  14536. public function isAssertion(): bool
  14537. {
  14538. return false;
  14539. }
  14540. public function __toString(): string
  14541. {
  14542. $result = $this->isDisabled() ? 'disabled(' : '(';
  14543. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  14544. return $result;
  14545. }
  14546. }
  14547. <?php declare(strict_types=1);
  14548. namespace Composer\DependencyResolver;
  14549. use Composer\Repository\RepositorySet;
  14550. class RuleSet implements \IteratorAggregate, \Countable
  14551. {
  14552. public const TYPE_PACKAGE = 0;
  14553. public const TYPE_REQUEST = 1;
  14554. public const TYPE_LEARNED = 4;
  14555. public $ruleById = [];
  14556. const TYPES = [
  14557. self::TYPE_PACKAGE => 'PACKAGE',
  14558. self::TYPE_REQUEST => 'REQUEST',
  14559. self::TYPE_LEARNED => 'LEARNED',
  14560. ];
  14561. protected $rules;
  14562. protected $nextRuleId = 0;
  14563. protected $rulesByHash = [];
  14564. public function __construct()
  14565. {
  14566. foreach ($this->getTypes() as $type) {
  14567. $this->rules[$type] = [];
  14568. }
  14569. }
  14570. public function add(Rule $rule, $type): void
  14571. {
  14572. if (!isset(self::TYPES[$type])) {
  14573. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  14574. }
  14575. $hash = $rule->getHash();
  14576. if (isset($this->rulesByHash[$hash])) {
  14577. $potentialDuplicates = $this->rulesByHash[$hash];
  14578. if (\is_array($potentialDuplicates)) {
  14579. foreach ($potentialDuplicates as $potentialDuplicate) {
  14580. if ($rule->equals($potentialDuplicate)) {
  14581. return;
  14582. }
  14583. }
  14584. } else {
  14585. if ($rule->equals($potentialDuplicates)) {
  14586. return;
  14587. }
  14588. }
  14589. }
  14590. if (!isset($this->rules[$type])) {
  14591. $this->rules[$type] = [];
  14592. }
  14593. $this->rules[$type][] = $rule;
  14594. $this->ruleById[$this->nextRuleId] = $rule;
  14595. $rule->setType($type);
  14596. $this->nextRuleId++;
  14597. if (!isset($this->rulesByHash[$hash])) {
  14598. $this->rulesByHash[$hash] = $rule;
  14599. } elseif (\is_array($this->rulesByHash[$hash])) {
  14600. $this->rulesByHash[$hash][] = $rule;
  14601. } else {
  14602. $originalRule = $this->rulesByHash[$hash];
  14603. $this->rulesByHash[$hash] = [$originalRule, $rule];
  14604. }
  14605. }
  14606. public function count(): int
  14607. {
  14608. return $this->nextRuleId;
  14609. }
  14610. public function ruleById(int $id): Rule
  14611. {
  14612. return $this->ruleById[$id];
  14613. }
  14614. public function getRules(): array
  14615. {
  14616. return $this->rules;
  14617. }
  14618. public function getIterator(): RuleSetIterator
  14619. {
  14620. return new RuleSetIterator($this->getRules());
  14621. }
  14622. public function getIteratorFor($types): RuleSetIterator
  14623. {
  14624. if (!\is_array($types)) {
  14625. $types = [$types];
  14626. }
  14627. $allRules = $this->getRules();
  14628. $rules = [];
  14629. foreach ($types as $type) {
  14630. $rules[$type] = $allRules[$type];
  14631. }
  14632. return new RuleSetIterator($rules);
  14633. }
  14634. public function getIteratorWithout($types): RuleSetIterator
  14635. {
  14636. if (!\is_array($types)) {
  14637. $types = [$types];
  14638. }
  14639. $rules = $this->getRules();
  14640. foreach ($types as $type) {
  14641. unset($rules[$type]);
  14642. }
  14643. return new RuleSetIterator($rules);
  14644. }
  14645. public function getTypes(): array
  14646. {
  14647. $types = self::TYPES;
  14648. return array_keys($types);
  14649. }
  14650. public function getPrettyString(?RepositorySet $repositorySet = null, ?Request $request = null, ?Pool $pool = null, bool $isVerbose = false): string
  14651. {
  14652. $string = "\n";
  14653. foreach ($this->rules as $type => $rules) {
  14654. $string .= str_pad(self::TYPES[$type], 8, ' ') . ": ";
  14655. foreach ($rules as $rule) {
  14656. $string .= ($repositorySet !== null && $request !== null && $pool !== null ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
  14657. }
  14658. $string .= "\n\n";
  14659. }
  14660. return $string;
  14661. }
  14662. public function __toString(): string
  14663. {
  14664. return $this->getPrettyString();
  14665. }
  14666. }
  14667. <?php declare(strict_types=1);
  14668. namespace Composer\DependencyResolver;
  14669. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  14670. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  14671. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  14672. use Composer\Package\BasePackage;
  14673. use Composer\Package\AliasPackage;
  14674. class RuleSetGenerator
  14675. {
  14676. protected $policy;
  14677. protected $pool;
  14678. protected $rules;
  14679. protected $addedMap = [];
  14680. protected $addedPackagesByNames = [];
  14681. public function __construct(PolicyInterface $policy, Pool $pool)
  14682. {
  14683. $this->policy = $policy;
  14684. $this->pool = $pool;
  14685. $this->rules = new RuleSet;
  14686. }
  14687. protected function createRequireRule(BasePackage $package, array $providers, $reason, $reasonData): ?Rule
  14688. {
  14689. $literals = [-$package->id];
  14690. foreach ($providers as $provider) {
  14691. if ($provider === $package) {
  14692. return null;
  14693. }
  14694. $literals[] = $provider->id;
  14695. }
  14696. return new GenericRule($literals, $reason, $reasonData);
  14697. }
  14698. protected function createInstallOneOfRule(array $packages, $reason, $reasonData): Rule
  14699. {
  14700. $literals = [];
  14701. foreach ($packages as $package) {
  14702. $literals[] = $package->id;
  14703. }
  14704. return new GenericRule($literals, $reason, $reasonData);
  14705. }
  14706. protected function createRule2Literals(BasePackage $issuer, BasePackage $provider, $reason, $reasonData): ?Rule
  14707. {
  14708. if ($issuer === $provider) {
  14709. return null;
  14710. }
  14711. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  14712. }
  14713. protected function createMultiConflictRule(array $packages, $reason, $reasonData): Rule
  14714. {
  14715. $literals = [];
  14716. foreach ($packages as $package) {
  14717. $literals[] = -$package->id;
  14718. }
  14719. if (\count($literals) === 2) {
  14720. return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
  14721. }
  14722. return new MultiConflictRule($literals, $reason, $reasonData);
  14723. }
  14724. private function addRule($type, ?Rule $newRule = null): void
  14725. {
  14726. if (null === $newRule) {
  14727. return;
  14728. }
  14729. $this->rules->add($newRule, $type);
  14730. }
  14731. protected function addRulesForPackage(BasePackage $package, PlatformRequirementFilterInterface $platformRequirementFilter): void
  14732. {
  14733. $workQueue = new \SplQueue;
  14734. $workQueue->enqueue($package);
  14735. while (!$workQueue->isEmpty()) {
  14736. $package = $workQueue->dequeue();
  14737. if (isset($this->addedMap[$package->id])) {
  14738. continue;
  14739. }
  14740. $this->addedMap[$package->id] = $package;
  14741. if (!$package instanceof AliasPackage) {
  14742. foreach ($package->getNames(false) as $name) {
  14743. $this->addedPackagesByNames[$name][] = $package;
  14744. }
  14745. } else {
  14746. $workQueue->enqueue($package->getAliasOf());
  14747. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, [$package->getAliasOf()], Rule::RULE_PACKAGE_ALIAS, $package));
  14748. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package->getAliasOf(), [$package], Rule::RULE_PACKAGE_INVERSE_ALIAS, $package->getAliasOf()));
  14749. if (!$package->hasSelfVersionRequires()) {
  14750. continue;
  14751. }
  14752. }
  14753. foreach ($package->getRequires() as $link) {
  14754. $constraint = $link->getConstraint();
  14755. if ($platformRequirementFilter->isIgnored($link->getTarget())) {
  14756. continue;
  14757. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  14758. $constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint);
  14759. }
  14760. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $constraint);
  14761. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  14762. foreach ($possibleRequires as $require) {
  14763. $workQueue->enqueue($require);
  14764. }
  14765. }
  14766. }
  14767. }
  14768. protected function addConflictRules(PlatformRequirementFilterInterface $platformRequirementFilter): void
  14769. {
  14770. foreach ($this->addedMap as $package) {
  14771. foreach ($package->getConflicts() as $link) {
  14772. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  14773. continue;
  14774. }
  14775. $constraint = $link->getConstraint();
  14776. if ($platformRequirementFilter->isIgnored($link->getTarget())) {
  14777. continue;
  14778. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  14779. $constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint, false);
  14780. }
  14781. $conflicts = $this->pool->whatProvides($link->getTarget(), $constraint);
  14782. foreach ($conflicts as $conflict) {
  14783. if (!$conflict instanceof AliasPackage || $conflict->getName() === $link->getTarget()) {
  14784. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  14785. }
  14786. }
  14787. }
  14788. }
  14789. foreach ($this->addedPackagesByNames as $name => $packages) {
  14790. if (\count($packages) > 1) {
  14791. $reason = Rule::RULE_PACKAGE_SAME_NAME;
  14792. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
  14793. }
  14794. }
  14795. }
  14796. protected function addRulesForRequest(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter): void
  14797. {
  14798. foreach ($request->getFixedPackages() as $package) {
  14799. if ($package->id === -1) {
  14800. if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
  14801. continue;
  14802. }
  14803. throw new \LogicException("Fixed package ".$package->getPrettyString()." was not added to solver pool.");
  14804. }
  14805. $this->addRulesForPackage($package, $platformRequirementFilter);
  14806. $rule = $this->createInstallOneOfRule([$package], Rule::RULE_FIXED, [
  14807. 'package' => $package,
  14808. ]);
  14809. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  14810. }
  14811. foreach ($request->getRequires() as $packageName => $constraint) {
  14812. if ($platformRequirementFilter->isIgnored($packageName)) {
  14813. continue;
  14814. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  14815. $constraint = $platformRequirementFilter->filterConstraint($packageName, $constraint);
  14816. }
  14817. $packages = $this->pool->whatProvides($packageName, $constraint);
  14818. if (\count($packages) > 0) {
  14819. foreach ($packages as $package) {
  14820. $this->addRulesForPackage($package, $platformRequirementFilter);
  14821. }
  14822. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, [
  14823. 'packageName' => $packageName,
  14824. 'constraint' => $constraint,
  14825. ]);
  14826. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  14827. }
  14828. }
  14829. }
  14830. protected function addRulesForRootAliases(PlatformRequirementFilterInterface $platformRequirementFilter): void
  14831. {
  14832. foreach ($this->pool->getPackages() as $package) {
  14833. if (!isset($this->addedMap[$package->id]) &&
  14834. $package instanceof AliasPackage &&
  14835. ($package->isRootPackageAlias() || isset($this->addedMap[$package->getAliasOf()->id]))
  14836. ) {
  14837. $this->addRulesForPackage($package, $platformRequirementFilter);
  14838. }
  14839. }
  14840. }
  14841. public function getRulesFor(Request $request, ?PlatformRequirementFilterInterface $platformRequirementFilter = null): RuleSet
  14842. {
  14843. $platformRequirementFilter = $platformRequirementFilter ?? PlatformRequirementFilterFactory::ignoreNothing();
  14844. $this->addRulesForRequest($request, $platformRequirementFilter);
  14845. $this->addRulesForRootAliases($platformRequirementFilter);
  14846. $this->addConflictRules($platformRequirementFilter);
  14847. $this->addedMap = $this->addedPackagesByNames = [];
  14848. $rules = $this->rules;
  14849. $this->rules = new RuleSet;
  14850. return $rules;
  14851. }
  14852. }
  14853. <?php declare(strict_types=1);
  14854. namespace Composer\DependencyResolver;
  14855. class RuleSetIterator implements \Iterator
  14856. {
  14857. protected $rules;
  14858. protected $types;
  14859. protected $currentOffset;
  14860. protected $currentType;
  14861. protected $currentTypeOffset;
  14862. public function __construct(array $rules)
  14863. {
  14864. $this->rules = $rules;
  14865. $this->types = array_keys($rules);
  14866. sort($this->types);
  14867. $this->rewind();
  14868. }
  14869. public function current(): Rule
  14870. {
  14871. return $this->rules[$this->currentType][$this->currentOffset];
  14872. }
  14873. public function key(): int
  14874. {
  14875. return $this->currentType;
  14876. }
  14877. public function next(): void
  14878. {
  14879. $this->currentOffset++;
  14880. if (!isset($this->rules[$this->currentType])) {
  14881. return;
  14882. }
  14883. if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
  14884. $this->currentOffset = 0;
  14885. do {
  14886. $this->currentTypeOffset++;
  14887. if (!isset($this->types[$this->currentTypeOffset])) {
  14888. $this->currentType = -1;
  14889. break;
  14890. }
  14891. $this->currentType = $this->types[$this->currentTypeOffset];
  14892. } while (0 === \count($this->rules[$this->currentType]));
  14893. }
  14894. }
  14895. public function rewind(): void
  14896. {
  14897. $this->currentOffset = 0;
  14898. $this->currentTypeOffset = -1;
  14899. $this->currentType = -1;
  14900. do {
  14901. $this->currentTypeOffset++;
  14902. if (!isset($this->types[$this->currentTypeOffset])) {
  14903. $this->currentType = -1;
  14904. break;
  14905. }
  14906. $this->currentType = $this->types[$this->currentTypeOffset];
  14907. } while (0 === \count($this->rules[$this->currentType]));
  14908. }
  14909. public function valid(): bool
  14910. {
  14911. return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
  14912. }
  14913. }
  14914. <?php declare(strict_types=1);
  14915. namespace Composer\DependencyResolver;
  14916. class RuleWatchChain extends \SplDoublyLinkedList
  14917. {
  14918. public function seek(int $offset): void
  14919. {
  14920. $this->rewind();
  14921. for ($i = 0; $i < $offset; $i++, $this->next());
  14922. }
  14923. public function remove(): void
  14924. {
  14925. $offset = $this->key();
  14926. $this->offsetUnset($offset);
  14927. $this->seek($offset);
  14928. }
  14929. }
  14930. <?php declare(strict_types=1);
  14931. namespace Composer\DependencyResolver;
  14932. class RuleWatchGraph
  14933. {
  14934. protected $watchChains = [];
  14935. public function insert(RuleWatchNode $node): void
  14936. {
  14937. if ($node->getRule()->isAssertion()) {
  14938. return;
  14939. }
  14940. if (!$node->getRule() instanceof MultiConflictRule) {
  14941. foreach ([$node->watch1, $node->watch2] as $literal) {
  14942. if (!isset($this->watchChains[$literal])) {
  14943. $this->watchChains[$literal] = new RuleWatchChain;
  14944. }
  14945. $this->watchChains[$literal]->unshift($node);
  14946. }
  14947. } else {
  14948. foreach ($node->getRule()->getLiterals() as $literal) {
  14949. if (!isset($this->watchChains[$literal])) {
  14950. $this->watchChains[$literal] = new RuleWatchChain;
  14951. }
  14952. $this->watchChains[$literal]->unshift($node);
  14953. }
  14954. }
  14955. }
  14956. public function propagateLiteral(int $decidedLiteral, int $level, Decisions $decisions): ?Rule
  14957. {
  14958. $literal = -$decidedLiteral;
  14959. if (!isset($this->watchChains[$literal])) {
  14960. return null;
  14961. }
  14962. $chain = $this->watchChains[$literal];
  14963. $chain->rewind();
  14964. while ($chain->valid()) {
  14965. $node = $chain->current();
  14966. if (!$node->getRule() instanceof MultiConflictRule) {
  14967. $otherWatch = $node->getOtherWatch($literal);
  14968. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  14969. $ruleLiterals = $node->getRule()->getLiterals();
  14970. $alternativeLiterals = array_filter($ruleLiterals, static function ($ruleLiteral) use ($literal, $otherWatch, $decisions): bool {
  14971. return $literal !== $ruleLiteral &&
  14972. $otherWatch !== $ruleLiteral &&
  14973. !$decisions->conflict($ruleLiteral);
  14974. });
  14975. if (\count($alternativeLiterals) > 0) {
  14976. reset($alternativeLiterals);
  14977. $this->moveWatch($literal, current($alternativeLiterals), $node);
  14978. continue;
  14979. }
  14980. if ($decisions->conflict($otherWatch)) {
  14981. return $node->getRule();
  14982. }
  14983. $decisions->decide($otherWatch, $level, $node->getRule());
  14984. }
  14985. } else {
  14986. foreach ($node->getRule()->getLiterals() as $otherLiteral) {
  14987. if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
  14988. if ($decisions->conflict($otherLiteral)) {
  14989. return $node->getRule();
  14990. }
  14991. $decisions->decide($otherLiteral, $level, $node->getRule());
  14992. }
  14993. }
  14994. }
  14995. $chain->next();
  14996. }
  14997. return null;
  14998. }
  14999. protected function moveWatch(int $fromLiteral, int $toLiteral, RuleWatchNode $node): void
  15000. {
  15001. if (!isset($this->watchChains[$toLiteral])) {
  15002. $this->watchChains[$toLiteral] = new RuleWatchChain;
  15003. }
  15004. $node->moveWatch($fromLiteral, $toLiteral);
  15005. $this->watchChains[$fromLiteral]->remove();
  15006. $this->watchChains[$toLiteral]->unshift($node);
  15007. }
  15008. }
  15009. <?php declare(strict_types=1);
  15010. namespace Composer\DependencyResolver;
  15011. class RuleWatchNode
  15012. {
  15013. public $watch1;
  15014. public $watch2;
  15015. protected $rule;
  15016. public function __construct(Rule $rule)
  15017. {
  15018. $this->rule = $rule;
  15019. $literals = $rule->getLiterals();
  15020. $literalCount = \count($literals);
  15021. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  15022. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  15023. }
  15024. public function watch2OnHighest(Decisions $decisions): void
  15025. {
  15026. $literals = $this->rule->getLiterals();
  15027. if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
  15028. return;
  15029. }
  15030. $watchLevel = 0;
  15031. foreach ($literals as $literal) {
  15032. $level = $decisions->decisionLevel($literal);
  15033. if ($level > $watchLevel) {
  15034. $this->watch2 = $literal;
  15035. $watchLevel = $level;
  15036. }
  15037. }
  15038. }
  15039. public function getRule(): Rule
  15040. {
  15041. return $this->rule;
  15042. }
  15043. public function getOtherWatch(int $literal): int
  15044. {
  15045. if ($this->watch1 === $literal) {
  15046. return $this->watch2;
  15047. }
  15048. return $this->watch1;
  15049. }
  15050. public function moveWatch(int $from, int $to): void
  15051. {
  15052. if ($this->watch1 === $from) {
  15053. $this->watch1 = $to;
  15054. } else {
  15055. $this->watch2 = $to;
  15056. }
  15057. }
  15058. }
  15059. <?php declare(strict_types=1);
  15060. namespace Composer\DependencyResolver;
  15061. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  15062. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  15063. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  15064. use Composer\IO\IOInterface;
  15065. use Composer\Package\BasePackage;
  15066. class Solver
  15067. {
  15068. private const BRANCH_LITERALS = 0;
  15069. private const BRANCH_LEVEL = 1;
  15070. protected $policy;
  15071. protected $pool;
  15072. protected $rules;
  15073. protected $watchGraph;
  15074. protected $decisions;
  15075. protected $fixedMap;
  15076. protected $propagateIndex;
  15077. protected $branches = [];
  15078. protected $problems = [];
  15079. protected $learnedPool = [];
  15080. protected $learnedWhy = [];
  15081. public $testFlagLearnedPositiveLiteral = false;
  15082. protected $io;
  15083. public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io)
  15084. {
  15085. $this->io = $io;
  15086. $this->policy = $policy;
  15087. $this->pool = $pool;
  15088. }
  15089. public function getRuleSetSize(): int
  15090. {
  15091. return \count($this->rules);
  15092. }
  15093. public function getPool(): Pool
  15094. {
  15095. return $this->pool;
  15096. }
  15097. private function makeAssertionRuleDecisions(): void
  15098. {
  15099. $decisionStart = \count($this->decisions) - 1;
  15100. $rulesCount = \count($this->rules);
  15101. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  15102. $rule = $this->rules->ruleById[$ruleIndex];
  15103. if (!$rule->isAssertion() || $rule->isDisabled()) {
  15104. continue;
  15105. }
  15106. $literals = $rule->getLiterals();
  15107. $literal = $literals[0];
  15108. if (!$this->decisions->decided($literal)) {
  15109. $this->decisions->decide($literal, 1, $rule);
  15110. continue;
  15111. }
  15112. if ($this->decisions->satisfy($literal)) {
  15113. continue;
  15114. }
  15115. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  15116. $rule->disable();
  15117. continue;
  15118. }
  15119. $conflict = $this->decisions->decisionRule($literal);
  15120. if (RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  15121. $problem = new Problem();
  15122. $problem->addRule($rule);
  15123. $problem->addRule($conflict);
  15124. $rule->disable();
  15125. $this->problems[] = $problem;
  15126. continue;
  15127. }
  15128. $problem = new Problem();
  15129. $problem->addRule($rule);
  15130. $problem->addRule($conflict);
  15131. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
  15132. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  15133. continue;
  15134. }
  15135. $assertRuleLiterals = $assertRule->getLiterals();
  15136. $assertRuleLiteral = $assertRuleLiterals[0];
  15137. if (abs($literal) !== abs($assertRuleLiteral)) {
  15138. continue;
  15139. }
  15140. $problem->addRule($assertRule);
  15141. $assertRule->disable();
  15142. }
  15143. $this->problems[] = $problem;
  15144. $this->decisions->resetToOffset($decisionStart);
  15145. $ruleIndex = -1;
  15146. }
  15147. }
  15148. protected function setupFixedMap(Request $request): void
  15149. {
  15150. $this->fixedMap = [];
  15151. foreach ($request->getFixedPackages() as $package) {
  15152. $this->fixedMap[$package->id] = $package;
  15153. }
  15154. }
  15155. protected function checkForRootRequireProblems(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter): void
  15156. {
  15157. foreach ($request->getRequires() as $packageName => $constraint) {
  15158. if ($platformRequirementFilter->isIgnored($packageName)) {
  15159. continue;
  15160. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  15161. $constraint = $platformRequirementFilter->filterConstraint($packageName, $constraint);
  15162. }
  15163. if (0 === \count($this->pool->whatProvides($packageName, $constraint))) {
  15164. $problem = new Problem();
  15165. $problem->addRule(new GenericRule([], Rule::RULE_ROOT_REQUIRE, ['packageName' => $packageName, 'constraint' => $constraint]));
  15166. $this->problems[] = $problem;
  15167. }
  15168. }
  15169. }
  15170. public function solve(Request $request, ?PlatformRequirementFilterInterface $platformRequirementFilter = null): LockTransaction
  15171. {
  15172. $platformRequirementFilter = $platformRequirementFilter ?? PlatformRequirementFilterFactory::ignoreNothing();
  15173. $this->setupFixedMap($request);
  15174. $this->io->writeError('Generating rules', true, IOInterface::DEBUG);
  15175. $ruleSetGenerator = new RuleSetGenerator($this->policy, $this->pool);
  15176. $this->rules = $ruleSetGenerator->getRulesFor($request, $platformRequirementFilter);
  15177. unset($ruleSetGenerator);
  15178. $this->checkForRootRequireProblems($request, $platformRequirementFilter);
  15179. $this->decisions = new Decisions($this->pool);
  15180. $this->watchGraph = new RuleWatchGraph;
  15181. foreach ($this->rules as $rule) {
  15182. $this->watchGraph->insert(new RuleWatchNode($rule));
  15183. }
  15184. $this->makeAssertionRuleDecisions();
  15185. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  15186. $before = microtime(true);
  15187. $this->runSat();
  15188. $this->io->writeError('', true, IOInterface::DEBUG);
  15189. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  15190. if (\count($this->problems) > 0) {
  15191. throw new SolverProblemsException($this->problems, $this->learnedPool);
  15192. }
  15193. return new LockTransaction($this->pool, $request->getPresentMap(), $request->getFixedPackagesMap(), $this->decisions);
  15194. }
  15195. protected function propagate(int $level): ?Rule
  15196. {
  15197. while ($this->decisions->validOffset($this->propagateIndex)) {
  15198. $decision = $this->decisions->atOffset($this->propagateIndex);
  15199. $conflict = $this->watchGraph->propagateLiteral(
  15200. $decision[Decisions::DECISION_LITERAL],
  15201. $level,
  15202. $this->decisions
  15203. );
  15204. $this->propagateIndex++;
  15205. if ($conflict !== null) {
  15206. return $conflict;
  15207. }
  15208. }
  15209. return null;
  15210. }
  15211. private function revert(int $level): void
  15212. {
  15213. while (!$this->decisions->isEmpty()) {
  15214. $literal = $this->decisions->lastLiteral();
  15215. if ($this->decisions->undecided($literal)) {
  15216. break;
  15217. }
  15218. $decisionLevel = $this->decisions->decisionLevel($literal);
  15219. if ($decisionLevel <= $level) {
  15220. break;
  15221. }
  15222. $this->decisions->revertLast();
  15223. $this->propagateIndex = \count($this->decisions);
  15224. }
  15225. while (\count($this->branches) > 0 && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  15226. array_pop($this->branches);
  15227. }
  15228. }
  15229. private function setPropagateLearn(int $level, int $literal, Rule $rule): int
  15230. {
  15231. $level++;
  15232. $this->decisions->decide($literal, $level, $rule);
  15233. while (true) {
  15234. $rule = $this->propagate($level);
  15235. if (null === $rule) {
  15236. break;
  15237. }
  15238. if ($level === 1) {
  15239. $this->analyzeUnsolvable($rule);
  15240. return 0;
  15241. }
  15242. [$learnLiteral, $newLevel, $newRule, $why] = $this->analyze($level, $rule);
  15243. if ($newLevel <= 0 || $newLevel >= $level) {
  15244. throw new SolverBugException(
  15245. "Trying to revert to invalid level ".$newLevel." from level ".$level."."
  15246. );
  15247. }
  15248. $level = $newLevel;
  15249. $this->revert($level);
  15250. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  15251. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  15252. $ruleNode = new RuleWatchNode($newRule);
  15253. $ruleNode->watch2OnHighest($this->decisions);
  15254. $this->watchGraph->insert($ruleNode);
  15255. $this->decisions->decide($learnLiteral, $level, $newRule);
  15256. }
  15257. return $level;
  15258. }
  15259. private function selectAndInstall(int $level, array $decisionQueue, Rule $rule): int
  15260. {
  15261. $literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
  15262. $selectedLiteral = array_shift($literals);
  15263. if (\count($literals) > 0) {
  15264. $this->branches[] = [$literals, $level];
  15265. }
  15266. return $this->setPropagateLearn($level, $selectedLiteral, $rule);
  15267. }
  15268. protected function analyze(int $level, Rule $rule): array
  15269. {
  15270. $analyzedRule = $rule;
  15271. $ruleLevel = 1;
  15272. $num = 0;
  15273. $l1num = 0;
  15274. $seen = [];
  15275. $learnedLiteral = null;
  15276. $otherLearnedLiterals = [];
  15277. $decisionId = \count($this->decisions);
  15278. $this->learnedPool[] = [];
  15279. while (true) {
  15280. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  15281. foreach ($rule->getLiterals() as $literal) {
  15282. if ($rule instanceof MultiConflictRule && !$this->decisions->decided($literal)) {
  15283. continue;
  15284. }
  15285. if ($this->decisions->satisfy($literal)) {
  15286. continue;
  15287. }
  15288. if (isset($seen[abs($literal)])) {
  15289. continue;
  15290. }
  15291. $seen[abs($literal)] = true;
  15292. $l = $this->decisions->decisionLevel($literal);
  15293. if (1 === $l) {
  15294. $l1num++;
  15295. } elseif ($level === $l) {
  15296. $num++;
  15297. } else {
  15298. $otherLearnedLiterals[] = $literal;
  15299. if ($l > $ruleLevel) {
  15300. $ruleLevel = $l;
  15301. }
  15302. }
  15303. }
  15304. unset($literal);
  15305. $l1retry = true;
  15306. while ($l1retry) {
  15307. $l1retry = false;
  15308. if (0 === $num && 0 === --$l1num) {
  15309. break 2;
  15310. }
  15311. while (true) {
  15312. if ($decisionId <= 0) {
  15313. throw new SolverBugException(
  15314. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  15315. );
  15316. }
  15317. $decisionId--;
  15318. $decision = $this->decisions->atOffset($decisionId);
  15319. $literal = $decision[Decisions::DECISION_LITERAL];
  15320. if (isset($seen[abs($literal)])) {
  15321. break;
  15322. }
  15323. }
  15324. unset($seen[abs($literal)]);
  15325. if (0 !== $num && 0 === --$num) {
  15326. if ($literal < 0) {
  15327. $this->testFlagLearnedPositiveLiteral = true;
  15328. }
  15329. $learnedLiteral = -$literal;
  15330. if (0 === $l1num) {
  15331. break 2;
  15332. }
  15333. foreach ($otherLearnedLiterals as $otherLiteral) {
  15334. unset($seen[abs($otherLiteral)]);
  15335. }
  15336. $l1num++;
  15337. $l1retry = true;
  15338. } else {
  15339. $decision = $this->decisions->atOffset($decisionId);
  15340. $rule = $decision[Decisions::DECISION_REASON];
  15341. if ($rule instanceof MultiConflictRule) {
  15342. foreach ($rule->getLiterals() as $ruleLiteral) {
  15343. if (!isset($seen[abs($ruleLiteral)]) && $this->decisions->satisfy(-$ruleLiteral)) {
  15344. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  15345. $l = $this->decisions->decisionLevel($ruleLiteral);
  15346. if (1 === $l) {
  15347. $l1num++;
  15348. } elseif ($level === $l) {
  15349. $num++;
  15350. } else {
  15351. $otherLearnedLiterals[] = $ruleLiteral;
  15352. if ($l > $ruleLevel) {
  15353. $ruleLevel = $l;
  15354. }
  15355. }
  15356. $seen[abs($ruleLiteral)] = true;
  15357. break;
  15358. }
  15359. }
  15360. $l1retry = true;
  15361. }
  15362. }
  15363. }
  15364. $decision = $this->decisions->atOffset($decisionId);
  15365. $rule = $decision[Decisions::DECISION_REASON];
  15366. }
  15367. $why = \count($this->learnedPool) - 1;
  15368. if (null === $learnedLiteral) {
  15369. throw new SolverBugException(
  15370. "Did not find a learnable literal in analyzed rule $analyzedRule."
  15371. );
  15372. }
  15373. array_unshift($otherLearnedLiterals, $learnedLiteral);
  15374. $newRule = new GenericRule($otherLearnedLiterals, Rule::RULE_LEARNED, $why);
  15375. return [$learnedLiteral, $ruleLevel, $newRule, $why];
  15376. }
  15377. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule, array &$ruleSeen): void
  15378. {
  15379. $why = spl_object_hash($conflictRule);
  15380. $ruleSeen[$why] = true;
  15381. if ($conflictRule->getType() === RuleSet::TYPE_LEARNED) {
  15382. $learnedWhy = $this->learnedWhy[$why];
  15383. $problemRules = $this->learnedPool[$learnedWhy];
  15384. foreach ($problemRules as $problemRule) {
  15385. if (!isset($ruleSeen[spl_object_hash($problemRule)])) {
  15386. $this->analyzeUnsolvableRule($problem, $problemRule, $ruleSeen);
  15387. }
  15388. }
  15389. return;
  15390. }
  15391. if ($conflictRule->getType() === RuleSet::TYPE_PACKAGE) {
  15392. return;
  15393. }
  15394. $problem->nextSection();
  15395. $problem->addRule($conflictRule);
  15396. }
  15397. private function analyzeUnsolvable(Rule $conflictRule): void
  15398. {
  15399. $problem = new Problem();
  15400. $problem->addRule($conflictRule);
  15401. $ruleSeen = [];
  15402. $this->analyzeUnsolvableRule($problem, $conflictRule, $ruleSeen);
  15403. $this->problems[] = $problem;
  15404. $seen = [];
  15405. $literals = $conflictRule->getLiterals();
  15406. foreach ($literals as $literal) {
  15407. if ($this->decisions->satisfy($literal)) {
  15408. continue;
  15409. }
  15410. $seen[abs($literal)] = true;
  15411. }
  15412. foreach ($this->decisions as $decision) {
  15413. $decisionLiteral = $decision[Decisions::DECISION_LITERAL];
  15414. if (!isset($seen[abs($decisionLiteral)])) {
  15415. continue;
  15416. }
  15417. $why = $decision[Decisions::DECISION_REASON];
  15418. $problem->addRule($why);
  15419. $this->analyzeUnsolvableRule($problem, $why, $ruleSeen);
  15420. $literals = $why->getLiterals();
  15421. foreach ($literals as $literal) {
  15422. if ($this->decisions->satisfy($literal)) {
  15423. continue;
  15424. }
  15425. $seen[abs($literal)] = true;
  15426. }
  15427. }
  15428. }
  15429. private function runSat(): void
  15430. {
  15431. $this->propagateIndex = 0;
  15432. $level = 1;
  15433. $systemLevel = $level + 1;
  15434. while (true) {
  15435. if (1 === $level) {
  15436. $conflictRule = $this->propagate($level);
  15437. if (null !== $conflictRule) {
  15438. $this->analyzeUnsolvable($conflictRule);
  15439. return;
  15440. }
  15441. }
  15442. if ($level < $systemLevel) {
  15443. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_REQUEST);
  15444. foreach ($iterator as $rule) {
  15445. if ($rule->isEnabled()) {
  15446. $decisionQueue = [];
  15447. $noneSatisfied = true;
  15448. foreach ($rule->getLiterals() as $literal) {
  15449. if ($this->decisions->satisfy($literal)) {
  15450. $noneSatisfied = false;
  15451. break;
  15452. }
  15453. if ($literal > 0 && $this->decisions->undecided($literal)) {
  15454. $decisionQueue[] = $literal;
  15455. }
  15456. }
  15457. if ($noneSatisfied && \count($decisionQueue) > 0) {
  15458. $prunedQueue = [];
  15459. foreach ($decisionQueue as $literal) {
  15460. if (isset($this->fixedMap[abs($literal)])) {
  15461. $prunedQueue[] = $literal;
  15462. }
  15463. }
  15464. if (\count($prunedQueue) > 0) {
  15465. $decisionQueue = $prunedQueue;
  15466. }
  15467. }
  15468. if ($noneSatisfied && \count($decisionQueue) > 0) {
  15469. $oLevel = $level;
  15470. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  15471. if (0 === $level) {
  15472. return;
  15473. }
  15474. if ($level <= $oLevel) {
  15475. break;
  15476. }
  15477. }
  15478. }
  15479. }
  15480. $systemLevel = $level + 1;
  15481. $iterator->next();
  15482. if ($iterator->valid()) {
  15483. continue;
  15484. }
  15485. }
  15486. if ($level < $systemLevel) {
  15487. $systemLevel = $level;
  15488. }
  15489. $rulesCount = \count($this->rules);
  15490. $pass = 1;
  15491. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  15492. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  15493. if ($i === $rulesCount) {
  15494. if (1 === $pass) {
  15495. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  15496. } else {
  15497. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  15498. }
  15499. $i = 0;
  15500. $pass++;
  15501. }
  15502. $rule = $this->rules->ruleById[$i];
  15503. $literals = $rule->getLiterals();
  15504. if ($rule->isDisabled()) {
  15505. continue;
  15506. }
  15507. $decisionQueue = [];
  15508. foreach ($literals as $literal) {
  15509. if ($literal <= 0) {
  15510. if (!$this->decisions->decidedInstall($literal)) {
  15511. continue 2;
  15512. }
  15513. } else {
  15514. if ($this->decisions->decidedInstall($literal)) {
  15515. continue 2;
  15516. }
  15517. if ($this->decisions->undecided($literal)) {
  15518. $decisionQueue[] = $literal;
  15519. }
  15520. }
  15521. }
  15522. if (\count($decisionQueue) < 2) {
  15523. continue;
  15524. }
  15525. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  15526. if (0 === $level) {
  15527. return;
  15528. }
  15529. $rulesCount = \count($this->rules);
  15530. $n = -1;
  15531. }
  15532. if ($level < $systemLevel) {
  15533. continue;
  15534. }
  15535. if (\count($this->branches) > 0) {
  15536. $lastLiteral = null;
  15537. $lastLevel = null;
  15538. $lastBranchIndex = 0;
  15539. $lastBranchOffset = 0;
  15540. for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
  15541. [$literals, $l] = $this->branches[$i];
  15542. foreach ($literals as $offset => $literal) {
  15543. if ($literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  15544. $lastLiteral = $literal;
  15545. $lastBranchIndex = $i;
  15546. $lastBranchOffset = $offset;
  15547. $lastLevel = $l;
  15548. }
  15549. }
  15550. }
  15551. if ($lastLiteral !== null) {
  15552. assert($lastLevel !== null);
  15553. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  15554. $level = $lastLevel;
  15555. $this->revert($level);
  15556. $why = $this->decisions->lastReason();
  15557. $level = $this->setPropagateLearn($level, $lastLiteral, $why);
  15558. if ($level === 0) {
  15559. return;
  15560. }
  15561. continue;
  15562. }
  15563. }
  15564. break;
  15565. }
  15566. }
  15567. }
  15568. <?php declare(strict_types=1);
  15569. namespace Composer\DependencyResolver;
  15570. class SolverBugException extends \RuntimeException
  15571. {
  15572. public function __construct(string $message)
  15573. {
  15574. parent::__construct(
  15575. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  15576. "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"
  15577. );
  15578. }
  15579. }
  15580. <?php declare(strict_types=1);
  15581. namespace Composer\DependencyResolver;
  15582. use Composer\Util\IniHelper;
  15583. use Composer\Repository\RepositorySet;
  15584. class SolverProblemsException extends \RuntimeException
  15585. {
  15586. public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
  15587. protected $problems;
  15588. protected $learnedPool;
  15589. public function __construct(array $problems, array $learnedPool)
  15590. {
  15591. $this->problems = $problems;
  15592. $this->learnedPool = $learnedPool;
  15593. parent::__construct('Failed resolving dependencies with '.\count($problems).' problems, call getPrettyString to get formatted details', self::ERROR_DEPENDENCY_RESOLUTION_FAILED);
  15594. }
  15595. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, bool $isDevExtraction = false): string
  15596. {
  15597. $installedMap = $request->getPresentMap(true);
  15598. $missingExtensions = [];
  15599. $isCausedByLock = false;
  15600. $problems = [];
  15601. foreach ($this->problems as $problem) {
  15602. $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n";
  15603. $missingExtensions = array_merge($missingExtensions, $this->getExtensionProblems($problem->getReasons()));
  15604. $isCausedByLock = $isCausedByLock || $problem->isCausedByLock($repositorySet, $request, $pool);
  15605. }
  15606. $i = 1;
  15607. $text = "\n";
  15608. foreach (array_unique($problems) as $problem) {
  15609. $text .= " Problem ".($i++).$problem;
  15610. }
  15611. $hints = [];
  15612. if (!$isDevExtraction && (str_contains($text, 'could not be found') || str_contains($text, 'no matching package found'))) {
  15613. $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.";
  15614. }
  15615. if (\count($missingExtensions) > 0) {
  15616. $hints[] = $this->createExtensionHint($missingExtensions);
  15617. }
  15618. if ($isCausedByLock && !$isDevExtraction && !$request->getUpdateAllowTransitiveRootDependencies()) {
  15619. $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
  15620. }
  15621. if (str_contains($text, 'found composer-plugin-api[2.0.0] but it does not match') && str_contains($text, '- ocramius/package-versions')) {
  15622. $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+.";
  15623. }
  15624. if (!class_exists('PHPUnit\Framework\TestCase', false)) {
  15625. if (str_contains($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
  15626. $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.";
  15627. }
  15628. }
  15629. if (\count($hints) > 0) {
  15630. $text .= "\n" . implode("\n\n", $hints);
  15631. }
  15632. return $text;
  15633. }
  15634. public function getProblems(): array
  15635. {
  15636. return $this->problems;
  15637. }
  15638. private function createExtensionHint(array $missingExtensions): string
  15639. {
  15640. $paths = IniHelper::getAll();
  15641. if ('' === $paths[0]) {
  15642. if (count($paths) === 1) {
  15643. return '';
  15644. }
  15645. array_shift($paths);
  15646. }
  15647. $ignoreExtensionsArguments = implode(" ", array_map(static function ($extension) {
  15648. return "--ignore-platform-req=$extension";
  15649. }, array_unique($missingExtensions)));
  15650. $text = "To enable extensions, verify that they are enabled in your .ini files:\n - ";
  15651. $text .= implode("\n - ", $paths);
  15652. $text .= "\nYou can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.";
  15653. $text .= "\nAlternatively, you can run Composer with `$ignoreExtensionsArguments` to temporarily ignore these required extensions.";
  15654. return $text;
  15655. }
  15656. private function getExtensionProblems(array $reasonSets): array
  15657. {
  15658. $missingExtensions = [];
  15659. foreach ($reasonSets as $reasonSet) {
  15660. foreach ($reasonSet as $rule) {
  15661. $required = $rule->getRequiredPackage();
  15662. if (null !== $required && 0 === strpos($required, 'ext-')) {
  15663. $missingExtensions[$required] = 1;
  15664. }
  15665. }
  15666. }
  15667. return array_keys($missingExtensions);
  15668. }
  15669. }
  15670. <?php declare(strict_types=1);
  15671. namespace Composer\DependencyResolver;
  15672. use Composer\Package\AliasPackage;
  15673. use Composer\Package\Link;
  15674. use Composer\Package\PackageInterface;
  15675. use Composer\Repository\PlatformRepository;
  15676. use Composer\DependencyResolver\Operation\OperationInterface;
  15677. class Transaction
  15678. {
  15679. protected $operations;
  15680. protected $presentPackages;
  15681. protected $resultPackageMap;
  15682. protected $resultPackagesByName = [];
  15683. public function __construct(array $presentPackages, array $resultPackages)
  15684. {
  15685. $this->presentPackages = $presentPackages;
  15686. $this->setResultPackageMaps($resultPackages);
  15687. $this->operations = $this->calculateOperations();
  15688. }
  15689. public function getOperations(): array
  15690. {
  15691. return $this->operations;
  15692. }
  15693. private function setResultPackageMaps(array $resultPackages): void
  15694. {
  15695. $packageSort = static function (PackageInterface $a, PackageInterface $b): int {
  15696. if ($a->getName() === $b->getName()) {
  15697. if ($a instanceof AliasPackage !== $b instanceof AliasPackage) {
  15698. return $a instanceof AliasPackage ? -1 : 1;
  15699. }
  15700. return strcmp($b->getVersion(), $a->getVersion());
  15701. }
  15702. return strcmp($b->getName(), $a->getName());
  15703. };
  15704. $this->resultPackageMap = [];
  15705. foreach ($resultPackages as $package) {
  15706. $this->resultPackageMap[spl_object_hash($package)] = $package;
  15707. foreach ($package->getNames() as $name) {
  15708. $this->resultPackagesByName[$name][] = $package;
  15709. }
  15710. }
  15711. uasort($this->resultPackageMap, $packageSort);
  15712. foreach ($this->resultPackagesByName as $name => $packages) {
  15713. uasort($this->resultPackagesByName[$name], $packageSort);
  15714. }
  15715. }
  15716. protected function calculateOperations(): array
  15717. {
  15718. $operations = [];
  15719. $presentPackageMap = [];
  15720. $removeMap = [];
  15721. $presentAliasMap = [];
  15722. $removeAliasMap = [];
  15723. foreach ($this->presentPackages as $package) {
  15724. if ($package instanceof AliasPackage) {
  15725. $presentAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  15726. $removeAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  15727. } else {
  15728. $presentPackageMap[$package->getName()] = $package;
  15729. $removeMap[$package->getName()] = $package;
  15730. }
  15731. }
  15732. $stack = $this->getRootPackages();
  15733. $visited = [];
  15734. $processed = [];
  15735. while (\count($stack) > 0) {
  15736. $package = array_pop($stack);
  15737. if (isset($processed[spl_object_hash($package)])) {
  15738. continue;
  15739. }
  15740. if (!isset($visited[spl_object_hash($package)])) {
  15741. $visited[spl_object_hash($package)] = true;
  15742. $stack[] = $package;
  15743. if ($package instanceof AliasPackage) {
  15744. $stack[] = $package->getAliasOf();
  15745. } else {
  15746. foreach ($package->getRequires() as $link) {
  15747. $possibleRequires = $this->getProvidersInResult($link);
  15748. foreach ($possibleRequires as $require) {
  15749. $stack[] = $require;
  15750. }
  15751. }
  15752. }
  15753. } elseif (!isset($processed[spl_object_hash($package)])) {
  15754. $processed[spl_object_hash($package)] = true;
  15755. if ($package instanceof AliasPackage) {
  15756. $aliasKey = $package->getName().'::'.$package->getVersion();
  15757. if (isset($presentAliasMap[$aliasKey])) {
  15758. unset($removeAliasMap[$aliasKey]);
  15759. } else {
  15760. $operations[] = new Operation\MarkAliasInstalledOperation($package);
  15761. }
  15762. } else {
  15763. if (isset($presentPackageMap[$package->getName()])) {
  15764. $source = $presentPackageMap[$package->getName()];
  15765. if ($package->getVersion() !== $presentPackageMap[$package->getName()]->getVersion() ||
  15766. $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
  15767. $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
  15768. ) {
  15769. $operations[] = new Operation\UpdateOperation($source, $package);
  15770. }
  15771. unset($removeMap[$package->getName()]);
  15772. } else {
  15773. $operations[] = new Operation\InstallOperation($package);
  15774. unset($removeMap[$package->getName()]);
  15775. }
  15776. }
  15777. }
  15778. }
  15779. foreach ($removeMap as $name => $package) {
  15780. array_unshift($operations, new Operation\UninstallOperation($package));
  15781. }
  15782. foreach ($removeAliasMap as $nameVersion => $package) {
  15783. $operations[] = new Operation\MarkAliasUninstalledOperation($package);
  15784. }
  15785. $operations = $this->movePluginsToFront($operations);
  15786. $operations = $this->moveUninstallsToFront($operations);
  15787. return $this->operations = $operations;
  15788. }
  15789. protected function getRootPackages(): array
  15790. {
  15791. $roots = $this->resultPackageMap;
  15792. foreach ($this->resultPackageMap as $packageHash => $package) {
  15793. if (!isset($roots[$packageHash])) {
  15794. continue;
  15795. }
  15796. foreach ($package->getRequires() as $link) {
  15797. $possibleRequires = $this->getProvidersInResult($link);
  15798. foreach ($possibleRequires as $require) {
  15799. if ($require !== $package) {
  15800. unset($roots[spl_object_hash($require)]);
  15801. }
  15802. }
  15803. }
  15804. }
  15805. return $roots;
  15806. }
  15807. protected function getProvidersInResult(Link $link): array
  15808. {
  15809. if (!isset($this->resultPackagesByName[$link->getTarget()])) {
  15810. return [];
  15811. }
  15812. return $this->resultPackagesByName[$link->getTarget()];
  15813. }
  15814. private function movePluginsToFront(array $operations): array
  15815. {
  15816. $dlModifyingPluginsNoDeps = [];
  15817. $dlModifyingPluginsWithDeps = [];
  15818. $dlModifyingPluginRequires = [];
  15819. $pluginsNoDeps = [];
  15820. $pluginsWithDeps = [];
  15821. $pluginRequires = [];
  15822. foreach (array_reverse($operations, true) as $idx => $op) {
  15823. if ($op instanceof Operation\InstallOperation) {
  15824. $package = $op->getPackage();
  15825. } elseif ($op instanceof Operation\UpdateOperation) {
  15826. $package = $op->getTargetPackage();
  15827. } else {
  15828. continue;
  15829. }
  15830. $extra = $package->getExtra();
  15831. $isDownloadsModifyingPlugin = $package->getType() === 'composer-plugin' && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true;
  15832. if ($isDownloadsModifyingPlugin || \count(array_intersect($package->getNames(), $dlModifyingPluginRequires)) > 0) {
  15833. $requires = array_filter(array_keys($package->getRequires()), static function ($req): bool {
  15834. return !PlatformRepository::isPlatformPackage($req);
  15835. });
  15836. if ($isDownloadsModifyingPlugin && 0 === \count($requires)) {
  15837. array_unshift($dlModifyingPluginsNoDeps, $op);
  15838. } else {
  15839. $dlModifyingPluginRequires = array_merge($dlModifyingPluginRequires, $requires);
  15840. array_unshift($dlModifyingPluginsWithDeps, $op);
  15841. }
  15842. unset($operations[$idx]);
  15843. continue;
  15844. }
  15845. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  15846. if ($isPlugin || \count(array_intersect($package->getNames(), $pluginRequires)) > 0) {
  15847. $requires = array_filter(array_keys($package->getRequires()), static function ($req): bool {
  15848. return !PlatformRepository::isPlatformPackage($req);
  15849. });
  15850. if ($isPlugin && 0 === \count($requires)) {
  15851. array_unshift($pluginsNoDeps, $op);
  15852. } else {
  15853. $pluginRequires = array_merge($pluginRequires, $requires);
  15854. array_unshift($pluginsWithDeps, $op);
  15855. }
  15856. unset($operations[$idx]);
  15857. }
  15858. }
  15859. return array_merge($dlModifyingPluginsNoDeps, $dlModifyingPluginsWithDeps, $pluginsNoDeps, $pluginsWithDeps, $operations);
  15860. }
  15861. private function moveUninstallsToFront(array $operations): array
  15862. {
  15863. $uninstOps = [];
  15864. foreach ($operations as $idx => $op) {
  15865. if ($op instanceof Operation\UninstallOperation || $op instanceof Operation\MarkAliasUninstalledOperation) {
  15866. $uninstOps[] = $op;
  15867. unset($operations[$idx]);
  15868. }
  15869. }
  15870. return array_merge($uninstOps, $operations);
  15871. }
  15872. }
  15873. <?php declare(strict_types=1);
  15874. namespace Composer\Downloader;
  15875. use Composer\Package\PackageInterface;
  15876. use Composer\Util\Platform;
  15877. use Symfony\Component\Finder\Finder;
  15878. use React\Promise\PromiseInterface;
  15879. use Composer\DependencyResolver\Operation\InstallOperation;
  15880. abstract class ArchiveDownloader extends FileDownloader
  15881. {
  15882. protected $cleanupExecuted = [];
  15883. public function prepare(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  15884. {
  15885. unset($this->cleanupExecuted[$package->getName()]);
  15886. return parent::prepare($type, $package, $path, $prevPackage);
  15887. }
  15888. public function cleanup(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  15889. {
  15890. $this->cleanupExecuted[$package->getName()] = true;
  15891. return parent::cleanup($type, $package, $path, $prevPackage);
  15892. }
  15893. public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  15894. {
  15895. if ($output) {
  15896. $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
  15897. }
  15898. $vendorDir = $this->config->get('vendor-dir');
  15899. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
  15900. $this->filesystem->emptyDirectory($path);
  15901. }
  15902. do {
  15903. $temporaryDir = $vendorDir.'/composer/'.bin2hex(random_bytes(4));
  15904. } while (is_dir($temporaryDir));
  15905. $this->addCleanupPath($package, $temporaryDir);
  15906. if (!is_dir($path) || realpath($path) !== Platform::getCwd()) {
  15907. $this->addCleanupPath($package, $path);
  15908. }
  15909. $this->filesystem->ensureDirectoryExists($temporaryDir);
  15910. $fileName = $this->getFileName($package, $path);
  15911. $filesystem = $this->filesystem;
  15912. $cleanup = function () use ($path, $filesystem, $temporaryDir, $package) {
  15913. $this->clearLastCacheWrite($package);
  15914. $filesystem->removeDirectory($temporaryDir);
  15915. if (is_dir($path) && realpath($path) !== Platform::getCwd()) {
  15916. $filesystem->removeDirectory($path);
  15917. }
  15918. $this->removeCleanupPath($package, $temporaryDir);
  15919. $realpath = realpath($path);
  15920. if ($realpath !== false) {
  15921. $this->removeCleanupPath($package, $realpath);
  15922. }
  15923. };
  15924. try {
  15925. $promise = $this->extract($package, $fileName, $temporaryDir);
  15926. } catch (\Exception $e) {
  15927. $cleanup();
  15928. throw $e;
  15929. }
  15930. return $promise->then(function () use ($package, $filesystem, $fileName, $temporaryDir, $path): \React\Promise\PromiseInterface {
  15931. if (file_exists($fileName)) {
  15932. $filesystem->unlink($fileName);
  15933. }
  15934. $getFolderContent = static function ($dir): array {
  15935. $finder = Finder::create()
  15936. ->ignoreVCS(false)
  15937. ->ignoreDotFiles(false)
  15938. ->notName('.DS_Store')
  15939. ->depth(0)
  15940. ->in($dir);
  15941. return iterator_to_array($finder);
  15942. };
  15943. $renameRecursively = null;
  15944. $renameRecursively = static function ($from, $to) use ($filesystem, $getFolderContent, $package, &$renameRecursively) {
  15945. $contentDir = $getFolderContent($from);
  15946. foreach ($contentDir as $file) {
  15947. $file = (string) $file;
  15948. if (is_dir($to . '/' . basename($file))) {
  15949. if (!is_dir($file)) {
  15950. throw new \RuntimeException('Installing '.$package.' would lead to overwriting the '.$to.'/'.basename($file).' directory with a file from the package, invalid operation.');
  15951. }
  15952. $renameRecursively($file, $to . '/' . basename($file));
  15953. } else {
  15954. $filesystem->rename($file, $to . '/' . basename($file));
  15955. }
  15956. }
  15957. };
  15958. $renameAsOne = false;
  15959. if (!file_exists($path)) {
  15960. $renameAsOne = true;
  15961. } elseif ($filesystem->isDirEmpty($path)) {
  15962. try {
  15963. if ($filesystem->removeDirectoryPhp($path)) {
  15964. $renameAsOne = true;
  15965. }
  15966. } catch (\RuntimeException $e) {
  15967. }
  15968. }
  15969. $contentDir = $getFolderContent($temporaryDir);
  15970. $singleDirAtTopLevel = 1 === count($contentDir) && is_dir((string) reset($contentDir));
  15971. if ($renameAsOne) {
  15972. if ($singleDirAtTopLevel) {
  15973. $extractedDir = (string) reset($contentDir);
  15974. } else {
  15975. $extractedDir = $temporaryDir;
  15976. }
  15977. $filesystem->rename($extractedDir, $path);
  15978. } else {
  15979. $from = $temporaryDir;
  15980. if ($singleDirAtTopLevel) {
  15981. $from = (string) reset($contentDir);
  15982. }
  15983. $renameRecursively($from, $path);
  15984. }
  15985. $promise = $filesystem->removeDirectoryAsync($temporaryDir);
  15986. return $promise->then(function () use ($package, $path, $temporaryDir) {
  15987. $this->removeCleanupPath($package, $temporaryDir);
  15988. $this->removeCleanupPath($package, $path);
  15989. });
  15990. }, static function ($e) use ($cleanup) {
  15991. $cleanup();
  15992. throw $e;
  15993. });
  15994. }
  15995. protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
  15996. {
  15997. return ': Extracting archive';
  15998. }
  15999. abstract protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface;
  16000. }
  16001. <?php declare(strict_types=1);
  16002. namespace Composer\Downloader;
  16003. use Composer\Package\PackageInterface;
  16004. interface ChangeReportInterface
  16005. {
  16006. public function getLocalChanges(PackageInterface $package, string $path): ?string;
  16007. }
  16008. <?php declare(strict_types=1);
  16009. namespace Composer\Downloader;
  16010. use Composer\Package\PackageInterface;
  16011. use Composer\IO\IOInterface;
  16012. use Composer\Pcre\Preg;
  16013. use Composer\Util\Filesystem;
  16014. use Composer\Exception\IrrecoverableDownloadException;
  16015. use React\Promise\PromiseInterface;
  16016. class DownloadManager
  16017. {
  16018. private $io;
  16019. private $preferDist = false;
  16020. private $preferSource;
  16021. private $packagePreferences = [];
  16022. private $filesystem;
  16023. private $downloaders = [];
  16024. public function __construct(IOInterface $io, bool $preferSource = false, ?Filesystem $filesystem = null)
  16025. {
  16026. $this->io = $io;
  16027. $this->preferSource = $preferSource;
  16028. $this->filesystem = $filesystem ?: new Filesystem();
  16029. }
  16030. public function setPreferSource(bool $preferSource): self
  16031. {
  16032. $this->preferSource = $preferSource;
  16033. return $this;
  16034. }
  16035. public function setPreferDist(bool $preferDist): self
  16036. {
  16037. $this->preferDist = $preferDist;
  16038. return $this;
  16039. }
  16040. public function setPreferences(array $preferences): self
  16041. {
  16042. $this->packagePreferences = $preferences;
  16043. return $this;
  16044. }
  16045. public function setDownloader(string $type, DownloaderInterface $downloader): self
  16046. {
  16047. $type = strtolower($type);
  16048. $this->downloaders[$type] = $downloader;
  16049. return $this;
  16050. }
  16051. public function getDownloader(string $type): DownloaderInterface
  16052. {
  16053. $type = strtolower($type);
  16054. if (!isset($this->downloaders[$type])) {
  16055. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  16056. }
  16057. return $this->downloaders[$type];
  16058. }
  16059. public function getDownloaderForPackage(PackageInterface $package): ?DownloaderInterface
  16060. {
  16061. $installationSource = $package->getInstallationSource();
  16062. if ('metapackage' === $package->getType()) {
  16063. return null;
  16064. }
  16065. if ('dist' === $installationSource) {
  16066. $downloader = $this->getDownloader($package->getDistType());
  16067. } elseif ('source' === $installationSource) {
  16068. $downloader = $this->getDownloader($package->getSourceType());
  16069. } else {
  16070. throw new \InvalidArgumentException(
  16071. 'Package '.$package.' does not have an installation source set'
  16072. );
  16073. }
  16074. if ($installationSource !== $downloader->getInstallationSource()) {
  16075. throw new \LogicException(sprintf(
  16076. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  16077. get_class($downloader),
  16078. $downloader->getInstallationSource(),
  16079. $installationSource,
  16080. $package
  16081. ));
  16082. }
  16083. return $downloader;
  16084. }
  16085. public function getDownloaderType(DownloaderInterface $downloader): string
  16086. {
  16087. return array_search($downloader, $this->downloaders);
  16088. }
  16089. public function download(PackageInterface $package, string $targetDir, ?PackageInterface $prevPackage = null): PromiseInterface
  16090. {
  16091. $targetDir = $this->normalizeTargetDir($targetDir);
  16092. $this->filesystem->ensureDirectoryExists(dirname($targetDir));
  16093. $sources = $this->getAvailableSources($package, $prevPackage);
  16094. $io = $this->io;
  16095. $download = function ($retry = false) use (&$sources, $io, $package, $targetDir, &$download, $prevPackage) {
  16096. $source = array_shift($sources);
  16097. if ($retry) {
  16098. $io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  16099. }
  16100. $package->setInstallationSource($source);
  16101. $downloader = $this->getDownloaderForPackage($package);
  16102. if (!$downloader) {
  16103. return \React\Promise\resolve(null);
  16104. }
  16105. $handleError = static function ($e) use ($sources, $source, $package, $io, $download) {
  16106. if ($e instanceof \RuntimeException && !$e instanceof IrrecoverableDownloadException) {
  16107. if (!$sources) {
  16108. throw $e;
  16109. }
  16110. $io->writeError(
  16111. ' <warning>Failed to download '.
  16112. $package->getPrettyName().
  16113. ' from ' . $source . ': '.
  16114. $e->getMessage().'</warning>'
  16115. );
  16116. return $download(true);
  16117. }
  16118. throw $e;
  16119. };
  16120. try {
  16121. $result = $downloader->download($package, $targetDir, $prevPackage);
  16122. } catch (\Exception $e) {
  16123. return $handleError($e);
  16124. }
  16125. $res = $result->then(static function ($res) {
  16126. return $res;
  16127. }, $handleError);
  16128. return $res;
  16129. };
  16130. return $download();
  16131. }
  16132. public function prepare(string $type, PackageInterface $package, string $targetDir, ?PackageInterface $prevPackage = null): PromiseInterface
  16133. {
  16134. $targetDir = $this->normalizeTargetDir($targetDir);
  16135. $downloader = $this->getDownloaderForPackage($package);
  16136. if ($downloader) {
  16137. return $downloader->prepare($type, $package, $targetDir, $prevPackage);
  16138. }
  16139. return \React\Promise\resolve(null);
  16140. }
  16141. public function install(PackageInterface $package, string $targetDir): PromiseInterface
  16142. {
  16143. $targetDir = $this->normalizeTargetDir($targetDir);
  16144. $downloader = $this->getDownloaderForPackage($package);
  16145. if ($downloader) {
  16146. return $downloader->install($package, $targetDir);
  16147. }
  16148. return \React\Promise\resolve(null);
  16149. }
  16150. public function update(PackageInterface $initial, PackageInterface $target, string $targetDir): PromiseInterface
  16151. {
  16152. $targetDir = $this->normalizeTargetDir($targetDir);
  16153. $downloader = $this->getDownloaderForPackage($target);
  16154. $initialDownloader = $this->getDownloaderForPackage($initial);
  16155. if (!$initialDownloader && !$downloader) {
  16156. return \React\Promise\resolve(null);
  16157. }
  16158. if (!$downloader) {
  16159. return $initialDownloader->remove($initial, $targetDir);
  16160. }
  16161. $initialType = $this->getDownloaderType($initialDownloader);
  16162. $targetType = $this->getDownloaderType($downloader);
  16163. if ($initialType === $targetType) {
  16164. try {
  16165. return $downloader->update($initial, $target, $targetDir);
  16166. } catch (\RuntimeException $e) {
  16167. if (!$this->io->isInteractive()) {
  16168. throw $e;
  16169. }
  16170. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  16171. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ')) {
  16172. throw $e;
  16173. }
  16174. }
  16175. }
  16176. $promise = $initialDownloader->remove($initial, $targetDir);
  16177. return $promise->then(function ($res) use ($target, $targetDir): PromiseInterface {
  16178. return $this->install($target, $targetDir);
  16179. });
  16180. }
  16181. public function remove(PackageInterface $package, string $targetDir): PromiseInterface
  16182. {
  16183. $targetDir = $this->normalizeTargetDir($targetDir);
  16184. $downloader = $this->getDownloaderForPackage($package);
  16185. if ($downloader) {
  16186. return $downloader->remove($package, $targetDir);
  16187. }
  16188. return \React\Promise\resolve(null);
  16189. }
  16190. public function cleanup(string $type, PackageInterface $package, string $targetDir, ?PackageInterface $prevPackage = null): PromiseInterface
  16191. {
  16192. $targetDir = $this->normalizeTargetDir($targetDir);
  16193. $downloader = $this->getDownloaderForPackage($package);
  16194. if ($downloader) {
  16195. return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
  16196. }
  16197. return \React\Promise\resolve(null);
  16198. }
  16199. protected function resolvePackageInstallPreference(PackageInterface $package): string
  16200. {
  16201. foreach ($this->packagePreferences as $pattern => $preference) {
  16202. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  16203. if (Preg::isMatch($pattern, $package->getName())) {
  16204. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  16205. return 'dist';
  16206. }
  16207. return 'source';
  16208. }
  16209. }
  16210. return $package->isDev() ? 'source' : 'dist';
  16211. }
  16212. private function getAvailableSources(PackageInterface $package, ?PackageInterface $prevPackage = null): array
  16213. {
  16214. $sourceType = $package->getSourceType();
  16215. $distType = $package->getDistType();
  16216. $sources = [];
  16217. if ($sourceType) {
  16218. $sources[] = 'source';
  16219. }
  16220. if ($distType) {
  16221. $sources[] = 'dist';
  16222. }
  16223. if (empty($sources)) {
  16224. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  16225. }
  16226. if (
  16227. $prevPackage
  16228. && in_array($prevPackage->getInstallationSource(), $sources, true)
  16229. && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())
  16230. ) {
  16231. $prevSource = $prevPackage->getInstallationSource();
  16232. usort($sources, static function ($a, $b) use ($prevSource): int {
  16233. return $a === $prevSource ? -1 : 1;
  16234. });
  16235. return $sources;
  16236. }
  16237. if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  16238. $sources = array_reverse($sources);
  16239. }
  16240. return $sources;
  16241. }
  16242. private function normalizeTargetDir(string $dir): string
  16243. {
  16244. if ($dir === '\\' || $dir === '/') {
  16245. return $dir;
  16246. }
  16247. return rtrim($dir, '\\/');
  16248. }
  16249. }
  16250. <?php declare(strict_types=1);
  16251. namespace Composer\Downloader;
  16252. use Composer\Package\PackageInterface;
  16253. use React\Promise\PromiseInterface;
  16254. interface DownloaderInterface
  16255. {
  16256. public function getInstallationSource(): string;
  16257. public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface;
  16258. public function prepare(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface;
  16259. public function install(PackageInterface $package, string $path): PromiseInterface;
  16260. public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface;
  16261. public function remove(PackageInterface $package, string $path): PromiseInterface;
  16262. public function cleanup(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface;
  16263. }
  16264. <?php declare(strict_types=1);
  16265. namespace Composer\Downloader;
  16266. use Composer\Package\PackageInterface;
  16267. interface DvcsDownloaderInterface
  16268. {
  16269. public function getUnpushedChanges(PackageInterface $package, string $path): ?string;
  16270. }
  16271. <?php declare(strict_types=1);
  16272. namespace Composer\Downloader;
  16273. use Composer\Config;
  16274. use Composer\Cache;
  16275. use Composer\IO\IOInterface;
  16276. use Composer\IO\NullIO;
  16277. use Composer\Exception\IrrecoverableDownloadException;
  16278. use Composer\Package\Comparer\Comparer;
  16279. use Composer\DependencyResolver\Operation\UpdateOperation;
  16280. use Composer\DependencyResolver\Operation\InstallOperation;
  16281. use Composer\DependencyResolver\Operation\UninstallOperation;
  16282. use Composer\Package\PackageInterface;
  16283. use Composer\Plugin\PluginEvents;
  16284. use Composer\Plugin\PostFileDownloadEvent;
  16285. use Composer\Plugin\PreFileDownloadEvent;
  16286. use Composer\EventDispatcher\EventDispatcher;
  16287. use Composer\Util\Filesystem;
  16288. use Composer\Util\Http\Response;
  16289. use Composer\Util\Platform;
  16290. use Composer\Util\Silencer;
  16291. use Composer\Util\HttpDownloader;
  16292. use Composer\Util\Url as UrlUtil;
  16293. use Composer\Util\ProcessExecutor;
  16294. use React\Promise\PromiseInterface;
  16295. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  16296. {
  16297. protected $io;
  16298. protected $config;
  16299. protected $httpDownloader;
  16300. protected $filesystem;
  16301. protected $cache;
  16302. protected $eventDispatcher;
  16303. protected $process;
  16304. public static $downloadMetadata = [];
  16305. public static $responseHeaders = [];
  16306. private $lastCacheWrites = [];
  16307. private $additionalCleanupPaths = [];
  16308. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ?EventDispatcher $eventDispatcher = null, ?Cache $cache = null, ?Filesystem $filesystem = null, ?ProcessExecutor $process = null)
  16309. {
  16310. $this->io = $io;
  16311. $this->config = $config;
  16312. $this->eventDispatcher = $eventDispatcher;
  16313. $this->httpDownloader = $httpDownloader;
  16314. $this->cache = $cache;
  16315. $this->process = $process ?? new ProcessExecutor($io);
  16316. $this->filesystem = $filesystem ?? new Filesystem($this->process);
  16317. if ($this->cache !== null && $this->cache->gcIsNecessary()) {
  16318. $this->io->writeError('Running cache garbage collection', true, IOInterface::VERY_VERBOSE);
  16319. $this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
  16320. }
  16321. }
  16322. public function getInstallationSource(): string
  16323. {
  16324. return 'dist';
  16325. }
  16326. public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
  16327. {
  16328. if (null === $package->getDistUrl()) {
  16329. throw new \InvalidArgumentException('The given package is missing url information');
  16330. }
  16331. $cacheKeyGenerator = static function (PackageInterface $package, $key): string {
  16332. $cacheKey = hash('sha1', $key);
  16333. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  16334. };
  16335. $retries = 3;
  16336. $distUrls = $package->getDistUrls();
  16337. $urls = [];
  16338. foreach ($distUrls as $index => $url) {
  16339. $processedUrl = $this->processUrl($package, $url);
  16340. $urls[$index] = [
  16341. 'base' => $url,
  16342. 'processed' => $processedUrl,
  16343. 'cacheKey' => $cacheKeyGenerator($package, $processedUrl),
  16344. ];
  16345. }
  16346. assert(count($urls) > 0);
  16347. $fileName = $this->getFileName($package, $path);
  16348. $this->filesystem->ensureDirectoryExists($path);
  16349. $this->filesystem->ensureDirectoryExists(dirname($fileName));
  16350. $accept = null;
  16351. $reject = null;
  16352. $download = function () use ($output, $cacheKeyGenerator, $package, $fileName, &$urls, &$accept, &$reject) {
  16353. $url = reset($urls);
  16354. $index = key($urls);
  16355. if ($this->eventDispatcher !== null) {
  16356. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $url['processed'], 'package', $package);
  16357. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  16358. if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
  16359. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
  16360. } elseif ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
  16361. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
  16362. }
  16363. $url['processed'] = $preFileDownloadEvent->getProcessedUrl();
  16364. }
  16365. $urls[$index] = $url;
  16366. $checksum = $package->getDistSha1Checksum();
  16367. $cacheKey = $url['cacheKey'];
  16368. if ($this->cache !== null && ($checksum === null || $checksum === '' || $checksum === $this->cache->sha1($cacheKey)) && $this->cache->copyTo($cacheKey, $fileName)) {
  16369. if ($output) {
  16370. $this->io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
  16371. }
  16372. if (!$this->cache->isReadOnly()) {
  16373. $this->lastCacheWrites[$package->getName()] = $cacheKey;
  16374. }
  16375. $result = \React\Promise\resolve($fileName);
  16376. } else {
  16377. if ($output) {
  16378. $this->io->writeError(" - Downloading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  16379. }
  16380. $result = $this->httpDownloader->addCopy($url['processed'], $fileName, $package->getTransportOptions())
  16381. ->then($accept, $reject);
  16382. }
  16383. return $result->then(function ($result) use ($fileName, $checksum, $url, $package): string {
  16384. if (null === $result) {
  16385. return $fileName;
  16386. }
  16387. if (!file_exists($fileName)) {
  16388. throw new \UnexpectedValueException($url['base'].' could not be saved to '.$fileName.', make sure the'
  16389. .' directory is writable and you have internet connectivity');
  16390. }
  16391. if ($checksum !== null && $checksum !== '' && hash_file('sha1', $fileName) !== $checksum) {
  16392. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url['base'].')');
  16393. }
  16394. if ($this->eventDispatcher !== null) {
  16395. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], 'package', $package);
  16396. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  16397. }
  16398. return $fileName;
  16399. });
  16400. };
  16401. $accept = function (Response $response) use ($package, $fileName, &$urls): string {
  16402. $url = reset($urls);
  16403. $cacheKey = $url['cacheKey'];
  16404. $fileSize = @filesize($fileName);
  16405. if (false === $fileSize) {
  16406. $fileSize = $response->getHeader('Content-Length') ?? '?';
  16407. }
  16408. FileDownloader::$downloadMetadata[$package->getName()] = $fileSize;
  16409. if (Platform::getEnv('GITHUB_ACTIONS') !== false && Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING') === false) {
  16410. FileDownloader::$responseHeaders[$package->getName()] = $response->getHeaders();
  16411. }
  16412. if ($this->cache !== null && !$this->cache->isReadOnly()) {
  16413. $this->lastCacheWrites[$package->getName()] = $cacheKey;
  16414. $this->cache->copyFrom($cacheKey, $fileName);
  16415. }
  16416. $response->collect();
  16417. return $fileName;
  16418. };
  16419. $reject = function ($e) use (&$urls, $download, $fileName, $package, &$retries) {
  16420. if (file_exists($fileName)) {
  16421. $this->filesystem->unlink($fileName);
  16422. }
  16423. $this->clearLastCacheWrite($package);
  16424. if ($e instanceof IrrecoverableDownloadException) {
  16425. throw $e;
  16426. }
  16427. if ($e instanceof MaxFileSizeExceededException) {
  16428. throw $e;
  16429. }
  16430. if ($e instanceof TransportException) {
  16431. if (0 !== $e->getCode() && !in_array($e->getCode(), [500, 502, 503, 504], true)) {
  16432. $retries = 0;
  16433. }
  16434. }
  16435. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  16436. $retries = 0;
  16437. $urls = [];
  16438. }
  16439. if ($retries > 0) {
  16440. usleep(500000);
  16441. $retries--;
  16442. return $download();
  16443. }
  16444. array_shift($urls);
  16445. if (\count($urls) > 0) {
  16446. if ($this->io->isDebug()) {
  16447. $this->io->writeError(' Failed downloading '.$package->getName().': ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  16448. $this->io->writeError(' Trying the next URL for '.$package->getName());
  16449. } else {
  16450. $this->io->writeError(' Failed downloading '.$package->getName().', trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
  16451. }
  16452. $retries = 3;
  16453. usleep(100000);
  16454. return $download();
  16455. }
  16456. throw $e;
  16457. };
  16458. return $download();
  16459. }
  16460. public function prepare(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  16461. {
  16462. return \React\Promise\resolve(null);
  16463. }
  16464. public function cleanup(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  16465. {
  16466. $fileName = $this->getFileName($package, $path);
  16467. if (file_exists($fileName)) {
  16468. $this->filesystem->unlink($fileName);
  16469. }
  16470. $dirsToCleanUp = [
  16471. $path,
  16472. $this->config->get('vendor-dir').'/'.explode('/', $package->getPrettyName())[0],
  16473. $this->config->get('vendor-dir').'/composer/',
  16474. $this->config->get('vendor-dir'),
  16475. ];
  16476. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  16477. foreach ($this->additionalCleanupPaths[$package->getName()] as $pathToClean) {
  16478. $this->filesystem->remove($pathToClean);
  16479. }
  16480. }
  16481. foreach ($dirsToCleanUp as $dir) {
  16482. if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== Platform::getCwd()) {
  16483. $this->filesystem->removeDirectoryPhp($dir);
  16484. }
  16485. }
  16486. return \React\Promise\resolve(null);
  16487. }
  16488. public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  16489. {
  16490. if ($output) {
  16491. $this->io->writeError(" - " . InstallOperation::format($package));
  16492. }
  16493. $vendorDir = $this->config->get('vendor-dir');
  16494. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
  16495. $this->filesystem->emptyDirectory($path);
  16496. }
  16497. $this->filesystem->ensureDirectoryExists($path);
  16498. $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . $this->getDistPath($package, PATHINFO_BASENAME));
  16499. foreach ($package->getBinaries() as $bin) {
  16500. if (file_exists($path . '/' . $bin) && !is_executable($path . '/' . $bin)) {
  16501. Silencer::call('chmod', $path . '/' . $bin, 0777 & ~umask());
  16502. }
  16503. }
  16504. return \React\Promise\resolve(null);
  16505. }
  16506. protected function getDistPath(PackageInterface $package, int $component): string
  16507. {
  16508. return pathinfo((string) parse_url(strtr((string) $package->getDistUrl(), '\\', '/'), PHP_URL_PATH), $component);
  16509. }
  16510. protected function clearLastCacheWrite(PackageInterface $package): void
  16511. {
  16512. if ($this->cache !== null && isset($this->lastCacheWrites[$package->getName()])) {
  16513. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  16514. unset($this->lastCacheWrites[$package->getName()]);
  16515. }
  16516. }
  16517. protected function addCleanupPath(PackageInterface $package, string $path): void
  16518. {
  16519. $this->additionalCleanupPaths[$package->getName()][] = $path;
  16520. }
  16521. protected function removeCleanupPath(PackageInterface $package, string $path): void
  16522. {
  16523. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  16524. $idx = array_search($path, $this->additionalCleanupPaths[$package->getName()], true);
  16525. if (false !== $idx) {
  16526. unset($this->additionalCleanupPaths[$package->getName()][$idx]);
  16527. }
  16528. }
  16529. }
  16530. public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface
  16531. {
  16532. $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . $this->getInstallOperationAppendix($target, $path));
  16533. $promise = $this->remove($initial, $path, false);
  16534. return $promise->then(function () use ($target, $path): PromiseInterface {
  16535. return $this->install($target, $path, false);
  16536. });
  16537. }
  16538. public function remove(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  16539. {
  16540. if ($output) {
  16541. $this->io->writeError(" - " . UninstallOperation::format($package));
  16542. }
  16543. $promise = $this->filesystem->removeDirectoryAsync($path);
  16544. return $promise->then(static function ($result) use ($path): void {
  16545. if (!$result) {
  16546. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  16547. }
  16548. });
  16549. }
  16550. protected function getFileName(PackageInterface $package, string $path): string
  16551. {
  16552. $extension = $this->getDistPath($package, PATHINFO_EXTENSION);
  16553. if ($extension === '') {
  16554. $extension = $package->getDistType();
  16555. }
  16556. return rtrim($this->config->get('vendor-dir') . '/composer/tmp-' . hash('md5', $package . spl_object_hash($package)) . '.' . $extension, '.');
  16557. }
  16558. protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
  16559. {
  16560. return '';
  16561. }
  16562. protected function processUrl(PackageInterface $package, string $url): string
  16563. {
  16564. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  16565. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  16566. }
  16567. if ($package->getDistReference() !== null) {
  16568. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  16569. }
  16570. return $url;
  16571. }
  16572. public function getLocalChanges(PackageInterface $package, string $path): ?string
  16573. {
  16574. $prevIO = $this->io;
  16575. $this->io = new NullIO;
  16576. $this->io->loadConfiguration($this->config);
  16577. $e = null;
  16578. $output = '';
  16579. $targetDir = Filesystem::trimTrailingSlash($path);
  16580. try {
  16581. if (is_dir($targetDir.'_compare')) {
  16582. $this->filesystem->removeDirectory($targetDir.'_compare');
  16583. }
  16584. $promise = $this->download($package, $targetDir.'_compare', null, false);
  16585. $promise->then(null, function ($ex) use (&$e) {
  16586. $e = $ex;
  16587. });
  16588. $this->httpDownloader->wait();
  16589. if ($e !== null) {
  16590. throw $e;
  16591. }
  16592. $promise = $this->install($package, $targetDir.'_compare', false);
  16593. $promise->then(null, function ($ex) use (&$e) {
  16594. $e = $ex;
  16595. });
  16596. $this->process->wait();
  16597. if ($e !== null) {
  16598. throw $e;
  16599. }
  16600. $comparer = new Comparer();
  16601. $comparer->setSource($targetDir.'_compare');
  16602. $comparer->setUpdate($targetDir);
  16603. $comparer->doCompare();
  16604. $output = $comparer->getChangedAsString(true);
  16605. $this->filesystem->removeDirectory($targetDir.'_compare');
  16606. } catch (\Exception $e) {
  16607. }
  16608. $this->io = $prevIO;
  16609. if ($e !== null) {
  16610. if ($this->io->isDebug()) {
  16611. throw $e;
  16612. }
  16613. return 'Failed to detect changes: ['.get_class($e).'] '.$e->getMessage();
  16614. }
  16615. $output = trim($output);
  16616. return strlen($output) > 0 ? $output : null;
  16617. }
  16618. }
  16619. <?php declare(strict_types=1);
  16620. namespace Composer\Downloader;
  16621. class FilesystemException extends \Exception
  16622. {
  16623. public function __construct(string $message = '', int $code = 0, ?\Exception $previous = null)
  16624. {
  16625. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  16626. }
  16627. }
  16628. <?php declare(strict_types=1);
  16629. namespace Composer\Downloader;
  16630. use Composer\Util\Platform;
  16631. use React\Promise\PromiseInterface;
  16632. use Composer\Package\PackageInterface;
  16633. use Composer\Pcre\Preg;
  16634. use Composer\Util\ProcessExecutor;
  16635. use RuntimeException;
  16636. class FossilDownloader extends VcsDownloader
  16637. {
  16638. protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface
  16639. {
  16640. return \React\Promise\resolve(null);
  16641. }
  16642. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  16643. {
  16644. $this->config->prohibitUrlByConfig($url, $this->io);
  16645. $repoFile = $path . '.fossil';
  16646. $realPath = Platform::realpath($path);
  16647. $this->io->writeError("Cloning ".$package->getSourceReference());
  16648. $this->execute(['fossil', 'clone', '--', $url, $repoFile]);
  16649. $this->execute(['fossil', 'open', '--nested', '--', $repoFile], $realPath);
  16650. $this->execute(['fossil', 'update', '--', (string) $package->getSourceReference()], $realPath);
  16651. return \React\Promise\resolve(null);
  16652. }
  16653. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  16654. {
  16655. $this->config->prohibitUrlByConfig($url, $this->io);
  16656. $this->io->writeError(" Updating to ".$target->getSourceReference());
  16657. if (!$this->hasMetadataRepository($path)) {
  16658. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  16659. }
  16660. $realPath = Platform::realpath($path);
  16661. $this->execute(['fossil', 'pull'], $realPath);
  16662. $this->execute(['fossil', 'up', (string) $target->getSourceReference()], $realPath);
  16663. return \React\Promise\resolve(null);
  16664. }
  16665. public function getLocalChanges(PackageInterface $package, string $path): ?string
  16666. {
  16667. if (!$this->hasMetadataRepository($path)) {
  16668. return null;
  16669. }
  16670. $this->process->execute(['fossil', 'changes'], $output, Platform::realpath($path));
  16671. $output = trim($output);
  16672. return strlen($output) > 0 ? $output : null;
  16673. }
  16674. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  16675. {
  16676. $this->execute(['fossil', 'timeline', '-t', 'ci', '-W', '0', '-n', '0', 'before', $toReference], Platform::realpath($path), $output);
  16677. $log = '';
  16678. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  16679. foreach ($this->process->splitLines($output) as $line) {
  16680. if (Preg::isMatch($match, $line)) {
  16681. break;
  16682. }
  16683. $log .= $line;
  16684. }
  16685. return $log;
  16686. }
  16687. private function execute(array $command, ?string $cwd = null, ?string &$output = null): void
  16688. {
  16689. if (0 !== $this->process->execute($command, $output, $cwd)) {
  16690. throw new \RuntimeException('Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput());
  16691. }
  16692. }
  16693. protected function hasMetadataRepository(string $path): bool
  16694. {
  16695. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  16696. }
  16697. }
  16698. <?php declare(strict_types=1);
  16699. namespace Composer\Downloader;
  16700. use Composer\Config;
  16701. use Composer\IO\IOInterface;
  16702. use Composer\Package\PackageInterface;
  16703. use Composer\Pcre\Preg;
  16704. use Composer\Util\Filesystem;
  16705. use Composer\Util\Git as GitUtil;
  16706. use Composer\Util\Url;
  16707. use Composer\Util\Platform;
  16708. use Composer\Util\ProcessExecutor;
  16709. use Composer\Cache;
  16710. use React\Promise\PromiseInterface;
  16711. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  16712. {
  16713. private $hasStashedChanges = [];
  16714. private $hasDiscardedChanges = [];
  16715. private $gitUtil;
  16716. private $cachedPackages = [];
  16717. public function __construct(IOInterface $io, Config $config, ?ProcessExecutor $process = null, ?Filesystem $fs = null)
  16718. {
  16719. parent::__construct($io, $config, $process, $fs);
  16720. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  16721. }
  16722. protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface
  16723. {
  16724. if (Filesystem::isLocalPath($url)) {
  16725. return \React\Promise\resolve(null);
  16726. }
  16727. GitUtil::cleanEnv();
  16728. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($url)).'/';
  16729. $gitVersion = GitUtil::getVersion($this->process);
  16730. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
  16731. $this->io->writeError(" - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
  16732. $this->io->writeError(sprintf(' Cloning to cache at %s', $cachePath), true, IOInterface::DEBUG);
  16733. $ref = $package->getSourceReference();
  16734. if ($this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref, $package->getPrettyVersion()) && is_dir($cachePath)) {
  16735. $this->cachedPackages[$package->getId()][$ref] = true;
  16736. }
  16737. } elseif (null === $gitVersion) {
  16738. throw new \RuntimeException('git was not found in your PATH, skipping source download');
  16739. }
  16740. return \React\Promise\resolve(null);
  16741. }
  16742. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  16743. {
  16744. GitUtil::cleanEnv();
  16745. $path = $this->normalizePath($path);
  16746. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($url)).'/';
  16747. $ref = $package->getSourceReference();
  16748. if (!empty($this->cachedPackages[$package->getId()][$ref])) {
  16749. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  16750. $cloneFlags = ['--dissociate', '--reference', $cachePath];
  16751. $transportOptions = $package->getTransportOptions();
  16752. if (isset($transportOptions['git']['single_use_clone']) && $transportOptions['git']['single_use_clone']) {
  16753. $cloneFlags = [];
  16754. }
  16755. $commands = [
  16756. array_merge(['git', 'clone', '--no-checkout', $cachePath, $path], $cloneFlags),
  16757. ['git', 'remote', 'set-url', 'origin', '--', '%sanitizedUrl%'],
  16758. ['git', 'remote', 'add', 'composer', '--', '%sanitizedUrl%'],
  16759. ];
  16760. } else {
  16761. $msg = "Cloning ".$this->getShortHash($ref);
  16762. $commands = [
  16763. array_merge(['git', 'clone', '--no-checkout', '--', '%url%', $path]),
  16764. ['git', 'remote', 'add', 'composer', '--', '%url%'],
  16765. ['git', 'fetch', 'composer'],
  16766. ['git', 'remote', 'set-url', 'origin', '--', '%sanitizedUrl%'],
  16767. ['git', 'remote', 'set-url', 'composer', '--', '%sanitizedUrl%'],
  16768. ];
  16769. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  16770. throw new \RuntimeException('The required git reference for '.$package->getName().' is not in cache and network is disabled, aborting');
  16771. }
  16772. }
  16773. $this->io->writeError($msg);
  16774. $this->gitUtil->runCommands($commands, $url, $path, true);
  16775. $sourceUrl = $package->getSourceUrl();
  16776. if ($url !== $sourceUrl && $sourceUrl !== null) {
  16777. $this->updateOriginUrl($path, $sourceUrl);
  16778. } else {
  16779. $this->setPushUrl($path, $url);
  16780. }
  16781. if ($newRef = $this->updateToCommit($package, $path, (string) $ref, $package->getPrettyVersion())) {
  16782. if ($package->getDistReference() === $package->getSourceReference()) {
  16783. $package->setDistReference($newRef);
  16784. }
  16785. $package->setSourceReference($newRef);
  16786. }
  16787. return \React\Promise\resolve(null);
  16788. }
  16789. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  16790. {
  16791. GitUtil::cleanEnv();
  16792. $path = $this->normalizePath($path);
  16793. if (!$this->hasMetadataRepository($path)) {
  16794. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  16795. }
  16796. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($url)).'/';
  16797. $ref = $target->getSourceReference();
  16798. if (!empty($this->cachedPackages[$target->getId()][$ref])) {
  16799. $msg = "Checking out ".$this->getShortHash($ref).' from cache';
  16800. $remoteUrl = $cachePath;
  16801. } else {
  16802. $msg = "Checking out ".$this->getShortHash($ref);
  16803. $remoteUrl = '%url%';
  16804. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  16805. throw new \RuntimeException('The required git reference for '.$target->getName().' is not in cache and network is disabled, aborting');
  16806. }
  16807. }
  16808. $this->io->writeError($msg);
  16809. if (0 !== $this->process->execute(['git', 'rev-parse', '--quiet', '--verify', $ref.'^{commit}'], $output, $path)) {
  16810. $commands = [
  16811. ['git', 'remote', 'set-url', 'composer', '--', $remoteUrl],
  16812. ['git', 'fetch', 'composer'],
  16813. ['git', 'fetch', '--tags', 'composer'],
  16814. ];
  16815. $this->gitUtil->runCommands($commands, $url, $path);
  16816. }
  16817. $command = ['git', 'remote', 'set-url', 'composer', '--', '%sanitizedUrl%'];
  16818. $this->gitUtil->runCommands([$command], $url, $path);
  16819. if ($newRef = $this->updateToCommit($target, $path, (string) $ref, $target->getPrettyVersion())) {
  16820. if ($target->getDistReference() === $target->getSourceReference()) {
  16821. $target->setDistReference($newRef);
  16822. }
  16823. $target->setSourceReference($newRef);
  16824. }
  16825. $updateOriginUrl = false;
  16826. if (
  16827. 0 === $this->process->execute(['git', 'remote', '-v'], $output, $path)
  16828. && Preg::isMatch('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  16829. && Preg::isMatch('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  16830. ) {
  16831. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  16832. $updateOriginUrl = true;
  16833. }
  16834. }
  16835. if ($updateOriginUrl && $target->getSourceUrl() !== null) {
  16836. $this->updateOriginUrl($path, $target->getSourceUrl());
  16837. }
  16838. return \React\Promise\resolve(null);
  16839. }
  16840. public function getLocalChanges(PackageInterface $package, string $path): ?string
  16841. {
  16842. GitUtil::cleanEnv();
  16843. if (!$this->hasMetadataRepository($path)) {
  16844. return null;
  16845. }
  16846. $command = ['git', 'status', '--porcelain', '--untracked-files=no'];
  16847. if (0 !== $this->process->execute($command, $output, $path)) {
  16848. throw new \RuntimeException('Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput());
  16849. }
  16850. $output = trim($output);
  16851. return strlen($output) > 0 ? $output : null;
  16852. }
  16853. public function getUnpushedChanges(PackageInterface $package, string $path): ?string
  16854. {
  16855. GitUtil::cleanEnv();
  16856. $path = $this->normalizePath($path);
  16857. if (!$this->hasMetadataRepository($path)) {
  16858. return null;
  16859. }
  16860. $command = ['git', 'show-ref', '--head', '-d'];
  16861. if (0 !== $this->process->execute($command, $output, $path)) {
  16862. throw new \RuntimeException('Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput());
  16863. }
  16864. $refs = trim($output);
  16865. if (!Preg::isMatchStrictGroups('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  16866. return null;
  16867. }
  16868. $headRef = $match[1];
  16869. if (!Preg::isMatchAllStrictGroups('{^'.preg_quote($headRef).' refs/heads/(.+)$}mi', $refs, $matches)) {
  16870. return null;
  16871. }
  16872. $candidateBranches = $matches[1];
  16873. $branch = $candidateBranches[0];
  16874. $unpushedChanges = null;
  16875. $branchNotFoundError = false;
  16876. for ($i = 0; $i <= 1; $i++) {
  16877. $remoteBranches = [];
  16878. foreach ($candidateBranches as $candidate) {
  16879. if (Preg::isMatchAllStrictGroups('{^[a-f0-9]+ refs/remotes/((?:[^/]+)/'.preg_quote($candidate).')$}mi', $refs, $matches)) {
  16880. foreach ($matches[1] as $match) {
  16881. $branch = $candidate;
  16882. $remoteBranches[] = $match;
  16883. }
  16884. break;
  16885. }
  16886. }
  16887. if (count($remoteBranches) === 0) {
  16888. $unpushedChanges = 'Branch ' . $branch . ' could not be found on any remote and appears to be unpushed';
  16889. $branchNotFoundError = true;
  16890. } else {
  16891. if ($branchNotFoundError) {
  16892. $unpushedChanges = null;
  16893. }
  16894. foreach ($remoteBranches as $remoteBranch) {
  16895. $command = ['git', 'diff', '--name-status', $remoteBranch.'...'.$branch, '--'];
  16896. if (0 !== $this->process->execute($command, $output, $path)) {
  16897. throw new \RuntimeException('Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput());
  16898. }
  16899. $output = trim($output);
  16900. if ($unpushedChanges === null || strlen($output) < strlen($unpushedChanges)) {
  16901. $unpushedChanges = $output;
  16902. }
  16903. }
  16904. }
  16905. if ($unpushedChanges && $i === 0) {
  16906. $this->process->execute(['git', 'fetch', '--all'], $output, $path);
  16907. $command = ['git', 'show-ref', '--head', '-d'];
  16908. if (0 !== $this->process->execute($command, $output, $path)) {
  16909. throw new \RuntimeException('Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput());
  16910. }
  16911. $refs = trim($output);
  16912. }
  16913. if (!$unpushedChanges) {
  16914. break;
  16915. }
  16916. }
  16917. return $unpushedChanges;
  16918. }
  16919. protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
  16920. {
  16921. GitUtil::cleanEnv();
  16922. $path = $this->normalizePath($path);
  16923. $unpushed = $this->getUnpushedChanges($package, $path);
  16924. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  16925. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  16926. }
  16927. if (null === ($changes = $this->getLocalChanges($package, $path))) {
  16928. return \React\Promise\resolve(null);
  16929. }
  16930. if (!$this->io->isInteractive()) {
  16931. $discardChanges = $this->config->get('discard-changes');
  16932. if (true === $discardChanges) {
  16933. return $this->discardChanges($path);
  16934. }
  16935. if ('stash' === $discardChanges) {
  16936. if (!$update) {
  16937. return parent::cleanChanges($package, $path, $update);
  16938. }
  16939. return $this->stashChanges($path);
  16940. }
  16941. return parent::cleanChanges($package, $path, $update);
  16942. }
  16943. $changes = array_map(static function ($elem): string {
  16944. return ' '.$elem;
  16945. }, Preg::split('{\s*\r?\n\s*}', $changes));
  16946. $this->io->writeError(' <error>'.$package->getPrettyName().' has modified files:</error>');
  16947. $this->io->writeError(array_slice($changes, 0, 10));
  16948. if (count($changes) > 10) {
  16949. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  16950. }
  16951. while (true) {
  16952. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  16953. case 'y':
  16954. $this->discardChanges($path);
  16955. break 2;
  16956. case 's':
  16957. if (!$update) {
  16958. goto help;
  16959. }
  16960. $this->stashChanges($path);
  16961. break 2;
  16962. case 'n':
  16963. throw new \RuntimeException('Update aborted');
  16964. case 'v':
  16965. $this->io->writeError($changes);
  16966. break;
  16967. case 'd':
  16968. $this->viewDiff($path);
  16969. break;
  16970. case '?':
  16971. default:
  16972. help :
  16973. $this->io->writeError([
  16974. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  16975. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  16976. ' v - view modified files',
  16977. ' d - view local modifications (diff)',
  16978. ]);
  16979. if ($update) {
  16980. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  16981. }
  16982. $this->io->writeError(' ? - print help');
  16983. break;
  16984. }
  16985. }
  16986. return \React\Promise\resolve(null);
  16987. }
  16988. protected function reapplyChanges(string $path): void
  16989. {
  16990. $path = $this->normalizePath($path);
  16991. if (!empty($this->hasStashedChanges[$path])) {
  16992. unset($this->hasStashedChanges[$path]);
  16993. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  16994. if (0 !== $this->process->execute(['git', 'stash', 'pop'], $output, $path)) {
  16995. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  16996. }
  16997. }
  16998. unset($this->hasDiscardedChanges[$path]);
  16999. }
  17000. protected function updateToCommit(PackageInterface $package, string $path, string $reference, string $prettyVersion): ?string
  17001. {
  17002. $force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? ['-f'] : [];
  17003. $branch = Preg::replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $prettyVersion);
  17004. $execute = function (array $command) use (&$output, $path) {
  17005. $output = '';
  17006. return 0 === $this->process->execute($command, $output, $path);
  17007. };
  17008. $branches = null;
  17009. if ($execute(['git', 'branch', '-r'])) {
  17010. $branches = $output;
  17011. }
  17012. $gitRef = $reference;
  17013. if (!Preg::isMatch('{^[a-f0-9]{40}$}', $reference)
  17014. && null !== $branches
  17015. && Preg::isMatch('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  17016. ) {
  17017. $command1 = array_merge(['git', 'checkout'], $force, ['-B', $branch, 'composer/'.$reference, '--']);
  17018. $command2 = ['git', 'reset', '--hard', 'composer/'.$reference, '--'];
  17019. if ($execute($command1) && $execute($command2)) {
  17020. return null;
  17021. }
  17022. }
  17023. if (Preg::isMatch('{^[a-f0-9]{40}$}', $reference)) {
  17024. if (null !== $branches && !Preg::isMatch('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && Preg::isMatch('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  17025. $branch = 'v' . $branch;
  17026. }
  17027. $command = ['git', 'checkout', $branch, '--'];
  17028. $fallbackCommand = array_merge(['git', 'checkout'], $force, ['-B', $branch, 'composer/'.$branch, '--']);
  17029. $resetCommand = ['git', 'reset', '--hard', $reference, '--'];
  17030. if (($execute($command) || $execute($fallbackCommand)) && $execute($resetCommand)) {
  17031. return null;
  17032. }
  17033. }
  17034. $command1 = array_merge(['git', 'checkout'], $force, [$gitRef, '--']);
  17035. $command2 = ['git', 'reset', '--hard', $gitRef, '--'];
  17036. if ($execute($command1) && $execute($command2)) {
  17037. return null;
  17038. }
  17039. $exceptionExtra = '';
  17040. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  17041. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  17042. $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.';
  17043. }
  17044. $command = implode(' ', $command1). ' && '.implode(' ', $command2);
  17045. throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput() . $exceptionExtra));
  17046. }
  17047. protected function updateOriginUrl(string $path, string $url): void
  17048. {
  17049. $this->process->execute(['git', 'remote', 'set-url', 'origin', '--', $url], $output, $path);
  17050. $this->setPushUrl($path, $url);
  17051. }
  17052. protected function setPushUrl(string $path, string $url): void
  17053. {
  17054. if (Preg::isMatch('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  17055. $protocols = $this->config->get('github-protocols');
  17056. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  17057. if (!in_array('ssh', $protocols, true)) {
  17058. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  17059. }
  17060. $cmd = ['git', 'remote', 'set-url', '--push', 'origin', '--', $pushUrl];
  17061. $this->process->execute($cmd, $ignoredOutput, $path);
  17062. }
  17063. }
  17064. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  17065. {
  17066. $path = $this->normalizePath($path);
  17067. $command = array_merge(['git', 'log', $fromReference.'..'.$toReference, '--pretty=format:%h - %an: %s'], GitUtil::getNoShowSignatureFlags($this->process));
  17068. if (0 !== $this->process->execute($command, $output, $path)) {
  17069. throw new \RuntimeException('Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput());
  17070. }
  17071. return $output;
  17072. }
  17073. protected function discardChanges(string $path): PromiseInterface
  17074. {
  17075. $path = $this->normalizePath($path);
  17076. if (0 !== $this->process->execute(['git', 'clean', '-df'], $output, $path)) {
  17077. throw new \RuntimeException("Could not reset changes\n\n:".$output);
  17078. }
  17079. if (0 !== $this->process->execute(['git', 'reset', '--hard'], $output, $path)) {
  17080. throw new \RuntimeException("Could not reset changes\n\n:".$output);
  17081. }
  17082. $this->hasDiscardedChanges[$path] = true;
  17083. return \React\Promise\resolve(null);
  17084. }
  17085. protected function stashChanges(string $path): PromiseInterface
  17086. {
  17087. $path = $this->normalizePath($path);
  17088. if (0 !== $this->process->execute(['git', 'stash', '--include-untracked'], $output, $path)) {
  17089. throw new \RuntimeException("Could not stash changes\n\n:".$output);
  17090. }
  17091. $this->hasStashedChanges[$path] = true;
  17092. return \React\Promise\resolve(null);
  17093. }
  17094. protected function viewDiff(string $path): void
  17095. {
  17096. $path = $this->normalizePath($path);
  17097. if (0 !== $this->process->execute(['git', 'diff', 'HEAD'], $output, $path)) {
  17098. throw new \RuntimeException("Could not view diff\n\n:".$output);
  17099. }
  17100. $this->io->writeError($output);
  17101. }
  17102. protected function normalizePath(string $path): string
  17103. {
  17104. if (Platform::isWindows() && strlen($path) > 0) {
  17105. $basePath = $path;
  17106. $removed = [];
  17107. while (!is_dir($basePath) && $basePath !== '\\') {
  17108. array_unshift($removed, basename($basePath));
  17109. $basePath = dirname($basePath);
  17110. }
  17111. if ($basePath === '\\') {
  17112. return $path;
  17113. }
  17114. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  17115. }
  17116. return $path;
  17117. }
  17118. protected function hasMetadataRepository(string $path): bool
  17119. {
  17120. $path = $this->normalizePath($path);
  17121. return is_dir($path.'/.git');
  17122. }
  17123. protected function getShortHash(string $reference): string
  17124. {
  17125. if (!$this->io->isVerbose() && Preg::isMatch('{^[0-9a-f]{40}$}', $reference)) {
  17126. return substr($reference, 0, 10);
  17127. }
  17128. return $reference;
  17129. }
  17130. }
  17131. <?php declare(strict_types=1);
  17132. namespace Composer\Downloader;
  17133. use React\Promise\PromiseInterface;
  17134. use Composer\Package\PackageInterface;
  17135. use Composer\Util\Platform;
  17136. use Composer\Util\ProcessExecutor;
  17137. class GzipDownloader extends ArchiveDownloader
  17138. {
  17139. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  17140. {
  17141. $filename = pathinfo(parse_url(strtr((string) $package->getDistUrl(), '\\', '/'), PHP_URL_PATH), PATHINFO_FILENAME);
  17142. $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
  17143. if (!Platform::isWindows()) {
  17144. $command = ['sh', '-c', 'gzip -cd -- "$0" > "$1"', $file, $targetFilepath];
  17145. if (0 === $this->process->execute($command, $ignoredOutput)) {
  17146. return \React\Promise\resolve(null);
  17147. }
  17148. if (extension_loaded('zlib')) {
  17149. $this->extractUsingExt($file, $targetFilepath);
  17150. return \React\Promise\resolve(null);
  17151. }
  17152. $processError = 'Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput();
  17153. throw new \RuntimeException($processError);
  17154. }
  17155. $this->extractUsingExt($file, $targetFilepath);
  17156. return \React\Promise\resolve(null);
  17157. }
  17158. private function extractUsingExt(string $file, string $targetFilepath): void
  17159. {
  17160. $archiveFile = gzopen($file, 'rb');
  17161. $targetFile = fopen($targetFilepath, 'wb');
  17162. while ($string = gzread($archiveFile, 4096)) {
  17163. fwrite($targetFile, $string, Platform::strlen($string));
  17164. }
  17165. gzclose($archiveFile);
  17166. fclose($targetFile);
  17167. }
  17168. }
  17169. <?php declare(strict_types=1);
  17170. namespace Composer\Downloader;
  17171. use React\Promise\PromiseInterface;
  17172. use Composer\Package\PackageInterface;
  17173. use Composer\Util\ProcessExecutor;
  17174. use Composer\Util\Hg as HgUtils;
  17175. class HgDownloader extends VcsDownloader
  17176. {
  17177. protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface
  17178. {
  17179. if (null === HgUtils::getVersion($this->process)) {
  17180. throw new \RuntimeException('hg was not found in your PATH, skipping source download');
  17181. }
  17182. return \React\Promise\resolve(null);
  17183. }
  17184. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  17185. {
  17186. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  17187. $cloneCommand = static function (string $url) use ($path): array {
  17188. return ['hg', 'clone', '--', $url, $path];
  17189. };
  17190. $hgUtils->runCommand($cloneCommand, $url, $path);
  17191. $command = ['hg', 'up', '--', (string) $package->getSourceReference()];
  17192. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  17193. throw new \RuntimeException('Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput());
  17194. }
  17195. return \React\Promise\resolve(null);
  17196. }
  17197. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  17198. {
  17199. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  17200. $ref = $target->getSourceReference();
  17201. $this->io->writeError(" Updating to ".$target->getSourceReference());
  17202. if (!$this->hasMetadataRepository($path)) {
  17203. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  17204. }
  17205. $command = static function ($url): array {
  17206. return ['hg', 'pull', '--', $url];
  17207. };
  17208. $hgUtils->runCommand($command, $url, $path);
  17209. $command = static function () use ($ref): array {
  17210. return ['hg', 'up', '--', $ref];
  17211. };
  17212. $hgUtils->runCommand($command, $url, $path);
  17213. return \React\Promise\resolve(null);
  17214. }
  17215. public function getLocalChanges(PackageInterface $package, string $path): ?string
  17216. {
  17217. if (!is_dir($path.'/.hg')) {
  17218. return null;
  17219. }
  17220. $this->process->execute(['hg', 'st'], $output, realpath($path));
  17221. $output = trim($output);
  17222. return strlen($output) > 0 ? $output : null;
  17223. }
  17224. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  17225. {
  17226. $command = ['hg', 'log', '-r', $fromReference.':'.$toReference, '--style', 'compact'];
  17227. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  17228. throw new \RuntimeException('Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput());
  17229. }
  17230. return $output;
  17231. }
  17232. protected function hasMetadataRepository(string $path): bool
  17233. {
  17234. return is_dir($path . '/.hg');
  17235. }
  17236. }
  17237. <?php declare(strict_types=1);
  17238. namespace Composer\Downloader;
  17239. class MaxFileSizeExceededException extends TransportException
  17240. {
  17241. }
  17242. <?php declare(strict_types=1);
  17243. namespace Composer\Downloader;
  17244. use React\Promise\PromiseInterface;
  17245. use Composer\Package\Archiver\ArchivableFilesFinder;
  17246. use Composer\Package\Dumper\ArrayDumper;
  17247. use Composer\Package\PackageInterface;
  17248. use Composer\Package\Version\VersionGuesser;
  17249. use Composer\Package\Version\VersionParser;
  17250. use Composer\Util\Platform;
  17251. use Composer\Util\Filesystem;
  17252. use Symfony\Component\Filesystem\Exception\IOException;
  17253. use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
  17254. use Composer\DependencyResolver\Operation\InstallOperation;
  17255. use Composer\DependencyResolver\Operation\UninstallOperation;
  17256. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  17257. {
  17258. private const STRATEGY_SYMLINK = 10;
  17259. private const STRATEGY_MIRROR = 20;
  17260. public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
  17261. {
  17262. $path = Filesystem::trimTrailingSlash($path);
  17263. $url = $package->getDistUrl();
  17264. if (null === $url) {
  17265. throw new \RuntimeException('The package '.$package->getPrettyName().' has no dist url configured, cannot download.');
  17266. }
  17267. $realUrl = realpath($url);
  17268. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  17269. throw new \RuntimeException(sprintf(
  17270. 'Source path "%s" is not found for package %s',
  17271. $url,
  17272. $package->getName()
  17273. ));
  17274. }
  17275. if (realpath($path) === $realUrl) {
  17276. return \React\Promise\resolve(null);
  17277. }
  17278. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  17279. throw new \RuntimeException(sprintf(
  17280. 'Package %s cannot install to "%s" inside its source at "%s"',
  17281. $package->getName(),
  17282. realpath($path),
  17283. $realUrl
  17284. ));
  17285. }
  17286. return \React\Promise\resolve(null);
  17287. }
  17288. public function install(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  17289. {
  17290. $path = Filesystem::trimTrailingSlash($path);
  17291. $url = $package->getDistUrl();
  17292. if (null === $url) {
  17293. throw new \RuntimeException('The package '.$package->getPrettyName().' has no dist url configured, cannot install.');
  17294. }
  17295. $realUrl = realpath($url);
  17296. if (false === $realUrl) {
  17297. throw new \RuntimeException('Failed to realpath '.$url);
  17298. }
  17299. if (realpath($path) === $realUrl) {
  17300. if ($output) {
  17301. $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
  17302. }
  17303. return \React\Promise\resolve(null);
  17304. }
  17305. $transportOptions = $package->getTransportOptions() + ['relative' => true];
  17306. [$currentStrategy, $allowedStrategies] = $this->computeAllowedStrategies($transportOptions);
  17307. $symfonyFilesystem = new SymfonyFilesystem();
  17308. $this->filesystem->removeDirectory($path);
  17309. if ($output) {
  17310. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  17311. }
  17312. $isFallback = false;
  17313. if (self::STRATEGY_SYMLINK === $currentStrategy) {
  17314. try {
  17315. if (Platform::isWindows()) {
  17316. if ($output) {
  17317. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  17318. }
  17319. $this->filesystem->junction($realUrl, $path);
  17320. } else {
  17321. $path = rtrim($path, "/");
  17322. if ($output) {
  17323. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  17324. }
  17325. if ($transportOptions['relative'] === true) {
  17326. $absolutePath = $path;
  17327. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  17328. $absolutePath = Platform::getCwd() . DIRECTORY_SEPARATOR . $path;
  17329. }
  17330. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl, false, true);
  17331. $symfonyFilesystem->symlink($shortestPath.'/', $path);
  17332. } else {
  17333. $symfonyFilesystem->symlink($realUrl.'/', $path);
  17334. }
  17335. }
  17336. } catch (IOException $e) {
  17337. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
  17338. if ($output) {
  17339. $this->io->writeError('');
  17340. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  17341. }
  17342. $currentStrategy = self::STRATEGY_MIRROR;
  17343. $isFallback = true;
  17344. } else {
  17345. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  17346. }
  17347. }
  17348. }
  17349. if (self::STRATEGY_MIRROR === $currentStrategy) {
  17350. $realUrl = $this->filesystem->normalizePath($realUrl);
  17351. if ($output) {
  17352. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  17353. }
  17354. $iterator = new ArchivableFilesFinder($realUrl, []);
  17355. $symfonyFilesystem->mirror($realUrl, $path, $iterator);
  17356. }
  17357. if ($output) {
  17358. $this->io->writeError('');
  17359. }
  17360. return \React\Promise\resolve(null);
  17361. }
  17362. public function remove(PackageInterface $package, string $path, bool $output = true): PromiseInterface
  17363. {
  17364. $path = Filesystem::trimTrailingSlash($path);
  17365. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  17366. if ($output) {
  17367. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  17368. }
  17369. if (!$this->filesystem->removeJunction($path)) {
  17370. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  17371. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  17372. }
  17373. return \React\Promise\resolve(null);
  17374. }
  17375. $url = $package->getDistUrl();
  17376. if (null === $url) {
  17377. throw new \RuntimeException('The package '.$package->getPrettyName().' has no dist url configured, cannot remove.');
  17378. }
  17379. $fs = new Filesystem;
  17380. $absPath = $fs->isAbsolutePath($path) ? $path : Platform::getCwd() . '/' . $path;
  17381. $absDistUrl = $fs->isAbsolutePath($url) ? $url : Platform::getCwd() . '/' . $url;
  17382. if ($fs->normalizePath($absPath) === $fs->normalizePath($absDistUrl)) {
  17383. if ($output) {
  17384. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  17385. }
  17386. return \React\Promise\resolve(null);
  17387. }
  17388. return parent::remove($package, $path, $output);
  17389. }
  17390. public function getVcsReference(PackageInterface $package, string $path): ?string
  17391. {
  17392. $path = Filesystem::trimTrailingSlash($path);
  17393. $parser = new VersionParser;
  17394. $guesser = new VersionGuesser($this->config, $this->process, $parser, $this->io);
  17395. $dumper = new ArrayDumper;
  17396. $packageConfig = $dumper->dump($package);
  17397. $packageVersion = $guesser->guessVersion($packageConfig, $path);
  17398. if ($packageVersion !== null) {
  17399. return $packageVersion['commit'];
  17400. }
  17401. return null;
  17402. }
  17403. protected function getInstallOperationAppendix(PackageInterface $package, string $path): string
  17404. {
  17405. $url = $package->getDistUrl();
  17406. if (null === $url) {
  17407. throw new \RuntimeException('The package '.$package->getPrettyName().' has no dist url configured, cannot install.');
  17408. }
  17409. $realUrl = realpath($url);
  17410. if (false === $realUrl) {
  17411. throw new \RuntimeException('Failed to realpath '.$url);
  17412. }
  17413. if (realpath($path) === $realUrl) {
  17414. return ': Source already present';
  17415. }
  17416. [$currentStrategy] = $this->computeAllowedStrategies($package->getTransportOptions());
  17417. if ($currentStrategy === self::STRATEGY_SYMLINK) {
  17418. if (Platform::isWindows()) {
  17419. return ': Junctioning from '.$package->getDistUrl();
  17420. }
  17421. return ': Symlinking from '.$package->getDistUrl();
  17422. }
  17423. return ': Mirroring from '.$package->getDistUrl();
  17424. }
  17425. private function computeAllowedStrategies(array $transportOptions): array
  17426. {
  17427. $currentStrategy = self::STRATEGY_SYMLINK;
  17428. $allowedStrategies = [self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR];
  17429. $mirrorPathRepos = Platform::getEnv('COMPOSER_MIRROR_PATH_REPOS');
  17430. if ((bool) $mirrorPathRepos) {
  17431. $currentStrategy = self::STRATEGY_MIRROR;
  17432. }
  17433. $symlinkOption = $transportOptions['symlink'] ?? null;
  17434. if (true === $symlinkOption) {
  17435. $currentStrategy = self::STRATEGY_SYMLINK;
  17436. $allowedStrategies = [self::STRATEGY_SYMLINK];
  17437. } elseif (false === $symlinkOption) {
  17438. $currentStrategy = self::STRATEGY_MIRROR;
  17439. $allowedStrategies = [self::STRATEGY_MIRROR];
  17440. }
  17441. if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
  17442. if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
  17443. 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');
  17444. }
  17445. $currentStrategy = self::STRATEGY_MIRROR;
  17446. $allowedStrategies = [self::STRATEGY_MIRROR];
  17447. }
  17448. if (!Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !function_exists('symlink')) {
  17449. if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
  17450. 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');
  17451. }
  17452. $currentStrategy = self::STRATEGY_MIRROR;
  17453. $allowedStrategies = [self::STRATEGY_MIRROR];
  17454. }
  17455. return [$currentStrategy, $allowedStrategies];
  17456. }
  17457. private function safeJunctions(): bool
  17458. {
  17459. return function_exists('proc_open') &&
  17460. (PHP_WINDOWS_VERSION_MAJOR > 6 ||
  17461. (PHP_WINDOWS_VERSION_MAJOR === 6 && PHP_WINDOWS_VERSION_MINOR >= 1));
  17462. }
  17463. }
  17464. <?php declare(strict_types=1);
  17465. namespace Composer\Downloader;
  17466. use React\Promise\PromiseInterface;
  17467. use Composer\Package\PackageInterface;
  17468. use Composer\Repository\VcsRepository;
  17469. use Composer\Util\Perforce;
  17470. class PerforceDownloader extends VcsDownloader
  17471. {
  17472. protected $perforce;
  17473. protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface
  17474. {
  17475. return \React\Promise\resolve(null);
  17476. }
  17477. public function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  17478. {
  17479. $ref = $package->getSourceReference();
  17480. $label = $this->getLabelFromSourceReference((string) $ref);
  17481. $this->io->writeError('Cloning ' . $ref);
  17482. $this->initPerforce($package, $path, $url);
  17483. $this->perforce->setStream($ref);
  17484. $this->perforce->p4Login();
  17485. $this->perforce->writeP4ClientSpec();
  17486. $this->perforce->connectClient();
  17487. $this->perforce->syncCodeBase($label);
  17488. $this->perforce->cleanupClientSpec();
  17489. return \React\Promise\resolve(null);
  17490. }
  17491. private function getLabelFromSourceReference(string $ref): ?string
  17492. {
  17493. $pos = strpos($ref, '@');
  17494. if (false !== $pos) {
  17495. return substr($ref, $pos + 1);
  17496. }
  17497. return null;
  17498. }
  17499. public function initPerforce(PackageInterface $package, string $path, string $url): void
  17500. {
  17501. if (!empty($this->perforce)) {
  17502. $this->perforce->initializePath($path);
  17503. return;
  17504. }
  17505. $repository = $package->getRepository();
  17506. $repoConfig = null;
  17507. if ($repository instanceof VcsRepository) {
  17508. $repoConfig = $this->getRepoConfig($repository);
  17509. }
  17510. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  17511. }
  17512. private function getRepoConfig(VcsRepository $repository): array
  17513. {
  17514. return $repository->getRepoConfig();
  17515. }
  17516. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  17517. {
  17518. return $this->doInstall($target, $path, $url);
  17519. }
  17520. public function getLocalChanges(PackageInterface $package, string $path): ?string
  17521. {
  17522. $this->io->writeError('Perforce driver does not check for local changes before overriding');
  17523. return null;
  17524. }
  17525. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  17526. {
  17527. return $this->perforce->getCommitLogs($fromReference, $toReference);
  17528. }
  17529. public function setPerforce(Perforce $perforce): void
  17530. {
  17531. $this->perforce = $perforce;
  17532. }
  17533. protected function hasMetadataRepository(string $path): bool
  17534. {
  17535. return true;
  17536. }
  17537. }
  17538. <?php declare(strict_types=1);
  17539. namespace Composer\Downloader;
  17540. use React\Promise\PromiseInterface;
  17541. use Composer\Package\PackageInterface;
  17542. class PharDownloader extends ArchiveDownloader
  17543. {
  17544. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  17545. {
  17546. $archive = new \Phar($file);
  17547. $archive->extractTo($path, null, true);
  17548. return \React\Promise\resolve(null);
  17549. }
  17550. }
  17551. <?php declare(strict_types=1);
  17552. namespace Composer\Downloader;
  17553. use React\Promise\PromiseInterface;
  17554. use Composer\Util\IniHelper;
  17555. use Composer\Util\Platform;
  17556. use Composer\Util\ProcessExecutor;
  17557. use Composer\Package\PackageInterface;
  17558. use RarArchive;
  17559. class RarDownloader extends ArchiveDownloader
  17560. {
  17561. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  17562. {
  17563. $processError = null;
  17564. if (!Platform::isWindows()) {
  17565. $command = ['sh', '-c', 'unrar x -- "$0" "$1" >/dev/null && chmod -R u+w "$1"', $file, $path];
  17566. if (0 === $this->process->execute($command, $ignoredOutput)) {
  17567. return \React\Promise\resolve(null);
  17568. }
  17569. $processError = 'Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput();
  17570. }
  17571. if (!class_exists('RarArchive')) {
  17572. $iniMessage = IniHelper::getMessage();
  17573. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  17574. . $iniMessage . "\n" . $processError;
  17575. if (!Platform::isWindows()) {
  17576. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  17577. }
  17578. throw new \RuntimeException($error);
  17579. }
  17580. $rarArchive = RarArchive::open($file);
  17581. if (false === $rarArchive) {
  17582. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  17583. }
  17584. $entries = $rarArchive->getEntries();
  17585. if (false === $entries) {
  17586. throw new \RuntimeException('Could not retrieve RAR archive entries');
  17587. }
  17588. foreach ($entries as $entry) {
  17589. if (false === $entry->extract($path)) {
  17590. throw new \RuntimeException('Could not extract entry');
  17591. }
  17592. }
  17593. $rarArchive->close();
  17594. return \React\Promise\resolve(null);
  17595. }
  17596. }
  17597. <?php declare(strict_types=1);
  17598. namespace Composer\Downloader;
  17599. use Composer\Package\PackageInterface;
  17600. use Composer\Pcre\Preg;
  17601. use Composer\Util\Svn as SvnUtil;
  17602. use Composer\Repository\VcsRepository;
  17603. use Composer\Util\ProcessExecutor;
  17604. use React\Promise\PromiseInterface;
  17605. class SvnDownloader extends VcsDownloader
  17606. {
  17607. protected $cacheCredentials = true;
  17608. protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface
  17609. {
  17610. SvnUtil::cleanEnv();
  17611. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  17612. if (null === $util->binaryVersion()) {
  17613. throw new \RuntimeException('svn was not found in your PATH, skipping source download');
  17614. }
  17615. return \React\Promise\resolve(null);
  17616. }
  17617. protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface
  17618. {
  17619. SvnUtil::cleanEnv();
  17620. $ref = $package->getSourceReference();
  17621. $repo = $package->getRepository();
  17622. if ($repo instanceof VcsRepository) {
  17623. $repoConfig = $repo->getRepoConfig();
  17624. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  17625. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  17626. }
  17627. }
  17628. $this->io->writeError(" Checking out ".$package->getSourceReference());
  17629. $this->execute($package, $url, ['svn', 'co'], sprintf("%s/%s", $url, $ref), null, $path);
  17630. return \React\Promise\resolve(null);
  17631. }
  17632. protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface
  17633. {
  17634. SvnUtil::cleanEnv();
  17635. $ref = $target->getSourceReference();
  17636. if (!$this->hasMetadataRepository($path)) {
  17637. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  17638. }
  17639. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  17640. $flags = [];
  17641. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  17642. $flags[] = '--ignore-ancestry';
  17643. }
  17644. $this->io->writeError(" Checking out " . $ref);
  17645. $this->execute($target, $url, array_merge(['svn', 'switch'], $flags), sprintf("%s/%s", $url, $ref), $path);
  17646. return \React\Promise\resolve(null);
  17647. }
  17648. public function getLocalChanges(PackageInterface $package, string $path): ?string
  17649. {
  17650. if (!$this->hasMetadataRepository($path)) {
  17651. return null;
  17652. }
  17653. $this->process->execute(['svn', 'status', '--ignore-externals'], $output, $path);
  17654. return Preg::isMatch('{^ *[^X ] +}m', $output) ? $output : null;
  17655. }
  17656. protected function execute(PackageInterface $package, string $baseUrl, array $command, string $url, ?string $cwd = null, ?string $path = null): string
  17657. {
  17658. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  17659. $util->setCacheCredentials($this->cacheCredentials);
  17660. try {
  17661. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  17662. } catch (\RuntimeException $e) {
  17663. throw new \RuntimeException(
  17664. $package->getPrettyName().' could not be downloaded, '.$e->getMessage()
  17665. );
  17666. }
  17667. }
  17668. protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
  17669. {
  17670. if (null === ($changes = $this->getLocalChanges($package, $path))) {
  17671. return \React\Promise\resolve(null);
  17672. }
  17673. if (!$this->io->isInteractive()) {
  17674. if (true === $this->config->get('discard-changes')) {
  17675. return $this->discardChanges($path);
  17676. }
  17677. return parent::cleanChanges($package, $path, $update);
  17678. }
  17679. $changes = array_map(static function ($elem): string {
  17680. return ' '.$elem;
  17681. }, Preg::split('{\s*\r?\n\s*}', $changes));
  17682. $countChanges = count($changes);
  17683. $this->io->writeError(sprintf(' <error>'.$package->getPrettyName().' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  17684. $this->io->writeError(array_slice($changes, 0, 10));
  17685. if ($countChanges > 10) {
  17686. $remainingChanges = $countChanges - 10;
  17687. $this->io->writeError(
  17688. sprintf(
  17689. ' <info>'.$remainingChanges.' more file%s modified, choose "v" to view the full list</info>',
  17690. $remainingChanges === 1 ? '' : 's'
  17691. )
  17692. );
  17693. }
  17694. while (true) {
  17695. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  17696. case 'y':
  17697. $this->discardChanges($path);
  17698. break 2;
  17699. case 'n':
  17700. throw new \RuntimeException('Update aborted');
  17701. case 'v':
  17702. $this->io->writeError($changes);
  17703. break;
  17704. case '?':
  17705. default:
  17706. $this->io->writeError([
  17707. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  17708. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  17709. ' v - view modified files',
  17710. ' ? - print help',
  17711. ]);
  17712. break;
  17713. }
  17714. }
  17715. return \React\Promise\resolve(null);
  17716. }
  17717. protected function getCommitLogs(string $fromReference, string $toReference, string $path): string
  17718. {
  17719. if (Preg::isMatch('{@(\d+)$}', $fromReference) && Preg::isMatch('{@(\d+)$}', $toReference)) {
  17720. $command = ['svn', 'info', '--non-interactive', '--xml', '--', $path];
  17721. if (0 !== $this->process->execute($command, $output, $path)) {
  17722. throw new \RuntimeException(
  17723. 'Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput()
  17724. );
  17725. }
  17726. $urlPattern = '#<url>(.*)</url>#';
  17727. if (Preg::isMatchStrictGroups($urlPattern, $output, $matches)) {
  17728. $baseUrl = $matches[1];
  17729. } else {
  17730. throw new \RuntimeException(
  17731. 'Unable to determine svn url for path '. $path
  17732. );
  17733. }
  17734. $fromRevision = Preg::replace('{.*@(\d+)$}', '$1', $fromReference);
  17735. $toRevision = Preg::replace('{.*@(\d+)$}', '$1', $toReference);
  17736. $command = ['svn', 'log', '-r', $fromRevision.':'.$toRevision, '--incremental'];
  17737. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  17738. $util->setCacheCredentials($this->cacheCredentials);
  17739. try {
  17740. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  17741. } catch (\RuntimeException $e) {
  17742. throw new \RuntimeException(
  17743. 'Failed to execute ' . implode(' ', $command) . "\n\n".$e->getMessage()
  17744. );
  17745. }
  17746. }
  17747. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  17748. }
  17749. protected function discardChanges(string $path): PromiseInterface
  17750. {
  17751. if (0 !== $this->process->execute(['svn', 'revert', '-R', '.'], $output, $path)) {
  17752. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  17753. }
  17754. return \React\Promise\resolve(null);
  17755. }
  17756. protected function hasMetadataRepository(string $path): bool
  17757. {
  17758. return is_dir($path.'/.svn');
  17759. }
  17760. }
  17761. <?php declare(strict_types=1);
  17762. namespace Composer\Downloader;
  17763. use Composer\Package\PackageInterface;
  17764. use React\Promise\PromiseInterface;
  17765. class TarDownloader extends ArchiveDownloader
  17766. {
  17767. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  17768. {
  17769. $archive = new \PharData($file);
  17770. $archive->extractTo($path, null, true);
  17771. return \React\Promise\resolve(null);
  17772. }
  17773. }
  17774. <?php declare(strict_types=1);
  17775. namespace Composer\Downloader;
  17776. class TransportException extends \RuntimeException
  17777. {
  17778. protected $headers;
  17779. protected $response;
  17780. protected $statusCode;
  17781. protected $responseInfo = [];
  17782. public function __construct(string $message = "", int $code = 400, ?\Throwable $previous = null)
  17783. {
  17784. parent::__construct($message, $code, $previous);
  17785. }
  17786. public function setHeaders(array $headers): void
  17787. {
  17788. $this->headers = $headers;
  17789. }
  17790. public function getHeaders(): ?array
  17791. {
  17792. return $this->headers;
  17793. }
  17794. public function setResponse(?string $response): void
  17795. {
  17796. $this->response = $response;
  17797. }
  17798. public function getResponse(): ?string
  17799. {
  17800. return $this->response;
  17801. }
  17802. public function setStatusCode($statusCode): void
  17803. {
  17804. $this->statusCode = $statusCode;
  17805. }
  17806. public function getStatusCode(): ?int
  17807. {
  17808. return $this->statusCode;
  17809. }
  17810. public function getResponseInfo(): array
  17811. {
  17812. return $this->responseInfo;
  17813. }
  17814. public function setResponseInfo(array $responseInfo): void
  17815. {
  17816. $this->responseInfo = $responseInfo;
  17817. }
  17818. }
  17819. <?php declare(strict_types=1);
  17820. namespace Composer\Downloader;
  17821. use Composer\Package\PackageInterface;
  17822. interface VcsCapableDownloaderInterface
  17823. {
  17824. public function getVcsReference(PackageInterface $package, string $path): ?string;
  17825. }
  17826. <?php declare(strict_types=1);
  17827. namespace Composer\Downloader;
  17828. use Composer\Config;
  17829. use Composer\Package\Dumper\ArrayDumper;
  17830. use Composer\Package\PackageInterface;
  17831. use Composer\Package\Version\VersionGuesser;
  17832. use Composer\Package\Version\VersionParser;
  17833. use Composer\Util\ProcessExecutor;
  17834. use Composer\IO\IOInterface;
  17835. use Composer\Util\Filesystem;
  17836. use React\Promise\PromiseInterface;
  17837. use Composer\DependencyResolver\Operation\UpdateOperation;
  17838. use Composer\DependencyResolver\Operation\InstallOperation;
  17839. use Composer\DependencyResolver\Operation\UninstallOperation;
  17840. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  17841. {
  17842. protected $io;
  17843. protected $config;
  17844. protected $process;
  17845. protected $filesystem;
  17846. protected $hasCleanedChanges = [];
  17847. public function __construct(IOInterface $io, Config $config, ?ProcessExecutor $process = null, ?Filesystem $fs = null)
  17848. {
  17849. $this->io = $io;
  17850. $this->config = $config;
  17851. $this->process = $process ?? new ProcessExecutor($io);
  17852. $this->filesystem = $fs ?? new Filesystem($this->process);
  17853. }
  17854. public function getInstallationSource(): string
  17855. {
  17856. return 'source';
  17857. }
  17858. public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  17859. {
  17860. if (!$package->getSourceReference()) {
  17861. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  17862. }
  17863. $urls = $this->prepareUrls($package->getSourceUrls());
  17864. while ($url = array_shift($urls)) {
  17865. try {
  17866. return $this->doDownload($package, $path, $url, $prevPackage);
  17867. } catch (\Exception $e) {
  17868. if ($e instanceof \PHPUnit\Framework\Exception) {
  17869. throw $e;
  17870. }
  17871. if ($this->io->isDebug()) {
  17872. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  17873. } elseif (count($urls)) {
  17874. $this->io->writeError(' Failed, trying the next URL');
  17875. }
  17876. if (!count($urls)) {
  17877. throw $e;
  17878. }
  17879. }
  17880. }
  17881. return \React\Promise\resolve(null);
  17882. }
  17883. public function prepare(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  17884. {
  17885. if ($type === 'update') {
  17886. $this->cleanChanges($prevPackage, $path, true);
  17887. $this->hasCleanedChanges[$prevPackage->getUniqueName()] = true;
  17888. } elseif ($type === 'install') {
  17889. $this->filesystem->emptyDirectory($path);
  17890. } elseif ($type === 'uninstall') {
  17891. $this->cleanChanges($package, $path, false);
  17892. }
  17893. return \React\Promise\resolve(null);
  17894. }
  17895. public function cleanup(string $type, PackageInterface $package, string $path, ?PackageInterface $prevPackage = null): PromiseInterface
  17896. {
  17897. if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
  17898. $this->reapplyChanges($path);
  17899. unset($this->hasCleanedChanges[$prevPackage->getUniqueName()]);
  17900. }
  17901. return \React\Promise\resolve(null);
  17902. }
  17903. public function install(PackageInterface $package, string $path): PromiseInterface
  17904. {
  17905. if (!$package->getSourceReference()) {
  17906. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  17907. }
  17908. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  17909. $urls = $this->prepareUrls($package->getSourceUrls());
  17910. while ($url = array_shift($urls)) {
  17911. try {
  17912. $this->doInstall($package, $path, $url);
  17913. break;
  17914. } catch (\Exception $e) {
  17915. if ($e instanceof \PHPUnit\Framework\Exception) {
  17916. throw $e;
  17917. }
  17918. if ($this->io->isDebug()) {
  17919. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  17920. } elseif (count($urls)) {
  17921. $this->io->writeError(' Failed, trying the next URL');
  17922. }
  17923. if (!count($urls)) {
  17924. throw $e;
  17925. }
  17926. }
  17927. }
  17928. return \React\Promise\resolve(null);
  17929. }
  17930. public function update(PackageInterface $initial, PackageInterface $target, string $path): PromiseInterface
  17931. {
  17932. if (!$target->getSourceReference()) {
  17933. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  17934. }
  17935. $this->io->writeError(" - " . UpdateOperation::format($initial, $target).': ', false);
  17936. $urls = $this->prepareUrls($target->getSourceUrls());
  17937. $exception = null;
  17938. while ($url = array_shift($urls)) {
  17939. try {
  17940. $this->doUpdate($initial, $target, $path, $url);
  17941. $exception = null;
  17942. break;
  17943. } catch (\Exception $exception) {
  17944. if ($exception instanceof \PHPUnit\Framework\Exception) {
  17945. throw $exception;
  17946. }
  17947. if ($this->io->isDebug()) {
  17948. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  17949. } elseif (count($urls)) {
  17950. $this->io->writeError(' Failed, trying the next URL');
  17951. }
  17952. }
  17953. }
  17954. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  17955. $message = 'Pulling in changes:';
  17956. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  17957. if ('' === trim($logs)) {
  17958. $message = 'Rolling back changes:';
  17959. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  17960. }
  17961. if ('' !== trim($logs)) {
  17962. $logs = implode("\n", array_map(static function ($line): string {
  17963. return ' ' . $line;
  17964. }, explode("\n", $logs)));
  17965. $logs = str_replace('<', '\<', $logs);
  17966. $this->io->writeError(' '.$message);
  17967. $this->io->writeError($logs);
  17968. }
  17969. }
  17970. if (!$urls && $exception) {
  17971. throw $exception;
  17972. }
  17973. return \React\Promise\resolve(null);
  17974. }
  17975. public function remove(PackageInterface $package, string $path): PromiseInterface
  17976. {
  17977. $this->io->writeError(" - " . UninstallOperation::format($package));
  17978. $promise = $this->filesystem->removeDirectoryAsync($path);
  17979. return $promise->then(static function (bool $result) use ($path) {
  17980. if (!$result) {
  17981. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  17982. }
  17983. });
  17984. }
  17985. public function getVcsReference(PackageInterface $package, string $path): ?string
  17986. {
  17987. $parser = new VersionParser;
  17988. $guesser = new VersionGuesser($this->config, $this->process, $parser, $this->io);
  17989. $dumper = new ArrayDumper;
  17990. $packageConfig = $dumper->dump($package);
  17991. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  17992. return $packageVersion['commit'];
  17993. }
  17994. return null;
  17995. }
  17996. protected function cleanChanges(PackageInterface $package, string $path, bool $update): PromiseInterface
  17997. {
  17998. if (null !== $this->getLocalChanges($package, $path)) {
  17999. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  18000. }
  18001. return \React\Promise\resolve(null);
  18002. }
  18003. protected function reapplyChanges(string $path): void
  18004. {
  18005. }
  18006. abstract protected function doDownload(PackageInterface $package, string $path, string $url, ?PackageInterface $prevPackage = null): PromiseInterface;
  18007. abstract protected function doInstall(PackageInterface $package, string $path, string $url): PromiseInterface;
  18008. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, string $path, string $url): PromiseInterface;
  18009. abstract protected function getCommitLogs(string $fromReference, string $toReference, string $path): string;
  18010. abstract protected function hasMetadataRepository(string $path): bool;
  18011. private function prepareUrls(array $urls): array
  18012. {
  18013. foreach ($urls as $index => $url) {
  18014. if (Filesystem::isLocalPath($url)) {
  18015. $fileProtocol = 'file://';
  18016. $isFileProtocol = false;
  18017. if (0 === strpos($url, $fileProtocol)) {
  18018. $url = substr($url, strlen($fileProtocol));
  18019. $isFileProtocol = true;
  18020. }
  18021. if (false !== strpos($url, '%')) {
  18022. $url = rawurldecode($url);
  18023. }
  18024. $urls[$index] = realpath($url);
  18025. if ($isFileProtocol) {
  18026. $urls[$index] = $fileProtocol . $urls[$index];
  18027. }
  18028. }
  18029. }
  18030. return $urls;
  18031. }
  18032. }
  18033. <?php declare(strict_types=1);
  18034. namespace Composer\Downloader;
  18035. use React\Promise\PromiseInterface;
  18036. use Composer\Package\PackageInterface;
  18037. use Composer\Util\ProcessExecutor;
  18038. class XzDownloader extends ArchiveDownloader
  18039. {
  18040. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  18041. {
  18042. $command = ['tar', '-xJf', $file, '-C', $path];
  18043. if (0 === $this->process->execute($command, $ignoredOutput)) {
  18044. return \React\Promise\resolve(null);
  18045. }
  18046. $processError = 'Failed to execute ' . implode(' ', $command) . "\n\n" . $this->process->getErrorOutput();
  18047. throw new \RuntimeException($processError);
  18048. }
  18049. }
  18050. <?php declare(strict_types=1);
  18051. namespace Composer\Downloader;
  18052. use Composer\Package\PackageInterface;
  18053. use Composer\Pcre\Preg;
  18054. use Composer\Util\IniHelper;
  18055. use Composer\Util\Platform;
  18056. use Composer\Util\ProcessExecutor;
  18057. use Symfony\Component\Process\ExecutableFinder;
  18058. use Symfony\Component\Process\Process;
  18059. use React\Promise\PromiseInterface;
  18060. use ZipArchive;
  18061. class ZipDownloader extends ArchiveDownloader
  18062. {
  18063. private static $unzipCommands;
  18064. private static $hasZipArchive;
  18065. private static $isWindows;
  18066. private $zipArchiveObject;
  18067. public function download(PackageInterface $package, string $path, ?PackageInterface $prevPackage = null, bool $output = true): PromiseInterface
  18068. {
  18069. if (null === self::$unzipCommands) {
  18070. self::$unzipCommands = [];
  18071. $finder = new ExecutableFinder;
  18072. if (Platform::isWindows() && ($cmd = $finder->find('7z', null, ['C:\Program Files\7-Zip']))) {
  18073. self::$unzipCommands[] = ['7z', $cmd, 'x', '-bb0', '-y', '%file%', '-o%path%'];
  18074. }
  18075. if ($cmd = $finder->find('unzip')) {
  18076. self::$unzipCommands[] = ['unzip', $cmd, '-qq', '%file%', '-d', '%path%'];
  18077. }
  18078. if (!Platform::isWindows() && ($cmd = $finder->find('7z'))) {
  18079. self::$unzipCommands[] = ['7z', $cmd, 'x', '-bb0', '-y', '%file%', '-o%path%'];
  18080. }
  18081. if (!Platform::isWindows() && ($cmd = $finder->find('7zz'))) {
  18082. self::$unzipCommands[] = ['7zz', $cmd, 'x', '-bb0', '-y', '%file%', '-o%path%'];
  18083. }
  18084. }
  18085. $procOpenMissing = false;
  18086. if (!function_exists('proc_open')) {
  18087. self::$unzipCommands = [];
  18088. $procOpenMissing = true;
  18089. }
  18090. if (null === self::$hasZipArchive) {
  18091. self::$hasZipArchive = class_exists('ZipArchive');
  18092. }
  18093. if (!self::$hasZipArchive && !self::$unzipCommands) {
  18094. $iniMessage = IniHelper::getMessage();
  18095. if ($procOpenMissing) {
  18096. $error = "The zip extension is missing and unzip/7z commands cannot be called as proc_open is disabled, skipping.\n" . $iniMessage;
  18097. } else {
  18098. $error = "The zip extension and unzip/7z commands are both missing, skipping.\n" . $iniMessage;
  18099. }
  18100. throw new \RuntimeException($error);
  18101. }
  18102. if (null === self::$isWindows) {
  18103. self::$isWindows = Platform::isWindows();
  18104. if (!self::$isWindows && !self::$unzipCommands) {
  18105. if ($procOpenMissing) {
  18106. $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>");
  18107. $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>");
  18108. $this->io->writeError("<warning>Enabling proc_open and installing 'unzip' or '7z' (21.01+) may remediate them.</warning>");
  18109. } else {
  18110. $this->io->writeError("<warning>As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  18111. $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>");
  18112. $this->io->writeError("<warning>Installing 'unzip' or '7z' (21.01+) may remediate them.</warning>");
  18113. }
  18114. }
  18115. }
  18116. return parent::download($package, $path, $prevPackage, $output);
  18117. }
  18118. private function extractWithSystemUnzip(PackageInterface $package, string $file, string $path): PromiseInterface
  18119. {
  18120. static $warned7ZipLinux = false;
  18121. $isLastChance = !self::$hasZipArchive;
  18122. if (0 === \count(self::$unzipCommands)) {
  18123. return $this->extractWithZipArchive($package, $file, $path);
  18124. }
  18125. $commandSpec = reset(self::$unzipCommands);
  18126. $executable = $commandSpec[0];
  18127. $command = array_slice($commandSpec, 1);
  18128. $map = [
  18129. '%file%' => strtr($file, '/', DIRECTORY_SEPARATOR),
  18130. '%path%' => strtr($path, '/', DIRECTORY_SEPARATOR),
  18131. ];
  18132. $command = array_map(static function ($value) use ($map) {
  18133. return strtr($value, $map);
  18134. }, $command);
  18135. if (!$warned7ZipLinux && !Platform::isWindows() && in_array($executable, ['7z', '7zz'], true)) {
  18136. $warned7ZipLinux = true;
  18137. if (0 === $this->process->execute([$commandSpec[1]], $output)) {
  18138. if (Preg::isMatchStrictGroups('{^\s*7-Zip(?: \[64\])? ([0-9.]+)}', $output, $match) && version_compare($match[1], '21.01', '<')) {
  18139. $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>');
  18140. }
  18141. }
  18142. }
  18143. $io = $this->io;
  18144. $tryFallback = function (\Throwable $processError) use ($isLastChance, $io, $file, $path, $package, $executable): \React\Promise\PromiseInterface {
  18145. if ($isLastChance) {
  18146. throw $processError;
  18147. }
  18148. if (str_contains($processError->getMessage(), 'zip bomb')) {
  18149. throw $processError;
  18150. }
  18151. if (!is_file($file)) {
  18152. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  18153. $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
  18154. $io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
  18155. } else {
  18156. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  18157. $io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  18158. $io->writeError(' Unzip with '.$executable.' command failed, falling back to ZipArchive class');
  18159. if (Platform::getEnv('GITHUB_ACTIONS') !== false && Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING') === false) {
  18160. $io->writeError(' <warning>Additional debug info, please report to https://github.com/composer/composer/issues/11148 if you see this:</warning>');
  18161. $io->writeError('File size: '.@filesize($file));
  18162. $io->writeError('File SHA1: '.hash_file('sha1', $file));
  18163. $io->writeError('First 100 bytes (hex): '.bin2hex(substr((string) file_get_contents($file), 0, 100)));
  18164. $io->writeError('Last 100 bytes (hex): '.bin2hex(substr((string) file_get_contents($file), -100)));
  18165. if (strlen((string) $package->getDistUrl()) > 0) {
  18166. $io->writeError('Origin URL: '.$this->processUrl($package, (string) $package->getDistUrl()));
  18167. $io->writeError('Response Headers: '.json_encode(FileDownloader::$responseHeaders[$package->getName()] ?? []));
  18168. }
  18169. }
  18170. }
  18171. return $this->extractWithZipArchive($package, $file, $path);
  18172. };
  18173. try {
  18174. $promise = $this->process->executeAsync($command);
  18175. return $promise->then(function (Process $process) use ($tryFallback, $command, $package, $file) {
  18176. if (!$process->isSuccessful()) {
  18177. if (isset($this->cleanupExecuted[$package->getName()])) {
  18178. throw new \RuntimeException('Failed to extract '.$package->getName().' as the installation was aborted by another package operation.');
  18179. }
  18180. $output = $process->getErrorOutput();
  18181. $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
  18182. return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.implode(' ', $command)."\n\n".$output));
  18183. }
  18184. });
  18185. } catch (\Throwable $e) {
  18186. return $tryFallback($e);
  18187. }
  18188. }
  18189. private function extractWithZipArchive(PackageInterface $package, string $file, string $path): PromiseInterface
  18190. {
  18191. $processError = null;
  18192. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  18193. try {
  18194. if (!file_exists($file) || ($filesize = filesize($file)) === false || $filesize === 0) {
  18195. $retval = -1;
  18196. } else {
  18197. $retval = $zipArchive->open($file);
  18198. }
  18199. if (true === $retval) {
  18200. $totalSize = 0;
  18201. $archiveSize = filesize($file);
  18202. $totalFiles = $zipArchive->count();
  18203. if ($totalFiles > 0) {
  18204. for ($i = 0; $i < min($totalFiles, 5); $i++) {
  18205. $stat = $zipArchive->statIndex(random_int(0, $totalFiles - 1));
  18206. if ($stat === false) {
  18207. continue;
  18208. }
  18209. $totalSize += $stat['size'];
  18210. if ($stat['size'] > $stat['comp_size'] * 200) {
  18211. throw new \RuntimeException('Invalid zip file with compression ratio >99% (possible zip bomb)');
  18212. }
  18213. }
  18214. if ($archiveSize !== false && $totalSize > $archiveSize * 100 && $totalSize > 50*1024*1024) {
  18215. throw new \RuntimeException('Invalid zip file with compression ratio >99% (possible zip bomb)');
  18216. }
  18217. }
  18218. $extractResult = $zipArchive->extractTo($path);
  18219. if (true === $extractResult) {
  18220. $zipArchive->close();
  18221. return \React\Promise\resolve(null);
  18222. }
  18223. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  18224. } else {
  18225. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  18226. }
  18227. } catch (\ErrorException $e) {
  18228. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  18229. } catch (\Throwable $e) {
  18230. $processError = $e;
  18231. }
  18232. throw $processError;
  18233. }
  18234. protected function extract(PackageInterface $package, string $file, string $path): PromiseInterface
  18235. {
  18236. return $this->extractWithSystemUnzip($package, $file, $path);
  18237. }
  18238. protected function getErrorMessage(int $retval, string $file): string
  18239. {
  18240. switch ($retval) {
  18241. case ZipArchive::ER_EXISTS:
  18242. return sprintf("File '%s' already exists.", $file);
  18243. case ZipArchive::ER_INCONS:
  18244. return sprintf("Zip archive '%s' is inconsistent.", $file);
  18245. case ZipArchive::ER_INVAL:
  18246. return sprintf("Invalid argument (%s)", $file);
  18247. case ZipArchive::ER_MEMORY:
  18248. return sprintf("Malloc failure (%s)", $file);
  18249. case ZipArchive::ER_NOENT:
  18250. return sprintf("No such zip file: '%s'", $file);
  18251. case ZipArchive::ER_NOZIP:
  18252. return sprintf("'%s' is not a zip archive.", $file);
  18253. case ZipArchive::ER_OPEN:
  18254. return sprintf("Can't open zip file: %s", $file);
  18255. case ZipArchive::ER_READ:
  18256. return sprintf("Zip read error (%s)", $file);
  18257. case ZipArchive::ER_SEEK:
  18258. return sprintf("Zip seek error (%s)", $file);
  18259. case -1:
  18260. return sprintf("'%s' is a corrupted zip archive (0 bytes), try again.", $file);
  18261. default:
  18262. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  18263. }
  18264. }
  18265. }
  18266. <?php declare(strict_types=1);
  18267. namespace Composer\EventDispatcher;
  18268. class Event
  18269. {
  18270. protected $name;
  18271. protected $args;
  18272. protected $flags;
  18273. private $propagationStopped = false;
  18274. public function __construct(string $name, array $args = [], array $flags = [])
  18275. {
  18276. $this->name = $name;
  18277. $this->args = $args;
  18278. $this->flags = $flags;
  18279. }
  18280. public function getName(): string
  18281. {
  18282. return $this->name;
  18283. }
  18284. public function getArguments(): array
  18285. {
  18286. return $this->args;
  18287. }
  18288. public function getFlags(): array
  18289. {
  18290. return $this->flags;
  18291. }
  18292. public function isPropagationStopped(): bool
  18293. {
  18294. return $this->propagationStopped;
  18295. }
  18296. public function stopPropagation(): void
  18297. {
  18298. $this->propagationStopped = true;
  18299. }
  18300. }
  18301. <?php declare(strict_types=1);
  18302. namespace Composer\EventDispatcher;
  18303. use Composer\DependencyResolver\Transaction;
  18304. use Composer\Installer\InstallerEvent;
  18305. use Composer\IO\BufferIO;
  18306. use Composer\IO\ConsoleIO;
  18307. use Composer\IO\IOInterface;
  18308. use Composer\Composer;
  18309. use Composer\PartialComposer;
  18310. use Composer\Pcre\Preg;
  18311. use Composer\Plugin\CommandEvent;
  18312. use Composer\Plugin\PreCommandRunEvent;
  18313. use Composer\Util\Platform;
  18314. use Composer\DependencyResolver\Operation\OperationInterface;
  18315. use Composer\Repository\RepositoryInterface;
  18316. use Composer\Script;
  18317. use Composer\Installer\PackageEvent;
  18318. use Composer\Installer\BinaryInstaller;
  18319. use Composer\Util\ProcessExecutor;
  18320. use Composer\Script\Event as ScriptEvent;
  18321. use Composer\Autoload\ClassLoader;
  18322. use Symfony\Component\Console\Application;
  18323. use Symfony\Component\Console\Command\Command;
  18324. use Symfony\Component\Console\Input\StringInput;
  18325. use Symfony\Component\Console\Output\ConsoleOutput;
  18326. use Symfony\Component\Process\PhpExecutableFinder;
  18327. use Symfony\Component\Process\ExecutableFinder;
  18328. class EventDispatcher
  18329. {
  18330. protected $composer;
  18331. protected $io;
  18332. protected $loader;
  18333. protected $process;
  18334. protected $listeners = [];
  18335. protected $runScripts = true;
  18336. private $eventStack;
  18337. private $skipScripts;
  18338. public function __construct(PartialComposer $composer, IOInterface $io, ?ProcessExecutor $process = null)
  18339. {
  18340. $this->composer = $composer;
  18341. $this->io = $io;
  18342. $this->process = $process ?? new ProcessExecutor($io);
  18343. $this->eventStack = [];
  18344. $this->skipScripts = array_values(array_filter(
  18345. array_map('trim', explode(',', (string) Platform::getEnv('COMPOSER_SKIP_SCRIPTS'))),
  18346. function ($val) {
  18347. return $val !== '';
  18348. }
  18349. ));
  18350. }
  18351. public function setRunScripts(bool $runScripts = true): self
  18352. {
  18353. $this->runScripts = $runScripts;
  18354. return $this;
  18355. }
  18356. public function dispatch(?string $eventName, ?Event $event = null): int
  18357. {
  18358. if (null === $event) {
  18359. if (null === $eventName) {
  18360. throw new \InvalidArgumentException('If no $event is passed in to '.__METHOD__.' you have to pass in an $eventName, got null.');
  18361. }
  18362. $event = new Event($eventName);
  18363. }
  18364. return $this->doDispatch($event);
  18365. }
  18366. public function dispatchScript(string $eventName, bool $devMode = false, array $additionalArgs = [], array $flags = []): int
  18367. {
  18368. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  18369. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  18370. }
  18371. public function dispatchPackageEvent(string $eventName, bool $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation): int
  18372. {
  18373. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  18374. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $localRepo, $operations, $operation));
  18375. }
  18376. public function dispatchInstallerEvent(string $eventName, bool $devMode, bool $executeOperations, Transaction $transaction): int
  18377. {
  18378. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  18379. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $executeOperations, $transaction));
  18380. }
  18381. protected function doDispatch(Event $event)
  18382. {
  18383. if (Platform::getEnv('COMPOSER_DEBUG_EVENTS')) {
  18384. $details = null;
  18385. if ($event instanceof PackageEvent) {
  18386. $details = (string) $event->getOperation();
  18387. } elseif ($event instanceof CommandEvent) {
  18388. $details = $event->getCommandName();
  18389. } elseif ($event instanceof PreCommandRunEvent) {
  18390. $details = $event->getCommand();
  18391. }
  18392. $this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
  18393. }
  18394. $listeners = $this->getListeners($event);
  18395. $this->pushEvent($event);
  18396. $autoloadersBefore = spl_autoload_functions();
  18397. try {
  18398. $returnMax = 0;
  18399. foreach ($listeners as $callable) {
  18400. $return = 0;
  18401. $this->ensureBinDirIsInPath();
  18402. $additionalArgs = $event->getArguments();
  18403. if (is_string($callable) && str_contains($callable, '@no_additional_args')) {
  18404. $callable = Preg::replace('{ ?@no_additional_args}', '', $callable);
  18405. $additionalArgs = [];
  18406. }
  18407. $formattedEventNameWithArgs = $event->getName() . ($additionalArgs !== [] ? ' (' . implode(', ', $additionalArgs) . ')' : '');
  18408. if (!is_string($callable)) {
  18409. if (!is_callable($callable)) {
  18410. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  18411. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  18412. }
  18413. if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
  18414. $this->io->writeError(sprintf('> %s: %s', $formattedEventNameWithArgs, (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1]), true, IOInterface::VERBOSE);
  18415. }
  18416. $return = false === $callable($event) ? 1 : 0;
  18417. } elseif ($this->isComposerScript($callable)) {
  18418. $this->io->writeError(sprintf('> %s: %s', $formattedEventNameWithArgs, $callable), true, IOInterface::VERBOSE);
  18419. $script = explode(' ', substr($callable, 1));
  18420. $scriptName = $script[0];
  18421. unset($script[0]);
  18422. $index = array_search('@additional_args', $script, true);
  18423. if ($index !== false) {
  18424. $args = array_splice($script, $index, 0, $additionalArgs);
  18425. } else {
  18426. $args = array_merge($script, $additionalArgs);
  18427. }
  18428. $flags = $event->getFlags();
  18429. if (isset($flags['script-alias-input'])) {
  18430. $argsString = implode(' ', array_map(static function ($arg) { return ProcessExecutor::escape($arg); }, $script));
  18431. $flags['script-alias-input'] = $argsString . ' ' . $flags['script-alias-input'];
  18432. unset($argsString);
  18433. }
  18434. if (strpos($callable, '@composer ') === 0) {
  18435. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(Platform::getEnv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
  18436. if (0 !== ($exitCode = $this->executeTty($exec))) {
  18437. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  18438. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  18439. }
  18440. } else {
  18441. if (!$this->getListeners(new Event($scriptName))) {
  18442. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  18443. }
  18444. try {
  18445. $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
  18446. $scriptEvent->setOriginatingEvent($event);
  18447. $return = $this->dispatch($scriptName, $scriptEvent);
  18448. } catch (ScriptExecutionException $e) {
  18449. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  18450. throw $e;
  18451. }
  18452. }
  18453. } elseif ($this->isPhpScript($callable)) {
  18454. $className = substr($callable, 0, strpos($callable, '::'));
  18455. $methodName = substr($callable, strpos($callable, '::') + 2);
  18456. if (!class_exists($className)) {
  18457. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  18458. continue;
  18459. }
  18460. if (!is_callable($callable)) {
  18461. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  18462. continue;
  18463. }
  18464. try {
  18465. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  18466. } catch (\Exception $e) {
  18467. $message = "Script %s handling the %s event terminated with an exception";
  18468. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  18469. throw $e;
  18470. }
  18471. } elseif ($this->isCommandClass($callable)) {
  18472. $className = $callable;
  18473. if (!class_exists($className)) {
  18474. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  18475. continue;
  18476. }
  18477. if (!is_a($className, Command::class, true)) {
  18478. $this->io->writeError('<warning>Class '.$className.' does not extend '.Command::class.', can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  18479. continue;
  18480. }
  18481. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($event->getName())))) {
  18482. $this->io->writeError('<warning>You cannot bind '.$event->getName().' to a Command class, use a non-reserved name</warning>', true, IOInterface::QUIET);
  18483. continue;
  18484. }
  18485. $app = new Application();
  18486. $app->setCatchExceptions(false);
  18487. if (method_exists($app, 'setCatchErrors')) {
  18488. $app->setCatchErrors(false);
  18489. }
  18490. $app->setAutoExit(false);
  18491. $cmd = new $className($event->getName());
  18492. $app->add($cmd);
  18493. $app->setDefaultCommand((string) $cmd->getName(), true);
  18494. try {
  18495. $args = implode(' ', array_map(static function ($arg) { return ProcessExecutor::escape($arg); }, $additionalArgs));
  18496. if ($this->io instanceof ConsoleIO) {
  18497. $reflProp = new \ReflectionProperty($this->io, 'output');
  18498. if (\PHP_VERSION_ID < 80100) {
  18499. $reflProp->setAccessible(true);
  18500. }
  18501. $output = $reflProp->getValue($this->io);
  18502. } else {
  18503. $output = new ConsoleOutput();
  18504. }
  18505. $return = $app->run(new StringInput($event->getFlags()['script-alias-input'] ?? $args), $output);
  18506. } catch (\Exception $e) {
  18507. $message = "Script %s handling the %s event terminated with an exception";
  18508. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  18509. throw $e;
  18510. }
  18511. } else {
  18512. $args = implode(' ', array_map(['Composer\Util\ProcessExecutor', 'escape'], $additionalArgs));
  18513. if (strpos($callable, '@putenv ') === 0) {
  18514. $exec = $callable;
  18515. } else {
  18516. if (str_contains($callable, '@additional_args')) {
  18517. $exec = str_replace('@additional_args', $args, $callable);
  18518. } else {
  18519. $exec = $callable . ($args === '' ? '' : ' '.$args);
  18520. }
  18521. }
  18522. if ($this->io->isVerbose()) {
  18523. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  18524. } elseif ($event->getName() !== '__exec_command') {
  18525. $this->io->writeError(sprintf('> %s', $exec));
  18526. }
  18527. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  18528. if (count($possibleLocalBinaries) > 0) {
  18529. foreach ($possibleLocalBinaries as $localExec) {
  18530. if (Preg::isMatch('{\b'.preg_quote($callable).'$}', $localExec)) {
  18531. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  18532. $exec = Preg::replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  18533. break;
  18534. }
  18535. }
  18536. }
  18537. if (strpos($exec, '@putenv ') === 0) {
  18538. if (false === strpos($exec, '=')) {
  18539. Platform::clearEnv(substr($exec, 8));
  18540. } else {
  18541. [$var, $value] = explode('=', substr($exec, 8), 2);
  18542. Platform::putEnv($var, $value);
  18543. }
  18544. continue;
  18545. }
  18546. if (strpos($exec, '@php ') === 0) {
  18547. $pathAndArgs = substr($exec, 5);
  18548. if (Platform::isWindows()) {
  18549. $pathAndArgs = Preg::replaceCallback('{^\S+}', static function ($path) {
  18550. return str_replace('/', '\\', $path[0]);
  18551. }, $pathAndArgs);
  18552. }
  18553. $matched = Preg::isMatchStrictGroups('{^[^\'"\s/\\\\]+}', $pathAndArgs, $match);
  18554. if ($matched && !file_exists($match[0])) {
  18555. $finder = new ExecutableFinder;
  18556. if ($pathToExec = $finder->find($match[0])) {
  18557. if (Platform::isWindows()) {
  18558. $execWithoutExt = Preg::replace('{\.(exe|bat|cmd|com)$}i', '', $pathToExec);
  18559. if (file_exists($execWithoutExt)) {
  18560. $pathToExec = $execWithoutExt;
  18561. }
  18562. unset($execWithoutExt);
  18563. }
  18564. $pathAndArgs = $pathToExec . substr($pathAndArgs, strlen($match[0]));
  18565. }
  18566. }
  18567. $exec = $this->getPhpExecCommand() . ' ' . $pathAndArgs;
  18568. } else {
  18569. $finder = new PhpExecutableFinder();
  18570. $phpPath = $finder->find(false);
  18571. if ($phpPath) {
  18572. Platform::putEnv('PHP_BINARY', $phpPath);
  18573. }
  18574. if (Platform::isWindows()) {
  18575. $exec = Preg::replaceCallback('{^\S+}', static function ($path) {
  18576. return str_replace('/', '\\', $path[0]);
  18577. }, $exec);
  18578. }
  18579. }
  18580. if (strpos($exec, 'composer ') === 0) {
  18581. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(Platform::getEnv('COMPOSER_BINARY')) . substr($exec, 8);
  18582. }
  18583. if (0 !== ($exitCode = $this->executeTty($exec))) {
  18584. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  18585. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  18586. }
  18587. }
  18588. $returnMax = max($returnMax, $return);
  18589. if ($event->isPropagationStopped()) {
  18590. break;
  18591. }
  18592. }
  18593. } finally {
  18594. $this->popEvent();
  18595. $knownIdentifiers = [];
  18596. foreach ($autoloadersBefore as $key => $cb) {
  18597. $knownIdentifiers[$this->getCallbackIdentifier($cb)] = ['key' => $key, 'callback' => $cb];
  18598. }
  18599. foreach (spl_autoload_functions() as $cb) {
  18600. if (isset($knownIdentifiers[$this->getCallbackIdentifier($cb)]) && $knownIdentifiers[$this->getCallbackIdentifier($cb)]['key'] === 0) {
  18601. break;
  18602. }
  18603. if ($cb instanceof ClassLoader) {
  18604. $cb->unregister();
  18605. $cb->register(false);
  18606. } else {
  18607. spl_autoload_unregister($cb);
  18608. spl_autoload_register($cb);
  18609. }
  18610. }
  18611. }
  18612. return $returnMax;
  18613. }
  18614. protected function executeTty(string $exec): int
  18615. {
  18616. if ($this->io->isInteractive()) {
  18617. return $this->process->executeTty($exec);
  18618. }
  18619. return $this->process->execute($exec);
  18620. }
  18621. protected function getPhpExecCommand(): string
  18622. {
  18623. $finder = new PhpExecutableFinder();
  18624. $phpPath = $finder->find(false);
  18625. if (!$phpPath) {
  18626. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  18627. }
  18628. $phpArgs = $finder->findArguments();
  18629. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  18630. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  18631. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  18632. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  18633. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  18634. }
  18635. protected function executeEventPhpScript(string $className, string $methodName, Event $event)
  18636. {
  18637. if ($this->io->isVerbose()) {
  18638. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  18639. } else {
  18640. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  18641. }
  18642. return $className::$methodName($event);
  18643. }
  18644. public function addListener(string $eventName, $listener, int $priority = 0): void
  18645. {
  18646. $this->listeners[$eventName][$priority][] = $listener;
  18647. }
  18648. public function removeListener($listener): void
  18649. {
  18650. foreach ($this->listeners as $eventName => $priorities) {
  18651. foreach ($priorities as $priority => $listeners) {
  18652. foreach ($listeners as $index => $candidate) {
  18653. if ($listener === $candidate || (is_array($candidate) && is_object($listener) && $candidate[0] === $listener)) {
  18654. unset($this->listeners[$eventName][$priority][$index]);
  18655. }
  18656. }
  18657. }
  18658. }
  18659. }
  18660. public function addSubscriber(EventSubscriberInterface $subscriber): void
  18661. {
  18662. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  18663. if (is_string($params)) {
  18664. $this->addListener($eventName, [$subscriber, $params]);
  18665. } elseif (is_string($params[0])) {
  18666. $this->addListener($eventName, [$subscriber, $params[0]], $params[1] ?? 0);
  18667. } else {
  18668. foreach ($params as $listener) {
  18669. $this->addListener($eventName, [$subscriber, $listener[0]], $listener[1] ?? 0);
  18670. }
  18671. }
  18672. }
  18673. }
  18674. protected function getListeners(Event $event): array
  18675. {
  18676. $scriptListeners = $this->runScripts ? $this->getScriptListeners($event) : [];
  18677. if (!isset($this->listeners[$event->getName()][0])) {
  18678. $this->listeners[$event->getName()][0] = [];
  18679. }
  18680. krsort($this->listeners[$event->getName()]);
  18681. $listeners = $this->listeners;
  18682. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  18683. return array_merge(...$listeners[$event->getName()]);
  18684. }
  18685. public function hasEventListeners(Event $event): bool
  18686. {
  18687. $listeners = $this->getListeners($event);
  18688. return count($listeners) > 0;
  18689. }
  18690. protected function getScriptListeners(Event $event): array
  18691. {
  18692. $package = $this->composer->getPackage();
  18693. $scripts = $package->getScripts();
  18694. if (empty($scripts[$event->getName()])) {
  18695. return [];
  18696. }
  18697. if (in_array($event->getName(), $this->skipScripts, true)) {
  18698. $this->io->writeError('Skipped script listeners for <info>'.$event->getName().'</info> because of COMPOSER_SKIP_SCRIPTS', true, IOInterface::VERBOSE);
  18699. return [];
  18700. }
  18701. assert($this->composer instanceof Composer, new \LogicException('This should only be reached with a fully loaded Composer'));
  18702. if ($this->loader) {
  18703. $this->loader->unregister();
  18704. }
  18705. $generator = $this->composer->getAutoloadGenerator();
  18706. if ($event instanceof ScriptEvent) {
  18707. $generator->setDevMode($event->isDevMode());
  18708. }
  18709. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  18710. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  18711. $map = $generator->parseAutoloads($packageMap, $package);
  18712. $this->loader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  18713. $this->loader->register(false);
  18714. return $scripts[$event->getName()];
  18715. }
  18716. protected function isPhpScript(string $callable): bool
  18717. {
  18718. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  18719. }
  18720. protected function isCommandClass(string $callable): bool
  18721. {
  18722. return str_contains($callable, '\\') && !str_contains($callable, ' ') && str_ends_with($callable, 'Command');
  18723. }
  18724. protected function isComposerScript(string $callable): bool
  18725. {
  18726. return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
  18727. }
  18728. protected function pushEvent(Event $event): int
  18729. {
  18730. $eventName = $event->getName();
  18731. if (in_array($eventName, $this->eventStack)) {
  18732. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  18733. }
  18734. return array_push($this->eventStack, $eventName);
  18735. }
  18736. protected function popEvent(): ?string
  18737. {
  18738. return array_pop($this->eventStack);
  18739. }
  18740. private function ensureBinDirIsInPath(): void
  18741. {
  18742. $pathEnv = 'PATH';
  18743. if (!isset($_SERVER[$pathEnv]) && isset($_SERVER['Path'])) {
  18744. $pathEnv = 'Path';
  18745. }
  18746. $binDir = $this->composer->getConfig()->get('bin-dir');
  18747. if (is_dir($binDir)) {
  18748. $binDir = realpath($binDir);
  18749. $pathValue = (string) Platform::getEnv($pathEnv);
  18750. if (!Preg::isMatch('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $pathValue)) {
  18751. Platform::putEnv($pathEnv, $binDir.PATH_SEPARATOR.$pathValue);
  18752. }
  18753. }
  18754. }
  18755. private function getCallbackIdentifier($cb): string
  18756. {
  18757. if (is_string($cb)) {
  18758. return 'fn:'.$cb;
  18759. }
  18760. if (is_object($cb)) {
  18761. return 'obj:'.spl_object_hash($cb);
  18762. }
  18763. if (is_array($cb)) {
  18764. return 'array:'.(is_string($cb[0]) ? $cb[0] : get_class($cb[0]) .'#'.spl_object_hash($cb[0])).'::'.$cb[1];
  18765. }
  18766. return 'unsupported';
  18767. }
  18768. }
  18769. <?php declare(strict_types=1);
  18770. namespace Composer\EventDispatcher;
  18771. interface EventSubscriberInterface
  18772. {
  18773. public static function getSubscribedEvents();
  18774. }
  18775. <?php declare(strict_types=1);
  18776. namespace Composer\EventDispatcher;
  18777. class ScriptExecutionException extends \RuntimeException
  18778. {
  18779. }
  18780. <?php declare(strict_types=1);
  18781. namespace Composer\Exception;
  18782. class IrrecoverableDownloadException extends \RuntimeException
  18783. {
  18784. }
  18785. <?php declare(strict_types=1);
  18786. namespace Composer\Exception;
  18787. class NoSslException extends \RuntimeException
  18788. {
  18789. }
  18790. <?php declare(strict_types=1);
  18791. namespace Composer;
  18792. use Composer\Config\JsonConfigSource;
  18793. use Composer\Json\JsonFile;
  18794. use Composer\IO\IOInterface;
  18795. use Composer\Package\Archiver;
  18796. use Composer\Package\Version\VersionGuesser;
  18797. use Composer\Package\RootPackageInterface;
  18798. use Composer\Repository\FilesystemRepository;
  18799. use Composer\Repository\RepositoryManager;
  18800. use Composer\Repository\RepositoryFactory;
  18801. use Composer\Util\Filesystem;
  18802. use Composer\Util\Platform;
  18803. use Composer\Util\ProcessExecutor;
  18804. use Composer\Util\HttpDownloader;
  18805. use Composer\Util\Loop;
  18806. use Composer\Util\Silencer;
  18807. use Composer\Plugin\PluginEvents;
  18808. use Composer\EventDispatcher\Event;
  18809. use Phar;
  18810. use Symfony\Component\Console\Formatter\OutputFormatter;
  18811. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  18812. use Symfony\Component\Console\Output\ConsoleOutput;
  18813. use Composer\EventDispatcher\EventDispatcher;
  18814. use Composer\Autoload\AutoloadGenerator;
  18815. use Composer\Package\Version\VersionParser;
  18816. use Composer\Downloader\TransportException;
  18817. use Composer\Json\JsonValidationException;
  18818. use Composer\Repository\InstalledRepositoryInterface;
  18819. use UnexpectedValueException;
  18820. use ZipArchive;
  18821. class Factory
  18822. {
  18823. protected static function getHomeDir(): string
  18824. {
  18825. $home = Platform::getEnv('COMPOSER_HOME');
  18826. if ($home) {
  18827. return $home;
  18828. }
  18829. if (Platform::isWindows()) {
  18830. if (!Platform::getEnv('APPDATA')) {
  18831. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  18832. }
  18833. return rtrim(strtr(Platform::getEnv('APPDATA'), '\\', '/'), '/') . '/Composer';
  18834. }
  18835. $userDir = self::getUserDir();
  18836. $dirs = [];
  18837. if (self::useXdg()) {
  18838. $xdgConfig = Platform::getEnv('XDG_CONFIG_HOME');
  18839. if (!$xdgConfig) {
  18840. $xdgConfig = $userDir . '/.config';
  18841. }
  18842. $dirs[] = $xdgConfig . '/composer';
  18843. }
  18844. $dirs[] = $userDir . '/.composer';
  18845. foreach ($dirs as $dir) {
  18846. if (Silencer::call('is_dir', $dir)) {
  18847. return $dir;
  18848. }
  18849. }
  18850. return $dirs[0];
  18851. }
  18852. protected static function getCacheDir(string $home): string
  18853. {
  18854. $cacheDir = Platform::getEnv('COMPOSER_CACHE_DIR');
  18855. if ($cacheDir) {
  18856. return $cacheDir;
  18857. }
  18858. $homeEnv = Platform::getEnv('COMPOSER_HOME');
  18859. if ($homeEnv) {
  18860. return $homeEnv . '/cache';
  18861. }
  18862. if (Platform::isWindows()) {
  18863. if ($cacheDir = Platform::getEnv('LOCALAPPDATA')) {
  18864. $cacheDir .= '/Composer';
  18865. } else {
  18866. $cacheDir = $home . '/cache';
  18867. }
  18868. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  18869. }
  18870. $userDir = self::getUserDir();
  18871. if (PHP_OS === 'Darwin') {
  18872. if (is_dir($home . '/cache') && !is_dir($userDir . '/Library/Caches/composer')) {
  18873. Silencer::call('rename', $home . '/cache', $userDir . '/Library/Caches/composer');
  18874. }
  18875. return $userDir . '/Library/Caches/composer';
  18876. }
  18877. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  18878. return $home . '/cache';
  18879. }
  18880. if (self::useXdg()) {
  18881. $xdgCache = Platform::getEnv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  18882. return $xdgCache . '/composer';
  18883. }
  18884. return $home . '/cache';
  18885. }
  18886. protected static function getDataDir(string $home): string
  18887. {
  18888. $homeEnv = Platform::getEnv('COMPOSER_HOME');
  18889. if ($homeEnv) {
  18890. return $homeEnv;
  18891. }
  18892. if (Platform::isWindows()) {
  18893. return strtr($home, '\\', '/');
  18894. }
  18895. $userDir = self::getUserDir();
  18896. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  18897. $xdgData = Platform::getEnv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  18898. return $xdgData . '/composer';
  18899. }
  18900. return $home;
  18901. }
  18902. public static function createConfig(?IOInterface $io = null, ?string $cwd = null): Config
  18903. {
  18904. $cwd = $cwd ?? Platform::getCwd(true);
  18905. $config = new Config(true, $cwd);
  18906. $home = self::getHomeDir();
  18907. $config->merge([
  18908. 'config' => [
  18909. 'home' => $home,
  18910. 'cache-dir' => self::getCacheDir($home),
  18911. 'data-dir' => self::getDataDir($home),
  18912. ],
  18913. ], Config::SOURCE_DEFAULT);
  18914. $file = new JsonFile($config->get('home').'/config.json');
  18915. if ($file->exists()) {
  18916. if ($io instanceof IOInterface) {
  18917. $io->writeError('Loading config file ' . $file->getPath(), true, IOInterface::DEBUG);
  18918. }
  18919. self::validateJsonSchema($io, $file);
  18920. $config->merge($file->read(), $file->getPath());
  18921. }
  18922. $config->setConfigSource(new JsonConfigSource($file));
  18923. $htaccessProtect = $config->get('htaccess-protect');
  18924. if ($htaccessProtect) {
  18925. $dirs = [$config->get('home'), $config->get('cache-dir'), $config->get('data-dir')];
  18926. foreach ($dirs as $dir) {
  18927. if (!file_exists($dir . '/.htaccess')) {
  18928. if (!is_dir($dir)) {
  18929. Silencer::call('mkdir', $dir, 0777, true);
  18930. }
  18931. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  18932. }
  18933. }
  18934. }
  18935. $file = new JsonFile($config->get('home').'/auth.json');
  18936. if ($file->exists()) {
  18937. if ($io instanceof IOInterface) {
  18938. $io->writeError('Loading config file ' . $file->getPath(), true, IOInterface::DEBUG);
  18939. }
  18940. self::validateJsonSchema($io, $file, JsonFile::AUTH_SCHEMA);
  18941. $config->merge(['config' => $file->read()], $file->getPath());
  18942. }
  18943. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  18944. self::loadComposerAuthEnv($config, $io);
  18945. return $config;
  18946. }
  18947. public static function getComposerFile(): string
  18948. {
  18949. $env = Platform::getEnv('COMPOSER');
  18950. if (is_string($env)) {
  18951. $env = trim($env);
  18952. if ('' !== $env) {
  18953. if (is_dir($env)) {
  18954. throw new \RuntimeException('The COMPOSER environment variable is set to '.$env.' which is a directory, this variable should point to a composer.json or be left unset.');
  18955. }
  18956. return $env;
  18957. }
  18958. }
  18959. return './composer.json';
  18960. }
  18961. public static function getLockFile(string $composerFile): string
  18962. {
  18963. return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  18964. ? substr($composerFile, 0, -4).'lock'
  18965. : $composerFile . '.lock';
  18966. }
  18967. public static function createAdditionalStyles(): array
  18968. {
  18969. return [
  18970. 'highlight' => new OutputFormatterStyle('red'),
  18971. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  18972. ];
  18973. }
  18974. public static function createOutput(): ConsoleOutput
  18975. {
  18976. $styles = self::createAdditionalStyles();
  18977. $formatter = new OutputFormatter(false, $styles);
  18978. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  18979. }
  18980. public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, ?string $cwd = null, bool $fullLoad = true, bool $disableScripts = false)
  18981. {
  18982. if (is_string($localConfig) && is_file($localConfig) && null === $cwd) {
  18983. $cwd = dirname($localConfig);
  18984. }
  18985. $cwd = $cwd ?? Platform::getCwd(true);
  18986. if (null === $localConfig) {
  18987. $localConfig = static::getComposerFile();
  18988. }
  18989. $localConfigSource = Config::SOURCE_UNKNOWN;
  18990. if (is_string($localConfig)) {
  18991. $composerFile = $localConfig;
  18992. $file = new JsonFile($localConfig, null, $io);
  18993. if (!$file->exists()) {
  18994. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  18995. $message = 'Composer could not find a composer.json file in '.$cwd;
  18996. } else {
  18997. $message = 'Composer could not find the config file: '.$localConfig;
  18998. }
  18999. $instructions = $fullLoad ? 'To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage' : '';
  19000. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  19001. }
  19002. if (!Platform::isInputCompletionProcess()) {
  19003. try {
  19004. $file->validateSchema(JsonFile::LAX_SCHEMA);
  19005. } catch (JsonValidationException $e) {
  19006. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  19007. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  19008. throw new JsonValidationException($message);
  19009. }
  19010. }
  19011. $localConfig = $file->read();
  19012. $localConfigSource = $file->getPath();
  19013. }
  19014. $config = static::createConfig($io, $cwd);
  19015. $isGlobal = $localConfigSource !== Config::SOURCE_UNKNOWN && realpath($config->get('home')) === realpath(dirname($localConfigSource));
  19016. $config->merge($localConfig, $localConfigSource);
  19017. if (isset($composerFile)) {
  19018. $io->writeError('Loading config file ' . $composerFile .' ('.realpath($composerFile).')', true, IOInterface::DEBUG);
  19019. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  19020. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  19021. if ($localAuthFile->exists()) {
  19022. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  19023. self::validateJsonSchema($io, $localAuthFile, JsonFile::AUTH_SCHEMA);
  19024. $config->merge(['config' => $localAuthFile->read()], $localAuthFile->getPath());
  19025. $config->setLocalAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  19026. }
  19027. }
  19028. self::loadComposerAuthEnv($config, $io);
  19029. $vendorDir = $config->get('vendor-dir');
  19030. $composer = $fullLoad ? new Composer() : new PartialComposer();
  19031. $composer->setConfig($config);
  19032. if ($isGlobal) {
  19033. $composer->setGlobal();
  19034. }
  19035. if ($fullLoad) {
  19036. $io->loadConfiguration($config);
  19037. if (false === $disablePlugins && false === $disableScripts && !class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/installed.php')) {
  19038. if (class_exists('Composer\InstalledVersions')) {
  19039. FilesystemRepository::safelyLoadInstalledVersions($installedVersionsPath);
  19040. }
  19041. }
  19042. }
  19043. $httpDownloader = self::createHttpDownloader($io, $config);
  19044. $process = new ProcessExecutor($io);
  19045. $loop = new Loop($httpDownloader, $process);
  19046. $composer->setLoop($loop);
  19047. $dispatcher = new EventDispatcher($composer, $io, $process);
  19048. $dispatcher->setRunScripts(!$disableScripts);
  19049. $composer->setEventDispatcher($dispatcher);
  19050. $rm = RepositoryFactory::manager($io, $config, $httpDownloader, $dispatcher, $process);
  19051. $composer->setRepositoryManager($rm);
  19052. if (!$fullLoad && !isset($localConfig['version'])) {
  19053. $localConfig['version'] = '1.0.0';
  19054. }
  19055. $parser = new VersionParser;
  19056. $guesser = new VersionGuesser($config, $process, $parser, $io);
  19057. $loader = $this->loadRootPackage($rm, $config, $parser, $guesser, $io);
  19058. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  19059. $composer->setPackage($package);
  19060. $this->addLocalRepository($io, $rm, $vendorDir, $package, $process);
  19061. $im = $this->createInstallationManager($loop, $io, $dispatcher);
  19062. $composer->setInstallationManager($im);
  19063. if ($composer instanceof Composer) {
  19064. $dm = $this->createDownloadManager($io, $config, $httpDownloader, $process, $dispatcher);
  19065. $composer->setDownloadManager($dm);
  19066. $generator = new AutoloadGenerator($dispatcher, $io);
  19067. $composer->setAutoloadGenerator($generator);
  19068. $am = $this->createArchiveManager($config, $dm, $loop);
  19069. $composer->setArchiveManager($am);
  19070. }
  19071. $this->createDefaultInstallers($im, $composer, $io, $process);
  19072. if ($composer instanceof Composer && isset($composerFile)) {
  19073. $lockFile = self::getLockFile($composerFile);
  19074. if (!$config->get('lock') && file_exists($lockFile)) {
  19075. $io->writeError('<warning>'.$lockFile.' is present but ignored as the "lock" config option is disabled.</warning>');
  19076. }
  19077. $locker = new Package\Locker($io, new JsonFile($config->get('lock') ? $lockFile : Platform::getDevNull(), null, $io), $im, file_get_contents($composerFile), $process);
  19078. $composer->setLocker($locker);
  19079. } elseif ($composer instanceof Composer) {
  19080. $locker = new Package\Locker($io, new JsonFile(Platform::getDevNull(), null, $io), $im, JsonFile::encode($localConfig), $process);
  19081. $composer->setLocker($locker);
  19082. }
  19083. if ($composer instanceof Composer) {
  19084. $globalComposer = null;
  19085. if (!$composer->isGlobal()) {
  19086. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins, $disableScripts);
  19087. }
  19088. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  19089. $composer->setPluginManager($pm);
  19090. if ($composer->isGlobal()) {
  19091. $pm->setRunningInGlobalDir(true);
  19092. }
  19093. $pm->loadInstalledPlugins();
  19094. }
  19095. if ($fullLoad) {
  19096. $initEvent = new Event(PluginEvents::INIT);
  19097. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  19098. $this->purgePackages($rm->getLocalRepository(), $im);
  19099. }
  19100. return $composer;
  19101. }
  19102. public static function createGlobal(IOInterface $io, bool $disablePlugins = false, bool $disableScripts = false): ?Composer
  19103. {
  19104. $factory = new static();
  19105. return $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, $disableScripts, true);
  19106. }
  19107. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, string $vendorDir, RootPackageInterface $rootPackage, ?ProcessExecutor $process = null): void
  19108. {
  19109. $fs = null;
  19110. if ($process) {
  19111. $fs = new Filesystem($process);
  19112. }
  19113. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io), true, $rootPackage, $fs));
  19114. }
  19115. protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, bool $disableScripts, bool $fullLoad = false): ?PartialComposer
  19116. {
  19117. $disablePlugins = $disablePlugins === 'global' || $disablePlugins === true;
  19118. $composer = null;
  19119. try {
  19120. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad, $disableScripts);
  19121. } catch (\Exception $e) {
  19122. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  19123. }
  19124. return $composer;
  19125. }
  19126. public function createDownloadManager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, ?EventDispatcher $eventDispatcher = null): Downloader\DownloadManager
  19127. {
  19128. $cache = null;
  19129. if ($config->get('cache-files-ttl') > 0) {
  19130. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  19131. $cache->setReadOnly($config->get('cache-read-only'));
  19132. }
  19133. $fs = new Filesystem($process);
  19134. $dm = new Downloader\DownloadManager($io, false, $fs);
  19135. switch ($preferred = $config->get('preferred-install')) {
  19136. case 'dist':
  19137. $dm->setPreferDist(true);
  19138. break;
  19139. case 'source':
  19140. $dm->setPreferSource(true);
  19141. break;
  19142. case 'auto':
  19143. default:
  19144. break;
  19145. }
  19146. if (is_array($preferred)) {
  19147. $dm->setPreferences($preferred);
  19148. }
  19149. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $process, $fs));
  19150. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $process, $fs));
  19151. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $process, $fs));
  19152. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $process, $fs));
  19153. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config, $process, $fs));
  19154. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  19155. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  19156. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  19157. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  19158. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  19159. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  19160. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  19161. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  19162. return $dm;
  19163. }
  19164. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm, Loop $loop)
  19165. {
  19166. $am = new Archiver\ArchiveManager($dm, $loop);
  19167. if (class_exists(ZipArchive::class)) {
  19168. $am->addArchiver(new Archiver\ZipArchiver);
  19169. }
  19170. if (class_exists(Phar::class)) {
  19171. $am->addArchiver(new Archiver\PharArchiver);
  19172. }
  19173. return $am;
  19174. }
  19175. protected function createPluginManager(IOInterface $io, Composer $composer, ?PartialComposer $globalComposer = null, $disablePlugins = false): Plugin\PluginManager
  19176. {
  19177. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  19178. }
  19179. public function createInstallationManager(Loop $loop, IOInterface $io, ?EventDispatcher $eventDispatcher = null): Installer\InstallationManager
  19180. {
  19181. return new Installer\InstallationManager($loop, $io, $eventDispatcher);
  19182. }
  19183. protected function createDefaultInstallers(Installer\InstallationManager $im, PartialComposer $composer, IOInterface $io, ?ProcessExecutor $process = null): void
  19184. {
  19185. $fs = new Filesystem($process);
  19186. $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs, rtrim($composer->getConfig()->get('vendor-dir'), '/'));
  19187. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
  19188. $im->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller));
  19189. $im->addInstaller(new Installer\MetapackageInstaller($io));
  19190. }
  19191. protected function purgePackages(InstalledRepositoryInterface $repo, Installer\InstallationManager $im): void
  19192. {
  19193. foreach ($repo->getPackages() as $package) {
  19194. if (!$im->isPackageInstalled($repo, $package)) {
  19195. $repo->removePackage($package);
  19196. }
  19197. }
  19198. }
  19199. protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io): Package\Loader\RootPackageLoader
  19200. {
  19201. return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);
  19202. }
  19203. public static function create(IOInterface $io, $config = null, $disablePlugins = false, bool $disableScripts = false): Composer
  19204. {
  19205. $factory = new static();
  19206. if ($config !== null && $config !== self::getComposerFile() && $disablePlugins === false) {
  19207. $disablePlugins = 'local';
  19208. }
  19209. return $factory->createComposer($io, $config, $disablePlugins, null, true, $disableScripts);
  19210. }
  19211. public static function createHttpDownloader(IOInterface $io, Config $config, array $options = []): HttpDownloader
  19212. {
  19213. static $warned = false;
  19214. $disableTls = false;
  19215. if (isset($_SERVER['argv']) && in_array('disable-tls', $_SERVER['argv']) && (in_array('conf', $_SERVER['argv']) || in_array('config', $_SERVER['argv']))) {
  19216. $warned = true;
  19217. $disableTls = !extension_loaded('openssl');
  19218. } elseif ($config->get('disable-tls') === true) {
  19219. if (!$warned) {
  19220. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  19221. }
  19222. $warned = true;
  19223. $disableTls = true;
  19224. } elseif (!extension_loaded('openssl')) {
  19225. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  19226. . '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.');
  19227. }
  19228. $httpDownloaderOptions = [];
  19229. if ($disableTls === false) {
  19230. if ('' !== $config->get('cafile')) {
  19231. $httpDownloaderOptions['ssl']['cafile'] = $config->get('cafile');
  19232. }
  19233. if ('' !== $config->get('capath')) {
  19234. $httpDownloaderOptions['ssl']['capath'] = $config->get('capath');
  19235. }
  19236. $httpDownloaderOptions = array_replace_recursive($httpDownloaderOptions, $options);
  19237. }
  19238. try {
  19239. $httpDownloader = new HttpDownloader($io, $config, $httpDownloaderOptions, $disableTls);
  19240. } catch (TransportException $e) {
  19241. if (false !== strpos($e->getMessage(), 'cafile')) {
  19242. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  19243. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  19244. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  19245. }
  19246. throw $e;
  19247. }
  19248. return $httpDownloader;
  19249. }
  19250. private static function loadComposerAuthEnv(Config $config, ?IOInterface $io): void
  19251. {
  19252. $composerAuthEnv = Platform::getEnv('COMPOSER_AUTH');
  19253. if (false === $composerAuthEnv || '' === $composerAuthEnv) {
  19254. return;
  19255. }
  19256. $authData = json_decode($composerAuthEnv);
  19257. if (null === $authData) {
  19258. throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed, should be a valid JSON object');
  19259. }
  19260. if ($io instanceof IOInterface) {
  19261. $io->writeError('Loading auth config from COMPOSER_AUTH', true, IOInterface::DEBUG);
  19262. }
  19263. self::validateJsonSchema($io, $authData, JsonFile::AUTH_SCHEMA, 'COMPOSER_AUTH');
  19264. $authData = json_decode($composerAuthEnv, true);
  19265. if (null !== $authData) {
  19266. $config->merge(['config' => $authData], 'COMPOSER_AUTH');
  19267. }
  19268. }
  19269. private static function useXdg(): bool
  19270. {
  19271. foreach (array_keys($_SERVER) as $key) {
  19272. if (strpos((string) $key, 'XDG_') === 0) {
  19273. return true;
  19274. }
  19275. }
  19276. if (Silencer::call('is_dir', '/etc/xdg')) {
  19277. return true;
  19278. }
  19279. return false;
  19280. }
  19281. private static function getUserDir(): string
  19282. {
  19283. $home = Platform::getEnv('HOME');
  19284. if (!$home) {
  19285. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  19286. }
  19287. return rtrim(strtr($home, '\\', '/'), '/');
  19288. }
  19289. private static function validateJsonSchema(?IOInterface $io, $fileOrData, int $schema = JsonFile::LAX_SCHEMA, ?string $source = null): void
  19290. {
  19291. if (Platform::isInputCompletionProcess()) {
  19292. return;
  19293. }
  19294. try {
  19295. if ($fileOrData instanceof JsonFile) {
  19296. $fileOrData->validateSchema($schema);
  19297. } else {
  19298. if (null === $source) {
  19299. throw new \InvalidArgumentException('$source is required to be provided if $fileOrData is arbitrary data');
  19300. }
  19301. JsonFile::validateJsonSchema($source, $fileOrData, $schema);
  19302. }
  19303. } catch (JsonValidationException $e) {
  19304. $msg = $e->getMessage().', this may result in errors and should be resolved:'.PHP_EOL.' - '.implode(PHP_EOL.' - ', $e->getErrors());
  19305. if ($io instanceof IOInterface) {
  19306. $io->writeError('<warning>'.$msg.'</>');
  19307. } else {
  19308. throw new UnexpectedValueException($msg);
  19309. }
  19310. }
  19311. }
  19312. }
  19313. <?php declare(strict_types=1);
  19314. namespace Composer\Filter\PlatformRequirementFilter;
  19315. use Composer\Repository\PlatformRepository;
  19316. final class IgnoreAllPlatformRequirementFilter implements PlatformRequirementFilterInterface
  19317. {
  19318. public function isIgnored(string $req): bool
  19319. {
  19320. return PlatformRepository::isPlatformPackage($req);
  19321. }
  19322. public function isUpperBoundIgnored(string $req): bool
  19323. {
  19324. return $this->isIgnored($req);
  19325. }
  19326. }
  19327. <?php declare(strict_types=1);
  19328. namespace Composer\Filter\PlatformRequirementFilter;
  19329. use Composer\Package\BasePackage;
  19330. use Composer\Pcre\Preg;
  19331. use Composer\Repository\PlatformRepository;
  19332. use Composer\Semver\Constraint\Constraint;
  19333. use Composer\Semver\Constraint\ConstraintInterface;
  19334. use Composer\Semver\Constraint\MatchAllConstraint;
  19335. use Composer\Semver\Constraint\MultiConstraint;
  19336. use Composer\Semver\Interval;
  19337. use Composer\Semver\Intervals;
  19338. final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFilterInterface
  19339. {
  19340. private $ignoreRegex;
  19341. private $ignoreUpperBoundRegex;
  19342. public function __construct(array $reqList)
  19343. {
  19344. $ignoreAll = $ignoreUpperBound = [];
  19345. foreach ($reqList as $req) {
  19346. if (substr($req, -1) === '+') {
  19347. $ignoreUpperBound[] = substr($req, 0, -1);
  19348. } else {
  19349. $ignoreAll[] = $req;
  19350. }
  19351. }
  19352. $this->ignoreRegex = BasePackage::packageNamesToRegexp($ignoreAll);
  19353. $this->ignoreUpperBoundRegex = BasePackage::packageNamesToRegexp($ignoreUpperBound);
  19354. }
  19355. public function isIgnored(string $req): bool
  19356. {
  19357. if (!PlatformRepository::isPlatformPackage($req)) {
  19358. return false;
  19359. }
  19360. return Preg::isMatch($this->ignoreRegex, $req);
  19361. }
  19362. public function isUpperBoundIgnored(string $req): bool
  19363. {
  19364. if (!PlatformRepository::isPlatformPackage($req)) {
  19365. return false;
  19366. }
  19367. return $this->isIgnored($req) || Preg::isMatch($this->ignoreUpperBoundRegex, $req);
  19368. }
  19369. public function filterConstraint(string $req, ConstraintInterface $constraint, bool $allowUpperBoundOverride = true): ConstraintInterface
  19370. {
  19371. if (!PlatformRepository::isPlatformPackage($req)) {
  19372. return $constraint;
  19373. }
  19374. if (!$allowUpperBoundOverride || !Preg::isMatch($this->ignoreUpperBoundRegex, $req)) {
  19375. return $constraint;
  19376. }
  19377. if (Preg::isMatch($this->ignoreRegex, $req)) {
  19378. return new MatchAllConstraint;
  19379. }
  19380. $intervals = Intervals::get($constraint);
  19381. $last = end($intervals['numeric']);
  19382. if ($last !== false && (string) $last->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  19383. $constraint = new MultiConstraint([$constraint, new Constraint('>=', $last->getEnd()->getVersion())], false);
  19384. }
  19385. return $constraint;
  19386. }
  19387. }
  19388. <?php declare(strict_types=1);
  19389. namespace Composer\Filter\PlatformRequirementFilter;
  19390. final class IgnoreNothingPlatformRequirementFilter implements PlatformRequirementFilterInterface
  19391. {
  19392. public function isIgnored(string $req): bool
  19393. {
  19394. return false;
  19395. }
  19396. public function isUpperBoundIgnored(string $req): bool
  19397. {
  19398. return false;
  19399. }
  19400. }
  19401. <?php declare(strict_types=1);
  19402. namespace Composer\Filter\PlatformRequirementFilter;
  19403. final class PlatformRequirementFilterFactory
  19404. {
  19405. public static function fromBoolOrList($boolOrList): PlatformRequirementFilterInterface
  19406. {
  19407. if (is_bool($boolOrList)) {
  19408. return $boolOrList ? self::ignoreAll() : self::ignoreNothing();
  19409. }
  19410. if (is_array($boolOrList)) {
  19411. return new IgnoreListPlatformRequirementFilter($boolOrList);
  19412. }
  19413. throw new \InvalidArgumentException(
  19414. sprintf(
  19415. 'PlatformRequirementFilter: Unknown $boolOrList parameter %s. Please report at https://github.com/composer/composer/issues/new.',
  19416. gettype($boolOrList)
  19417. )
  19418. );
  19419. }
  19420. public static function ignoreAll(): PlatformRequirementFilterInterface
  19421. {
  19422. return new IgnoreAllPlatformRequirementFilter();
  19423. }
  19424. public static function ignoreNothing(): PlatformRequirementFilterInterface
  19425. {
  19426. return new IgnoreNothingPlatformRequirementFilter();
  19427. }
  19428. }
  19429. <?php declare(strict_types=1);
  19430. namespace Composer\Filter\PlatformRequirementFilter;
  19431. interface PlatformRequirementFilterInterface
  19432. {
  19433. public function isIgnored(string $req): bool;
  19434. public function isUpperBoundIgnored(string $req): bool;
  19435. }
  19436. <?php declare(strict_types=1);
  19437. namespace Composer\IO;
  19438. use Composer\Config;
  19439. use Composer\Pcre\Preg;
  19440. use Composer\Util\ProcessExecutor;
  19441. use Composer\Util\Silencer;
  19442. use Psr\Log\LogLevel;
  19443. abstract class BaseIO implements IOInterface
  19444. {
  19445. protected $authentications = [];
  19446. public function getAuthentications()
  19447. {
  19448. return $this->authentications;
  19449. }
  19450. public function resetAuthentications()
  19451. {
  19452. $this->authentications = [];
  19453. }
  19454. public function hasAuthentication($repositoryName)
  19455. {
  19456. return isset($this->authentications[$repositoryName]);
  19457. }
  19458. public function getAuthentication($repositoryName)
  19459. {
  19460. if (isset($this->authentications[$repositoryName])) {
  19461. return $this->authentications[$repositoryName];
  19462. }
  19463. return ['username' => null, 'password' => null];
  19464. }
  19465. public function setAuthentication($repositoryName, $username, $password = null)
  19466. {
  19467. $this->authentications[$repositoryName] = ['username' => $username, 'password' => $password];
  19468. }
  19469. public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  19470. {
  19471. $this->write($messages, $newline, $verbosity);
  19472. }
  19473. public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  19474. {
  19475. $this->writeError($messages, $newline, $verbosity);
  19476. }
  19477. protected function checkAndSetAuthentication(string $repositoryName, string $username, ?string $password = null)
  19478. {
  19479. if ($this->hasAuthentication($repositoryName)) {
  19480. $auth = $this->getAuthentication($repositoryName);
  19481. if ($auth['username'] === $username && $auth['password'] === $password) {
  19482. return;
  19483. }
  19484. $this->writeError(
  19485. sprintf(
  19486. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  19487. $repositoryName
  19488. )
  19489. );
  19490. }
  19491. $this->setAuthentication($repositoryName, $username, $password);
  19492. }
  19493. public function loadConfiguration(Config $config)
  19494. {
  19495. $bitbucketOauth = $config->get('bitbucket-oauth');
  19496. $githubOauth = $config->get('github-oauth');
  19497. $gitlabOauth = $config->get('gitlab-oauth');
  19498. $gitlabToken = $config->get('gitlab-token');
  19499. $httpBasic = $config->get('http-basic');
  19500. $bearerToken = $config->get('bearer');
  19501. foreach ($bitbucketOauth as $domain => $cred) {
  19502. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  19503. }
  19504. foreach ($githubOauth as $domain => $token) {
  19505. if ($domain !== 'github.com' && !in_array($domain, $config->get('github-domains'), true)) {
  19506. $this->debug($domain.' is not in the configured github-domains, adding it implicitly as authentication is configured for this domain');
  19507. $config->merge(['config' => ['github-domains' => array_merge($config->get('github-domains'), [$domain])]], 'implicit-due-to-auth');
  19508. }
  19509. if (!Preg::isMatch('{^[.A-Za-z0-9_]+$}', $token)) {
  19510. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  19511. }
  19512. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  19513. }
  19514. foreach ($gitlabOauth as $domain => $token) {
  19515. if ($domain !== 'gitlab.com' && !in_array($domain, $config->get('gitlab-domains'), true)) {
  19516. $this->debug($domain.' is not in the configured gitlab-domains, adding it implicitly as authentication is configured for this domain');
  19517. $config->merge(['config' => ['gitlab-domains' => array_merge($config->get('gitlab-domains'), [$domain])]], 'implicit-due-to-auth');
  19518. }
  19519. $token = is_array($token) ? $token["token"] : $token;
  19520. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  19521. }
  19522. foreach ($gitlabToken as $domain => $token) {
  19523. if ($domain !== 'gitlab.com' && !in_array($domain, $config->get('gitlab-domains'), true)) {
  19524. $this->debug($domain.' is not in the configured gitlab-domains, adding it implicitly as authentication is configured for this domain');
  19525. $config->merge(['config' => ['gitlab-domains' => array_merge($config->get('gitlab-domains'), [$domain])]], 'implicit-due-to-auth');
  19526. }
  19527. $username = is_array($token) ? $token["username"] : $token;
  19528. $password = is_array($token) ? $token["token"] : 'private-token';
  19529. $this->checkAndSetAuthentication($domain, $username, $password);
  19530. }
  19531. foreach ($httpBasic as $domain => $cred) {
  19532. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  19533. }
  19534. foreach ($bearerToken as $domain => $token) {
  19535. $this->checkAndSetAuthentication($domain, $token, 'bearer');
  19536. }
  19537. ProcessExecutor::setTimeout($config->get('process-timeout'));
  19538. }
  19539. public function emergency($message, array $context = []): void
  19540. {
  19541. $this->log(LogLevel::EMERGENCY, $message, $context);
  19542. }
  19543. public function alert($message, array $context = []): void
  19544. {
  19545. $this->log(LogLevel::ALERT, $message, $context);
  19546. }
  19547. public function critical($message, array $context = []): void
  19548. {
  19549. $this->log(LogLevel::CRITICAL, $message, $context);
  19550. }
  19551. public function error($message, array $context = []): void
  19552. {
  19553. $this->log(LogLevel::ERROR, $message, $context);
  19554. }
  19555. public function warning($message, array $context = []): void
  19556. {
  19557. $this->log(LogLevel::WARNING, $message, $context);
  19558. }
  19559. public function notice($message, array $context = []): void
  19560. {
  19561. $this->log(LogLevel::NOTICE, $message, $context);
  19562. }
  19563. public function info($message, array $context = []): void
  19564. {
  19565. $this->log(LogLevel::INFO, $message, $context);
  19566. }
  19567. public function debug($message, array $context = []): void
  19568. {
  19569. $this->log(LogLevel::DEBUG, $message, $context);
  19570. }
  19571. public function log($level, $message, array $context = []): void
  19572. {
  19573. $message = (string) $message;
  19574. if ($context !== []) {
  19575. $json = Silencer::call('json_encode', $context, JSON_INVALID_UTF8_IGNORE|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
  19576. if ($json !== false) {
  19577. $message .= ' ' . $json;
  19578. }
  19579. }
  19580. if (in_array($level, [LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR])) {
  19581. $this->writeError('<error>'.$message.'</error>');
  19582. } elseif ($level === LogLevel::WARNING) {
  19583. $this->writeError('<warning>'.$message.'</warning>');
  19584. } elseif ($level === LogLevel::NOTICE) {
  19585. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  19586. } elseif ($level === LogLevel::INFO) {
  19587. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  19588. } else {
  19589. $this->writeError($message, true, self::DEBUG);
  19590. }
  19591. }
  19592. }
  19593. <?php declare(strict_types=1);
  19594. namespace Composer\IO;
  19595. use Composer\Pcre\Preg;
  19596. use Symfony\Component\Console\Helper\QuestionHelper;
  19597. use Symfony\Component\Console\Input\InputInterface;
  19598. use Symfony\Component\Console\Output\OutputInterface;
  19599. use Symfony\Component\Console\Output\StreamOutput;
  19600. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  19601. use Symfony\Component\Console\Input\StreamableInputInterface;
  19602. use Symfony\Component\Console\Input\StringInput;
  19603. use Symfony\Component\Console\Helper\HelperSet;
  19604. class BufferIO extends ConsoleIO
  19605. {
  19606. public function __construct(string $input = '', int $verbosity = StreamOutput::VERBOSITY_NORMAL, ?OutputFormatterInterface $formatter = null)
  19607. {
  19608. $input = new StringInput($input);
  19609. $input->setInteractive(false);
  19610. $stream = fopen('php://memory', 'rw');
  19611. if ($stream === false) {
  19612. throw new \RuntimeException('Unable to open memory output stream');
  19613. }
  19614. $output = new StreamOutput($stream, $verbosity, $formatter !== null ? $formatter->isDecorated() : false, $formatter);
  19615. parent::__construct($input, $output, new HelperSet([
  19616. new QuestionHelper(),
  19617. ]));
  19618. }
  19619. public function getOutput(): string
  19620. {
  19621. assert($this->output instanceof StreamOutput);
  19622. fseek($this->output->getStream(), 0);
  19623. $output = (string) stream_get_contents($this->output->getStream());
  19624. $output = Preg::replaceCallback("{(?<=^|\n|\x08)(.+?)(\x08+)}", static function ($matches): string {
  19625. $pre = strip_tags($matches[1]);
  19626. if (strlen($pre) === strlen($matches[2])) {
  19627. return '';
  19628. }
  19629. return rtrim($matches[1])."\n";
  19630. }, $output);
  19631. return $output;
  19632. }
  19633. public function setUserInputs(array $inputs): void
  19634. {
  19635. if (!$this->input instanceof StreamableInputInterface) {
  19636. throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
  19637. }
  19638. $this->input->setStream($this->createStream($inputs));
  19639. $this->input->setInteractive(true);
  19640. }
  19641. private function createStream(array $inputs)
  19642. {
  19643. $stream = fopen('php://memory', 'r+');
  19644. if ($stream === false) {
  19645. throw new \RuntimeException('Unable to open memory output stream');
  19646. }
  19647. foreach ($inputs as $input) {
  19648. fwrite($stream, $input.PHP_EOL);
  19649. }
  19650. rewind($stream);
  19651. return $stream;
  19652. }
  19653. }
  19654. <?php declare(strict_types=1);
  19655. namespace Composer\IO;
  19656. use Composer\Question\StrictConfirmationQuestion;
  19657. use Symfony\Component\Console\Helper\HelperSet;
  19658. use Symfony\Component\Console\Helper\ProgressBar;
  19659. use Symfony\Component\Console\Helper\Table;
  19660. use Symfony\Component\Console\Input\InputInterface;
  19661. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  19662. use Symfony\Component\Console\Output\OutputInterface;
  19663. use Symfony\Component\Console\Question\ChoiceQuestion;
  19664. use Symfony\Component\Console\Question\Question;
  19665. class ConsoleIO extends BaseIO
  19666. {
  19667. protected $input;
  19668. protected $output;
  19669. protected $helperSet;
  19670. protected $lastMessage = '';
  19671. protected $lastMessageErr = '';
  19672. private $startTime;
  19673. private $verbosityMap;
  19674. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  19675. {
  19676. $this->input = $input;
  19677. $this->output = $output;
  19678. $this->helperSet = $helperSet;
  19679. $this->verbosityMap = [
  19680. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  19681. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  19682. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  19683. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  19684. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  19685. ];
  19686. }
  19687. public function enableDebugging(float $startTime)
  19688. {
  19689. $this->startTime = $startTime;
  19690. }
  19691. public function isInteractive()
  19692. {
  19693. return $this->input->isInteractive();
  19694. }
  19695. public function isDecorated()
  19696. {
  19697. return $this->output->isDecorated();
  19698. }
  19699. public function isVerbose()
  19700. {
  19701. return $this->output->isVerbose();
  19702. }
  19703. public function isVeryVerbose()
  19704. {
  19705. return $this->output->isVeryVerbose();
  19706. }
  19707. public function isDebug()
  19708. {
  19709. return $this->output->isDebug();
  19710. }
  19711. public function write($messages, bool $newline = true, int $verbosity = self::NORMAL)
  19712. {
  19713. $this->doWrite($messages, $newline, false, $verbosity);
  19714. }
  19715. public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL)
  19716. {
  19717. $this->doWrite($messages, $newline, true, $verbosity);
  19718. }
  19719. public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  19720. {
  19721. $this->doWrite($messages, $newline, false, $verbosity, true);
  19722. }
  19723. public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL)
  19724. {
  19725. $this->doWrite($messages, $newline, true, $verbosity, true);
  19726. }
  19727. private function doWrite($messages, bool $newline, bool $stderr, int $verbosity, bool $raw = false): void
  19728. {
  19729. $sfVerbosity = $this->verbosityMap[$verbosity];
  19730. if ($sfVerbosity > $this->output->getVerbosity()) {
  19731. return;
  19732. }
  19733. if ($raw) {
  19734. $sfVerbosity |= OutputInterface::OUTPUT_RAW;
  19735. }
  19736. if (null !== $this->startTime) {
  19737. $memoryUsage = memory_get_usage() / 1024 / 1024;
  19738. $timeSpent = microtime(true) - $this->startTime;
  19739. $messages = array_map(static function ($message) use ($memoryUsage, $timeSpent): string {
  19740. return sprintf('[%.1fMiB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  19741. }, (array) $messages);
  19742. }
  19743. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  19744. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  19745. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  19746. return;
  19747. }
  19748. $this->output->write($messages, $newline, $sfVerbosity);
  19749. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  19750. }
  19751. public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL)
  19752. {
  19753. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  19754. }
  19755. public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL)
  19756. {
  19757. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  19758. }
  19759. private function doOverwrite($messages, bool $newline, ?int $size, bool $stderr, int $verbosity): void
  19760. {
  19761. $messages = implode($newline ? "\n" : '', (array) $messages);
  19762. if (!isset($size)) {
  19763. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  19764. }
  19765. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  19766. $this->doWrite($messages, false, $stderr, $verbosity);
  19767. $fill = $size - strlen(strip_tags($messages));
  19768. if ($fill > 0) {
  19769. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  19770. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  19771. }
  19772. if ($newline) {
  19773. $this->doWrite('', true, $stderr, $verbosity);
  19774. }
  19775. if ($stderr) {
  19776. $this->lastMessageErr = $messages;
  19777. } else {
  19778. $this->lastMessage = $messages;
  19779. }
  19780. }
  19781. public function getProgressBar(int $max = 0)
  19782. {
  19783. return new ProgressBar($this->getErrorOutput(), $max);
  19784. }
  19785. public function ask($question, $default = null)
  19786. {
  19787. $helper = $this->helperSet->get('question');
  19788. $question = new Question($question, $default);
  19789. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  19790. }
  19791. public function askConfirmation($question, $default = true)
  19792. {
  19793. $helper = $this->helperSet->get('question');
  19794. $question = new StrictConfirmationQuestion($question, $default);
  19795. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  19796. }
  19797. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  19798. {
  19799. $helper = $this->helperSet->get('question');
  19800. $question = new Question($question, $default);
  19801. $question->setValidator($validator);
  19802. $question->setMaxAttempts($attempts);
  19803. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  19804. }
  19805. public function askAndHideAnswer($question)
  19806. {
  19807. $helper = $this->helperSet->get('question');
  19808. $question = new Question($question);
  19809. $question->setHidden(true);
  19810. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  19811. }
  19812. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  19813. {
  19814. $helper = $this->helperSet->get('question');
  19815. $question = new ChoiceQuestion($question, $choices, $default);
  19816. $question->setMaxAttempts($attempts ?: null);
  19817. $question->setErrorMessage($errorMessage);
  19818. $question->setMultiselect($multiselect);
  19819. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  19820. $isAssoc = (bool) \count(array_filter(array_keys($choices), 'is_string'));
  19821. if ($isAssoc) {
  19822. return $result;
  19823. }
  19824. if (!is_array($result)) {
  19825. return (string) array_search($result, $choices, true);
  19826. }
  19827. $results = [];
  19828. foreach ($choices as $index => $choice) {
  19829. if (in_array($choice, $result, true)) {
  19830. $results[] = (string) $index;
  19831. }
  19832. }
  19833. return $results;
  19834. }
  19835. public function getTable(): Table
  19836. {
  19837. return new Table($this->output);
  19838. }
  19839. private function getErrorOutput(): OutputInterface
  19840. {
  19841. if ($this->output instanceof ConsoleOutputInterface) {
  19842. return $this->output->getErrorOutput();
  19843. }
  19844. return $this->output;
  19845. }
  19846. }
  19847. <?php declare(strict_types=1);
  19848. namespace Composer\IO;
  19849. use Composer\Config;
  19850. use Psr\Log\LoggerInterface;
  19851. interface IOInterface extends LoggerInterface
  19852. {
  19853. public const QUIET = 1;
  19854. public const NORMAL = 2;
  19855. public const VERBOSE = 4;
  19856. public const VERY_VERBOSE = 8;
  19857. public const DEBUG = 16;
  19858. public function isInteractive();
  19859. public function isVerbose();
  19860. public function isVeryVerbose();
  19861. public function isDebug();
  19862. public function isDecorated();
  19863. public function write($messages, bool $newline = true, int $verbosity = self::NORMAL);
  19864. public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL);
  19865. public function writeRaw($messages, bool $newline = true, int $verbosity = self::NORMAL);
  19866. public function writeErrorRaw($messages, bool $newline = true, int $verbosity = self::NORMAL);
  19867. public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL);
  19868. public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL);
  19869. public function ask(string $question, $default = null);
  19870. public function askConfirmation(string $question, bool $default = true);
  19871. public function askAndValidate(string $question, callable $validator, ?int $attempts = null, $default = null);
  19872. public function askAndHideAnswer(string $question);
  19873. public function select(string $question, array $choices, $default, $attempts = false, string $errorMessage = 'Value "%s" is invalid', bool $multiselect = false);
  19874. public function getAuthentications();
  19875. public function hasAuthentication(string $repositoryName);
  19876. public function getAuthentication(string $repositoryName);
  19877. public function setAuthentication(string $repositoryName, string $username, ?string $password = null);
  19878. public function loadConfiguration(Config $config);
  19879. }
  19880. <?php declare(strict_types=1);
  19881. namespace Composer\IO;
  19882. class NullIO extends BaseIO
  19883. {
  19884. public function isInteractive(): bool
  19885. {
  19886. return false;
  19887. }
  19888. public function isVerbose(): bool
  19889. {
  19890. return false;
  19891. }
  19892. public function isVeryVerbose(): bool
  19893. {
  19894. return false;
  19895. }
  19896. public function isDebug(): bool
  19897. {
  19898. return false;
  19899. }
  19900. public function isDecorated(): bool
  19901. {
  19902. return false;
  19903. }
  19904. public function write($messages, bool $newline = true, int $verbosity = self::NORMAL): void
  19905. {
  19906. }
  19907. public function writeError($messages, bool $newline = true, int $verbosity = self::NORMAL): void
  19908. {
  19909. }
  19910. public function overwrite($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL): void
  19911. {
  19912. }
  19913. public function overwriteError($messages, bool $newline = true, ?int $size = null, int $verbosity = self::NORMAL): void
  19914. {
  19915. }
  19916. public function ask($question, $default = null)
  19917. {
  19918. return $default;
  19919. }
  19920. public function askConfirmation($question, $default = true): bool
  19921. {
  19922. return $default;
  19923. }
  19924. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  19925. {
  19926. return $default;
  19927. }
  19928. public function askAndHideAnswer($question): ?string
  19929. {
  19930. return null;
  19931. }
  19932. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  19933. {
  19934. return $default;
  19935. }
  19936. }
  19937. <?php declare(strict_types=1);
  19938. namespace Composer;
  19939. use Composer\Autoload\AutoloadGenerator;
  19940. use Composer\Console\GithubActionError;
  19941. use Composer\DependencyResolver\DefaultPolicy;
  19942. use Composer\DependencyResolver\LocalRepoTransaction;
  19943. use Composer\DependencyResolver\LockTransaction;
  19944. use Composer\DependencyResolver\Operation\UpdateOperation;
  19945. use Composer\DependencyResolver\Operation\InstallOperation;
  19946. use Composer\DependencyResolver\Operation\UninstallOperation;
  19947. use Composer\DependencyResolver\PoolOptimizer;
  19948. use Composer\DependencyResolver\Pool;
  19949. use Composer\DependencyResolver\Request;
  19950. use Composer\DependencyResolver\Solver;
  19951. use Composer\DependencyResolver\SolverProblemsException;
  19952. use Composer\DependencyResolver\PolicyInterface;
  19953. use Composer\Downloader\DownloadManager;
  19954. use Composer\Downloader\TransportException;
  19955. use Composer\EventDispatcher\EventDispatcher;
  19956. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  19957. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  19958. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  19959. use Composer\Installer\InstallationManager;
  19960. use Composer\Installer\InstallerEvents;
  19961. use Composer\Installer\SuggestedPackagesReporter;
  19962. use Composer\IO\IOInterface;
  19963. use Composer\Package\AliasPackage;
  19964. use Composer\Package\RootAliasPackage;
  19965. use Composer\Package\BasePackage;
  19966. use Composer\Package\CompletePackage;
  19967. use Composer\Package\CompletePackageInterface;
  19968. use Composer\Package\Link;
  19969. use Composer\Package\Loader\ArrayLoader;
  19970. use Composer\Package\Dumper\ArrayDumper;
  19971. use Composer\Package\Version\VersionParser;
  19972. use Composer\Package\Package;
  19973. use Composer\Repository\ArrayRepository;
  19974. use Composer\Repository\RepositorySet;
  19975. use Composer\Repository\CompositeRepository;
  19976. use Composer\Semver\Constraint\Constraint;
  19977. use Composer\Package\Locker;
  19978. use Composer\Package\RootPackageInterface;
  19979. use Composer\Repository\InstalledArrayRepository;
  19980. use Composer\Repository\InstalledRepositoryInterface;
  19981. use Composer\Repository\InstalledRepository;
  19982. use Composer\Repository\RootPackageRepository;
  19983. use Composer\Repository\PlatformRepository;
  19984. use Composer\Repository\RepositoryInterface;
  19985. use Composer\Repository\RepositoryManager;
  19986. use Composer\Repository\LockArrayRepository;
  19987. use Composer\Script\ScriptEvents;
  19988. use Composer\Semver\Constraint\ConstraintInterface;
  19989. use Composer\Advisory\Auditor;
  19990. use Composer\Util\Platform;
  19991. class Installer
  19992. {
  19993. public const ERROR_NONE = 0;
  19994. public const ERROR_GENERIC_FAILURE = 1;
  19995. public const ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE = 3;
  19996. public const ERROR_LOCK_FILE_INVALID = 4;
  19997. public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
  19998. public const ERROR_AUDIT_FAILED = 5;
  19999. public const ERROR_TRANSPORT_EXCEPTION = 100;
  20000. protected $io;
  20001. protected $config;
  20002. protected $package;
  20003. protected $fixedRootPackage;
  20004. protected $downloadManager;
  20005. protected $repositoryManager;
  20006. protected $locker;
  20007. protected $installationManager;
  20008. protected $eventDispatcher;
  20009. protected $autoloadGenerator;
  20010. protected $preferSource = false;
  20011. protected $preferDist = false;
  20012. protected $optimizeAutoloader = false;
  20013. protected $classMapAuthoritative = false;
  20014. protected $apcuAutoloader = false;
  20015. protected $apcuAutoloaderPrefix = null;
  20016. protected $devMode = false;
  20017. protected $dryRun = false;
  20018. protected $downloadOnly = false;
  20019. protected $verbose = false;
  20020. protected $update = false;
  20021. protected $install = true;
  20022. protected $dumpAutoloader = true;
  20023. protected $runScripts = true;
  20024. protected $preferStable = false;
  20025. protected $preferLowest = false;
  20026. protected $minimalUpdate = false;
  20027. protected $writeLock;
  20028. protected $executeOperations = true;
  20029. protected $audit = true;
  20030. protected $errorOnAudit = false;
  20031. protected $auditFormat = Auditor::FORMAT_SUMMARY;
  20032. private $ignoredTypes = ['php-ext', 'php-ext-zend'];
  20033. private $allowedTypes = null;
  20034. protected $updateMirrors = false;
  20035. protected $updateAllowList = null;
  20036. protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  20037. protected $suggestedPackagesReporter;
  20038. protected $platformRequirementFilter;
  20039. protected $additionalFixedRepository;
  20040. protected $temporaryConstraints = [];
  20041. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  20042. {
  20043. $this->io = $io;
  20044. $this->config = $config;
  20045. $this->package = $package;
  20046. $this->downloadManager = $downloadManager;
  20047. $this->repositoryManager = $repositoryManager;
  20048. $this->locker = $locker;
  20049. $this->installationManager = $installationManager;
  20050. $this->eventDispatcher = $eventDispatcher;
  20051. $this->autoloadGenerator = $autoloadGenerator;
  20052. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  20053. $this->platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  20054. $this->writeLock = $config->get('lock');
  20055. }
  20056. public function run(): int
  20057. {
  20058. gc_collect_cycles();
  20059. gc_disable();
  20060. if ($this->updateAllowList !== null && $this->updateMirrors) {
  20061. throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
  20062. }
  20063. $isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
  20064. if (!$this->update && !$this->locker->isLocked()) {
  20065. $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>');
  20066. $this->update = true;
  20067. }
  20068. if ($this->dryRun) {
  20069. $this->verbose = true;
  20070. $this->runScripts = false;
  20071. $this->executeOperations = false;
  20072. $this->writeLock = false;
  20073. $this->dumpAutoloader = false;
  20074. $this->mockLocalRepositories($this->repositoryManager);
  20075. }
  20076. if ($this->downloadOnly) {
  20077. $this->dumpAutoloader = false;
  20078. }
  20079. if ($this->update && !$this->install) {
  20080. $this->dumpAutoloader = false;
  20081. }
  20082. if ($this->runScripts) {
  20083. Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
  20084. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  20085. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  20086. }
  20087. $this->downloadManager->setPreferSource($this->preferSource);
  20088. $this->downloadManager->setPreferDist($this->preferDist);
  20089. $localRepo = $this->repositoryManager->getLocalRepository();
  20090. try {
  20091. if ($this->update) {
  20092. $res = $this->doUpdate($localRepo, $this->install);
  20093. } else {
  20094. $res = $this->doInstall($localRepo);
  20095. }
  20096. if ($res !== 0) {
  20097. return $res;
  20098. }
  20099. } catch (\Exception $e) {
  20100. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  20101. $this->installationManager->notifyInstalls($this->io);
  20102. }
  20103. throw $e;
  20104. }
  20105. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  20106. $this->installationManager->notifyInstalls($this->io);
  20107. }
  20108. if ($this->update) {
  20109. $installedRepo = new InstalledRepository([
  20110. $this->locker->getLockedRepository($this->devMode),
  20111. $this->createPlatformRepo(false),
  20112. new RootPackageRepository(clone $this->package),
  20113. ]);
  20114. if ($isFreshInstall) {
  20115. $this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
  20116. }
  20117. $this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
  20118. }
  20119. $lockedRepository = $this->locker->getLockedRepository(true);
  20120. foreach ($lockedRepository->getPackages() as $package) {
  20121. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  20122. continue;
  20123. }
  20124. $replacement = is_string($package->getReplacementPackage())
  20125. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  20126. : 'No replacement was suggested';
  20127. $this->io->writeError(
  20128. sprintf(
  20129. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  20130. $package->getPrettyName(),
  20131. $replacement
  20132. )
  20133. );
  20134. }
  20135. if ($this->dumpAutoloader) {
  20136. if ($this->optimizeAutoloader) {
  20137. $this->io->writeError('<info>Generating optimized autoload files</info>');
  20138. } else {
  20139. $this->io->writeError('<info>Generating autoload files</info>');
  20140. }
  20141. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  20142. $this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
  20143. $this->autoloadGenerator->setRunScripts($this->runScripts);
  20144. $this->autoloadGenerator->setPlatformRequirementFilter($this->platformRequirementFilter);
  20145. $this
  20146. ->autoloadGenerator
  20147. ->dump(
  20148. $this->config,
  20149. $localRepo,
  20150. $this->package,
  20151. $this->installationManager,
  20152. 'composer',
  20153. $this->optimizeAutoloader,
  20154. null,
  20155. $this->locker
  20156. );
  20157. }
  20158. if ($this->install && $this->executeOperations) {
  20159. foreach ($localRepo->getPackages() as $package) {
  20160. $this->installationManager->ensureBinariesPresence($package);
  20161. }
  20162. }
  20163. $fundEnv = Platform::getEnv('COMPOSER_FUND');
  20164. $showFunding = true;
  20165. if (is_numeric($fundEnv)) {
  20166. $showFunding = intval($fundEnv) !== 0;
  20167. }
  20168. if ($showFunding) {
  20169. $fundingCount = 0;
  20170. foreach ($localRepo->getPackages() as $package) {
  20171. if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
  20172. $fundingCount++;
  20173. }
  20174. }
  20175. if ($fundingCount > 0) {
  20176. $this->io->writeError([
  20177. sprintf(
  20178. "<info>%d package%s you are using %s looking for funding.</info>",
  20179. $fundingCount,
  20180. 1 === $fundingCount ? '' : 's',
  20181. 1 === $fundingCount ? 'is' : 'are'
  20182. ),
  20183. '<info>Use the `composer fund` command to find out more!</info>',
  20184. ]);
  20185. }
  20186. }
  20187. if ($this->runScripts) {
  20188. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  20189. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  20190. }
  20191. if (!defined('HHVM_VERSION')) {
  20192. gc_enable();
  20193. }
  20194. if ($this->audit) {
  20195. if ($this->update && !$this->install) {
  20196. $packages = $lockedRepository->getCanonicalPackages();
  20197. $target = 'locked';
  20198. } else {
  20199. $packages = $localRepo->getCanonicalPackages();
  20200. $target = 'installed';
  20201. }
  20202. if (count($packages) > 0) {
  20203. try {
  20204. $auditor = new Auditor();
  20205. $repoSet = new RepositorySet();
  20206. foreach ($this->repositoryManager->getRepositories() as $repo) {
  20207. $repoSet->addRepository($repo);
  20208. }
  20209. $auditConfig = $this->config->get('audit');
  20210. return $auditor->audit($this->io, $repoSet, $packages, $this->auditFormat, true, $auditConfig['ignore'] ?? [], $auditConfig['abandoned'] ?? Auditor::ABANDONED_FAIL) > 0 && $this->errorOnAudit ? self::ERROR_AUDIT_FAILED : 0;
  20211. } catch (TransportException $e) {
  20212. $this->io->error('Failed to audit '.$target.' packages.');
  20213. if ($this->io->isVerbose()) {
  20214. $this->io->error('['.get_class($e).'] '.$e->getMessage());
  20215. }
  20216. }
  20217. } else {
  20218. $this->io->writeError('No '.$target.' packages - skipping audit.');
  20219. }
  20220. }
  20221. return 0;
  20222. }
  20223. protected function doUpdate(InstalledRepositoryInterface $localRepo, bool $doInstall): int
  20224. {
  20225. $platformRepo = $this->createPlatformRepo(true);
  20226. $aliases = $this->getRootAliases(true);
  20227. $lockedRepository = null;
  20228. try {
  20229. if ($this->locker->isLocked()) {
  20230. $lockedRepository = $this->locker->getLockedRepository(true);
  20231. }
  20232. } catch (\Seld\JsonLint\ParsingException $e) {
  20233. if ($this->updateAllowList !== null || $this->updateMirrors) {
  20234. throw $e;
  20235. }
  20236. }
  20237. if (($this->updateAllowList !== null || $this->updateMirrors) && !$lockedRepository) {
  20238. $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);
  20239. return self::ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE;
  20240. }
  20241. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  20242. $policy = $this->createPolicy(true, $lockedRepository);
  20243. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  20244. $repositories = $this->repositoryManager->getRepositories();
  20245. foreach ($repositories as $repository) {
  20246. $repositorySet->addRepository($repository);
  20247. }
  20248. if ($lockedRepository) {
  20249. $repositorySet->addRepository($lockedRepository);
  20250. }
  20251. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  20252. $this->requirePackagesForUpdate($request, $lockedRepository, true);
  20253. if ($this->updateAllowList !== null) {
  20254. $request->setUpdateAllowList($this->updateAllowList, $this->updateAllowTransitiveDependencies);
  20255. }
  20256. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher, $this->createPoolOptimizer($policy), $this->ignoredTypes, $this->allowedTypes);
  20257. $this->io->writeError('<info>Updating dependencies</info>');
  20258. $solver = new Solver($policy, $pool, $this->io);
  20259. try {
  20260. $lockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  20261. $ruleSetSize = $solver->getRuleSetSize();
  20262. $solver = null;
  20263. } catch (SolverProblemsException $e) {
  20264. $err = 'Your requirements could not be resolved to an installable set of packages.';
  20265. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  20266. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  20267. $this->io->writeError($prettyProblem);
  20268. if (!$this->devMode) {
  20269. $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);
  20270. }
  20271. $ghe = new GithubActionError($this->io);
  20272. $ghe->emit($err."\n".$prettyProblem);
  20273. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  20274. }
  20275. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  20276. $this->io->writeError("Analyzed ".$ruleSetSize." rules to resolve dependencies", true, IOInterface::VERBOSE);
  20277. $pool = null;
  20278. if (!$lockTransaction->getOperations()) {
  20279. $this->io->writeError('Nothing to modify in lock file');
  20280. }
  20281. $exitCode = $this->extractDevPackages($lockTransaction, $platformRepo, $aliases, $policy, $lockedRepository);
  20282. if ($exitCode !== 0) {
  20283. return $exitCode;
  20284. }
  20285. \Composer\Semver\CompilingMatcher::clear();
  20286. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  20287. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  20288. $installsUpdates = $uninstalls = [];
  20289. if ($lockTransaction->getOperations()) {
  20290. $installNames = $updateNames = $uninstallNames = [];
  20291. foreach ($lockTransaction->getOperations() as $operation) {
  20292. if ($operation instanceof InstallOperation) {
  20293. $installsUpdates[] = $operation;
  20294. $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  20295. } elseif ($operation instanceof UpdateOperation) {
  20296. if ($this->updateMirrors
  20297. && $operation->getInitialPackage()->getName() === $operation->getTargetPackage()->getName()
  20298. && $operation->getInitialPackage()->getVersion() === $operation->getTargetPackage()->getVersion()
  20299. ) {
  20300. continue;
  20301. }
  20302. $installsUpdates[] = $operation;
  20303. $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  20304. } elseif ($operation instanceof UninstallOperation) {
  20305. $uninstalls[] = $operation;
  20306. $uninstallNames[] = $operation->getPackage()->getPrettyName();
  20307. }
  20308. }
  20309. if ($this->config->get('lock')) {
  20310. $this->io->writeError(sprintf(
  20311. "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>",
  20312. count($installNames),
  20313. 1 === count($installNames) ? '' : 's',
  20314. count($updateNames),
  20315. 1 === count($updateNames) ? '' : 's',
  20316. count($uninstalls),
  20317. 1 === count($uninstalls) ? '' : 's'
  20318. ));
  20319. if ($installNames) {
  20320. $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE);
  20321. }
  20322. if ($updateNames) {
  20323. $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE);
  20324. }
  20325. if ($uninstalls) {
  20326. $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE);
  20327. }
  20328. }
  20329. }
  20330. $sortByName = static function ($a, $b): int {
  20331. if ($a instanceof UpdateOperation) {
  20332. $a = $a->getTargetPackage()->getName();
  20333. } else {
  20334. $a = $a->getPackage()->getName();
  20335. }
  20336. if ($b instanceof UpdateOperation) {
  20337. $b = $b->getTargetPackage()->getName();
  20338. } else {
  20339. $b = $b->getPackage()->getName();
  20340. }
  20341. return strcmp($a, $b);
  20342. };
  20343. usort($uninstalls, $sortByName);
  20344. usort($installsUpdates, $sortByName);
  20345. foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
  20346. if ($operation instanceof InstallOperation) {
  20347. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  20348. }
  20349. if ($this->config->get('lock') && (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug())) {
  20350. $sourceRepo = '';
  20351. if ($this->io->isVeryVerbose() && false === strpos($operation->getOperationType(), 'Alias')) {
  20352. $operationPkg = ($operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage());
  20353. if ($operationPkg->getRepository() !== null) {
  20354. $sourceRepo = ' from ' . $operationPkg->getRepository()->getRepoName();
  20355. }
  20356. }
  20357. $this->io->writeError(' - ' . $operation->show(true) . $sourceRepo);
  20358. }
  20359. }
  20360. $updatedLock = $this->locker->setLockData(
  20361. $lockTransaction->getNewLockPackages(false, $this->updateMirrors),
  20362. $lockTransaction->getNewLockPackages(true, $this->updateMirrors),
  20363. $platformReqs,
  20364. $platformDevReqs,
  20365. $lockTransaction->getAliases($aliases),
  20366. $this->package->getMinimumStability(),
  20367. $this->package->getStabilityFlags(),
  20368. $this->preferStable || $this->package->getPreferStable(),
  20369. $this->preferLowest,
  20370. $this->config->get('platform') ?: [],
  20371. $this->writeLock && $this->executeOperations
  20372. );
  20373. if ($updatedLock && $this->writeLock && $this->executeOperations) {
  20374. $this->io->writeError('<info>Writing lock file</info>');
  20375. }
  20376. if ($doInstall) {
  20377. return $this->doInstall($localRepo, true);
  20378. }
  20379. return 0;
  20380. }
  20381. protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, ?LockArrayRepository $lockedRepository = null): int
  20382. {
  20383. if (!$this->package->getDevRequires()) {
  20384. return 0;
  20385. }
  20386. $resultRepo = new ArrayRepository([]);
  20387. $loader = new ArrayLoader(null, true);
  20388. $dumper = new ArrayDumper();
  20389. foreach ($lockTransaction->getNewLockPackages(false) as $pkg) {
  20390. $resultRepo->addPackage($loader->load($dumper->dump($pkg)));
  20391. }
  20392. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  20393. $repositorySet->addRepository($resultRepo);
  20394. $request = $this->createRequest($this->fixedRootPackage, $platformRepo);
  20395. $this->requirePackagesForUpdate($request, $lockedRepository, false);
  20396. $pool = $repositorySet->createPoolWithAllPackages();
  20397. $solver = new Solver($policy, $pool, $this->io);
  20398. try {
  20399. $nonDevLockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  20400. $solver = null;
  20401. } catch (SolverProblemsException $e) {
  20402. $err = 'Unable to find a compatible set of packages based on your non-dev requirements alone.';
  20403. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose(), true);
  20404. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  20405. $this->io->writeError('Your requirements can be resolved successfully when require-dev packages are present.');
  20406. $this->io->writeError('You may need to move packages from require-dev or some of their dependencies to require.');
  20407. $this->io->writeError($prettyProblem);
  20408. $ghe = new GithubActionError($this->io);
  20409. $ghe->emit($err."\n".$prettyProblem);
  20410. return $e->getCode();
  20411. }
  20412. $lockTransaction->setNonDevPackages($nonDevLockTransaction);
  20413. return 0;
  20414. }
  20415. protected function doInstall(InstalledRepositoryInterface $localRepo, bool $alreadySolved = false): int
  20416. {
  20417. if ($this->config->get('lock')) {
  20418. $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  20419. }
  20420. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  20421. if (!$alreadySolved) {
  20422. $this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
  20423. $platformRepo = $this->createPlatformRepo(false);
  20424. $policy = $this->createPolicy(false);
  20425. $repositorySet = $this->createRepositorySet(false, $platformRepo, [], $lockedRepository);
  20426. $repositorySet->addRepository($lockedRepository);
  20427. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  20428. if (!$this->locker->isFresh()) {
  20429. $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);
  20430. }
  20431. $missingRequirementInfo = $this->locker->getMissingRequirementInfo($this->package, $this->devMode);
  20432. if ($missingRequirementInfo !== []) {
  20433. $this->io->writeError($missingRequirementInfo);
  20434. if (!$this->config->get('allow-missing-requirements')) {
  20435. return self::ERROR_LOCK_FILE_INVALID;
  20436. }
  20437. }
  20438. foreach ($lockedRepository->getPackages() as $package) {
  20439. $request->fixLockedPackage($package);
  20440. }
  20441. $rootRequires = $this->package->getRequires();
  20442. if ($this->devMode) {
  20443. $rootRequires = array_merge($rootRequires, $this->package->getDevRequires());
  20444. }
  20445. foreach ($rootRequires as $link) {
  20446. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  20447. $request->requireName($link->getTarget(), $link->getConstraint());
  20448. }
  20449. }
  20450. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  20451. if (!isset($rootRequires[$link->getTarget()])) {
  20452. $request->requireName($link->getTarget(), $link->getConstraint());
  20453. }
  20454. }
  20455. unset($rootRequires, $link);
  20456. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher, null, $this->ignoredTypes, $this->allowedTypes);
  20457. $solver = new Solver($policy, $pool, $this->io);
  20458. try {
  20459. $lockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  20460. $solver = null;
  20461. if (0 !== count($lockTransaction->getOperations())) {
  20462. $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
  20463. return self::ERROR_LOCK_FILE_INVALID;
  20464. }
  20465. } catch (SolverProblemsException $e) {
  20466. $err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
  20467. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  20468. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  20469. $this->io->writeError($prettyProblem);
  20470. $ghe = new GithubActionError($this->io);
  20471. $ghe->emit($err."\n".$prettyProblem);
  20472. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  20473. }
  20474. }
  20475. $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo);
  20476. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction);
  20477. $installs = $updates = $uninstalls = [];
  20478. foreach ($localRepoTransaction->getOperations() as $operation) {
  20479. if ($operation instanceof InstallOperation) {
  20480. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  20481. } elseif ($operation instanceof UpdateOperation) {
  20482. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  20483. } elseif ($operation instanceof UninstallOperation) {
  20484. $uninstalls[] = $operation->getPackage()->getPrettyName();
  20485. }
  20486. }
  20487. if ($installs === [] && $updates === [] && $uninstalls === []) {
  20488. $this->io->writeError('Nothing to install, update or remove');
  20489. } else {
  20490. $this->io->writeError(sprintf(
  20491. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  20492. count($installs),
  20493. 1 === count($installs) ? '' : 's',
  20494. count($updates),
  20495. 1 === count($updates) ? '' : 's',
  20496. count($uninstalls),
  20497. 1 === count($uninstalls) ? '' : 's'
  20498. ));
  20499. if ($installs) {
  20500. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  20501. }
  20502. if ($updates) {
  20503. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  20504. }
  20505. if ($uninstalls) {
  20506. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  20507. }
  20508. }
  20509. if ($this->executeOperations) {
  20510. $localRepo->setDevPackageNames($this->locker->getDevPackageNames());
  20511. $this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts, $this->downloadOnly);
  20512. if (count($localRepoTransaction->getOperations()) > 0) {
  20513. $vendorDir = $this->config->get('vendor-dir');
  20514. if (is_dir($vendorDir)) {
  20515. @touch($vendorDir);
  20516. }
  20517. }
  20518. } else {
  20519. foreach ($localRepoTransaction->getOperations() as $operation) {
  20520. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  20521. $this->io->writeError(' - ' . $operation->show(false));
  20522. }
  20523. }
  20524. }
  20525. return 0;
  20526. }
  20527. protected function createPlatformRepo(bool $forUpdate): PlatformRepository
  20528. {
  20529. if ($forUpdate) {
  20530. $platformOverrides = $this->config->get('platform') ?: [];
  20531. } else {
  20532. $platformOverrides = $this->locker->getPlatformOverrides();
  20533. }
  20534. return new PlatformRepository([], $platformOverrides);
  20535. }
  20536. private function createRepositorySet(bool $forUpdate, PlatformRepository $platformRepo, array $rootAliases = [], ?RepositoryInterface $lockedRepository = null): RepositorySet
  20537. {
  20538. if ($forUpdate) {
  20539. $minimumStability = $this->package->getMinimumStability();
  20540. $stabilityFlags = $this->package->getStabilityFlags();
  20541. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  20542. } else {
  20543. $minimumStability = $this->locker->getMinimumStability();
  20544. $stabilityFlags = $this->locker->getStabilityFlags();
  20545. $requires = [];
  20546. foreach ($lockedRepository->getPackages() as $package) {
  20547. $constraint = new Constraint('=', $package->getVersion());
  20548. $constraint->setPrettyString($package->getPrettyVersion());
  20549. $requires[$package->getName()] = $constraint;
  20550. }
  20551. }
  20552. $rootRequires = [];
  20553. foreach ($requires as $req => $constraint) {
  20554. if ($constraint instanceof Link) {
  20555. $constraint = $constraint->getConstraint();
  20556. }
  20557. if ($this->platformRequirementFilter->isIgnored($req)) {
  20558. continue;
  20559. } elseif ($this->platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  20560. $constraint = $this->platformRequirementFilter->filterConstraint($req, $constraint);
  20561. }
  20562. $rootRequires[$req] = $constraint;
  20563. }
  20564. $this->fixedRootPackage = clone $this->package;
  20565. $this->fixedRootPackage->setRequires([]);
  20566. $this->fixedRootPackage->setDevRequires([]);
  20567. $stabilityFlags[$this->package->getName()] = BasePackage::STABILITIES[VersionParser::parseStability($this->package->getVersion())];
  20568. $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires, $this->temporaryConstraints);
  20569. $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage));
  20570. $repositorySet->addRepository($platformRepo);
  20571. if ($this->additionalFixedRepository) {
  20572. $additionalFixedRepositories = $this->additionalFixedRepository;
  20573. if ($additionalFixedRepositories instanceof CompositeRepository) {
  20574. $additionalFixedRepositories = $additionalFixedRepositories->getRepositories();
  20575. } else {
  20576. $additionalFixedRepositories = [$additionalFixedRepositories];
  20577. }
  20578. foreach ($additionalFixedRepositories as $additionalFixedRepository) {
  20579. if ($additionalFixedRepository instanceof InstalledRepository || $additionalFixedRepository instanceof InstalledRepositoryInterface) {
  20580. $repositorySet->allowInstalledRepositories();
  20581. break;
  20582. }
  20583. }
  20584. $repositorySet->addRepository($this->additionalFixedRepository);
  20585. }
  20586. return $repositorySet;
  20587. }
  20588. private function createPolicy(bool $forUpdate, ?LockArrayRepository $lockedRepo = null): DefaultPolicy
  20589. {
  20590. $preferStable = null;
  20591. $preferLowest = null;
  20592. if (!$forUpdate) {
  20593. $preferStable = $this->locker->getPreferStable();
  20594. $preferLowest = $this->locker->getPreferLowest();
  20595. }
  20596. if (null === $preferStable) {
  20597. $preferStable = $this->preferStable || $this->package->getPreferStable();
  20598. }
  20599. if (null === $preferLowest) {
  20600. $preferLowest = $this->preferLowest;
  20601. }
  20602. $preferredVersions = null;
  20603. if ($forUpdate && $this->minimalUpdate && $this->updateAllowList !== null && $lockedRepo !== null) {
  20604. $preferredVersions = [];
  20605. foreach ($lockedRepo->getPackages() as $pkg) {
  20606. if ($pkg instanceof AliasPackage || in_array($pkg->getName(), $this->updateAllowList, true)) {
  20607. continue;
  20608. }
  20609. $preferredVersions[$pkg->getName()] = $pkg->getVersion();
  20610. }
  20611. }
  20612. return new DefaultPolicy($preferStable, $preferLowest, $preferredVersions);
  20613. }
  20614. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, ?LockArrayRepository $lockedRepository = null): Request
  20615. {
  20616. $request = new Request($lockedRepository);
  20617. $request->fixPackage($rootPackage);
  20618. if ($rootPackage instanceof RootAliasPackage) {
  20619. $request->fixPackage($rootPackage->getAliasOf());
  20620. }
  20621. $fixedPackages = $platformRepo->getPackages();
  20622. if ($this->additionalFixedRepository) {
  20623. $fixedPackages = array_merge($fixedPackages, $this->additionalFixedRepository->getPackages());
  20624. }
  20625. $provided = $rootPackage->getProvides();
  20626. foreach ($fixedPackages as $package) {
  20627. if ($package->getRepository() !== $platformRepo
  20628. || !isset($provided[$package->getName()])
  20629. || !$provided[$package->getName()]->getConstraint()->matches(new Constraint('=', $package->getVersion()))
  20630. ) {
  20631. $request->fixPackage($package);
  20632. }
  20633. }
  20634. return $request;
  20635. }
  20636. private function requirePackagesForUpdate(Request $request, ?LockArrayRepository $lockedRepository = null, bool $includeDevRequires = true): void
  20637. {
  20638. if ($this->updateMirrors) {
  20639. $excludedPackages = [];
  20640. if (!$includeDevRequires) {
  20641. $excludedPackages = array_flip($this->locker->getDevPackageNames());
  20642. }
  20643. foreach ($lockedRepository->getPackages() as $lockedPackage) {
  20644. if (!$lockedPackage instanceof AliasPackage && !isset($excludedPackages[$lockedPackage->getName()])) {
  20645. $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
  20646. }
  20647. }
  20648. } else {
  20649. $links = $this->package->getRequires();
  20650. if ($includeDevRequires) {
  20651. $links = array_merge($links, $this->package->getDevRequires());
  20652. }
  20653. foreach ($links as $link) {
  20654. $request->requireName($link->getTarget(), $link->getConstraint());
  20655. }
  20656. }
  20657. }
  20658. private function getRootAliases(bool $forUpdate): array
  20659. {
  20660. if ($forUpdate) {
  20661. $aliases = $this->package->getAliases();
  20662. } else {
  20663. $aliases = $this->locker->getAliases();
  20664. }
  20665. return $aliases;
  20666. }
  20667. private function extractPlatformRequirements(array $links): array
  20668. {
  20669. $platformReqs = [];
  20670. foreach ($links as $link) {
  20671. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  20672. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  20673. }
  20674. }
  20675. return $platformReqs;
  20676. }
  20677. private function mockLocalRepositories(RepositoryManager $rm): void
  20678. {
  20679. $packages = [];
  20680. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  20681. $packages[(string) $package] = clone $package;
  20682. }
  20683. foreach ($packages as $key => $package) {
  20684. if ($package instanceof AliasPackage) {
  20685. $alias = (string) $package->getAliasOf();
  20686. $className = get_class($package);
  20687. $packages[$key] = new $className($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  20688. }
  20689. }
  20690. $rm->setLocalRepository(
  20691. new InstalledArrayRepository($packages)
  20692. );
  20693. }
  20694. private function createPoolOptimizer(PolicyInterface $policy): ?PoolOptimizer
  20695. {
  20696. if ('0' === Platform::getEnv('COMPOSER_POOL_OPTIMIZER')) {
  20697. $this->io->write('Pool Optimizer was disabled for debugging purposes.', true, IOInterface::DEBUG);
  20698. return null;
  20699. }
  20700. return new PoolOptimizer($policy);
  20701. }
  20702. public static function create(IOInterface $io, Composer $composer): self
  20703. {
  20704. return new static(
  20705. $io,
  20706. $composer->getConfig(),
  20707. $composer->getPackage(),
  20708. $composer->getDownloadManager(),
  20709. $composer->getRepositoryManager(),
  20710. $composer->getLocker(),
  20711. $composer->getInstallationManager(),
  20712. $composer->getEventDispatcher(),
  20713. $composer->getAutoloadGenerator()
  20714. );
  20715. }
  20716. public function setIgnoredTypes(array $types): self
  20717. {
  20718. $this->ignoredTypes = $types;
  20719. return $this;
  20720. }
  20721. public function setAllowedTypes(?array $types): self
  20722. {
  20723. $this->allowedTypes = $types;
  20724. return $this;
  20725. }
  20726. public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository): self
  20727. {
  20728. $this->additionalFixedRepository = $additionalFixedRepository;
  20729. return $this;
  20730. }
  20731. public function setTemporaryConstraints(array $constraints): self
  20732. {
  20733. $this->temporaryConstraints = $constraints;
  20734. return $this;
  20735. }
  20736. public function setDryRun(bool $dryRun = true): self
  20737. {
  20738. $this->dryRun = $dryRun;
  20739. return $this;
  20740. }
  20741. public function isDryRun(): bool
  20742. {
  20743. return $this->dryRun;
  20744. }
  20745. public function setDownloadOnly(bool $downloadOnly = true): self
  20746. {
  20747. $this->downloadOnly = $downloadOnly;
  20748. return $this;
  20749. }
  20750. public function setPreferSource(bool $preferSource = true): self
  20751. {
  20752. $this->preferSource = $preferSource;
  20753. return $this;
  20754. }
  20755. public function setPreferDist(bool $preferDist = true): self
  20756. {
  20757. $this->preferDist = $preferDist;
  20758. return $this;
  20759. }
  20760. public function setOptimizeAutoloader(bool $optimizeAutoloader): self
  20761. {
  20762. $this->optimizeAutoloader = $optimizeAutoloader;
  20763. if (!$this->optimizeAutoloader) {
  20764. $this->setClassMapAuthoritative(false);
  20765. }
  20766. return $this;
  20767. }
  20768. public function setClassMapAuthoritative(bool $classMapAuthoritative): self
  20769. {
  20770. $this->classMapAuthoritative = $classMapAuthoritative;
  20771. if ($this->classMapAuthoritative) {
  20772. $this->setOptimizeAutoloader(true);
  20773. }
  20774. return $this;
  20775. }
  20776. public function setApcuAutoloader(bool $apcuAutoloader, ?string $apcuAutoloaderPrefix = null): self
  20777. {
  20778. $this->apcuAutoloader = $apcuAutoloader;
  20779. $this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
  20780. return $this;
  20781. }
  20782. public function setUpdate(bool $update): self
  20783. {
  20784. $this->update = $update;
  20785. return $this;
  20786. }
  20787. public function setInstall(bool $install): self
  20788. {
  20789. $this->install = $install;
  20790. return $this;
  20791. }
  20792. public function setDevMode(bool $devMode = true): self
  20793. {
  20794. $this->devMode = $devMode;
  20795. return $this;
  20796. }
  20797. public function setDumpAutoloader(bool $dumpAutoloader = true): self
  20798. {
  20799. $this->dumpAutoloader = $dumpAutoloader;
  20800. return $this;
  20801. }
  20802. public function setRunScripts(bool $runScripts = true): self
  20803. {
  20804. $this->runScripts = $runScripts;
  20805. return $this;
  20806. }
  20807. public function setConfig(Config $config): self
  20808. {
  20809. $this->config = $config;
  20810. return $this;
  20811. }
  20812. public function setVerbose(bool $verbose = true): self
  20813. {
  20814. $this->verbose = $verbose;
  20815. return $this;
  20816. }
  20817. public function isVerbose(): bool
  20818. {
  20819. return $this->verbose;
  20820. }
  20821. public function setIgnorePlatformRequirements($ignorePlatformReqs): self
  20822. {
  20823. trigger_error('Installer::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead.', E_USER_DEPRECATED);
  20824. return $this->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  20825. }
  20826. public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter): self
  20827. {
  20828. $this->platformRequirementFilter = $platformRequirementFilter;
  20829. return $this;
  20830. }
  20831. public function setUpdateMirrors(bool $updateMirrors): self
  20832. {
  20833. $this->updateMirrors = $updateMirrors;
  20834. return $this;
  20835. }
  20836. public function setUpdateAllowList(array $packages): self
  20837. {
  20838. if (count($packages) === 0) {
  20839. $this->updateAllowList = null;
  20840. } else {
  20841. $this->updateAllowList = array_values(array_unique(array_map('strtolower', $packages)));
  20842. }
  20843. return $this;
  20844. }
  20845. public function setUpdateAllowTransitiveDependencies(int $updateAllowTransitiveDependencies): self
  20846. {
  20847. if (!in_array($updateAllowTransitiveDependencies, [Request::UPDATE_ONLY_LISTED, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE, Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS], true)) {
  20848. throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
  20849. }
  20850. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  20851. return $this;
  20852. }
  20853. public function setPreferStable(bool $preferStable = true): self
  20854. {
  20855. $this->preferStable = $preferStable;
  20856. return $this;
  20857. }
  20858. public function setPreferLowest(bool $preferLowest = true): self
  20859. {
  20860. $this->preferLowest = $preferLowest;
  20861. return $this;
  20862. }
  20863. public function setMinimalUpdate(bool $minimalUpdate = true): self
  20864. {
  20865. $this->minimalUpdate = $minimalUpdate;
  20866. return $this;
  20867. }
  20868. public function setWriteLock(bool $writeLock = true): self
  20869. {
  20870. $this->writeLock = $writeLock;
  20871. return $this;
  20872. }
  20873. public function setExecuteOperations(bool $executeOperations = true): self
  20874. {
  20875. $this->executeOperations = $executeOperations;
  20876. return $this;
  20877. }
  20878. public function setAudit(bool $audit): self
  20879. {
  20880. $this->audit = $audit;
  20881. return $this;
  20882. }
  20883. public function setErrorOnAudit(bool $errorOnAudit): self
  20884. {
  20885. $this->errorOnAudit = $errorOnAudit;
  20886. return $this;
  20887. }
  20888. public function setAuditFormat(string $auditFormat): self
  20889. {
  20890. $this->auditFormat = $auditFormat;
  20891. return $this;
  20892. }
  20893. public function disablePlugins(): self
  20894. {
  20895. $this->installationManager->disablePlugins();
  20896. return $this;
  20897. }
  20898. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter): self
  20899. {
  20900. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  20901. return $this;
  20902. }
  20903. }
  20904. <?php declare(strict_types=1);
  20905. namespace Composer\Installer;
  20906. use Composer\IO\IOInterface;
  20907. use Composer\Package\PackageInterface;
  20908. use Composer\Pcre\Preg;
  20909. use Composer\Util\Filesystem;
  20910. use Composer\Util\Platform;
  20911. use Composer\Util\ProcessExecutor;
  20912. use Composer\Util\Silencer;
  20913. class BinaryInstaller
  20914. {
  20915. protected $binDir;
  20916. protected $binCompat;
  20917. protected $io;
  20918. protected $filesystem;
  20919. private $vendorDir;
  20920. public function __construct(IOInterface $io, string $binDir, string $binCompat, ?Filesystem $filesystem = null, ?string $vendorDir = null)
  20921. {
  20922. $this->binDir = $binDir;
  20923. $this->binCompat = $binCompat;
  20924. $this->io = $io;
  20925. $this->filesystem = $filesystem ?: new Filesystem();
  20926. $this->vendorDir = $vendorDir;
  20927. }
  20928. public function installBinaries(PackageInterface $package, string $installPath, bool $warnOnOverwrite = true): void
  20929. {
  20930. $binaries = $this->getBinaries($package);
  20931. if (!$binaries) {
  20932. return;
  20933. }
  20934. Platform::workaroundFilesystemIssues();
  20935. foreach ($binaries as $bin) {
  20936. $binPath = $installPath.'/'.$bin;
  20937. if (!file_exists($binPath)) {
  20938. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  20939. continue;
  20940. }
  20941. if (is_dir($binPath)) {
  20942. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': found a directory at that path</warning>');
  20943. continue;
  20944. }
  20945. if (!$this->filesystem->isAbsolutePath($binPath)) {
  20946. $binPath = realpath($binPath);
  20947. }
  20948. $this->initializeBinDir();
  20949. $link = $this->binDir.'/'.basename($bin);
  20950. if (file_exists($link)) {
  20951. if (!is_link($link)) {
  20952. if ($warnOnOverwrite) {
  20953. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  20954. }
  20955. continue;
  20956. }
  20957. if (realpath($link) === realpath($binPath)) {
  20958. $this->filesystem->unlink($link);
  20959. }
  20960. }
  20961. $binCompat = $this->binCompat;
  20962. if ($binCompat === "auto" && (Platform::isWindows() || Platform::isWindowsSubsystemForLinux())) {
  20963. $binCompat = 'full';
  20964. }
  20965. if ($binCompat === "full") {
  20966. $this->installFullBinaries($binPath, $link, $bin, $package);
  20967. } else {
  20968. $this->installUnixyProxyBinaries($binPath, $link);
  20969. }
  20970. Silencer::call('chmod', $binPath, 0777 & ~umask());
  20971. }
  20972. }
  20973. public function removeBinaries(PackageInterface $package): void
  20974. {
  20975. $this->initializeBinDir();
  20976. $binaries = $this->getBinaries($package);
  20977. if (!$binaries) {
  20978. return;
  20979. }
  20980. foreach ($binaries as $bin) {
  20981. $link = $this->binDir.'/'.basename($bin);
  20982. if (is_link($link) || file_exists($link)) {
  20983. $this->filesystem->unlink($link);
  20984. }
  20985. if (is_file($link.'.bat')) {
  20986. $this->filesystem->unlink($link.'.bat');
  20987. }
  20988. }
  20989. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  20990. Silencer::call('rmdir', $this->binDir);
  20991. }
  20992. }
  20993. public static function determineBinaryCaller(string $bin): string
  20994. {
  20995. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  20996. return 'call';
  20997. }
  20998. $handle = fopen($bin, 'r');
  20999. $line = fgets($handle);
  21000. fclose($handle);
  21001. if (Preg::isMatchStrictGroups('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', (string) $line, $match)) {
  21002. return trim($match[1]);
  21003. }
  21004. return 'php';
  21005. }
  21006. protected function getBinaries(PackageInterface $package): array
  21007. {
  21008. return $package->getBinaries();
  21009. }
  21010. protected function installFullBinaries(string $binPath, string $link, string $bin, PackageInterface $package): void
  21011. {
  21012. if ('.bat' !== substr($binPath, -4)) {
  21013. $this->installUnixyProxyBinaries($binPath, $link);
  21014. $link .= '.bat';
  21015. if (file_exists($link)) {
  21016. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  21017. }
  21018. }
  21019. if (!file_exists($link)) {
  21020. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  21021. Silencer::call('chmod', $link, 0777 & ~umask());
  21022. }
  21023. }
  21024. protected function installUnixyProxyBinaries(string $binPath, string $link): void
  21025. {
  21026. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  21027. Silencer::call('chmod', $link, 0777 & ~umask());
  21028. }
  21029. protected function initializeBinDir(): void
  21030. {
  21031. $this->filesystem->ensureDirectoryExists($this->binDir);
  21032. $this->binDir = realpath($this->binDir);
  21033. }
  21034. protected function generateWindowsProxyCode(string $bin, string $link): string
  21035. {
  21036. $binPath = $this->filesystem->findShortestPath($link, $bin);
  21037. $caller = self::determineBinaryCaller($bin);
  21038. if ($caller === 'php') {
  21039. return "@ECHO OFF\r\n".
  21040. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  21041. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape(basename($link, '.bat')), '"\'')."\r\n".
  21042. "SET COMPOSER_RUNTIME_BIN_DIR=%~dp0\r\n".
  21043. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  21044. }
  21045. return "@ECHO OFF\r\n".
  21046. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  21047. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  21048. "SET COMPOSER_RUNTIME_BIN_DIR=%~dp0\r\n".
  21049. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  21050. }
  21051. protected function generateUnixyProxyCode(string $bin, string $link): string
  21052. {
  21053. $binPath = $this->filesystem->findShortestPath($link, $bin);
  21054. $binDir = ProcessExecutor::escape(dirname($binPath));
  21055. $binFile = basename($binPath);
  21056. $binContents = (string) file_get_contents($bin, false, null, 0, 500);
  21057. if (Preg::isMatch('{^(#!.*\r?\n)?[\r\n\t ]*<\?php}', $binContents, $match)) {
  21058. $proxyCode = $match[1] === null ? '#!/usr/bin/env php' : trim($match[1]);
  21059. $binPathExported = $this->filesystem->findShortestPathCode($link, $bin, false, true);
  21060. $streamProxyCode = $streamHint = '';
  21061. $globalsCode = '$GLOBALS[\'_composer_bin_dir\'] = __DIR__;'."\n";
  21062. $phpunitHack1 = $phpunitHack2 = '';
  21063. if ($this->vendorDir !== null) {
  21064. $vendorDirReal = realpath($this->vendorDir);
  21065. if ($vendorDirReal === false) {
  21066. $vendorDirReal = $this->vendorDir;
  21067. }
  21068. $globalsCode .= '$GLOBALS[\'_composer_autoload_path\'] = ' . $this->filesystem->findShortestPathCode($link, $vendorDirReal . '/autoload.php', false, true).";\n";
  21069. }
  21070. if ($this->filesystem->normalizePath($bin) === $this->filesystem->normalizePath($this->vendorDir.'/phpunit/phpunit/phpunit')) {
  21071. $globalsCode .= '$GLOBALS[\'__PHPUNIT_ISOLATION_EXCLUDE_LIST\'] = $GLOBALS[\'__PHPUNIT_ISOLATION_BLACKLIST\'] = array(realpath('.$binPathExported.'));'."\n";
  21072. $phpunitHack1 = "'phpvfscomposer://'.";
  21073. $phpunitHack2 = '
  21074. $data = str_replace(\'__DIR__\', var_export(dirname($this->realpath), true), $data);
  21075. $data = str_replace(\'__FILE__\', var_export($this->realpath, true), $data);';
  21076. }
  21077. if (trim($match[0]) !== '<?php') {
  21078. $streamHint = ' using a stream wrapper to prevent the shebang from being output on PHP<8'."\n *";
  21079. $streamProxyCode = <<<STREAMPROXY
  21080. if (PHP_VERSION_ID < 80000) {
  21081. if (!class_exists('Composer\BinProxyWrapper')) {
  21082. /**
  21083. * @internal
  21084. */
  21085. final class BinProxyWrapper
  21086. {
  21087. private \$handle;
  21088. private \$position;
  21089. private \$realpath;
  21090. public function stream_open(\$path, \$mode, \$options, &\$opened_path)
  21091. {
  21092. // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
  21093. \$opened_path = substr(\$path, 17);
  21094. \$this->realpath = realpath(\$opened_path) ?: \$opened_path;
  21095. \$opened_path = $phpunitHack1\$this->realpath;
  21096. \$this->handle = fopen(\$this->realpath, \$mode);
  21097. \$this->position = 0;
  21098. return (bool) \$this->handle;
  21099. }
  21100. public function stream_read(\$count)
  21101. {
  21102. \$data = fread(\$this->handle, \$count);
  21103. if (\$this->position === 0) {
  21104. \$data = preg_replace('{^#!.*\\r?\\n}', '', \$data);
  21105. }$phpunitHack2
  21106. \$this->position += strlen(\$data);
  21107. return \$data;
  21108. }
  21109. public function stream_cast(\$castAs)
  21110. {
  21111. return \$this->handle;
  21112. }
  21113. public function stream_close()
  21114. {
  21115. fclose(\$this->handle);
  21116. }
  21117. public function stream_lock(\$operation)
  21118. {
  21119. return \$operation ? flock(\$this->handle, \$operation) : true;
  21120. }
  21121. public function stream_seek(\$offset, \$whence)
  21122. {
  21123. if (0 === fseek(\$this->handle, \$offset, \$whence)) {
  21124. \$this->position = ftell(\$this->handle);
  21125. return true;
  21126. }
  21127. return false;
  21128. }
  21129. public function stream_tell()
  21130. {
  21131. return \$this->position;
  21132. }
  21133. public function stream_eof()
  21134. {
  21135. return feof(\$this->handle);
  21136. }
  21137. public function stream_stat()
  21138. {
  21139. return array();
  21140. }
  21141. public function stream_set_option(\$option, \$arg1, \$arg2)
  21142. {
  21143. return true;
  21144. }
  21145. public function url_stat(\$path, \$flags)
  21146. {
  21147. \$path = substr(\$path, 17);
  21148. if (file_exists(\$path)) {
  21149. return stat(\$path);
  21150. }
  21151. return false;
  21152. }
  21153. }
  21154. }
  21155. if (
  21156. (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
  21157. || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
  21158. ) {
  21159. return include("phpvfscomposer://" . $binPathExported);
  21160. }
  21161. }
  21162. STREAMPROXY;
  21163. }
  21164. return $proxyCode . "\n" . <<<PROXY
  21165. <?php
  21166. /**
  21167. * Proxy PHP file generated by Composer
  21168. *
  21169. * This file includes the referenced bin path ($binPath)
  21170. *$streamHint
  21171. * @generated
  21172. */
  21173. namespace Composer;
  21174. $globalsCode
  21175. $streamProxyCode
  21176. return include $binPathExported;
  21177. PROXY;
  21178. }
  21179. return <<<PROXY
  21180. #!/usr/bin/env sh
  21181. # Support bash to support `source` with fallback on $0 if this does not run with bash
  21182. # https://stackoverflow.com/a/35006505/6512
  21183. selfArg="\$BASH_SOURCE"
  21184. if [ -z "\$selfArg" ]; then
  21185. selfArg="\$0"
  21186. fi
  21187. self=\$(realpath \$selfArg 2> /dev/null)
  21188. if [ -z "\$self" ]; then
  21189. self="\$selfArg"
  21190. fi
  21191. dir=\$(cd "\${self%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  21192. if [ -d /proc/cygdrive ]; then
  21193. case \$(which php) in
  21194. \$(readlink -n /proc/cygdrive)/*)
  21195. # We are in Cygwin using Windows php, so the path must be translated
  21196. dir=\$(cygpath -m "\$dir");
  21197. ;;
  21198. esac
  21199. fi
  21200. export COMPOSER_RUNTIME_BIN_DIR="\$(cd "\${self%[/\\\\]*}" > /dev/null; pwd)"
  21201. # If bash is sourcing this file, we have to source the target as well
  21202. bashSource="\$BASH_SOURCE"
  21203. if [ -n "\$bashSource" ]; then
  21204. if [ "\$bashSource" != "\$0" ]; then
  21205. source "\${dir}/$binFile" "\$@"
  21206. return
  21207. fi
  21208. fi
  21209. exec "\${dir}/$binFile" "\$@"
  21210. PROXY;
  21211. }
  21212. }
  21213. <?php declare(strict_types=1);
  21214. namespace Composer\Installer;
  21215. use Composer\Package\PackageInterface;
  21216. interface BinaryPresenceInterface
  21217. {
  21218. public function ensureBinariesPresence(PackageInterface $package);
  21219. }
  21220. <?php declare(strict_types=1);
  21221. namespace Composer\Installer;
  21222. use Composer\IO\IOInterface;
  21223. use Composer\IO\ConsoleIO;
  21224. use Composer\Package\PackageInterface;
  21225. use Composer\Package\AliasPackage;
  21226. use Composer\Repository\InstalledRepositoryInterface;
  21227. use Composer\DependencyResolver\Operation\OperationInterface;
  21228. use Composer\DependencyResolver\Operation\InstallOperation;
  21229. use Composer\DependencyResolver\Operation\UpdateOperation;
  21230. use Composer\DependencyResolver\Operation\UninstallOperation;
  21231. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  21232. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  21233. use Composer\Downloader\FileDownloader;
  21234. use Composer\EventDispatcher\EventDispatcher;
  21235. use Composer\Util\Loop;
  21236. use Composer\Util\Platform;
  21237. use React\Promise\PromiseInterface;
  21238. use Seld\Signal\SignalHandler;
  21239. class InstallationManager
  21240. {
  21241. private $installers = [];
  21242. private $cache = [];
  21243. private $notifiablePackages = [];
  21244. private $loop;
  21245. private $io;
  21246. private $eventDispatcher;
  21247. private $outputProgress;
  21248. public function __construct(Loop $loop, IOInterface $io, ?EventDispatcher $eventDispatcher = null)
  21249. {
  21250. $this->loop = $loop;
  21251. $this->io = $io;
  21252. $this->eventDispatcher = $eventDispatcher;
  21253. }
  21254. public function reset(): void
  21255. {
  21256. $this->notifiablePackages = [];
  21257. FileDownloader::$downloadMetadata = [];
  21258. }
  21259. public function addInstaller(InstallerInterface $installer): void
  21260. {
  21261. array_unshift($this->installers, $installer);
  21262. $this->cache = [];
  21263. }
  21264. public function removeInstaller(InstallerInterface $installer): void
  21265. {
  21266. if (false !== ($key = array_search($installer, $this->installers, true))) {
  21267. array_splice($this->installers, $key, 1);
  21268. $this->cache = [];
  21269. }
  21270. }
  21271. public function disablePlugins(): void
  21272. {
  21273. foreach ($this->installers as $i => $installer) {
  21274. if (!$installer instanceof PluginInstaller) {
  21275. continue;
  21276. }
  21277. $installer->disablePlugins();
  21278. }
  21279. }
  21280. public function getInstaller(string $type): InstallerInterface
  21281. {
  21282. $type = strtolower($type);
  21283. if (isset($this->cache[$type])) {
  21284. return $this->cache[$type];
  21285. }
  21286. foreach ($this->installers as $installer) {
  21287. if ($installer->supports($type)) {
  21288. return $this->cache[$type] = $installer;
  21289. }
  21290. }
  21291. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  21292. }
  21293. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package): bool
  21294. {
  21295. if ($package instanceof AliasPackage) {
  21296. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  21297. }
  21298. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  21299. }
  21300. public function ensureBinariesPresence(PackageInterface $package): void
  21301. {
  21302. try {
  21303. $installer = $this->getInstaller($package->getType());
  21304. } catch (\InvalidArgumentException $e) {
  21305. return;
  21306. }
  21307. if ($installer instanceof BinaryPresenceInterface) {
  21308. $installer->ensureBinariesPresence($package);
  21309. }
  21310. }
  21311. public function execute(InstalledRepositoryInterface $repo, array $operations, bool $devMode = true, bool $runScripts = true, bool $downloadOnly = false): void
  21312. {
  21313. $cleanupPromises = [];
  21314. $signalHandler = SignalHandler::create([SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP], function (string $signal, SignalHandler $handler) use (&$cleanupPromises) {
  21315. $this->io->writeError('Received '.$signal.', aborting', true, IOInterface::DEBUG);
  21316. $this->runCleanup($cleanupPromises);
  21317. $handler->exitWithLastSignal();
  21318. });
  21319. try {
  21320. $batches = [];
  21321. $batch = [];
  21322. foreach ($operations as $index => $operation) {
  21323. if ($operation instanceof UpdateOperation || $operation instanceof InstallOperation) {
  21324. $package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
  21325. if ($package->getType() === 'composer-plugin') {
  21326. $extra = $package->getExtra();
  21327. if (isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true) {
  21328. if (count($batch) > 0) {
  21329. $batches[] = $batch;
  21330. }
  21331. $batches[] = [$index => $operation];
  21332. $batch = [];
  21333. continue;
  21334. }
  21335. }
  21336. }
  21337. $batch[$index] = $operation;
  21338. }
  21339. if (count($batch) > 0) {
  21340. $batches[] = $batch;
  21341. }
  21342. foreach ($batches as $batchToExecute) {
  21343. $this->downloadAndExecuteBatch($repo, $batchToExecute, $cleanupPromises, $devMode, $runScripts, $downloadOnly, $operations);
  21344. }
  21345. } catch (\Exception $e) {
  21346. $this->runCleanup($cleanupPromises);
  21347. throw $e;
  21348. } finally {
  21349. $signalHandler->unregister();
  21350. }
  21351. if ($downloadOnly) {
  21352. return;
  21353. }
  21354. $repo->write($devMode, $this);
  21355. }
  21356. private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, bool $devMode, bool $runScripts, bool $downloadOnly, array $allOperations): void
  21357. {
  21358. $promises = [];
  21359. foreach ($operations as $index => $operation) {
  21360. $opType = $operation->getOperationType();
  21361. if (!in_array($opType, ['update', 'install', 'uninstall'], true)) {
  21362. continue;
  21363. }
  21364. if ($opType === 'update') {
  21365. $package = $operation->getTargetPackage();
  21366. $initialPackage = $operation->getInitialPackage();
  21367. } else {
  21368. $package = $operation->getPackage();
  21369. $initialPackage = null;
  21370. }
  21371. $installer = $this->getInstaller($package->getType());
  21372. $cleanupPromises[$index] = static function () use ($opType, $installer, $package, $initialPackage): ?PromiseInterface {
  21373. if (null === $package->getInstallationSource()) {
  21374. return \React\Promise\resolve(null);
  21375. }
  21376. return $installer->cleanup($opType, $package, $initialPackage);
  21377. };
  21378. if ($opType !== 'uninstall') {
  21379. $promise = $installer->download($package, $initialPackage);
  21380. if (null !== $promise) {
  21381. $promises[] = $promise;
  21382. }
  21383. }
  21384. }
  21385. if (count($promises) > 0) {
  21386. $this->waitOnPromises($promises);
  21387. }
  21388. if ($downloadOnly) {
  21389. $this->runCleanup($cleanupPromises);
  21390. return;
  21391. }
  21392. $batches = [];
  21393. $batch = [];
  21394. foreach ($operations as $index => $operation) {
  21395. if ($operation instanceof InstallOperation || $operation instanceof UpdateOperation) {
  21396. $package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
  21397. if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
  21398. if (count($batch) > 0) {
  21399. $batches[] = $batch;
  21400. }
  21401. $batches[] = [$index => $operation];
  21402. $batch = [];
  21403. continue;
  21404. }
  21405. }
  21406. $batch[$index] = $operation;
  21407. }
  21408. if (count($batch) > 0) {
  21409. $batches[] = $batch;
  21410. }
  21411. foreach ($batches as $batchToExecute) {
  21412. $this->executeBatch($repo, $batchToExecute, $cleanupPromises, $devMode, $runScripts, $allOperations);
  21413. }
  21414. }
  21415. private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, bool $devMode, bool $runScripts, array $allOperations): void
  21416. {
  21417. $promises = [];
  21418. $postExecCallbacks = [];
  21419. foreach ($operations as $index => $operation) {
  21420. $opType = $operation->getOperationType();
  21421. if (!in_array($opType, ['update', 'install', 'uninstall'], true)) {
  21422. if ($this->io->isDebug()) {
  21423. $this->io->writeError(' - ' . $operation->show(false));
  21424. }
  21425. $this->{$opType}($repo, $operation);
  21426. continue;
  21427. }
  21428. if ($opType === 'update') {
  21429. $package = $operation->getTargetPackage();
  21430. $initialPackage = $operation->getInitialPackage();
  21431. } else {
  21432. $package = $operation->getPackage();
  21433. $initialPackage = null;
  21434. }
  21435. $installer = $this->getInstaller($package->getType());
  21436. $eventName = [
  21437. 'install' => PackageEvents::PRE_PACKAGE_INSTALL,
  21438. 'update' => PackageEvents::PRE_PACKAGE_UPDATE,
  21439. 'uninstall' => PackageEvents::PRE_PACKAGE_UNINSTALL,
  21440. ][$opType];
  21441. if ($runScripts && $this->eventDispatcher !== null) {
  21442. $this->eventDispatcher->dispatchPackageEvent($eventName, $devMode, $repo, $allOperations, $operation);
  21443. }
  21444. $dispatcher = $this->eventDispatcher;
  21445. $io = $this->io;
  21446. $promise = $installer->prepare($opType, $package, $initialPackage);
  21447. if (!$promise instanceof PromiseInterface) {
  21448. $promise = \React\Promise\resolve(null);
  21449. }
  21450. $promise = $promise->then(function () use ($opType, $repo, $operation) {
  21451. return $this->{$opType}($repo, $operation);
  21452. })->then($cleanupPromises[$index])
  21453. ->then(function () use ($devMode, $repo): void {
  21454. $repo->write($devMode, $this);
  21455. }, static function ($e) use ($opType, $package, $io): void {
  21456. $io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
  21457. throw $e;
  21458. });
  21459. $eventName = [
  21460. 'install' => PackageEvents::POST_PACKAGE_INSTALL,
  21461. 'update' => PackageEvents::POST_PACKAGE_UPDATE,
  21462. 'uninstall' => PackageEvents::POST_PACKAGE_UNINSTALL,
  21463. ][$opType];
  21464. if ($runScripts && $dispatcher !== null) {
  21465. $postExecCallbacks[] = static function () use ($dispatcher, $eventName, $devMode, $repo, $allOperations, $operation): void {
  21466. $dispatcher->dispatchPackageEvent($eventName, $devMode, $repo, $allOperations, $operation);
  21467. };
  21468. }
  21469. $promises[] = $promise;
  21470. }
  21471. if (count($promises) > 0) {
  21472. $this->waitOnPromises($promises);
  21473. }
  21474. Platform::workaroundFilesystemIssues();
  21475. foreach ($postExecCallbacks as $cb) {
  21476. $cb();
  21477. }
  21478. }
  21479. private function waitOnPromises(array $promises): void
  21480. {
  21481. $progress = null;
  21482. if (
  21483. $this->outputProgress
  21484. && $this->io instanceof ConsoleIO
  21485. && !((bool) Platform::getEnv('CI'))
  21486. && !$this->io->isDebug()
  21487. && count($promises) > 1
  21488. ) {
  21489. $progress = $this->io->getProgressBar();
  21490. }
  21491. $this->loop->wait($promises, $progress);
  21492. if ($progress !== null) {
  21493. $progress->clear();
  21494. if (!$this->io->isDecorated()) {
  21495. $this->io->writeError('');
  21496. }
  21497. }
  21498. }
  21499. public function download(PackageInterface $package): ?PromiseInterface
  21500. {
  21501. $installer = $this->getInstaller($package->getType());
  21502. $promise = $installer->cleanup("install", $package);
  21503. return $promise;
  21504. }
  21505. public function install(InstalledRepositoryInterface $repo, InstallOperation $operation): ?PromiseInterface
  21506. {
  21507. $package = $operation->getPackage();
  21508. $installer = $this->getInstaller($package->getType());
  21509. $promise = $installer->install($repo, $package);
  21510. $this->markForNotification($package);
  21511. return $promise;
  21512. }
  21513. public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation): ?PromiseInterface
  21514. {
  21515. $initial = $operation->getInitialPackage();
  21516. $target = $operation->getTargetPackage();
  21517. $initialType = $initial->getType();
  21518. $targetType = $target->getType();
  21519. if ($initialType === $targetType) {
  21520. $installer = $this->getInstaller($initialType);
  21521. $promise = $installer->update($repo, $initial, $target);
  21522. $this->markForNotification($target);
  21523. } else {
  21524. $promise = $this->getInstaller($initialType)->uninstall($repo, $initial);
  21525. if (!$promise instanceof PromiseInterface) {
  21526. $promise = \React\Promise\resolve(null);
  21527. }
  21528. $installer = $this->getInstaller($targetType);
  21529. $promise = $promise->then(static function () use ($installer, $repo, $target): PromiseInterface {
  21530. $promise = $installer->install($repo, $target);
  21531. if ($promise instanceof PromiseInterface) {
  21532. return $promise;
  21533. }
  21534. return \React\Promise\resolve(null);
  21535. });
  21536. }
  21537. return $promise;
  21538. }
  21539. public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation): ?PromiseInterface
  21540. {
  21541. $package = $operation->getPackage();
  21542. $installer = $this->getInstaller($package->getType());
  21543. return $installer->uninstall($repo, $package);
  21544. }
  21545. public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation): void
  21546. {
  21547. $package = $operation->getPackage();
  21548. if (!$repo->hasPackage($package)) {
  21549. $repo->addPackage(clone $package);
  21550. }
  21551. }
  21552. public function markAliasUninstalled(InstalledRepositoryInterface $repo, MarkAliasUninstalledOperation $operation): void
  21553. {
  21554. $package = $operation->getPackage();
  21555. $repo->removePackage($package);
  21556. }
  21557. public function getInstallPath(PackageInterface $package): ?string
  21558. {
  21559. $installer = $this->getInstaller($package->getType());
  21560. return $installer->getInstallPath($package);
  21561. }
  21562. public function setOutputProgress(bool $outputProgress): void
  21563. {
  21564. $this->outputProgress = $outputProgress;
  21565. }
  21566. public function notifyInstalls(IOInterface $io): void
  21567. {
  21568. $promises = [];
  21569. try {
  21570. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  21571. if (str_contains($repoUrl, '%package%')) {
  21572. foreach ($packages as $package) {
  21573. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  21574. $params = [
  21575. 'version' => $package->getPrettyVersion(),
  21576. 'version_normalized' => $package->getVersion(),
  21577. ];
  21578. $opts = [
  21579. 'retry-auth-failure' => false,
  21580. 'http' => [
  21581. 'method' => 'POST',
  21582. 'header' => ['Content-type: application/x-www-form-urlencoded'],
  21583. 'content' => http_build_query($params, '', '&'),
  21584. 'timeout' => 3,
  21585. ],
  21586. ];
  21587. $promises[] = $this->loop->getHttpDownloader()->add($url, $opts);
  21588. }
  21589. continue;
  21590. }
  21591. $postData = ['downloads' => []];
  21592. foreach ($packages as $package) {
  21593. $packageNotification = [
  21594. 'name' => $package->getPrettyName(),
  21595. 'version' => $package->getVersion(),
  21596. ];
  21597. if (strpos($repoUrl, 'packagist.org/') !== false) {
  21598. if (isset(FileDownloader::$downloadMetadata[$package->getName()])) {
  21599. $packageNotification['downloaded'] = FileDownloader::$downloadMetadata[$package->getName()];
  21600. } else {
  21601. $packageNotification['downloaded'] = false;
  21602. }
  21603. }
  21604. $postData['downloads'][] = $packageNotification;
  21605. }
  21606. $opts = [
  21607. 'retry-auth-failure' => false,
  21608. 'http' => [
  21609. 'method' => 'POST',
  21610. 'header' => ['Content-Type: application/json'],
  21611. 'content' => json_encode($postData),
  21612. 'timeout' => 6,
  21613. ],
  21614. ];
  21615. $promises[] = $this->loop->getHttpDownloader()->add($repoUrl, $opts);
  21616. }
  21617. $this->loop->wait($promises);
  21618. } catch (\Exception $e) {
  21619. }
  21620. $this->reset();
  21621. }
  21622. private function markForNotification(PackageInterface $package): void
  21623. {
  21624. if ($package->getNotificationUrl() !== null) {
  21625. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  21626. }
  21627. }
  21628. private function runCleanup(array $cleanupPromises): void
  21629. {
  21630. $promises = [];
  21631. $this->loop->abortJobs();
  21632. foreach ($cleanupPromises as $cleanup) {
  21633. $promises[] = new \React\Promise\Promise(static function ($resolve) use ($cleanup): void {
  21634. $promise = $cleanup();
  21635. if (!$promise instanceof PromiseInterface) {
  21636. $resolve(null);
  21637. } else {
  21638. $promise->then(static function () use ($resolve): void {
  21639. $resolve(null);
  21640. });
  21641. }
  21642. });
  21643. }
  21644. if (count($promises) > 0) {
  21645. $this->loop->wait($promises);
  21646. }
  21647. }
  21648. }
  21649. <?php declare(strict_types=1);
  21650. namespace Composer\Installer;
  21651. use Composer\Composer;
  21652. use Composer\DependencyResolver\Transaction;
  21653. use Composer\EventDispatcher\Event;
  21654. use Composer\IO\IOInterface;
  21655. class InstallerEvent extends Event
  21656. {
  21657. private $composer;
  21658. private $io;
  21659. private $devMode;
  21660. private $executeOperations;
  21661. private $transaction;
  21662. public function __construct(string $eventName, Composer $composer, IOInterface $io, bool $devMode, bool $executeOperations, Transaction $transaction)
  21663. {
  21664. parent::__construct($eventName);
  21665. $this->composer = $composer;
  21666. $this->io = $io;
  21667. $this->devMode = $devMode;
  21668. $this->executeOperations = $executeOperations;
  21669. $this->transaction = $transaction;
  21670. }
  21671. public function getComposer(): Composer
  21672. {
  21673. return $this->composer;
  21674. }
  21675. public function getIO(): IOInterface
  21676. {
  21677. return $this->io;
  21678. }
  21679. public function isDevMode(): bool
  21680. {
  21681. return $this->devMode;
  21682. }
  21683. public function isExecutingOperations(): bool
  21684. {
  21685. return $this->executeOperations;
  21686. }
  21687. public function getTransaction(): ?Transaction
  21688. {
  21689. return $this->transaction;
  21690. }
  21691. }
  21692. <?php declare(strict_types=1);
  21693. namespace Composer\Installer;
  21694. class InstallerEvents
  21695. {
  21696. public const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
  21697. }
  21698. <?php declare(strict_types=1);
  21699. namespace Composer\Installer;
  21700. use Composer\Package\PackageInterface;
  21701. use Composer\Repository\InstalledRepositoryInterface;
  21702. use InvalidArgumentException;
  21703. use React\Promise\PromiseInterface;
  21704. interface InstallerInterface
  21705. {
  21706. public function supports(string $packageType);
  21707. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  21708. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null);
  21709. public function prepare(string $type, PackageInterface $package, ?PackageInterface $prevPackage = null);
  21710. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  21711. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  21712. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  21713. public function cleanup(string $type, PackageInterface $package, ?PackageInterface $prevPackage = null);
  21714. public function getInstallPath(PackageInterface $package);
  21715. }
  21716. <?php declare(strict_types=1);
  21717. namespace Composer\Installer;
  21718. use Composer\Composer;
  21719. use Composer\IO\IOInterface;
  21720. use Composer\PartialComposer;
  21721. use Composer\Pcre\Preg;
  21722. use Composer\Repository\InstalledRepositoryInterface;
  21723. use Composer\Package\PackageInterface;
  21724. use Composer\Util\Filesystem;
  21725. use Composer\Util\Silencer;
  21726. use Composer\Util\Platform;
  21727. use React\Promise\PromiseInterface;
  21728. use Composer\Downloader\DownloadManager;
  21729. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  21730. {
  21731. protected $composer;
  21732. protected $vendorDir;
  21733. protected $downloadManager;
  21734. protected $io;
  21735. protected $type;
  21736. protected $filesystem;
  21737. protected $binaryInstaller;
  21738. public function __construct(IOInterface $io, PartialComposer $composer, ?string $type = 'library', ?Filesystem $filesystem = null, ?BinaryInstaller $binaryInstaller = null)
  21739. {
  21740. $this->composer = $composer;
  21741. $this->downloadManager = $composer instanceof Composer ? $composer->getDownloadManager() : null;
  21742. $this->io = $io;
  21743. $this->type = $type;
  21744. $this->filesystem = $filesystem ?: new Filesystem();
  21745. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  21746. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem, $this->vendorDir);
  21747. }
  21748. public function supports(string $packageType)
  21749. {
  21750. return $packageType === $this->type || null === $this->type;
  21751. }
  21752. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  21753. {
  21754. if (!$repo->hasPackage($package)) {
  21755. return false;
  21756. }
  21757. $installPath = $this->getInstallPath($package);
  21758. if (Filesystem::isReadable($installPath)) {
  21759. return true;
  21760. }
  21761. if (Platform::isWindows() && $this->filesystem->isJunction($installPath)) {
  21762. return true;
  21763. }
  21764. if (is_link($installPath)) {
  21765. if (realpath($installPath) === false) {
  21766. return false;
  21767. }
  21768. return true;
  21769. }
  21770. return false;
  21771. }
  21772. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null)
  21773. {
  21774. $this->initializeVendorDir();
  21775. $downloadPath = $this->getInstallPath($package);
  21776. return $this->getDownloadManager()->download($package, $downloadPath, $prevPackage);
  21777. }
  21778. public function prepare($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  21779. {
  21780. $this->initializeVendorDir();
  21781. $downloadPath = $this->getInstallPath($package);
  21782. return $this->getDownloadManager()->prepare($type, $package, $downloadPath, $prevPackage);
  21783. }
  21784. public function cleanup($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  21785. {
  21786. $this->initializeVendorDir();
  21787. $downloadPath = $this->getInstallPath($package);
  21788. return $this->getDownloadManager()->cleanup($type, $package, $downloadPath, $prevPackage);
  21789. }
  21790. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  21791. {
  21792. $this->initializeVendorDir();
  21793. $downloadPath = $this->getInstallPath($package);
  21794. if (!Filesystem::isReadable($downloadPath) && $repo->hasPackage($package)) {
  21795. $this->binaryInstaller->removeBinaries($package);
  21796. }
  21797. $promise = $this->installCode($package);
  21798. if (!$promise instanceof PromiseInterface) {
  21799. $promise = \React\Promise\resolve(null);
  21800. }
  21801. $binaryInstaller = $this->binaryInstaller;
  21802. $installPath = $this->getInstallPath($package);
  21803. return $promise->then(static function () use ($binaryInstaller, $installPath, $package, $repo): void {
  21804. $binaryInstaller->installBinaries($package, $installPath);
  21805. if (!$repo->hasPackage($package)) {
  21806. $repo->addPackage(clone $package);
  21807. }
  21808. });
  21809. }
  21810. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  21811. {
  21812. if (!$repo->hasPackage($initial)) {
  21813. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  21814. }
  21815. $this->initializeVendorDir();
  21816. $this->binaryInstaller->removeBinaries($initial);
  21817. $promise = $this->updateCode($initial, $target);
  21818. if (!$promise instanceof PromiseInterface) {
  21819. $promise = \React\Promise\resolve(null);
  21820. }
  21821. $binaryInstaller = $this->binaryInstaller;
  21822. $installPath = $this->getInstallPath($target);
  21823. return $promise->then(static function () use ($binaryInstaller, $installPath, $target, $initial, $repo): void {
  21824. $binaryInstaller->installBinaries($target, $installPath);
  21825. $repo->removePackage($initial);
  21826. if (!$repo->hasPackage($target)) {
  21827. $repo->addPackage(clone $target);
  21828. }
  21829. });
  21830. }
  21831. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  21832. {
  21833. if (!$repo->hasPackage($package)) {
  21834. throw new \InvalidArgumentException('Package is not installed: '.$package);
  21835. }
  21836. $promise = $this->removeCode($package);
  21837. if (!$promise instanceof PromiseInterface) {
  21838. $promise = \React\Promise\resolve(null);
  21839. }
  21840. $binaryInstaller = $this->binaryInstaller;
  21841. $downloadPath = $this->getPackageBasePath($package);
  21842. $filesystem = $this->filesystem;
  21843. return $promise->then(static function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo): void {
  21844. $binaryInstaller->removeBinaries($package);
  21845. $repo->removePackage($package);
  21846. if (strpos($package->getName(), '/')) {
  21847. $packageVendorDir = dirname($downloadPath);
  21848. if (is_dir($packageVendorDir) && $filesystem->isDirEmpty($packageVendorDir)) {
  21849. Silencer::call('rmdir', $packageVendorDir);
  21850. }
  21851. }
  21852. });
  21853. }
  21854. public function getInstallPath(PackageInterface $package)
  21855. {
  21856. $this->initializeVendorDir();
  21857. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  21858. $targetDir = $package->getTargetDir();
  21859. return $basePath . ($targetDir ? '/'.$targetDir : '');
  21860. }
  21861. public function ensureBinariesPresence(PackageInterface $package)
  21862. {
  21863. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  21864. }
  21865. protected function getPackageBasePath(PackageInterface $package)
  21866. {
  21867. $installPath = $this->getInstallPath($package);
  21868. $targetDir = $package->getTargetDir();
  21869. if ($targetDir) {
  21870. return Preg::replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  21871. }
  21872. return $installPath;
  21873. }
  21874. protected function installCode(PackageInterface $package)
  21875. {
  21876. $downloadPath = $this->getInstallPath($package);
  21877. return $this->getDownloadManager()->install($package, $downloadPath);
  21878. }
  21879. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  21880. {
  21881. $initialDownloadPath = $this->getInstallPath($initial);
  21882. $targetDownloadPath = $this->getInstallPath($target);
  21883. if ($targetDownloadPath !== $initialDownloadPath) {
  21884. if (strpos($initialDownloadPath, $targetDownloadPath) === 0
  21885. || strpos($targetDownloadPath, $initialDownloadPath) === 0
  21886. ) {
  21887. $promise = $this->removeCode($initial);
  21888. if (!$promise instanceof PromiseInterface) {
  21889. $promise = \React\Promise\resolve(null);
  21890. }
  21891. return $promise->then(function () use ($target): PromiseInterface {
  21892. $promise = $this->installCode($target);
  21893. if ($promise instanceof PromiseInterface) {
  21894. return $promise;
  21895. }
  21896. return \React\Promise\resolve(null);
  21897. });
  21898. }
  21899. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  21900. }
  21901. return $this->getDownloadManager()->update($initial, $target, $targetDownloadPath);
  21902. }
  21903. protected function removeCode(PackageInterface $package)
  21904. {
  21905. $downloadPath = $this->getPackageBasePath($package);
  21906. return $this->getDownloadManager()->remove($package, $downloadPath);
  21907. }
  21908. protected function initializeVendorDir()
  21909. {
  21910. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  21911. $this->vendorDir = realpath($this->vendorDir);
  21912. }
  21913. protected function getDownloadManager(): DownloadManager
  21914. {
  21915. assert($this->downloadManager instanceof DownloadManager, new \LogicException(self::class.' should be initialized with a fully loaded Composer instance to be able to install/... packages'));
  21916. return $this->downloadManager;
  21917. }
  21918. }
  21919. <?php declare(strict_types=1);
  21920. namespace Composer\Installer;
  21921. use Composer\Repository\InstalledRepositoryInterface;
  21922. use Composer\Package\PackageInterface;
  21923. use Composer\IO\IOInterface;
  21924. use Composer\DependencyResolver\Operation\UpdateOperation;
  21925. use Composer\DependencyResolver\Operation\InstallOperation;
  21926. use Composer\DependencyResolver\Operation\UninstallOperation;
  21927. class MetapackageInstaller implements InstallerInterface
  21928. {
  21929. private $io;
  21930. public function __construct(IOInterface $io)
  21931. {
  21932. $this->io = $io;
  21933. }
  21934. public function supports(string $packageType)
  21935. {
  21936. return $packageType === 'metapackage';
  21937. }
  21938. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  21939. {
  21940. return $repo->hasPackage($package);
  21941. }
  21942. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null)
  21943. {
  21944. return \React\Promise\resolve(null);
  21945. }
  21946. public function prepare($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  21947. {
  21948. return \React\Promise\resolve(null);
  21949. }
  21950. public function cleanup($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  21951. {
  21952. return \React\Promise\resolve(null);
  21953. }
  21954. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  21955. {
  21956. $this->io->writeError(" - " . InstallOperation::format($package));
  21957. $repo->addPackage(clone $package);
  21958. return \React\Promise\resolve(null);
  21959. }
  21960. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  21961. {
  21962. if (!$repo->hasPackage($initial)) {
  21963. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  21964. }
  21965. $this->io->writeError(" - " . UpdateOperation::format($initial, $target));
  21966. $repo->removePackage($initial);
  21967. $repo->addPackage(clone $target);
  21968. return \React\Promise\resolve(null);
  21969. }
  21970. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  21971. {
  21972. if (!$repo->hasPackage($package)) {
  21973. throw new \InvalidArgumentException('Package is not installed: '.$package);
  21974. }
  21975. $this->io->writeError(" - " . UninstallOperation::format($package));
  21976. $repo->removePackage($package);
  21977. return \React\Promise\resolve(null);
  21978. }
  21979. public function getInstallPath(PackageInterface $package)
  21980. {
  21981. return null;
  21982. }
  21983. }
  21984. <?php declare(strict_types=1);
  21985. namespace Composer\Installer;
  21986. use Composer\Repository\InstalledRepositoryInterface;
  21987. use Composer\Package\PackageInterface;
  21988. class NoopInstaller implements InstallerInterface
  21989. {
  21990. public function supports(string $packageType)
  21991. {
  21992. return true;
  21993. }
  21994. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  21995. {
  21996. return $repo->hasPackage($package);
  21997. }
  21998. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null)
  21999. {
  22000. return \React\Promise\resolve(null);
  22001. }
  22002. public function prepare($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  22003. {
  22004. return \React\Promise\resolve(null);
  22005. }
  22006. public function cleanup($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  22007. {
  22008. return \React\Promise\resolve(null);
  22009. }
  22010. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  22011. {
  22012. if (!$repo->hasPackage($package)) {
  22013. $repo->addPackage(clone $package);
  22014. }
  22015. return \React\Promise\resolve(null);
  22016. }
  22017. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  22018. {
  22019. if (!$repo->hasPackage($initial)) {
  22020. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  22021. }
  22022. $repo->removePackage($initial);
  22023. if (!$repo->hasPackage($target)) {
  22024. $repo->addPackage(clone $target);
  22025. }
  22026. return \React\Promise\resolve(null);
  22027. }
  22028. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  22029. {
  22030. if (!$repo->hasPackage($package)) {
  22031. throw new \InvalidArgumentException('Package is not installed: '.$package);
  22032. }
  22033. $repo->removePackage($package);
  22034. return \React\Promise\resolve(null);
  22035. }
  22036. public function getInstallPath(PackageInterface $package)
  22037. {
  22038. $targetDir = $package->getTargetDir();
  22039. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  22040. }
  22041. }
  22042. <?php declare(strict_types=1);
  22043. namespace Composer\Installer;
  22044. use Composer\Composer;
  22045. use Composer\IO\IOInterface;
  22046. use Composer\DependencyResolver\Operation\OperationInterface;
  22047. use Composer\Repository\RepositoryInterface;
  22048. use Composer\EventDispatcher\Event;
  22049. class PackageEvent extends Event
  22050. {
  22051. private $composer;
  22052. private $io;
  22053. private $devMode;
  22054. private $localRepo;
  22055. private $operations;
  22056. private $operation;
  22057. public function __construct(string $eventName, Composer $composer, IOInterface $io, bool $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  22058. {
  22059. parent::__construct($eventName);
  22060. $this->composer = $composer;
  22061. $this->io = $io;
  22062. $this->devMode = $devMode;
  22063. $this->localRepo = $localRepo;
  22064. $this->operations = $operations;
  22065. $this->operation = $operation;
  22066. }
  22067. public function getComposer(): Composer
  22068. {
  22069. return $this->composer;
  22070. }
  22071. public function getIO(): IOInterface
  22072. {
  22073. return $this->io;
  22074. }
  22075. public function isDevMode(): bool
  22076. {
  22077. return $this->devMode;
  22078. }
  22079. public function getLocalRepo(): RepositoryInterface
  22080. {
  22081. return $this->localRepo;
  22082. }
  22083. public function getOperations(): array
  22084. {
  22085. return $this->operations;
  22086. }
  22087. public function getOperation(): OperationInterface
  22088. {
  22089. return $this->operation;
  22090. }
  22091. }
  22092. <?php declare(strict_types=1);
  22093. namespace Composer\Installer;
  22094. class PackageEvents
  22095. {
  22096. public const PRE_PACKAGE_INSTALL = 'pre-package-install';
  22097. public const POST_PACKAGE_INSTALL = 'post-package-install';
  22098. public const PRE_PACKAGE_UPDATE = 'pre-package-update';
  22099. public const POST_PACKAGE_UPDATE = 'post-package-update';
  22100. public const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  22101. public const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  22102. }
  22103. <?php declare(strict_types=1);
  22104. namespace Composer\Installer;
  22105. use Composer\Composer;
  22106. use Composer\IO\IOInterface;
  22107. use Composer\PartialComposer;
  22108. use Composer\Repository\InstalledRepositoryInterface;
  22109. use Composer\Package\PackageInterface;
  22110. use Composer\Plugin\PluginManager;
  22111. use Composer\Util\Filesystem;
  22112. use Composer\Util\Platform;
  22113. use React\Promise\PromiseInterface;
  22114. class PluginInstaller extends LibraryInstaller
  22115. {
  22116. public function __construct(IOInterface $io, PartialComposer $composer, ?Filesystem $fs = null, ?BinaryInstaller $binaryInstaller = null)
  22117. {
  22118. parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
  22119. }
  22120. public function supports(string $packageType)
  22121. {
  22122. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  22123. }
  22124. public function disablePlugins(): void
  22125. {
  22126. $this->getPluginManager()->disablePlugins();
  22127. }
  22128. public function prepare($type, PackageInterface $package, ?PackageInterface $prevPackage = null)
  22129. {
  22130. if (($type === 'install' || $type === 'update') && !$this->getPluginManager()->arePluginsDisabled('local')) {
  22131. $this->getPluginManager()->isPluginAllowed($package->getName(), false, true === ($package->getExtra()['plugin-optional'] ?? false));
  22132. }
  22133. return parent::prepare($type, $package, $prevPackage);
  22134. }
  22135. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null)
  22136. {
  22137. $extra = $package->getExtra();
  22138. if (empty($extra['class'])) {
  22139. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  22140. }
  22141. return parent::download($package, $prevPackage);
  22142. }
  22143. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  22144. {
  22145. $promise = parent::install($repo, $package);
  22146. if (!$promise instanceof PromiseInterface) {
  22147. $promise = \React\Promise\resolve(null);
  22148. }
  22149. return $promise->then(function () use ($package, $repo): void {
  22150. try {
  22151. Platform::workaroundFilesystemIssues();
  22152. $this->getPluginManager()->registerPackage($package, true);
  22153. } catch (\Exception $e) {
  22154. $this->rollbackInstall($e, $repo, $package);
  22155. }
  22156. });
  22157. }
  22158. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  22159. {
  22160. $promise = parent::update($repo, $initial, $target);
  22161. if (!$promise instanceof PromiseInterface) {
  22162. $promise = \React\Promise\resolve(null);
  22163. }
  22164. return $promise->then(function () use ($initial, $target, $repo): void {
  22165. try {
  22166. Platform::workaroundFilesystemIssues();
  22167. $this->getPluginManager()->deactivatePackage($initial);
  22168. $this->getPluginManager()->registerPackage($target, true);
  22169. } catch (\Exception $e) {
  22170. $this->rollbackInstall($e, $repo, $target);
  22171. }
  22172. });
  22173. }
  22174. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  22175. {
  22176. $this->getPluginManager()->uninstallPackage($package);
  22177. return parent::uninstall($repo, $package);
  22178. }
  22179. private function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package): void
  22180. {
  22181. $this->io->writeError('Plugin initialization failed ('.$e->getMessage().'), uninstalling plugin');
  22182. parent::uninstall($repo, $package);
  22183. throw $e;
  22184. }
  22185. protected function getPluginManager(): PluginManager
  22186. {
  22187. assert($this->composer instanceof Composer, new \LogicException(self::class.' should be initialized with a fully loaded Composer instance.'));
  22188. $pluginManager = $this->composer->getPluginManager();
  22189. return $pluginManager;
  22190. }
  22191. }
  22192. <?php declare(strict_types=1);
  22193. namespace Composer\Installer;
  22194. use React\Promise\PromiseInterface;
  22195. use Composer\Package\PackageInterface;
  22196. use Composer\Downloader\DownloadManager;
  22197. use Composer\Repository\InstalledRepositoryInterface;
  22198. use Composer\Util\Filesystem;
  22199. class ProjectInstaller implements InstallerInterface
  22200. {
  22201. private $installPath;
  22202. private $downloadManager;
  22203. private $filesystem;
  22204. public function __construct(string $installPath, DownloadManager $dm, Filesystem $fs)
  22205. {
  22206. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  22207. $this->downloadManager = $dm;
  22208. $this->filesystem = $fs;
  22209. }
  22210. public function supports(string $packageType): bool
  22211. {
  22212. return true;
  22213. }
  22214. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package): bool
  22215. {
  22216. return false;
  22217. }
  22218. public function download(PackageInterface $package, ?PackageInterface $prevPackage = null): ?PromiseInterface
  22219. {
  22220. $installPath = $this->installPath;
  22221. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  22222. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  22223. }
  22224. if (!is_dir($installPath)) {
  22225. mkdir($installPath, 0777, true);
  22226. }
  22227. return $this->downloadManager->download($package, $installPath, $prevPackage);
  22228. }
  22229. public function prepare($type, PackageInterface $package, ?PackageInterface $prevPackage = null): ?PromiseInterface
  22230. {
  22231. return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
  22232. }
  22233. public function cleanup($type, PackageInterface $package, ?PackageInterface $prevPackage = null): ?PromiseInterface
  22234. {
  22235. return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
  22236. }
  22237. public function install(InstalledRepositoryInterface $repo, PackageInterface $package): ?PromiseInterface
  22238. {
  22239. return $this->downloadManager->install($package, $this->installPath);
  22240. }
  22241. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target): ?PromiseInterface
  22242. {
  22243. throw new \InvalidArgumentException("not supported");
  22244. }
  22245. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package): ?PromiseInterface
  22246. {
  22247. throw new \InvalidArgumentException("not supported");
  22248. }
  22249. public function getInstallPath(PackageInterface $package): string
  22250. {
  22251. return $this->installPath;
  22252. }
  22253. }
  22254. <?php declare(strict_types=1);
  22255. namespace Composer\Installer;
  22256. use Composer\IO\IOInterface;
  22257. use Composer\Package\PackageInterface;
  22258. use Composer\Pcre\Preg;
  22259. use Composer\Repository\InstalledRepository;
  22260. use Symfony\Component\Console\Formatter\OutputFormatter;
  22261. class SuggestedPackagesReporter
  22262. {
  22263. public const MODE_LIST = 1;
  22264. public const MODE_BY_PACKAGE = 2;
  22265. public const MODE_BY_SUGGESTION = 4;
  22266. protected $suggestedPackages = [];
  22267. private $io;
  22268. public function __construct(IOInterface $io)
  22269. {
  22270. $this->io = $io;
  22271. }
  22272. public function getPackages(): array
  22273. {
  22274. return $this->suggestedPackages;
  22275. }
  22276. public function addPackage(string $source, string $target, string $reason): SuggestedPackagesReporter
  22277. {
  22278. $this->suggestedPackages[] = [
  22279. 'source' => $source,
  22280. 'target' => $target,
  22281. 'reason' => $reason,
  22282. ];
  22283. return $this;
  22284. }
  22285. public function addSuggestionsFromPackage(PackageInterface $package): SuggestedPackagesReporter
  22286. {
  22287. $source = $package->getPrettyName();
  22288. foreach ($package->getSuggests() as $target => $reason) {
  22289. $this->addPackage(
  22290. $source,
  22291. $target,
  22292. $reason
  22293. );
  22294. }
  22295. return $this;
  22296. }
  22297. public function output(int $mode, ?InstalledRepository $installedRepo = null, ?PackageInterface $onlyDependentsOf = null): void
  22298. {
  22299. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  22300. $suggesters = [];
  22301. $suggested = [];
  22302. foreach ($suggestedPackages as $suggestion) {
  22303. $suggesters[$suggestion['source']][$suggestion['target']] = $suggestion['reason'];
  22304. $suggested[$suggestion['target']][$suggestion['source']] = $suggestion['reason'];
  22305. }
  22306. ksort($suggesters);
  22307. ksort($suggested);
  22308. if ($mode & self::MODE_LIST) {
  22309. foreach (array_keys($suggested) as $name) {
  22310. $this->io->write(sprintf('<info>%s</info>', $name));
  22311. }
  22312. return;
  22313. }
  22314. if ($mode & self::MODE_BY_PACKAGE) {
  22315. foreach ($suggesters as $suggester => $suggestions) {
  22316. $this->io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  22317. foreach ($suggestions as $suggestion => $reason) {
  22318. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggestion, $this->escapeOutput($reason)));
  22319. }
  22320. $this->io->write('');
  22321. }
  22322. }
  22323. if ($mode & self::MODE_BY_SUGGESTION) {
  22324. if ($mode & self::MODE_BY_PACKAGE) {
  22325. $this->io->write(str_repeat('-', 78));
  22326. }
  22327. foreach ($suggested as $suggestion => $suggesters) {
  22328. $this->io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  22329. foreach ($suggesters as $suggester => $reason) {
  22330. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggester, $this->escapeOutput($reason)));
  22331. }
  22332. $this->io->write('');
  22333. }
  22334. }
  22335. if ($onlyDependentsOf) {
  22336. $allSuggestedPackages = $this->getFilteredSuggestions($installedRepo);
  22337. $diff = count($allSuggestedPackages) - count($suggestedPackages);
  22338. if ($diff) {
  22339. $this->io->write('<info>'.$diff.' additional suggestions</info> by transitive dependencies can be shown with <info>--all</info>');
  22340. }
  22341. }
  22342. }
  22343. public function outputMinimalistic(?InstalledRepository $installedRepo = null, ?PackageInterface $onlyDependentsOf = null): void
  22344. {
  22345. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  22346. if ($suggestedPackages) {
  22347. $this->io->writeError('<info>'.count($suggestedPackages).' package suggestions were added by new dependencies, use `composer suggest` to see details.</info>');
  22348. }
  22349. }
  22350. private function getFilteredSuggestions(?InstalledRepository $installedRepo = null, ?PackageInterface $onlyDependentsOf = null): array
  22351. {
  22352. $suggestedPackages = $this->getPackages();
  22353. $installedNames = [];
  22354. if (null !== $installedRepo && !empty($suggestedPackages)) {
  22355. foreach ($installedRepo->getPackages() as $package) {
  22356. $installedNames = array_merge(
  22357. $installedNames,
  22358. $package->getNames()
  22359. );
  22360. }
  22361. }
  22362. $sourceFilter = [];
  22363. if ($onlyDependentsOf) {
  22364. $sourceFilter = array_map(static function ($link): string {
  22365. return $link->getTarget();
  22366. }, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
  22367. $sourceFilter[] = $onlyDependentsOf->getName();
  22368. }
  22369. $suggestions = [];
  22370. foreach ($suggestedPackages as $suggestion) {
  22371. if (in_array($suggestion['target'], $installedNames) || ($sourceFilter && !in_array($suggestion['source'], $sourceFilter))) {
  22372. continue;
  22373. }
  22374. $suggestions[] = $suggestion;
  22375. }
  22376. return $suggestions;
  22377. }
  22378. private function escapeOutput(string $string): string
  22379. {
  22380. return OutputFormatter::escape(
  22381. $this->removeControlCharacters($string)
  22382. );
  22383. }
  22384. private function removeControlCharacters(string $string): string
  22385. {
  22386. return Preg::replace(
  22387. '/[[:cntrl:]]/',
  22388. '',
  22389. str_replace("\n", ' ', $string)
  22390. );
  22391. }
  22392. }
  22393. <?php declare(strict_types=1);
  22394. namespace Composer\Json;
  22395. use Composer\Pcre\Preg;
  22396. use Composer\Util\Filesystem;
  22397. use JsonSchema\Validator;
  22398. use Seld\JsonLint\JsonParser;
  22399. use Seld\JsonLint\ParsingException;
  22400. use Composer\Util\HttpDownloader;
  22401. use Composer\IO\IOInterface;
  22402. use Composer\Downloader\TransportException;
  22403. class JsonFile
  22404. {
  22405. public const LAX_SCHEMA = 1;
  22406. public const STRICT_SCHEMA = 2;
  22407. public const AUTH_SCHEMA = 3;
  22408. public const LOCK_SCHEMA = 4;
  22409. public const JSON_UNESCAPED_SLASHES = 64;
  22410. public const JSON_PRETTY_PRINT = 128;
  22411. public const JSON_UNESCAPED_UNICODE = 256;
  22412. public const COMPOSER_SCHEMA_PATH = __DIR__ . '/../../../res/composer-schema.json';
  22413. public const LOCK_SCHEMA_PATH = __DIR__ . '/../../../res/composer-lock-schema.json';
  22414. public const INDENT_DEFAULT = ' ';
  22415. private $path;
  22416. private $httpDownloader;
  22417. private $io;
  22418. private $indent = self::INDENT_DEFAULT;
  22419. public function __construct(string $path, ?HttpDownloader $httpDownloader = null, ?IOInterface $io = null)
  22420. {
  22421. $this->path = $path;
  22422. if (null === $httpDownloader && Preg::isMatch('{^https?://}i', $path)) {
  22423. throw new \InvalidArgumentException('http urls require a HttpDownloader instance to be passed');
  22424. }
  22425. $this->httpDownloader = $httpDownloader;
  22426. $this->io = $io;
  22427. }
  22428. public function getPath(): string
  22429. {
  22430. return $this->path;
  22431. }
  22432. public function exists(): bool
  22433. {
  22434. return is_file($this->path);
  22435. }
  22436. public function read()
  22437. {
  22438. try {
  22439. if ($this->httpDownloader) {
  22440. $json = $this->httpDownloader->get($this->path)->getBody();
  22441. } else {
  22442. if (!Filesystem::isReadable($this->path)) {
  22443. throw new \RuntimeException('The file "'.$this->path.'" is not readable.');
  22444. }
  22445. if ($this->io && $this->io->isDebug()) {
  22446. $realpathInfo = '';
  22447. $realpath = realpath($this->path);
  22448. if (false !== $realpath && $realpath !== $this->path) {
  22449. $realpathInfo = ' (' . $realpath . ')';
  22450. }
  22451. $this->io->writeError('Reading ' . $this->path . $realpathInfo);
  22452. }
  22453. $json = file_get_contents($this->path);
  22454. }
  22455. } catch (TransportException $e) {
  22456. throw new \RuntimeException($e->getMessage(), 0, $e);
  22457. } catch (\Exception $e) {
  22458. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  22459. }
  22460. if ($json === false) {
  22461. throw new \RuntimeException('Could not read '.$this->path);
  22462. }
  22463. $this->indent = self::detectIndenting($json);
  22464. return static::parseJson($json, $this->path);
  22465. }
  22466. public function write(array $hash, int $options = JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
  22467. {
  22468. if ($this->path === 'php://memory') {
  22469. file_put_contents($this->path, static::encode($hash, $options, $this->indent));
  22470. return;
  22471. }
  22472. $dir = dirname($this->path);
  22473. if (!is_dir($dir)) {
  22474. if (file_exists($dir)) {
  22475. throw new \UnexpectedValueException(
  22476. realpath($dir).' exists and is not a directory.'
  22477. );
  22478. }
  22479. if (!@mkdir($dir, 0777, true)) {
  22480. throw new \UnexpectedValueException(
  22481. $dir.' does not exist and could not be created.'
  22482. );
  22483. }
  22484. }
  22485. $retries = 3;
  22486. while ($retries--) {
  22487. try {
  22488. $this->filePutContentsIfModified($this->path, static::encode($hash, $options, $this->indent). ($options & JSON_PRETTY_PRINT ? "\n" : ''));
  22489. break;
  22490. } catch (\Exception $e) {
  22491. if ($retries > 0) {
  22492. usleep(500000);
  22493. continue;
  22494. }
  22495. throw $e;
  22496. }
  22497. }
  22498. }
  22499. private function filePutContentsIfModified(string $path, string $content)
  22500. {
  22501. $currentContent = @file_get_contents($path);
  22502. if (false === $currentContent || $currentContent !== $content) {
  22503. return file_put_contents($path, $content);
  22504. }
  22505. return 0;
  22506. }
  22507. public function validateSchema(int $schema = self::STRICT_SCHEMA, ?string $schemaFile = null): bool
  22508. {
  22509. if (!Filesystem::isReadable($this->path)) {
  22510. throw new \RuntimeException('The file "'.$this->path.'" is not readable.');
  22511. }
  22512. $content = file_get_contents($this->path);
  22513. $data = json_decode($content);
  22514. if (null === $data && 'null' !== $content) {
  22515. self::validateSyntax($content, $this->path);
  22516. }
  22517. return self::validateJsonSchema($this->path, $data, $schema, $schemaFile);
  22518. }
  22519. public static function validateJsonSchema(string $source, $data, int $schema, ?string $schemaFile = null): bool
  22520. {
  22521. $isComposerSchemaFile = false;
  22522. if (null === $schemaFile) {
  22523. if ($schema === self::LOCK_SCHEMA) {
  22524. $schemaFile = self::LOCK_SCHEMA_PATH;
  22525. } else {
  22526. $isComposerSchemaFile = true;
  22527. $schemaFile = self::COMPOSER_SCHEMA_PATH;
  22528. }
  22529. }
  22530. if (false === strpos($schemaFile, '://')) {
  22531. $schemaFile = 'file://' . $schemaFile;
  22532. }
  22533. $schemaData = (object) ['$ref' => $schemaFile, '$schema' => "https://json-schema.org/draft-04/schema#"];
  22534. if ($schema === self::STRICT_SCHEMA && $isComposerSchemaFile) {
  22535. $schemaData = json_decode((string) file_get_contents($schemaFile));
  22536. $schemaData->additionalProperties = false;
  22537. $schemaData->required = ['name', 'description'];
  22538. } elseif ($schema === self::AUTH_SCHEMA && $isComposerSchemaFile) {
  22539. $schemaData = (object) ['$ref' => $schemaFile.'#/properties/config', '$schema' => "https://json-schema.org/draft-04/schema#"];
  22540. }
  22541. $validator = new Validator();
  22542. $data = json_decode((string) json_encode($data));
  22543. $validator->validate($data, $schemaData);
  22544. if (!$validator->isValid()) {
  22545. $errors = [];
  22546. foreach ($validator->getErrors() as $error) {
  22547. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  22548. }
  22549. throw new JsonValidationException('"'.$source.'" does not match the expected JSON schema', $errors);
  22550. }
  22551. return true;
  22552. }
  22553. public static function encode($data, int $options = 448, string $indent = self::INDENT_DEFAULT): string
  22554. {
  22555. $json = json_encode($data, $options);
  22556. if (false === $json) {
  22557. self::throwEncodeError(json_last_error());
  22558. }
  22559. if (($options & JSON_PRETTY_PRINT) > 0 && $indent !== self::INDENT_DEFAULT ) {
  22560. return Preg::replaceCallback(
  22561. '#^ {4,}#m',
  22562. static function ($match) use ($indent): string {
  22563. return str_repeat($indent, (int)(strlen($match[0]) / 4));
  22564. },
  22565. $json
  22566. );
  22567. }
  22568. return $json;
  22569. }
  22570. private static function throwEncodeError(int $code): void
  22571. {
  22572. switch ($code) {
  22573. case JSON_ERROR_DEPTH:
  22574. $msg = 'Maximum stack depth exceeded';
  22575. break;
  22576. case JSON_ERROR_STATE_MISMATCH:
  22577. $msg = 'Underflow or the modes mismatch';
  22578. break;
  22579. case JSON_ERROR_CTRL_CHAR:
  22580. $msg = 'Unexpected control character found';
  22581. break;
  22582. case JSON_ERROR_UTF8:
  22583. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  22584. break;
  22585. default:
  22586. $msg = 'Unknown error';
  22587. }
  22588. throw new \RuntimeException('JSON encoding failed: '.$msg);
  22589. }
  22590. public static function parseJson(?string $json, ?string $file = null)
  22591. {
  22592. if (null === $json) {
  22593. return null;
  22594. }
  22595. $data = json_decode($json, true);
  22596. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  22597. self::validateSyntax($json, $file);
  22598. }
  22599. return $data;
  22600. }
  22601. protected static function validateSyntax(string $json, ?string $file = null): bool
  22602. {
  22603. $parser = new JsonParser();
  22604. $result = $parser->lint($json);
  22605. if (null === $result) {
  22606. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  22607. if ($file === null) {
  22608. throw new \UnexpectedValueException('The input is not UTF-8, could not parse as JSON');
  22609. } else {
  22610. throw new \UnexpectedValueException('"' . $file . '" is not UTF-8, could not parse as JSON');
  22611. }
  22612. }
  22613. return true;
  22614. }
  22615. if ($file === null) {
  22616. throw new ParsingException('The input does not contain valid JSON' . "\n" . $result->getMessage(),
  22617. $result->getDetails());
  22618. } else {
  22619. throw new ParsingException('"' . $file . '" does not contain valid JSON' . "\n" . $result->getMessage(),
  22620. $result->getDetails());
  22621. }
  22622. }
  22623. public static function detectIndenting(?string $json): string
  22624. {
  22625. if (Preg::isMatchStrictGroups('#^([ \t]+)"#m', $json ?? '', $match)) {
  22626. return $match[1];
  22627. }
  22628. return self::INDENT_DEFAULT;
  22629. }
  22630. }
  22631. <?php declare(strict_types=1);
  22632. namespace Composer\Json;
  22633. use Composer\Pcre\Preg;
  22634. class JsonFormatter
  22635. {
  22636. public static function format(string $json, bool $unescapeUnicode, bool $unescapeSlashes): string
  22637. {
  22638. $result = '';
  22639. $pos = 0;
  22640. $strLen = strlen($json);
  22641. $indentStr = ' ';
  22642. $newLine = "\n";
  22643. $outOfQuotes = true;
  22644. $buffer = '';
  22645. $noescape = true;
  22646. for ($i = 0; $i < $strLen; $i++) {
  22647. $char = substr($json, $i, 1);
  22648. if ('"' === $char && $noescape) {
  22649. $outOfQuotes = !$outOfQuotes;
  22650. }
  22651. if (!$outOfQuotes) {
  22652. $buffer .= $char;
  22653. $noescape = '\\' === $char ? !$noescape : true;
  22654. continue;
  22655. }
  22656. if ('' !== $buffer) {
  22657. if ($unescapeSlashes) {
  22658. $buffer = str_replace('\\/', '/', $buffer);
  22659. }
  22660. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  22661. $buffer = Preg::replaceCallback('/(\\\\+)u([0-9a-f]{4})/i', static function ($match): string {
  22662. $l = strlen($match[1]);
  22663. if ($l % 2) {
  22664. $code = hexdec($match[2]);
  22665. if (0xD800 <= $code && 0xDFFF >= $code) {
  22666. return $match[0];
  22667. }
  22668. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  22669. pack('H*', $match[2]),
  22670. 'UTF-8',
  22671. 'UCS-2BE'
  22672. );
  22673. }
  22674. return $match[0];
  22675. }, $buffer);
  22676. }
  22677. $result .= $buffer.$char;
  22678. $buffer = '';
  22679. continue;
  22680. }
  22681. if (':' === $char) {
  22682. $char .= ' ';
  22683. } elseif ('}' === $char || ']' === $char) {
  22684. $pos--;
  22685. $prevChar = substr($json, $i - 1, 1);
  22686. if ('{' !== $prevChar && '[' !== $prevChar) {
  22687. $result .= $newLine;
  22688. $result .= str_repeat($indentStr, $pos);
  22689. } else {
  22690. $result = rtrim($result);
  22691. }
  22692. }
  22693. $result .= $char;
  22694. if (',' === $char || '{' === $char || '[' === $char) {
  22695. $result .= $newLine;
  22696. if ('{' === $char || '[' === $char) {
  22697. $pos++;
  22698. }
  22699. $result .= str_repeat($indentStr, $pos);
  22700. }
  22701. }
  22702. return $result;
  22703. }
  22704. }
  22705. <?php declare(strict_types=1);
  22706. namespace Composer\Json;
  22707. use Composer\Pcre\Preg;
  22708. use Composer\Repository\PlatformRepository;
  22709. class JsonManipulator
  22710. {
  22711. private const DEFINES = '(?(DEFINE)
  22712. (?<number> -? (?= [1-9]|0(?!\d) ) \d++ (?:\.\d++)? (?:[eE] [+-]?+ \d++)? )
  22713. (?<boolean> true | false | null )
  22714. (?<string> " (?:[^"\\\\]*+ | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
  22715. (?<array> \[ (?: (?&json) \s*+ (?: , (?&json) \s*+ )*+ )?+ \s*+ \] )
  22716. (?<pair> \s*+ (?&string) \s*+ : (?&json) \s*+ )
  22717. (?<object> \{ (?: (?&pair) (?: , (?&pair) )*+ )?+ \s*+ \} )
  22718. (?<json> \s*+ (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  22719. )';
  22720. private $contents;
  22721. private $newline;
  22722. private $indent;
  22723. public function __construct(string $contents)
  22724. {
  22725. $contents = trim($contents);
  22726. if ($contents === '') {
  22727. $contents = '{}';
  22728. }
  22729. if (!Preg::isMatch('#^\{(.*)\}$#s', $contents)) {
  22730. throw new \InvalidArgumentException('The json file must be an object ({})');
  22731. }
  22732. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  22733. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  22734. $this->detectIndenting();
  22735. }
  22736. public function getContents(): string
  22737. {
  22738. return $this->contents . $this->newline;
  22739. }
  22740. public function addLink(string $type, string $package, string $constraint, bool $sortPackages = false): bool
  22741. {
  22742. $decoded = JsonFile::parseJson($this->contents);
  22743. if (!isset($decoded[$type])) {
  22744. return $this->addMainKey($type, [$package => $constraint]);
  22745. }
  22746. $regex = '{'.self::DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  22747. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  22748. if (!Preg::isMatch($regex, $this->contents, $matches)) {
  22749. return false;
  22750. }
  22751. assert(is_string($matches['start']));
  22752. assert(is_string($matches['value']));
  22753. assert(is_string($matches['end']));
  22754. $links = $matches['value'];
  22755. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  22756. $regex = '{'.self::DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  22757. if (Preg::isMatch($regex, $links, $packageMatches)) {
  22758. assert(is_string($packageMatches['package']));
  22759. $existingPackage = $packageMatches['package'];
  22760. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  22761. $links = Preg::replaceCallback('{'.self::DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', static function ($m) use ($existingPackage, $constraint): string {
  22762. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  22763. }, $links);
  22764. } else {
  22765. if (Preg::isMatchStrictGroups('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  22766. $links = Preg::replace(
  22767. '{'.preg_quote($match[1]).'$}',
  22768. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  22769. $links
  22770. );
  22771. } else {
  22772. $links = '{' . $this->newline .
  22773. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  22774. $this->indent . '}';
  22775. }
  22776. }
  22777. if (true === $sortPackages) {
  22778. $requirements = json_decode($links, true);
  22779. $this->sortPackages($requirements);
  22780. $links = $this->format($requirements);
  22781. }
  22782. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  22783. return true;
  22784. }
  22785. private function sortPackages(array &$packages = []): void
  22786. {
  22787. $prefix = static function ($requirement): string {
  22788. if (PlatformRepository::isPlatformPackage($requirement)) {
  22789. return Preg::replace(
  22790. [
  22791. '/^php/',
  22792. '/^hhvm/',
  22793. '/^ext/',
  22794. '/^lib/',
  22795. '/^\D/',
  22796. ],
  22797. [
  22798. '0-$0',
  22799. '1-$0',
  22800. '2-$0',
  22801. '3-$0',
  22802. '4-$0',
  22803. ],
  22804. $requirement
  22805. );
  22806. }
  22807. return '5-'.$requirement;
  22808. };
  22809. uksort($packages, static function ($a, $b) use ($prefix): int {
  22810. return strnatcmp($prefix($a), $prefix($b));
  22811. });
  22812. }
  22813. public function addRepository(string $name, $config, bool $append = true): bool
  22814. {
  22815. return $this->addSubNode('repositories', $name, $config, $append);
  22816. }
  22817. public function removeRepository(string $name): bool
  22818. {
  22819. return $this->removeSubNode('repositories', $name);
  22820. }
  22821. public function addConfigSetting(string $name, $value): bool
  22822. {
  22823. return $this->addSubNode('config', $name, $value);
  22824. }
  22825. public function removeConfigSetting(string $name): bool
  22826. {
  22827. return $this->removeSubNode('config', $name);
  22828. }
  22829. public function addProperty(string $name, $value): bool
  22830. {
  22831. if (strpos($name, 'suggest.') === 0) {
  22832. return $this->addSubNode('suggest', substr($name, 8), $value);
  22833. }
  22834. if (strpos($name, 'extra.') === 0) {
  22835. return $this->addSubNode('extra', substr($name, 6), $value);
  22836. }
  22837. if (strpos($name, 'scripts.') === 0) {
  22838. return $this->addSubNode('scripts', substr($name, 8), $value);
  22839. }
  22840. return $this->addMainKey($name, $value);
  22841. }
  22842. public function removeProperty(string $name): bool
  22843. {
  22844. if (strpos($name, 'suggest.') === 0) {
  22845. return $this->removeSubNode('suggest', substr($name, 8));
  22846. }
  22847. if (strpos($name, 'extra.') === 0) {
  22848. return $this->removeSubNode('extra', substr($name, 6));
  22849. }
  22850. if (strpos($name, 'scripts.') === 0) {
  22851. return $this->removeSubNode('scripts', substr($name, 8));
  22852. }
  22853. if (strpos($name, 'autoload.') === 0) {
  22854. return $this->removeSubNode('autoload', substr($name, 9));
  22855. }
  22856. if (strpos($name, 'autoload-dev.') === 0) {
  22857. return $this->removeSubNode('autoload-dev', substr($name, 13));
  22858. }
  22859. return $this->removeMainKey($name);
  22860. }
  22861. public function addSubNode(string $mainNode, string $name, $value, bool $append = true): bool
  22862. {
  22863. $decoded = JsonFile::parseJson($this->contents);
  22864. $subName = null;
  22865. if (in_array($mainNode, ['config', 'extra', 'scripts']) && false !== strpos($name, '.')) {
  22866. [$name, $subName] = explode('.', $name, 2);
  22867. }
  22868. if (!isset($decoded[$mainNode])) {
  22869. if ($subName !== null) {
  22870. $this->addMainKey($mainNode, [$name => [$subName => $value]]);
  22871. } else {
  22872. $this->addMainKey($mainNode, [$name => $value]);
  22873. }
  22874. return true;
  22875. }
  22876. $nodeRegex = '{'.self::DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  22877. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  22878. try {
  22879. if (!Preg::isMatch($nodeRegex, $this->contents, $match)) {
  22880. return false;
  22881. }
  22882. } catch (\RuntimeException $e) {
  22883. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  22884. return false;
  22885. }
  22886. throw $e;
  22887. }
  22888. assert(is_string($match['start']));
  22889. assert(is_string($match['content']));
  22890. assert(is_string($match['end']));
  22891. $children = $match['content'];
  22892. if (!@json_decode($children)) {
  22893. return false;
  22894. }
  22895. $childRegex = '{'.self::DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  22896. if (Preg::isMatch($childRegex, $children, $matches)) {
  22897. $children = Preg::replaceCallback($childRegex, function ($matches) use ($subName, $value): string {
  22898. if ($subName !== null && is_string($matches['content'])) {
  22899. $curVal = json_decode($matches['content'], true);
  22900. if (!is_array($curVal)) {
  22901. $curVal = [];
  22902. }
  22903. $curVal[$subName] = $value;
  22904. $value = $curVal;
  22905. }
  22906. return $matches['start'] . $this->format($value, 1) . $matches['end'];
  22907. }, $children);
  22908. } elseif (Preg::isMatch('#^\{(?P<leadingspace>\s*?)(?P<content>\S+.*?)?(?P<trailingspace>\s*)\}$#s', $children, $match)) {
  22909. $whitespace = $match['trailingspace'];
  22910. if (null !== $match['content']) {
  22911. if ($subName !== null) {
  22912. $value = [$subName => $value];
  22913. }
  22914. if ($append) {
  22915. $children = Preg::replace(
  22916. '#'.$whitespace.'}$#',
  22917. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  22918. $children
  22919. );
  22920. } else {
  22921. $whitespace = $match['leadingspace'];
  22922. $children = Preg::replace(
  22923. '#^{'.$whitespace.'#',
  22924. addcslashes('{' . $whitespace . JsonFile::encode($name).': '.$this->format($value, 1) . ',' . $this->newline . $this->indent . $this->indent, '\\$'),
  22925. $children
  22926. );
  22927. }
  22928. } else {
  22929. if ($subName !== null) {
  22930. $value = [$subName => $value];
  22931. }
  22932. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  22933. }
  22934. } else {
  22935. throw new \LogicException('Nothing matched above for: '.$children);
  22936. }
  22937. $this->contents = Preg::replaceCallback($nodeRegex, static function ($m) use ($children): string {
  22938. return $m['start'] . $children . $m['end'];
  22939. }, $this->contents);
  22940. return true;
  22941. }
  22942. public function removeSubNode(string $mainNode, string $name): bool
  22943. {
  22944. $decoded = JsonFile::parseJson($this->contents);
  22945. if (empty($decoded[$mainNode])) {
  22946. return true;
  22947. }
  22948. $nodeRegex = '{'.self::DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  22949. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  22950. try {
  22951. if (!Preg::isMatch($nodeRegex, $this->contents, $match)) {
  22952. return false;
  22953. }
  22954. } catch (\RuntimeException $e) {
  22955. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  22956. return false;
  22957. }
  22958. throw $e;
  22959. }
  22960. assert(is_string($match['start']));
  22961. assert(is_string($match['content']));
  22962. assert(is_string($match['end']));
  22963. $children = $match['content'];
  22964. if (!@json_decode($children, true)) {
  22965. return false;
  22966. }
  22967. $subName = null;
  22968. if (in_array($mainNode, ['config', 'extra', 'scripts']) && false !== strpos($name, '.')) {
  22969. [$name, $subName] = explode('.', $name, 2);
  22970. }
  22971. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  22972. return true;
  22973. }
  22974. $keyRegex = str_replace('/', '\\\\?/', preg_quote($name));
  22975. if (Preg::isMatch('{"'.$keyRegex.'"\s*:}i', $children)) {
  22976. if (Preg::isMatchAll('{'.self::DEFINES.'"'.$keyRegex.'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  22977. $bestMatch = '';
  22978. foreach ($matches[0] as $match) {
  22979. assert(is_string($match));
  22980. if (strlen($bestMatch) < strlen($match)) {
  22981. $bestMatch = $match;
  22982. }
  22983. }
  22984. $childrenClean = Preg::replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  22985. if (1 !== $count) {
  22986. $childrenClean = Preg::replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  22987. if (1 !== $count) {
  22988. return false;
  22989. }
  22990. }
  22991. }
  22992. } else {
  22993. $childrenClean = $children;
  22994. }
  22995. if (!isset($childrenClean)) {
  22996. throw new \InvalidArgumentException("JsonManipulator: \$childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.");
  22997. }
  22998. unset($match);
  22999. if (Preg::isMatch('#^\{\s*?(?P<content>\S+.*?)?(?P<trailingspace>\s*)\}$#s', $childrenClean, $match)) {
  23000. if (null === $match['content']) {
  23001. $newline = $this->newline;
  23002. $indent = $this->indent;
  23003. $this->contents = Preg::replaceCallback($nodeRegex, static function ($matches) use ($indent, $newline): string {
  23004. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  23005. }, $this->contents);
  23006. if ($subName !== null) {
  23007. $curVal = json_decode($children, true);
  23008. unset($curVal[$name][$subName]);
  23009. if ($curVal[$name] === []) {
  23010. $curVal[$name] = new \ArrayObject();
  23011. }
  23012. $this->addSubNode($mainNode, $name, $curVal[$name]);
  23013. }
  23014. return true;
  23015. }
  23016. }
  23017. $this->contents = Preg::replaceCallback($nodeRegex, function ($matches) use ($name, $subName, $childrenClean): string {
  23018. assert(is_string($matches['content']));
  23019. if ($subName !== null) {
  23020. $curVal = json_decode($matches['content'], true);
  23021. unset($curVal[$name][$subName]);
  23022. if ($curVal[$name] === []) {
  23023. $curVal[$name] = new \ArrayObject();
  23024. }
  23025. $childrenClean = $this->format($curVal, 0, true);
  23026. }
  23027. return $matches['start'] . $childrenClean . $matches['end'];
  23028. }, $this->contents);
  23029. return true;
  23030. }
  23031. public function addMainKey(string $key, $content): bool
  23032. {
  23033. $decoded = JsonFile::parseJson($this->contents);
  23034. $content = $this->format($content);
  23035. $regex = '{'.self::DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  23036. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  23037. if (isset($decoded[$key]) && Preg::isMatch($regex, $this->contents, $matches)) {
  23038. if (!@json_decode('{'.$matches['key'].'}')) {
  23039. return false;
  23040. }
  23041. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  23042. return true;
  23043. }
  23044. if (Preg::isMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  23045. $this->contents = Preg::replace(
  23046. '#'.$match[1].'\}$#',
  23047. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  23048. $this->contents
  23049. );
  23050. return true;
  23051. }
  23052. $this->contents = Preg::replace(
  23053. '#\}$#',
  23054. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  23055. $this->contents
  23056. );
  23057. return true;
  23058. }
  23059. public function removeMainKey(string $key): bool
  23060. {
  23061. $decoded = JsonFile::parseJson($this->contents);
  23062. if (!array_key_exists($key, $decoded)) {
  23063. return true;
  23064. }
  23065. $regex = '{'.self::DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  23066. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  23067. if (Preg::isMatch($regex, $this->contents, $matches)) {
  23068. assert(is_string($matches['start']));
  23069. assert(is_string($matches['removal']));
  23070. assert(is_string($matches['end']));
  23071. if (!@json_decode('{'.$matches['removal'].'}')) {
  23072. return false;
  23073. }
  23074. if (Preg::isMatchStrictGroups('#,\s*$#', $matches['start']) && Preg::isMatch('#^\}$#', $matches['end'])) {
  23075. $matches['start'] = rtrim(Preg::replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  23076. }
  23077. $this->contents = $matches['start'] . $matches['end'];
  23078. if (Preg::isMatch('#^\{\s*\}\s*$#', $this->contents)) {
  23079. $this->contents = "{\n}";
  23080. }
  23081. return true;
  23082. }
  23083. return false;
  23084. }
  23085. public function removeMainKeyIfEmpty(string $key): bool
  23086. {
  23087. $decoded = JsonFile::parseJson($this->contents);
  23088. if (!array_key_exists($key, $decoded)) {
  23089. return true;
  23090. }
  23091. if (is_array($decoded[$key]) && count($decoded[$key]) === 0) {
  23092. return $this->removeMainKey($key);
  23093. }
  23094. return true;
  23095. }
  23096. public function format($data, int $depth = 0, bool $wasObject = false): string
  23097. {
  23098. if ($data instanceof \stdClass || $data instanceof \ArrayObject) {
  23099. $data = (array) $data;
  23100. $wasObject = true;
  23101. }
  23102. if (is_array($data)) {
  23103. if (\count($data) === 0) {
  23104. return $wasObject ? '{' . $this->newline . str_repeat($this->indent, $depth + 1) . '}' : '[]';
  23105. }
  23106. if (array_is_list($data)) {
  23107. foreach ($data as $key => $val) {
  23108. $data[$key] = $this->format($val, $depth + 1);
  23109. }
  23110. return '['.implode(', ', $data).']';
  23111. }
  23112. $out = '{' . $this->newline;
  23113. $elems = [];
  23114. foreach ($data as $key => $val) {
  23115. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode((string) $key). ': '.$this->format($val, $depth + 1);
  23116. }
  23117. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  23118. }
  23119. return JsonFile::encode($data);
  23120. }
  23121. protected function detectIndenting(): void
  23122. {
  23123. $this->indent = JsonFile::detectIndenting($this->contents);
  23124. }
  23125. }
  23126. <?php declare(strict_types=1);
  23127. namespace Composer\Json;
  23128. use Exception;
  23129. class JsonValidationException extends Exception
  23130. {
  23131. protected $errors;
  23132. public function __construct(string $message, array $errors = [], ?Exception $previous = null)
  23133. {
  23134. $this->errors = $errors;
  23135. parent::__construct((string) $message, 0, $previous);
  23136. }
  23137. public function getErrors(): array
  23138. {
  23139. return $this->errors;
  23140. }
  23141. }
  23142. <?php declare(strict_types=1);
  23143. namespace Composer\PHPStan;
  23144. use Composer\Config;
  23145. use Composer\Json\JsonFile;
  23146. use PhpParser\Node\Expr\MethodCall;
  23147. use PHPStan\Analyser\Scope;
  23148. use PHPStan\Reflection\MethodReflection;
  23149. use PHPStan\Reflection\ParametersAcceptorSelector;
  23150. use PHPStan\Type\ArrayType;
  23151. use PHPStan\Type\BooleanType;
  23152. use PHPStan\Type\Constant\ConstantArrayType;
  23153. use PHPStan\Type\Constant\ConstantBooleanType;
  23154. use PHPStan\Type\Constant\ConstantStringType;
  23155. use PHPStan\Type\DynamicMethodReturnTypeExtension;
  23156. use PHPStan\Type\IntegerRangeType;
  23157. use PHPStan\Type\IntegerType;
  23158. use PHPStan\Type\MixedType;
  23159. use PHPStan\Type\StringType;
  23160. use PHPStan\Type\Type;
  23161. use PHPStan\Type\TypeCombinator;
  23162. use PHPStan\Type\TypeUtils;
  23163. use PHPStan\Type\UnionType;
  23164. final class ConfigReturnTypeExtension implements DynamicMethodReturnTypeExtension
  23165. {
  23166. private $properties = [];
  23167. public function __construct()
  23168. {
  23169. $schema = JsonFile::parseJson((string) file_get_contents(JsonFile::COMPOSER_SCHEMA_PATH));
  23170. foreach ($schema['properties']['config']['properties'] as $prop => $conf) {
  23171. $type = $this->parseType($conf, $prop);
  23172. $this->properties[$prop] = $type;
  23173. }
  23174. }
  23175. public function getClass(): string
  23176. {
  23177. return Config::class;
  23178. }
  23179. public function isMethodSupported(MethodReflection $methodReflection): bool
  23180. {
  23181. return strtolower($methodReflection->getName()) === 'get';
  23182. }
  23183. public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type
  23184. {
  23185. $args = $methodCall->getArgs();
  23186. if (count($args) < 1) {
  23187. return null;
  23188. }
  23189. $keyType = $scope->getType($args[0]->value);
  23190. if (method_exists($keyType, 'getConstantStrings')) {
  23191. $strings = $keyType->getConstantStrings();
  23192. } else {
  23193. $strings = TypeUtils::getConstantStrings($keyType);
  23194. }
  23195. if ($strings !== []) {
  23196. $types = [];
  23197. foreach($strings as $string) {
  23198. if (!isset($this->properties[$string->getValue()])) {
  23199. return null;
  23200. }
  23201. $types[] = $this->properties[$string->getValue()];
  23202. }
  23203. return TypeCombinator::union(...$types);
  23204. }
  23205. return null;
  23206. }
  23207. private function parseType(array $def, string $path): Type
  23208. {
  23209. if (isset($def['type'])) {
  23210. $types = [];
  23211. foreach ((array) $def['type'] as $type) {
  23212. switch ($type) {
  23213. case 'integer':
  23214. if (in_array($path, ['process-timeout', 'cache-ttl', 'cache-files-ttl', 'cache-files-maxsize'], true)) {
  23215. $types[] = IntegerRangeType::createAllGreaterThanOrEqualTo(0);
  23216. } else {
  23217. $types[] = new IntegerType();
  23218. }
  23219. break;
  23220. case 'string':
  23221. if ($path === 'cache-files-maxsize') {
  23222. } elseif ($path === 'discard-changes') {
  23223. $types[] = new ConstantStringType('stash');
  23224. } elseif ($path === 'use-parent-dir') {
  23225. $types[] = new ConstantStringType('prompt');
  23226. } elseif ($path === 'store-auths') {
  23227. $types[] = new ConstantStringType('prompt');
  23228. } elseif ($path === 'platform-check') {
  23229. $types[] = new ConstantStringType('php-only');
  23230. } elseif ($path === 'github-protocols') {
  23231. $types[] = new UnionType([new ConstantStringType('git'), new ConstantStringType('https'), new ConstantStringType('ssh'), new ConstantStringType('http')]);
  23232. } elseif (str_starts_with($path, 'preferred-install')) {
  23233. $types[] = new UnionType([new ConstantStringType('source'), new ConstantStringType('dist'), new ConstantStringType('auto')]);
  23234. } else {
  23235. $types[] = new StringType();
  23236. }
  23237. break;
  23238. case 'boolean':
  23239. if ($path === 'platform.additionalProperties') {
  23240. $types[] = new ConstantBooleanType(false);
  23241. } else {
  23242. $types[] = new BooleanType();
  23243. }
  23244. break;
  23245. case 'object':
  23246. $addlPropType = null;
  23247. if (isset($def['additionalProperties'])) {
  23248. $addlPropType = $this->parseType($def['additionalProperties'], $path.'.additionalProperties');
  23249. }
  23250. if (isset($def['properties'])) {
  23251. $keyNames = [];
  23252. $valTypes = [];
  23253. $optionalKeys = [];
  23254. $propIndex = 0;
  23255. foreach ($def['properties'] as $propName => $propdef) {
  23256. $keyNames[] = new ConstantStringType($propName);
  23257. $valType = $this->parseType($propdef, $path.'.'.$propName);
  23258. if (!isset($def['required']) || !in_array($propName, $def['required'], true)) {
  23259. $valType = TypeCombinator::addNull($valType);
  23260. $optionalKeys[] = $propIndex;
  23261. }
  23262. $valTypes[] = $valType;
  23263. $propIndex++;
  23264. }
  23265. if ($addlPropType !== null) {
  23266. $types[] = new ArrayType(TypeCombinator::union(new StringType(), ...$keyNames), TypeCombinator::union($addlPropType, ...$valTypes));
  23267. } else {
  23268. $types[] = new ConstantArrayType($keyNames, $valTypes, [0], $optionalKeys);
  23269. }
  23270. } else {
  23271. $types[] = new ArrayType(new StringType(), $addlPropType ?? new MixedType());
  23272. }
  23273. break;
  23274. case 'array':
  23275. if (isset($def['items'])) {
  23276. $valType = $this->parseType($def['items'], $path.'.items');
  23277. } else {
  23278. $valType = new MixedType();
  23279. }
  23280. $types[] = new ArrayType(new IntegerType(), $valType);
  23281. break;
  23282. default:
  23283. $types[] = new MixedType();
  23284. }
  23285. }
  23286. $type = TypeCombinator::union(...$types);
  23287. } elseif (isset($def['enum'])) {
  23288. $type = TypeCombinator::union(...array_map(static function (string $value): ConstantStringType {
  23289. return new ConstantStringType($value);
  23290. }, $def['enum']));
  23291. } else {
  23292. $type = new MixedType();
  23293. }
  23294. if ($path === 'allow-plugins' && time() < strtotime('2022-07-01')) {
  23295. $type = TypeCombinator::addNull($type);
  23296. }
  23297. if (in_array($path, ['autoloader-suffix', 'gitlab-protocol'], true)) {
  23298. $type = TypeCombinator::addNull($type);
  23299. }
  23300. return $type;
  23301. }
  23302. }
  23303. <?php declare(strict_types=1);
  23304. namespace Composer\PHPStan;
  23305. use Composer\DependencyResolver\Rule;
  23306. use Composer\Package\BasePackage;
  23307. use Composer\Package\Link;
  23308. use Composer\Semver\Constraint\ConstraintInterface;
  23309. use PhpParser\Node\Expr\MethodCall;
  23310. use PHPStan\Analyser\Scope;
  23311. use PHPStan\Reflection\MethodReflection;
  23312. use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
  23313. use PHPStan\Type\Constant\ConstantArrayType;
  23314. use PHPStan\Type\Constant\ConstantStringType;
  23315. use PHPStan\Type\Constant\ConstantIntegerType;
  23316. use PHPStan\Type\DynamicMethodReturnTypeExtension;
  23317. use PHPStan\Type\IntegerType;
  23318. use PHPStan\Type\StringType;
  23319. use PHPStan\Type\Type;
  23320. use PHPStan\Type\ObjectType;
  23321. use PHPStan\Type\TypeCombinator;
  23322. use PhpParser\Node\Identifier;
  23323. final class RuleReasonDataReturnTypeExtension implements DynamicMethodReturnTypeExtension
  23324. {
  23325. public function getClass(): string
  23326. {
  23327. return Rule::class;
  23328. }
  23329. public function isMethodSupported(MethodReflection $methodReflection): bool
  23330. {
  23331. return strtolower($methodReflection->getName()) === 'getreasondata';
  23332. }
  23333. public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
  23334. {
  23335. $reasonType = $scope->getType(new MethodCall($methodCall->var, new Identifier('getReason')));
  23336. $types = [
  23337. Rule::RULE_ROOT_REQUIRE => new ConstantArrayType([new ConstantStringType('packageName'), new ConstantStringType('constraint')], [new StringType, new ObjectType(ConstraintInterface::class)]),
  23338. Rule::RULE_FIXED => new ConstantArrayType([new ConstantStringType('package')], [new ObjectType(BasePackage::class)]),
  23339. Rule::RULE_PACKAGE_CONFLICT => new ObjectType(Link::class),
  23340. Rule::RULE_PACKAGE_REQUIRES => new ObjectType(Link::class),
  23341. Rule::RULE_PACKAGE_SAME_NAME => TypeCombinator::intersect(new StringType, new AccessoryNonEmptyStringType()),
  23342. Rule::RULE_LEARNED => new IntegerType(),
  23343. Rule::RULE_PACKAGE_ALIAS => new ObjectType(BasePackage::class),
  23344. Rule::RULE_PACKAGE_INVERSE_ALIAS => new ObjectType(BasePackage::class),
  23345. ];
  23346. foreach ($types as $const => $type) {
  23347. if ((new ConstantIntegerType($const))->isSuperTypeOf($reasonType)->yes()) {
  23348. return $type;
  23349. }
  23350. }
  23351. return TypeCombinator::union(...$types);
  23352. }
  23353. }
  23354. <?php declare(strict_types=1);
  23355. namespace Composer\Package;
  23356. use Composer\Semver\Constraint\Constraint;
  23357. use Composer\Package\Version\VersionParser;
  23358. class AliasPackage extends BasePackage
  23359. {
  23360. protected $version;
  23361. protected $prettyVersion;
  23362. protected $dev;
  23363. protected $rootPackageAlias = false;
  23364. protected $stability;
  23365. protected $hasSelfVersionRequires = false;
  23366. protected $aliasOf;
  23367. protected $requires;
  23368. protected $devRequires;
  23369. protected $conflicts;
  23370. protected $provides;
  23371. protected $replaces;
  23372. public function __construct(BasePackage $aliasOf, string $version, string $prettyVersion)
  23373. {
  23374. parent::__construct($aliasOf->getName());
  23375. $this->version = $version;
  23376. $this->prettyVersion = $prettyVersion;
  23377. $this->aliasOf = $aliasOf;
  23378. $this->stability = VersionParser::parseStability($version);
  23379. $this->dev = $this->stability === 'dev';
  23380. foreach (Link::$TYPES as $type) {
  23381. $links = $aliasOf->{'get' . ucfirst($type)}();
  23382. $this->{$type} = $this->replaceSelfVersionDependencies($links, $type);
  23383. }
  23384. }
  23385. public function getAliasOf()
  23386. {
  23387. return $this->aliasOf;
  23388. }
  23389. public function getVersion(): string
  23390. {
  23391. return $this->version;
  23392. }
  23393. public function getStability(): string
  23394. {
  23395. return $this->stability;
  23396. }
  23397. public function getPrettyVersion(): string
  23398. {
  23399. return $this->prettyVersion;
  23400. }
  23401. public function isDev(): bool
  23402. {
  23403. return $this->dev;
  23404. }
  23405. public function getRequires(): array
  23406. {
  23407. return $this->requires;
  23408. }
  23409. public function getConflicts(): array
  23410. {
  23411. return $this->conflicts;
  23412. }
  23413. public function getProvides(): array
  23414. {
  23415. return $this->provides;
  23416. }
  23417. public function getReplaces(): array
  23418. {
  23419. return $this->replaces;
  23420. }
  23421. public function getDevRequires(): array
  23422. {
  23423. return $this->devRequires;
  23424. }
  23425. public function setRootPackageAlias(bool $value): void
  23426. {
  23427. $this->rootPackageAlias = $value;
  23428. }
  23429. public function isRootPackageAlias(): bool
  23430. {
  23431. return $this->rootPackageAlias;
  23432. }
  23433. protected function replaceSelfVersionDependencies(array $links, $linkType): array
  23434. {
  23435. $prettyVersion = $this->prettyVersion;
  23436. if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23437. $prettyVersion = $this->aliasOf->getPrettyVersion();
  23438. }
  23439. if (\in_array($linkType, [Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE], true)) {
  23440. $newLinks = [];
  23441. foreach ($links as $link) {
  23442. if ('self.version' === $link->getPrettyConstraint()) {
  23443. $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  23444. $constraint->setPrettyString($prettyVersion);
  23445. }
  23446. }
  23447. $links = array_merge($links, $newLinks);
  23448. } else {
  23449. foreach ($links as $index => $link) {
  23450. if ('self.version' === $link->getPrettyConstraint()) {
  23451. if ($linkType === Link::TYPE_REQUIRE) {
  23452. $this->hasSelfVersionRequires = true;
  23453. }
  23454. $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  23455. $constraint->setPrettyString($prettyVersion);
  23456. }
  23457. }
  23458. }
  23459. return $links;
  23460. }
  23461. public function hasSelfVersionRequires(): bool
  23462. {
  23463. return $this->hasSelfVersionRequires;
  23464. }
  23465. public function __toString(): string
  23466. {
  23467. return parent::__toString().' ('.($this->rootPackageAlias ? 'root ' : ''). 'alias of '.$this->aliasOf->getVersion().')';
  23468. }
  23469. public function getType(): string
  23470. {
  23471. return $this->aliasOf->getType();
  23472. }
  23473. public function getTargetDir(): ?string
  23474. {
  23475. return $this->aliasOf->getTargetDir();
  23476. }
  23477. public function getExtra(): array
  23478. {
  23479. return $this->aliasOf->getExtra();
  23480. }
  23481. public function setInstallationSource(?string $type): void
  23482. {
  23483. $this->aliasOf->setInstallationSource($type);
  23484. }
  23485. public function getInstallationSource(): ?string
  23486. {
  23487. return $this->aliasOf->getInstallationSource();
  23488. }
  23489. public function getSourceType(): ?string
  23490. {
  23491. return $this->aliasOf->getSourceType();
  23492. }
  23493. public function getSourceUrl(): ?string
  23494. {
  23495. return $this->aliasOf->getSourceUrl();
  23496. }
  23497. public function getSourceUrls(): array
  23498. {
  23499. return $this->aliasOf->getSourceUrls();
  23500. }
  23501. public function getSourceReference(): ?string
  23502. {
  23503. return $this->aliasOf->getSourceReference();
  23504. }
  23505. public function setSourceReference(?string $reference): void
  23506. {
  23507. $this->aliasOf->setSourceReference($reference);
  23508. }
  23509. public function setSourceMirrors(?array $mirrors): void
  23510. {
  23511. $this->aliasOf->setSourceMirrors($mirrors);
  23512. }
  23513. public function getSourceMirrors(): ?array
  23514. {
  23515. return $this->aliasOf->getSourceMirrors();
  23516. }
  23517. public function getDistType(): ?string
  23518. {
  23519. return $this->aliasOf->getDistType();
  23520. }
  23521. public function getDistUrl(): ?string
  23522. {
  23523. return $this->aliasOf->getDistUrl();
  23524. }
  23525. public function getDistUrls(): array
  23526. {
  23527. return $this->aliasOf->getDistUrls();
  23528. }
  23529. public function getDistReference(): ?string
  23530. {
  23531. return $this->aliasOf->getDistReference();
  23532. }
  23533. public function setDistReference(?string $reference): void
  23534. {
  23535. $this->aliasOf->setDistReference($reference);
  23536. }
  23537. public function getDistSha1Checksum(): ?string
  23538. {
  23539. return $this->aliasOf->getDistSha1Checksum();
  23540. }
  23541. public function setTransportOptions(array $options): void
  23542. {
  23543. $this->aliasOf->setTransportOptions($options);
  23544. }
  23545. public function getTransportOptions(): array
  23546. {
  23547. return $this->aliasOf->getTransportOptions();
  23548. }
  23549. public function setDistMirrors(?array $mirrors): void
  23550. {
  23551. $this->aliasOf->setDistMirrors($mirrors);
  23552. }
  23553. public function getDistMirrors(): ?array
  23554. {
  23555. return $this->aliasOf->getDistMirrors();
  23556. }
  23557. public function getAutoload(): array
  23558. {
  23559. return $this->aliasOf->getAutoload();
  23560. }
  23561. public function getDevAutoload(): array
  23562. {
  23563. return $this->aliasOf->getDevAutoload();
  23564. }
  23565. public function getIncludePaths(): array
  23566. {
  23567. return $this->aliasOf->getIncludePaths();
  23568. }
  23569. public function getPhpExt(): ?array
  23570. {
  23571. return $this->aliasOf->getPhpExt();
  23572. }
  23573. public function getReleaseDate(): ?\DateTimeInterface
  23574. {
  23575. return $this->aliasOf->getReleaseDate();
  23576. }
  23577. public function getBinaries(): array
  23578. {
  23579. return $this->aliasOf->getBinaries();
  23580. }
  23581. public function getSuggests(): array
  23582. {
  23583. return $this->aliasOf->getSuggests();
  23584. }
  23585. public function getNotificationUrl(): ?string
  23586. {
  23587. return $this->aliasOf->getNotificationUrl();
  23588. }
  23589. public function isDefaultBranch(): bool
  23590. {
  23591. return $this->aliasOf->isDefaultBranch();
  23592. }
  23593. public function setDistUrl(?string $url): void
  23594. {
  23595. $this->aliasOf->setDistUrl($url);
  23596. }
  23597. public function setDistType(?string $type): void
  23598. {
  23599. $this->aliasOf->setDistType($type);
  23600. }
  23601. public function setSourceDistReferences(string $reference): void
  23602. {
  23603. $this->aliasOf->setSourceDistReferences($reference);
  23604. }
  23605. }
  23606. <?php declare(strict_types=1);
  23607. namespace Composer\Package\Archiver;
  23608. use FilterIterator;
  23609. use Iterator;
  23610. use PharData;
  23611. use SplFileInfo;
  23612. class ArchivableFilesFilter extends FilterIterator
  23613. {
  23614. private $dirs = [];
  23615. public function accept(): bool
  23616. {
  23617. $file = $this->getInnerIterator()->current();
  23618. if ($file->isDir()) {
  23619. $this->dirs[] = (string) $file;
  23620. return false;
  23621. }
  23622. return true;
  23623. }
  23624. public function addEmptyDir(PharData $phar, string $sources): void
  23625. {
  23626. foreach ($this->dirs as $filepath) {
  23627. $localname = str_replace($sources . "/", '', $filepath);
  23628. $phar->addEmptyDir($localname);
  23629. }
  23630. }
  23631. }
  23632. <?php declare(strict_types=1);
  23633. namespace Composer\Package\Archiver;
  23634. use Composer\Pcre\Preg;
  23635. use Composer\Util\Filesystem;
  23636. use FilesystemIterator;
  23637. use FilterIterator;
  23638. use Iterator;
  23639. use Symfony\Component\Finder\Finder;
  23640. use Symfony\Component\Finder\SplFileInfo;
  23641. class ArchivableFilesFinder extends FilterIterator
  23642. {
  23643. protected $finder;
  23644. public function __construct(string $sources, array $excludes, bool $ignoreFilters = false)
  23645. {
  23646. $fs = new Filesystem();
  23647. $sourcesRealPath = realpath($sources);
  23648. if ($sourcesRealPath === false) {
  23649. throw new \RuntimeException('Could not realpath() the source directory "'.$sources.'"');
  23650. }
  23651. $sources = $fs->normalizePath($sourcesRealPath);
  23652. if ($ignoreFilters) {
  23653. $filters = [];
  23654. } else {
  23655. $filters = [
  23656. new GitExcludeFilter($sources),
  23657. new ComposerExcludeFilter($sources, $excludes),
  23658. ];
  23659. }
  23660. $this->finder = new Finder();
  23661. $filter = static function (\SplFileInfo $file) use ($sources, $filters, $fs): bool {
  23662. $realpath = $file->getRealPath();
  23663. if ($realpath === false) {
  23664. return false;
  23665. }
  23666. if ($file->isLink() && strpos($realpath, $sources) !== 0) {
  23667. return false;
  23668. }
  23669. $relativePath = Preg::replace(
  23670. '#^'.preg_quote($sources, '#').'#',
  23671. '',
  23672. $fs->normalizePath($realpath)
  23673. );
  23674. $exclude = false;
  23675. foreach ($filters as $filter) {
  23676. $exclude = $filter->filter($relativePath, $exclude);
  23677. }
  23678. return !$exclude;
  23679. };
  23680. $this->finder
  23681. ->in($sources)
  23682. ->filter($filter)
  23683. ->ignoreVCS(true)
  23684. ->ignoreDotFiles(false)
  23685. ->sortByName();
  23686. parent::__construct($this->finder->getIterator());
  23687. }
  23688. public function accept(): bool
  23689. {
  23690. $current = $this->getInnerIterator()->current();
  23691. if (!$current->isDir()) {
  23692. return true;
  23693. }
  23694. $iterator = new FilesystemIterator((string) $current, FilesystemIterator::SKIP_DOTS);
  23695. return !$iterator->valid();
  23696. }
  23697. }
  23698. <?php declare(strict_types=1);
  23699. namespace Composer\Package\Archiver;
  23700. use Composer\Downloader\DownloadManager;
  23701. use Composer\Package\RootPackageInterface;
  23702. use Composer\Pcre\Preg;
  23703. use Composer\Util\Filesystem;
  23704. use Composer\Util\Loop;
  23705. use Composer\Util\SyncHelper;
  23706. use Composer\Json\JsonFile;
  23707. use Composer\Package\CompletePackageInterface;
  23708. class ArchiveManager
  23709. {
  23710. protected $downloadManager;
  23711. protected $loop;
  23712. protected $archivers = [];
  23713. protected $overwriteFiles = true;
  23714. public function __construct(DownloadManager $downloadManager, Loop $loop)
  23715. {
  23716. $this->downloadManager = $downloadManager;
  23717. $this->loop = $loop;
  23718. }
  23719. public function addArchiver(ArchiverInterface $archiver): void
  23720. {
  23721. $this->archivers[] = $archiver;
  23722. }
  23723. public function setOverwriteFiles(bool $overwriteFiles): self
  23724. {
  23725. $this->overwriteFiles = $overwriteFiles;
  23726. return $this;
  23727. }
  23728. public function getPackageFilenameParts(CompletePackageInterface $package): array
  23729. {
  23730. $baseName = $package->getArchiveName();
  23731. if (null === $baseName) {
  23732. $baseName = Preg::replace('#[^a-z0-9-_]#i', '-', $package->getName());
  23733. }
  23734. $parts = [
  23735. 'base' => $baseName,
  23736. ];
  23737. $distReference = $package->getDistReference();
  23738. if (null !== $distReference && Preg::isMatch('{^[a-f0-9]{40}$}', $distReference)) {
  23739. $parts['dist_reference'] = $distReference;
  23740. $parts['dist_type'] = $package->getDistType();
  23741. } else {
  23742. $parts['version'] = $package->getPrettyVersion();
  23743. $parts['dist_reference'] = $distReference;
  23744. }
  23745. $sourceReference = $package->getSourceReference();
  23746. if (null !== $sourceReference) {
  23747. $parts['source_reference'] = substr(hash('sha1', $sourceReference), 0, 6);
  23748. }
  23749. $parts = array_filter($parts, function (?string $part) {
  23750. return $part !== null;
  23751. });
  23752. foreach ($parts as $key => $part) {
  23753. $parts[$key] = str_replace('/', '-', $part);
  23754. }
  23755. return $parts;
  23756. }
  23757. public function getPackageFilenameFromParts(array $parts): string
  23758. {
  23759. return implode('-', $parts);
  23760. }
  23761. public function getPackageFilename(CompletePackageInterface $package): string
  23762. {
  23763. return $this->getPackageFilenameFromParts($this->getPackageFilenameParts($package));
  23764. }
  23765. public function archive(CompletePackageInterface $package, string $format, string $targetDir, ?string $fileName = null, bool $ignoreFilters = false): string
  23766. {
  23767. if (empty($format)) {
  23768. throw new \InvalidArgumentException('Format must be specified');
  23769. }
  23770. $usableArchiver = null;
  23771. foreach ($this->archivers as $archiver) {
  23772. if ($archiver->supports($format, $package->getSourceType())) {
  23773. $usableArchiver = $archiver;
  23774. break;
  23775. }
  23776. }
  23777. if (null === $usableArchiver) {
  23778. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  23779. }
  23780. $filesystem = new Filesystem();
  23781. if ($package instanceof RootPackageInterface) {
  23782. $sourcePath = realpath('.');
  23783. } else {
  23784. $sourcePath = sys_get_temp_dir().'/composer_archive'.bin2hex(random_bytes(5));
  23785. $filesystem->ensureDirectoryExists($sourcePath);
  23786. try {
  23787. $promise = $this->downloadManager->download($package, $sourcePath);
  23788. SyncHelper::await($this->loop, $promise);
  23789. $promise = $this->downloadManager->install($package, $sourcePath);
  23790. SyncHelper::await($this->loop, $promise);
  23791. } catch (\Exception $e) {
  23792. $filesystem->removeDirectory($sourcePath);
  23793. throw $e;
  23794. }
  23795. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  23796. $jsonFile = new JsonFile($composerJsonPath);
  23797. $jsonData = $jsonFile->read();
  23798. if (!empty($jsonData['archive']['name'])) {
  23799. $package->setArchiveName($jsonData['archive']['name']);
  23800. }
  23801. if (!empty($jsonData['archive']['exclude'])) {
  23802. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  23803. }
  23804. }
  23805. }
  23806. $supportedFormats = $this->getSupportedFormats();
  23807. $packageNameParts = null === $fileName ?
  23808. $this->getPackageFilenameParts($package)
  23809. : ['base' => $fileName];
  23810. $packageName = $this->getPackageFilenameFromParts($packageNameParts);
  23811. $excludePatterns = $this->buildExcludePatterns($packageNameParts, $supportedFormats);
  23812. $filesystem->ensureDirectoryExists($targetDir);
  23813. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  23814. $filesystem->ensureDirectoryExists(dirname($target));
  23815. if (!$this->overwriteFiles && file_exists($target)) {
  23816. return $target;
  23817. }
  23818. $tempTarget = sys_get_temp_dir().'/composer_archive'.bin2hex(random_bytes(5)).'.'.$format;
  23819. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  23820. $archivePath = $usableArchiver->archive(
  23821. $sourcePath,
  23822. $tempTarget,
  23823. $format,
  23824. array_merge($excludePatterns, $package->getArchiveExcludes()),
  23825. $ignoreFilters
  23826. );
  23827. $filesystem->rename($archivePath, $target);
  23828. if (!$package instanceof RootPackageInterface) {
  23829. $filesystem->removeDirectory($sourcePath);
  23830. }
  23831. $filesystem->remove($tempTarget);
  23832. return $target;
  23833. }
  23834. private function buildExcludePatterns(array $parts, array $formats): array
  23835. {
  23836. $base = $parts['base'];
  23837. if (count($parts) > 1) {
  23838. $base .= '-*';
  23839. }
  23840. $patterns = [];
  23841. foreach ($formats as $format) {
  23842. $patterns[] = "$base.$format";
  23843. }
  23844. return $patterns;
  23845. }
  23846. private function getSupportedFormats(): array
  23847. {
  23848. $formats = [];
  23849. foreach ($this->archivers as $archiver) {
  23850. $items = [];
  23851. switch (get_class($archiver)) {
  23852. case ZipArchiver::class:
  23853. $items = ['zip'];
  23854. break;
  23855. case PharArchiver::class:
  23856. $items = ['zip', 'tar', 'tar.gz', 'tar.bz2'];
  23857. break;
  23858. }
  23859. $formats = array_merge($formats, $items);
  23860. }
  23861. return array_unique($formats);
  23862. }
  23863. }
  23864. <?php declare(strict_types=1);
  23865. namespace Composer\Package\Archiver;
  23866. interface ArchiverInterface
  23867. {
  23868. public function archive(string $sources, string $target, string $format, array $excludes = [], bool $ignoreFilters = false): string;
  23869. public function supports(string $format, ?string $sourceType): bool;
  23870. }
  23871. <?php declare(strict_types=1);
  23872. namespace Composer\Package\Archiver;
  23873. use Composer\Pcre\Preg;
  23874. use Symfony\Component\Finder;
  23875. abstract class BaseExcludeFilter
  23876. {
  23877. protected $sourcePath;
  23878. protected $excludePatterns;
  23879. public function __construct(string $sourcePath)
  23880. {
  23881. $this->sourcePath = $sourcePath;
  23882. $this->excludePatterns = [];
  23883. }
  23884. public function filter(string $relativePath, bool $exclude): bool
  23885. {
  23886. foreach ($this->excludePatterns as $patternData) {
  23887. [$pattern, $negate, $stripLeadingSlash] = $patternData;
  23888. if ($stripLeadingSlash) {
  23889. $path = substr($relativePath, 1);
  23890. } else {
  23891. $path = $relativePath;
  23892. }
  23893. try {
  23894. if (Preg::isMatch($pattern, $path)) {
  23895. $exclude = !$negate;
  23896. }
  23897. } catch (\RuntimeException $e) {
  23898. }
  23899. }
  23900. return $exclude;
  23901. }
  23902. protected function parseLines(array $lines, callable $lineParser): array
  23903. {
  23904. return array_filter(
  23905. array_map(
  23906. static function ($line) use ($lineParser) {
  23907. $line = trim($line);
  23908. if (!$line || 0 === strpos($line, '#')) {
  23909. return null;
  23910. }
  23911. return $lineParser($line);
  23912. },
  23913. $lines
  23914. ),
  23915. static function ($pattern): bool {
  23916. return $pattern !== null;
  23917. }
  23918. );
  23919. }
  23920. protected function generatePatterns(array $rules): array
  23921. {
  23922. $patterns = [];
  23923. foreach ($rules as $rule) {
  23924. $patterns[] = $this->generatePattern($rule);
  23925. }
  23926. return $patterns;
  23927. }
  23928. protected function generatePattern(string $rule): array
  23929. {
  23930. $negate = false;
  23931. $pattern = '';
  23932. if ($rule !== '' && $rule[0] === '!') {
  23933. $negate = true;
  23934. $rule = ltrim($rule, '!');
  23935. }
  23936. $firstSlashPosition = strpos($rule, '/');
  23937. if (0 === $firstSlashPosition) {
  23938. $pattern = '^/';
  23939. } elseif (false === $firstSlashPosition || strlen($rule) - 1 === $firstSlashPosition) {
  23940. $pattern = '/';
  23941. }
  23942. $rule = trim($rule, '/');
  23943. $rule = substr(Finder\Glob::toRegex($rule), 2, -2);
  23944. return ['{'.$pattern.$rule.'(?=$|/)}', $negate, false];
  23945. }
  23946. }
  23947. <?php declare(strict_types=1);
  23948. namespace Composer\Package\Archiver;
  23949. class ComposerExcludeFilter extends BaseExcludeFilter
  23950. {
  23951. public function __construct(string $sourcePath, array $excludeRules)
  23952. {
  23953. parent::__construct($sourcePath);
  23954. $this->excludePatterns = $this->generatePatterns($excludeRules);
  23955. }
  23956. }
  23957. <?php declare(strict_types=1);
  23958. namespace Composer\Package\Archiver;
  23959. use Composer\Pcre\Preg;
  23960. class GitExcludeFilter extends BaseExcludeFilter
  23961. {
  23962. public function __construct(string $sourcePath)
  23963. {
  23964. parent::__construct($sourcePath);
  23965. if (file_exists($sourcePath.'/.gitattributes')) {
  23966. $this->excludePatterns = array_merge(
  23967. $this->excludePatterns,
  23968. $this->parseLines(
  23969. file($sourcePath.'/.gitattributes'),
  23970. [$this, 'parseGitAttributesLine']
  23971. )
  23972. );
  23973. }
  23974. }
  23975. public function parseGitAttributesLine(string $line): ?array
  23976. {
  23977. $parts = Preg::split('#\s+#', $line);
  23978. if (count($parts) === 2 && $parts[1] === 'export-ignore') {
  23979. return $this->generatePattern($parts[0]);
  23980. }
  23981. if (count($parts) === 2 && $parts[1] === '-export-ignore') {
  23982. return $this->generatePattern('!'.$parts[0]);
  23983. }
  23984. return null;
  23985. }
  23986. }
  23987. <?php declare(strict_types=1);
  23988. namespace Composer\Package\Archiver;
  23989. class PharArchiver implements ArchiverInterface
  23990. {
  23991. protected static $formats = [
  23992. 'zip' => \Phar::ZIP,
  23993. 'tar' => \Phar::TAR,
  23994. 'tar.gz' => \Phar::TAR,
  23995. 'tar.bz2' => \Phar::TAR,
  23996. ];
  23997. protected static $compressFormats = [
  23998. 'tar.gz' => \Phar::GZ,
  23999. 'tar.bz2' => \Phar::BZ2,
  24000. ];
  24001. public function archive(string $sources, string $target, string $format, array $excludes = [], bool $ignoreFilters = false): string
  24002. {
  24003. $sources = realpath($sources);
  24004. if (file_exists($target)) {
  24005. unlink($target);
  24006. }
  24007. try {
  24008. $filename = substr($target, 0, strrpos($target, $format) - 1);
  24009. if (isset(static::$compressFormats[$format])) {
  24010. $target = $filename . '.tar';
  24011. }
  24012. $phar = new \PharData(
  24013. $target,
  24014. \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO,
  24015. '',
  24016. static::$formats[$format]
  24017. );
  24018. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  24019. $filesOnly = new ArchivableFilesFilter($files);
  24020. $phar->buildFromIterator($filesOnly, $sources);
  24021. $filesOnly->addEmptyDir($phar, $sources);
  24022. if (isset(static::$compressFormats[$format])) {
  24023. if (!$phar->canCompress(static::$compressFormats[$format])) {
  24024. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  24025. }
  24026. unlink($target);
  24027. $phar->compress(static::$compressFormats[$format]);
  24028. $target = $filename . '.' . $format;
  24029. }
  24030. return $target;
  24031. } catch (\UnexpectedValueException $e) {
  24032. $message = sprintf(
  24033. "Could not create archive '%s' from '%s': %s",
  24034. $target,
  24035. $sources,
  24036. $e->getMessage()
  24037. );
  24038. throw new \RuntimeException($message, $e->getCode(), $e);
  24039. }
  24040. }
  24041. public function supports(string $format, ?string $sourceType): bool
  24042. {
  24043. return isset(static::$formats[$format]);
  24044. }
  24045. }
  24046. <?php declare(strict_types=1);
  24047. namespace Composer\Package\Archiver;
  24048. use Composer\Util\Filesystem;
  24049. use Composer\Util\Platform;
  24050. use ZipArchive;
  24051. class ZipArchiver implements ArchiverInterface
  24052. {
  24053. protected static $formats = [
  24054. 'zip' => true,
  24055. ];
  24056. public function archive(string $sources, string $target, string $format, array $excludes = [], bool $ignoreFilters = false): string
  24057. {
  24058. $fs = new Filesystem();
  24059. $sourcesRealpath = realpath($sources);
  24060. if (false !== $sourcesRealpath) {
  24061. $sources = $sourcesRealpath;
  24062. }
  24063. unset($sourcesRealpath);
  24064. $sources = $fs->normalizePath($sources);
  24065. $zip = new ZipArchive();
  24066. $res = $zip->open($target, ZipArchive::CREATE);
  24067. if ($res === true) {
  24068. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  24069. foreach ($files as $file) {
  24070. $filepath = $file->getPathname();
  24071. $relativePath = $file->getRelativePathname();
  24072. if (Platform::isWindows()) {
  24073. $relativePath = strtr($relativePath, '\\', '/');
  24074. }
  24075. if ($file->isDir()) {
  24076. $zip->addEmptyDir($relativePath);
  24077. } else {
  24078. $zip->addFile($filepath, $relativePath);
  24079. }
  24080. if (method_exists($zip, 'setExternalAttributesName')) {
  24081. $perms = fileperms($filepath);
  24082. $zip->setExternalAttributesName($relativePath, ZipArchive::OPSYS_UNIX, $perms << 16);
  24083. }
  24084. }
  24085. if ($zip->close()) {
  24086. return $target;
  24087. }
  24088. }
  24089. $message = sprintf(
  24090. "Could not create archive '%s' from '%s': %s",
  24091. $target,
  24092. $sources,
  24093. $zip->getStatusString()
  24094. );
  24095. throw new \RuntimeException($message);
  24096. }
  24097. public function supports(string $format, ?string $sourceType): bool
  24098. {
  24099. return isset(static::$formats[$format]) && $this->compressionAvailable();
  24100. }
  24101. private function compressionAvailable(): bool
  24102. {
  24103. return class_exists('ZipArchive');
  24104. }
  24105. }
  24106. <?php declare(strict_types=1);
  24107. namespace Composer\Package;
  24108. use Composer\Repository\RepositoryInterface;
  24109. use Composer\Repository\PlatformRepository;
  24110. abstract class BasePackage implements PackageInterface
  24111. {
  24112. public static $supportedLinkTypes = [
  24113. 'require' => ['description' => 'requires', 'method' => Link::TYPE_REQUIRE],
  24114. 'conflict' => ['description' => 'conflicts', 'method' => Link::TYPE_CONFLICT],
  24115. 'provide' => ['description' => 'provides', 'method' => Link::TYPE_PROVIDE],
  24116. 'replace' => ['description' => 'replaces', 'method' => Link::TYPE_REPLACE],
  24117. 'require-dev' => ['description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE],
  24118. ];
  24119. public const STABILITY_STABLE = 0;
  24120. public const STABILITY_RC = 5;
  24121. public const STABILITY_BETA = 10;
  24122. public const STABILITY_ALPHA = 15;
  24123. public const STABILITY_DEV = 20;
  24124. public const STABILITIES = [
  24125. 'stable' => self::STABILITY_STABLE,
  24126. 'RC' => self::STABILITY_RC,
  24127. 'beta' => self::STABILITY_BETA,
  24128. 'alpha' => self::STABILITY_ALPHA,
  24129. 'dev' => self::STABILITY_DEV,
  24130. ];
  24131. public static $stabilities = self::STABILITIES;
  24132. public $id;
  24133. protected $name;
  24134. protected $prettyName;
  24135. protected $repository = null;
  24136. public function __construct(string $name)
  24137. {
  24138. $this->prettyName = $name;
  24139. $this->name = strtolower($name);
  24140. $this->id = -1;
  24141. }
  24142. public function getName(): string
  24143. {
  24144. return $this->name;
  24145. }
  24146. public function getPrettyName(): string
  24147. {
  24148. return $this->prettyName;
  24149. }
  24150. public function getNames($provides = true): array
  24151. {
  24152. $names = [
  24153. $this->getName() => true,
  24154. ];
  24155. if ($provides) {
  24156. foreach ($this->getProvides() as $link) {
  24157. $names[$link->getTarget()] = true;
  24158. }
  24159. }
  24160. foreach ($this->getReplaces() as $link) {
  24161. $names[$link->getTarget()] = true;
  24162. }
  24163. return array_keys($names);
  24164. }
  24165. public function setId(int $id): void
  24166. {
  24167. $this->id = $id;
  24168. }
  24169. public function getId(): int
  24170. {
  24171. return $this->id;
  24172. }
  24173. public function setRepository(RepositoryInterface $repository): void
  24174. {
  24175. if ($this->repository && $repository !== $this->repository) {
  24176. throw new \LogicException(sprintf(
  24177. 'Package "%s" cannot be added to repository "%s" as it is already in repository "%s".',
  24178. $this->getPrettyName(),
  24179. $repository->getRepoName(),
  24180. $this->repository->getRepoName()
  24181. ));
  24182. }
  24183. $this->repository = $repository;
  24184. }
  24185. public function getRepository(): ?RepositoryInterface
  24186. {
  24187. return $this->repository;
  24188. }
  24189. public function isPlatform(): bool
  24190. {
  24191. return $this->getRepository() instanceof PlatformRepository;
  24192. }
  24193. public function getUniqueName(): string
  24194. {
  24195. return $this->getName().'-'.$this->getVersion();
  24196. }
  24197. public function equals(PackageInterface $package): bool
  24198. {
  24199. $self = $this;
  24200. if ($this instanceof AliasPackage) {
  24201. $self = $this->getAliasOf();
  24202. }
  24203. if ($package instanceof AliasPackage) {
  24204. $package = $package->getAliasOf();
  24205. }
  24206. return $package === $self;
  24207. }
  24208. public function __toString(): string
  24209. {
  24210. return $this->getUniqueName();
  24211. }
  24212. public function getPrettyString(): string
  24213. {
  24214. return $this->getPrettyName().' '.$this->getPrettyVersion();
  24215. }
  24216. public function getFullPrettyVersion(bool $truncate = true, int $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV): string
  24217. {
  24218. if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
  24219. (!$this->isDev() || !\in_array($this->getSourceType(), ['hg', 'git']))
  24220. ) {
  24221. return $this->getPrettyVersion();
  24222. }
  24223. switch ($displayMode) {
  24224. case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
  24225. case PackageInterface::DISPLAY_SOURCE_REF:
  24226. $reference = $this->getSourceReference();
  24227. break;
  24228. case PackageInterface::DISPLAY_DIST_REF:
  24229. $reference = $this->getDistReference();
  24230. break;
  24231. default:
  24232. throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
  24233. }
  24234. if (null === $reference) {
  24235. return $this->getPrettyVersion();
  24236. }
  24237. if ($truncate && \strlen($reference) === 40 && $this->getSourceType() !== 'svn') {
  24238. return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
  24239. }
  24240. return $this->getPrettyVersion() . ' ' . $reference;
  24241. }
  24242. public function getStabilityPriority(): int
  24243. {
  24244. return self::STABILITIES[$this->getStability()];
  24245. }
  24246. public function __clone()
  24247. {
  24248. $this->repository = null;
  24249. $this->id = -1;
  24250. }
  24251. public static function packageNameToRegexp(string $allowPattern, string $wrap = '{^%s$}i'): string
  24252. {
  24253. $cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
  24254. return sprintf($wrap, $cleanedAllowPattern);
  24255. }
  24256. public static function packageNamesToRegexp(array $packageNames, string $wrap = '{^(?:%s)$}iD'): string
  24257. {
  24258. $packageNames = array_map(
  24259. static function ($packageName): string {
  24260. return BasePackage::packageNameToRegexp($packageName, '%s');
  24261. },
  24262. $packageNames
  24263. );
  24264. return sprintf($wrap, implode('|', $packageNames));
  24265. }
  24266. }
  24267. <?php declare(strict_types=1);
  24268. namespace Composer\Package\Comparer;
  24269. use Composer\Util\Platform;
  24270. class Comparer
  24271. {
  24272. private $source;
  24273. private $update;
  24274. private $changed;
  24275. public function setSource(string $source): void
  24276. {
  24277. $this->source = $source;
  24278. }
  24279. public function setUpdate(string $update): void
  24280. {
  24281. $this->update = $update;
  24282. }
  24283. public function getChanged(bool $explicated = false)
  24284. {
  24285. $changed = $this->changed;
  24286. if (!count($changed)) {
  24287. return false;
  24288. }
  24289. if ($explicated) {
  24290. foreach ($changed as $sectionKey => $itemSection) {
  24291. foreach ($itemSection as $itemKey => $item) {
  24292. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  24293. }
  24294. }
  24295. }
  24296. return $changed;
  24297. }
  24298. public function getChangedAsString(bool $toString = false, bool $explicated = false): string
  24299. {
  24300. $changed = $this->getChanged($explicated);
  24301. if (false === $changed) {
  24302. return '';
  24303. }
  24304. $strings = [];
  24305. foreach ($changed as $sectionKey => $itemSection) {
  24306. foreach ($itemSection as $itemKey => $item) {
  24307. $strings[] = $item."\r\n";
  24308. }
  24309. }
  24310. return trim(implode("\r\n", $strings));
  24311. }
  24312. public function doCompare(): void
  24313. {
  24314. $source = [];
  24315. $destination = [];
  24316. $this->changed = [];
  24317. $currentDirectory = Platform::getCwd();
  24318. chdir($this->source);
  24319. $source = $this->doTree('.', $source);
  24320. if (!is_array($source)) {
  24321. return;
  24322. }
  24323. chdir($currentDirectory);
  24324. chdir($this->update);
  24325. $destination = $this->doTree('.', $destination);
  24326. if (!is_array($destination)) {
  24327. exit;
  24328. }
  24329. chdir($currentDirectory);
  24330. foreach ($source as $dir => $value) {
  24331. foreach ($value as $file => $hash) {
  24332. if (isset($destination[$dir][$file])) {
  24333. if ($hash !== $destination[$dir][$file]) {
  24334. $this->changed['changed'][] = $dir.'/'.$file;
  24335. }
  24336. } else {
  24337. $this->changed['removed'][] = $dir.'/'.$file;
  24338. }
  24339. }
  24340. }
  24341. foreach ($destination as $dir => $value) {
  24342. foreach ($value as $file => $hash) {
  24343. if (!isset($source[$dir][$file])) {
  24344. $this->changed['added'][] = $dir.'/'.$file;
  24345. }
  24346. }
  24347. }
  24348. }
  24349. private function doTree(string $dir, array &$array)
  24350. {
  24351. if ($dh = opendir($dir)) {
  24352. while ($file = readdir($dh)) {
  24353. if ($file !== '.' && $file !== '..') {
  24354. if (is_link($dir.'/'.$file)) {
  24355. $array[$dir][$file] = readlink($dir.'/'.$file);
  24356. } elseif (is_dir($dir.'/'.$file)) {
  24357. if (!count($array)) {
  24358. $array[0] = 'Temp';
  24359. }
  24360. if (!$this->doTree($dir.'/'.$file, $array)) {
  24361. return false;
  24362. }
  24363. } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) {
  24364. $array[$dir][$file] = hash_file(\PHP_VERSION_ID > 80100 ? 'xxh3' : 'sha1', $dir.'/'.$file);
  24365. }
  24366. }
  24367. }
  24368. if (count($array) > 1 && isset($array['0'])) {
  24369. unset($array['0']);
  24370. }
  24371. return $array;
  24372. }
  24373. return false;
  24374. }
  24375. }
  24376. <?php declare(strict_types=1);
  24377. namespace Composer\Package;
  24378. class CompleteAliasPackage extends AliasPackage implements CompletePackageInterface
  24379. {
  24380. protected $aliasOf;
  24381. public function __construct(CompletePackage $aliasOf, string $version, string $prettyVersion)
  24382. {
  24383. parent::__construct($aliasOf, $version, $prettyVersion);
  24384. }
  24385. public function getAliasOf()
  24386. {
  24387. return $this->aliasOf;
  24388. }
  24389. public function getScripts(): array
  24390. {
  24391. return $this->aliasOf->getScripts();
  24392. }
  24393. public function setScripts(array $scripts): void
  24394. {
  24395. $this->aliasOf->setScripts($scripts);
  24396. }
  24397. public function getRepositories(): array
  24398. {
  24399. return $this->aliasOf->getRepositories();
  24400. }
  24401. public function setRepositories(array $repositories): void
  24402. {
  24403. $this->aliasOf->setRepositories($repositories);
  24404. }
  24405. public function getLicense(): array
  24406. {
  24407. return $this->aliasOf->getLicense();
  24408. }
  24409. public function setLicense(array $license): void
  24410. {
  24411. $this->aliasOf->setLicense($license);
  24412. }
  24413. public function getKeywords(): array
  24414. {
  24415. return $this->aliasOf->getKeywords();
  24416. }
  24417. public function setKeywords(array $keywords): void
  24418. {
  24419. $this->aliasOf->setKeywords($keywords);
  24420. }
  24421. public function getDescription(): ?string
  24422. {
  24423. return $this->aliasOf->getDescription();
  24424. }
  24425. public function setDescription(?string $description): void
  24426. {
  24427. $this->aliasOf->setDescription($description);
  24428. }
  24429. public function getHomepage(): ?string
  24430. {
  24431. return $this->aliasOf->getHomepage();
  24432. }
  24433. public function setHomepage(?string $homepage): void
  24434. {
  24435. $this->aliasOf->setHomepage($homepage);
  24436. }
  24437. public function getAuthors(): array
  24438. {
  24439. return $this->aliasOf->getAuthors();
  24440. }
  24441. public function setAuthors(array $authors): void
  24442. {
  24443. $this->aliasOf->setAuthors($authors);
  24444. }
  24445. public function getSupport(): array
  24446. {
  24447. return $this->aliasOf->getSupport();
  24448. }
  24449. public function setSupport(array $support): void
  24450. {
  24451. $this->aliasOf->setSupport($support);
  24452. }
  24453. public function getFunding(): array
  24454. {
  24455. return $this->aliasOf->getFunding();
  24456. }
  24457. public function setFunding(array $funding): void
  24458. {
  24459. $this->aliasOf->setFunding($funding);
  24460. }
  24461. public function isAbandoned(): bool
  24462. {
  24463. return $this->aliasOf->isAbandoned();
  24464. }
  24465. public function getReplacementPackage(): ?string
  24466. {
  24467. return $this->aliasOf->getReplacementPackage();
  24468. }
  24469. public function setAbandoned($abandoned): void
  24470. {
  24471. $this->aliasOf->setAbandoned($abandoned);
  24472. }
  24473. public function getArchiveName(): ?string
  24474. {
  24475. return $this->aliasOf->getArchiveName();
  24476. }
  24477. public function setArchiveName(?string $name): void
  24478. {
  24479. $this->aliasOf->setArchiveName($name);
  24480. }
  24481. public function getArchiveExcludes(): array
  24482. {
  24483. return $this->aliasOf->getArchiveExcludes();
  24484. }
  24485. public function setArchiveExcludes(array $excludes): void
  24486. {
  24487. $this->aliasOf->setArchiveExcludes($excludes);
  24488. }
  24489. }
  24490. <?php declare(strict_types=1);
  24491. namespace Composer\Package;
  24492. class CompletePackage extends Package implements CompletePackageInterface
  24493. {
  24494. protected $repositories = [];
  24495. protected $license = [];
  24496. protected $keywords = [];
  24497. protected $authors = [];
  24498. protected $description = null;
  24499. protected $homepage = null;
  24500. protected $scripts = [];
  24501. protected $support = [];
  24502. protected $funding = [];
  24503. protected $abandoned = false;
  24504. protected $archiveName = null;
  24505. protected $archiveExcludes = [];
  24506. public function setScripts(array $scripts): void
  24507. {
  24508. $this->scripts = $scripts;
  24509. }
  24510. public function getScripts(): array
  24511. {
  24512. return $this->scripts;
  24513. }
  24514. public function setRepositories(array $repositories): void
  24515. {
  24516. $this->repositories = $repositories;
  24517. }
  24518. public function getRepositories(): array
  24519. {
  24520. return $this->repositories;
  24521. }
  24522. public function setLicense(array $license): void
  24523. {
  24524. $this->license = $license;
  24525. }
  24526. public function getLicense(): array
  24527. {
  24528. return $this->license;
  24529. }
  24530. public function setKeywords(array $keywords): void
  24531. {
  24532. $this->keywords = $keywords;
  24533. }
  24534. public function getKeywords(): array
  24535. {
  24536. return $this->keywords;
  24537. }
  24538. public function setAuthors(array $authors): void
  24539. {
  24540. $this->authors = $authors;
  24541. }
  24542. public function getAuthors(): array
  24543. {
  24544. return $this->authors;
  24545. }
  24546. public function setDescription(?string $description): void
  24547. {
  24548. $this->description = $description;
  24549. }
  24550. public function getDescription(): ?string
  24551. {
  24552. return $this->description;
  24553. }
  24554. public function setHomepage(?string $homepage): void
  24555. {
  24556. $this->homepage = $homepage;
  24557. }
  24558. public function getHomepage(): ?string
  24559. {
  24560. return $this->homepage;
  24561. }
  24562. public function setSupport(array $support): void
  24563. {
  24564. $this->support = $support;
  24565. }
  24566. public function getSupport(): array
  24567. {
  24568. return $this->support;
  24569. }
  24570. public function setFunding(array $funding): void
  24571. {
  24572. $this->funding = $funding;
  24573. }
  24574. public function getFunding(): array
  24575. {
  24576. return $this->funding;
  24577. }
  24578. public function isAbandoned(): bool
  24579. {
  24580. return (bool) $this->abandoned;
  24581. }
  24582. public function setAbandoned($abandoned): void
  24583. {
  24584. $this->abandoned = $abandoned;
  24585. }
  24586. public function getReplacementPackage(): ?string
  24587. {
  24588. return \is_string($this->abandoned) ? $this->abandoned : null;
  24589. }
  24590. public function setArchiveName(?string $name): void
  24591. {
  24592. $this->archiveName = $name;
  24593. }
  24594. public function getArchiveName(): ?string
  24595. {
  24596. return $this->archiveName;
  24597. }
  24598. public function setArchiveExcludes(array $excludes): void
  24599. {
  24600. $this->archiveExcludes = $excludes;
  24601. }
  24602. public function getArchiveExcludes(): array
  24603. {
  24604. return $this->archiveExcludes;
  24605. }
  24606. }
  24607. <?php declare(strict_types=1);
  24608. namespace Composer\Package;
  24609. interface CompletePackageInterface extends PackageInterface
  24610. {
  24611. public function getScripts(): array;
  24612. public function setScripts(array $scripts): void;
  24613. public function getRepositories(): array;
  24614. public function setRepositories(array $repositories): void;
  24615. public function getLicense(): array;
  24616. public function setLicense(array $license): void;
  24617. public function getKeywords(): array;
  24618. public function setKeywords(array $keywords): void;
  24619. public function getDescription(): ?string;
  24620. public function setDescription(string $description): void;
  24621. public function getHomepage(): ?string;
  24622. public function setHomepage(string $homepage): void;
  24623. public function getAuthors(): array;
  24624. public function setAuthors(array $authors): void;
  24625. public function getSupport(): array;
  24626. public function setSupport(array $support): void;
  24627. public function getFunding(): array;
  24628. public function setFunding(array $funding): void;
  24629. public function isAbandoned(): bool;
  24630. public function getReplacementPackage(): ?string;
  24631. public function setAbandoned($abandoned): void;
  24632. public function getArchiveName(): ?string;
  24633. public function setArchiveName(string $name): void;
  24634. public function getArchiveExcludes(): array;
  24635. public function setArchiveExcludes(array $excludes): void;
  24636. }
  24637. <?php declare(strict_types=1);
  24638. namespace Composer\Package\Dumper;
  24639. use Composer\Package\BasePackage;
  24640. use Composer\Package\PackageInterface;
  24641. use Composer\Package\CompletePackageInterface;
  24642. use Composer\Package\RootPackageInterface;
  24643. class ArrayDumper
  24644. {
  24645. public function dump(PackageInterface $package): array
  24646. {
  24647. $keys = [
  24648. 'binaries' => 'bin',
  24649. 'type',
  24650. 'extra',
  24651. 'installationSource' => 'installation-source',
  24652. 'autoload',
  24653. 'devAutoload' => 'autoload-dev',
  24654. 'notificationUrl' => 'notification-url',
  24655. 'includePaths' => 'include-path',
  24656. 'phpExt' => 'php-ext',
  24657. ];
  24658. $data = [];
  24659. $data['name'] = $package->getPrettyName();
  24660. $data['version'] = $package->getPrettyVersion();
  24661. $data['version_normalized'] = $package->getVersion();
  24662. if ($package->getTargetDir() !== null) {
  24663. $data['target-dir'] = $package->getTargetDir();
  24664. }
  24665. if ($package->getSourceType() !== null) {
  24666. $data['source']['type'] = $package->getSourceType();
  24667. $data['source']['url'] = $package->getSourceUrl();
  24668. if (null !== ($value = $package->getSourceReference())) {
  24669. $data['source']['reference'] = $value;
  24670. }
  24671. if ($mirrors = $package->getSourceMirrors()) {
  24672. $data['source']['mirrors'] = $mirrors;
  24673. }
  24674. }
  24675. if ($package->getDistType() !== null) {
  24676. $data['dist']['type'] = $package->getDistType();
  24677. $data['dist']['url'] = $package->getDistUrl();
  24678. if (null !== ($value = $package->getDistReference())) {
  24679. $data['dist']['reference'] = $value;
  24680. }
  24681. if (null !== ($value = $package->getDistSha1Checksum())) {
  24682. $data['dist']['shasum'] = $value;
  24683. }
  24684. if ($mirrors = $package->getDistMirrors()) {
  24685. $data['dist']['mirrors'] = $mirrors;
  24686. }
  24687. }
  24688. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  24689. $links = $package->{'get'.ucfirst($opts['method'])}();
  24690. if (\count($links) === 0) {
  24691. continue;
  24692. }
  24693. foreach ($links as $link) {
  24694. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  24695. }
  24696. ksort($data[$type]);
  24697. }
  24698. $packages = $package->getSuggests();
  24699. if (\count($packages) > 0) {
  24700. ksort($packages);
  24701. $data['suggest'] = $packages;
  24702. }
  24703. if ($package->getReleaseDate() instanceof \DateTimeInterface) {
  24704. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  24705. }
  24706. if ($package->isDefaultBranch()) {
  24707. $data['default-branch'] = true;
  24708. }
  24709. $data = $this->dumpValues($package, $keys, $data);
  24710. if ($package instanceof CompletePackageInterface) {
  24711. if ($package->getArchiveName()) {
  24712. $data['archive']['name'] = $package->getArchiveName();
  24713. }
  24714. if ($package->getArchiveExcludes()) {
  24715. $data['archive']['exclude'] = $package->getArchiveExcludes();
  24716. }
  24717. $keys = [
  24718. 'scripts',
  24719. 'license',
  24720. 'authors',
  24721. 'description',
  24722. 'homepage',
  24723. 'keywords',
  24724. 'repositories',
  24725. 'support',
  24726. 'funding',
  24727. ];
  24728. $data = $this->dumpValues($package, $keys, $data);
  24729. if (isset($data['keywords']) && \is_array($data['keywords'])) {
  24730. sort($data['keywords']);
  24731. }
  24732. if ($package->isAbandoned()) {
  24733. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  24734. }
  24735. }
  24736. if ($package instanceof RootPackageInterface) {
  24737. $minimumStability = $package->getMinimumStability();
  24738. if ($minimumStability !== '') {
  24739. $data['minimum-stability'] = $minimumStability;
  24740. }
  24741. }
  24742. if (\count($package->getTransportOptions()) > 0) {
  24743. $data['transport-options'] = $package->getTransportOptions();
  24744. }
  24745. return $data;
  24746. }
  24747. private function dumpValues(PackageInterface $package, array $keys, array $data): array
  24748. {
  24749. foreach ($keys as $method => $key) {
  24750. if (is_numeric($method)) {
  24751. $method = $key;
  24752. }
  24753. $getter = 'get'.ucfirst($method);
  24754. $value = $package->{$getter}();
  24755. if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
  24756. $data[$key] = $value;
  24757. }
  24758. }
  24759. return $data;
  24760. }
  24761. }
  24762. <?php declare(strict_types=1);
  24763. namespace Composer\Package;
  24764. use Composer\Semver\Constraint\ConstraintInterface;
  24765. class Link
  24766. {
  24767. public const TYPE_REQUIRE = 'requires';
  24768. public const TYPE_DEV_REQUIRE = 'devRequires';
  24769. public const TYPE_PROVIDE = 'provides';
  24770. public const TYPE_CONFLICT = 'conflicts';
  24771. public const TYPE_REPLACE = 'replaces';
  24772. public const TYPE_DOES_NOT_REQUIRE = 'does not require';
  24773. private const TYPE_UNKNOWN = 'relates to';
  24774. public static $TYPES = [
  24775. self::TYPE_REQUIRE,
  24776. self::TYPE_DEV_REQUIRE,
  24777. self::TYPE_PROVIDE,
  24778. self::TYPE_CONFLICT,
  24779. self::TYPE_REPLACE,
  24780. ];
  24781. protected $source;
  24782. protected $target;
  24783. protected $constraint;
  24784. protected $description;
  24785. protected $prettyConstraint;
  24786. public function __construct(
  24787. string $source,
  24788. string $target,
  24789. ConstraintInterface $constraint,
  24790. $description = self::TYPE_UNKNOWN,
  24791. ?string $prettyConstraint = null
  24792. ) {
  24793. $this->source = strtolower($source);
  24794. $this->target = strtolower($target);
  24795. $this->constraint = $constraint;
  24796. $this->description = self::TYPE_DEV_REQUIRE === $description ? 'requires (for development)' : $description;
  24797. $this->prettyConstraint = $prettyConstraint;
  24798. }
  24799. public function getDescription(): string
  24800. {
  24801. return $this->description;
  24802. }
  24803. public function getSource(): string
  24804. {
  24805. return $this->source;
  24806. }
  24807. public function getTarget(): string
  24808. {
  24809. return $this->target;
  24810. }
  24811. public function getConstraint(): ConstraintInterface
  24812. {
  24813. return $this->constraint;
  24814. }
  24815. public function getPrettyConstraint(): string
  24816. {
  24817. if (null === $this->prettyConstraint) {
  24818. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  24819. }
  24820. return $this->prettyConstraint;
  24821. }
  24822. public function __toString(): string
  24823. {
  24824. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  24825. }
  24826. public function getPrettyString(PackageInterface $sourcePackage): string
  24827. {
  24828. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.' '.$this->constraint->getPrettyString();
  24829. }
  24830. }
  24831. <?php declare(strict_types=1);
  24832. namespace Composer\Package\Loader;
  24833. use Composer\Package\BasePackage;
  24834. use Composer\Package\CompleteAliasPackage;
  24835. use Composer\Package\CompletePackage;
  24836. use Composer\Package\RootPackage;
  24837. use Composer\Package\PackageInterface;
  24838. use Composer\Package\CompletePackageInterface;
  24839. use Composer\Package\Link;
  24840. use Composer\Package\RootAliasPackage;
  24841. use Composer\Package\Version\VersionParser;
  24842. use Composer\Pcre\Preg;
  24843. class ArrayLoader implements LoaderInterface
  24844. {
  24845. protected $versionParser;
  24846. protected $loadOptions;
  24847. public function __construct(?VersionParser $parser = null, bool $loadOptions = false)
  24848. {
  24849. if (!$parser) {
  24850. $parser = new VersionParser;
  24851. }
  24852. $this->versionParser = $parser;
  24853. $this->loadOptions = $loadOptions;
  24854. }
  24855. public function load(array $config, string $class = 'Composer\Package\CompletePackage'): BasePackage
  24856. {
  24857. if ($class !== 'Composer\Package\CompletePackage' && $class !== 'Composer\Package\RootPackage') {
  24858. trigger_error('The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.', E_USER_DEPRECATED);
  24859. }
  24860. $package = $this->createObject($config, $class);
  24861. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  24862. if (!isset($config[$type]) || !is_array($config[$type])) {
  24863. continue;
  24864. }
  24865. $method = 'set'.ucfirst($opts['method']);
  24866. $package->{$method}(
  24867. $this->parseLinks(
  24868. $package->getName(),
  24869. $package->getPrettyVersion(),
  24870. $opts['method'],
  24871. $config[$type]
  24872. )
  24873. );
  24874. }
  24875. $package = $this->configureObject($package, $config);
  24876. return $package;
  24877. }
  24878. public function loadPackages(array $versions): array
  24879. {
  24880. $packages = [];
  24881. $linkCache = [];
  24882. foreach ($versions as $version) {
  24883. $package = $this->createObject($version, 'Composer\Package\CompletePackage');
  24884. $this->configureCachedLinks($linkCache, $package, $version);
  24885. $package = $this->configureObject($package, $version);
  24886. $packages[] = $package;
  24887. }
  24888. return $packages;
  24889. }
  24890. private function createObject(array $config, string $class): CompletePackage
  24891. {
  24892. if (!isset($config['name'])) {
  24893. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  24894. }
  24895. if (!isset($config['version']) || !is_scalar($config['version'])) {
  24896. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  24897. }
  24898. if (!is_string($config['version'])) {
  24899. $config['version'] = (string) $config['version'];
  24900. }
  24901. if (isset($config['version_normalized']) && is_string($config['version_normalized'])) {
  24902. $version = $config['version_normalized'];
  24903. if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
  24904. $version = $this->versionParser->normalize($config['version']);
  24905. }
  24906. } else {
  24907. $version = $this->versionParser->normalize($config['version']);
  24908. }
  24909. return new $class($config['name'], $version, $config['version']);
  24910. }
  24911. private function configureObject(PackageInterface $package, array $config): BasePackage
  24912. {
  24913. if (!$package instanceof CompletePackage) {
  24914. throw new \LogicException('ArrayLoader expects instances of the Composer\Package\CompletePackage class to function correctly');
  24915. }
  24916. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  24917. if (isset($config['target-dir'])) {
  24918. $package->setTargetDir($config['target-dir']);
  24919. }
  24920. if (isset($config['extra']) && \is_array($config['extra'])) {
  24921. $package->setExtra($config['extra']);
  24922. }
  24923. if (isset($config['bin'])) {
  24924. if (!\is_array($config['bin'])) {
  24925. $config['bin'] = [$config['bin']];
  24926. }
  24927. foreach ($config['bin'] as $key => $bin) {
  24928. $config['bin'][$key] = ltrim($bin, '/');
  24929. }
  24930. $package->setBinaries($config['bin']);
  24931. }
  24932. if (isset($config['installation-source'])) {
  24933. $package->setInstallationSource($config['installation-source']);
  24934. }
  24935. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  24936. $package->setIsDefaultBranch(true);
  24937. }
  24938. if (isset($config['source'])) {
  24939. if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
  24940. throw new \UnexpectedValueException(sprintf(
  24941. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  24942. $config['name'],
  24943. json_encode($config['source'])
  24944. ));
  24945. }
  24946. $package->setSourceType($config['source']['type']);
  24947. $package->setSourceUrl($config['source']['url']);
  24948. $package->setSourceReference(isset($config['source']['reference']) ? (string) $config['source']['reference'] : null);
  24949. if (isset($config['source']['mirrors'])) {
  24950. $package->setSourceMirrors($config['source']['mirrors']);
  24951. }
  24952. }
  24953. if (isset($config['dist'])) {
  24954. if (!isset($config['dist']['type'], $config['dist']['url'])) {
  24955. throw new \UnexpectedValueException(sprintf(
  24956. "Package %s's dist key should be specified as ".
  24957. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  24958. $config['name'],
  24959. json_encode($config['dist'])
  24960. ));
  24961. }
  24962. $package->setDistType($config['dist']['type']);
  24963. $package->setDistUrl($config['dist']['url']);
  24964. $package->setDistReference(isset($config['dist']['reference']) ? (string) $config['dist']['reference'] : null);
  24965. $package->setDistSha1Checksum($config['dist']['shasum'] ?? null);
  24966. if (isset($config['dist']['mirrors'])) {
  24967. $package->setDistMirrors($config['dist']['mirrors']);
  24968. }
  24969. }
  24970. if (isset($config['suggest']) && \is_array($config['suggest'])) {
  24971. foreach ($config['suggest'] as $target => $reason) {
  24972. if ('self.version' === trim($reason)) {
  24973. $config['suggest'][$target] = $package->getPrettyVersion();
  24974. }
  24975. }
  24976. $package->setSuggests($config['suggest']);
  24977. }
  24978. if (isset($config['autoload'])) {
  24979. $package->setAutoload($config['autoload']);
  24980. }
  24981. if (isset($config['autoload-dev'])) {
  24982. $package->setDevAutoload($config['autoload-dev']);
  24983. }
  24984. if (isset($config['include-path'])) {
  24985. $package->setIncludePaths($config['include-path']);
  24986. }
  24987. if (isset($config['php-ext'])) {
  24988. $package->setPhpExt($config['php-ext']);
  24989. }
  24990. if (!empty($config['time'])) {
  24991. $time = Preg::isMatch('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  24992. try {
  24993. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  24994. $package->setReleaseDate($date);
  24995. } catch (\Exception $e) {
  24996. }
  24997. }
  24998. if (!empty($config['notification-url'])) {
  24999. $package->setNotificationUrl($config['notification-url']);
  25000. }
  25001. if ($package instanceof CompletePackageInterface) {
  25002. if (!empty($config['archive']['name'])) {
  25003. $package->setArchiveName($config['archive']['name']);
  25004. }
  25005. if (!empty($config['archive']['exclude'])) {
  25006. $package->setArchiveExcludes($config['archive']['exclude']);
  25007. }
  25008. if (isset($config['scripts']) && \is_array($config['scripts'])) {
  25009. foreach ($config['scripts'] as $event => $listeners) {
  25010. $config['scripts'][$event] = (array) $listeners;
  25011. }
  25012. foreach (['composer', 'php', 'putenv'] as $reserved) {
  25013. if (isset($config['scripts'][$reserved])) {
  25014. trigger_error('The `'.$reserved.'` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  25015. }
  25016. }
  25017. $package->setScripts($config['scripts']);
  25018. }
  25019. if (!empty($config['description']) && \is_string($config['description'])) {
  25020. $package->setDescription($config['description']);
  25021. }
  25022. if (!empty($config['homepage']) && \is_string($config['homepage'])) {
  25023. $package->setHomepage($config['homepage']);
  25024. }
  25025. if (!empty($config['keywords']) && \is_array($config['keywords'])) {
  25026. $package->setKeywords(array_map('strval', $config['keywords']));
  25027. }
  25028. if (!empty($config['license'])) {
  25029. $package->setLicense(\is_array($config['license']) ? $config['license'] : [$config['license']]);
  25030. }
  25031. if (!empty($config['authors']) && \is_array($config['authors'])) {
  25032. $package->setAuthors($config['authors']);
  25033. }
  25034. if (isset($config['support']) && \is_array($config['support'])) {
  25035. $package->setSupport($config['support']);
  25036. }
  25037. if (!empty($config['funding']) && \is_array($config['funding'])) {
  25038. $package->setFunding($config['funding']);
  25039. }
  25040. if (isset($config['abandoned'])) {
  25041. $package->setAbandoned($config['abandoned']);
  25042. }
  25043. }
  25044. if ($this->loadOptions && isset($config['transport-options'])) {
  25045. $package->setTransportOptions($config['transport-options']);
  25046. }
  25047. if ($aliasNormalized = $this->getBranchAlias($config)) {
  25048. $prettyAlias = Preg::replace('{(\.9{7})+}', '.x', $aliasNormalized);
  25049. if ($package instanceof RootPackage) {
  25050. return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
  25051. }
  25052. return new CompleteAliasPackage($package, $aliasNormalized, $prettyAlias);
  25053. }
  25054. return $package;
  25055. }
  25056. private function configureCachedLinks(array &$linkCache, PackageInterface $package, array $config): void
  25057. {
  25058. $name = $package->getName();
  25059. $prettyVersion = $package->getPrettyVersion();
  25060. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  25061. if (isset($config[$type])) {
  25062. $method = 'set'.ucfirst($opts['method']);
  25063. $links = [];
  25064. foreach ($config[$type] as $prettyTarget => $constraint) {
  25065. $target = strtolower($prettyTarget);
  25066. if ($target === $name) {
  25067. continue;
  25068. }
  25069. if ($constraint === 'self.version') {
  25070. $links[$target] = $this->createLink($name, $prettyVersion, $opts['method'], $target, $constraint);
  25071. } else {
  25072. if (!isset($linkCache[$name][$type][$target][$constraint])) {
  25073. $linkCache[$name][$type][$target][$constraint] = [$target, $this->createLink($name, $prettyVersion, $opts['method'], $target, $constraint)];
  25074. }
  25075. [$target, $link] = $linkCache[$name][$type][$target][$constraint];
  25076. $links[$target] = $link;
  25077. }
  25078. }
  25079. $package->{$method}($links);
  25080. }
  25081. }
  25082. }
  25083. public function parseLinks(string $source, string $sourceVersion, string $description, array $links): array
  25084. {
  25085. $res = [];
  25086. foreach ($links as $target => $constraint) {
  25087. if (!is_string($constraint)) {
  25088. continue;
  25089. }
  25090. $target = strtolower((string) $target);
  25091. $res[$target] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
  25092. }
  25093. return $res;
  25094. }
  25095. private function createLink(string $source, string $sourceVersion, string $description, string $target, string $prettyConstraint): Link
  25096. {
  25097. if (!\is_string($prettyConstraint)) {
  25098. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
  25099. }
  25100. if ('self.version' === $prettyConstraint) {
  25101. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  25102. } else {
  25103. $parsedConstraint = $this->versionParser->parseConstraints($prettyConstraint);
  25104. }
  25105. return new Link($source, $target, $parsedConstraint, $description, $prettyConstraint);
  25106. }
  25107. public function getBranchAlias(array $config): ?string
  25108. {
  25109. if (!isset($config['version']) || !is_scalar($config['version'])) {
  25110. throw new \UnexpectedValueException('no/invalid version defined');
  25111. }
  25112. if (!is_string($config['version'])) {
  25113. $config['version'] = (string) $config['version'];
  25114. }
  25115. if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
  25116. return null;
  25117. }
  25118. if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
  25119. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  25120. $sourceBranch = (string) $sourceBranch;
  25121. if ('-dev' !== substr($targetBranch, -4)) {
  25122. continue;
  25123. }
  25124. if ($targetBranch === VersionParser::DEFAULT_BRANCH_ALIAS) {
  25125. $validatedTargetBranch = VersionParser::DEFAULT_BRANCH_ALIAS;
  25126. } else {
  25127. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  25128. }
  25129. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  25130. continue;
  25131. }
  25132. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  25133. continue;
  25134. }
  25135. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  25136. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  25137. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  25138. ) {
  25139. continue;
  25140. }
  25141. return $validatedTargetBranch;
  25142. }
  25143. }
  25144. if (
  25145. isset($config['default-branch'])
  25146. && $config['default-branch'] === true
  25147. && false === $this->versionParser->parseNumericAliasPrefix(Preg::replace('{^v}', '', $config['version']))
  25148. ) {
  25149. return VersionParser::DEFAULT_BRANCH_ALIAS;
  25150. }
  25151. return null;
  25152. }
  25153. }
  25154. <?php declare(strict_types=1);
  25155. namespace Composer\Package\Loader;
  25156. class InvalidPackageException extends \Exception
  25157. {
  25158. private $errors;
  25159. private $warnings;
  25160. private $data;
  25161. public function __construct(array $errors, array $warnings, array $data)
  25162. {
  25163. $this->errors = $errors;
  25164. $this->warnings = $warnings;
  25165. $this->data = $data;
  25166. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  25167. }
  25168. public function getData(): array
  25169. {
  25170. return $this->data;
  25171. }
  25172. public function getErrors(): array
  25173. {
  25174. return $this->errors;
  25175. }
  25176. public function getWarnings(): array
  25177. {
  25178. return $this->warnings;
  25179. }
  25180. }
  25181. <?php declare(strict_types=1);
  25182. namespace Composer\Package\Loader;
  25183. use Composer\Json\JsonFile;
  25184. use Composer\Package\BasePackage;
  25185. use Composer\Package\CompletePackage;
  25186. use Composer\Package\CompleteAliasPackage;
  25187. use Composer\Package\RootPackage;
  25188. use Composer\Package\RootAliasPackage;
  25189. class JsonLoader
  25190. {
  25191. private $loader;
  25192. public function __construct(LoaderInterface $loader)
  25193. {
  25194. $this->loader = $loader;
  25195. }
  25196. public function load($json): BasePackage
  25197. {
  25198. if ($json instanceof JsonFile) {
  25199. $config = $json->read();
  25200. } elseif (file_exists($json)) {
  25201. $config = JsonFile::parseJson(file_get_contents($json), $json);
  25202. } elseif (is_string($json)) {
  25203. $config = JsonFile::parseJson($json);
  25204. } else {
  25205. throw new \InvalidArgumentException(sprintf(
  25206. "JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.",
  25207. gettype($json)
  25208. ));
  25209. }
  25210. return $this->loader->load($config);
  25211. }
  25212. }
  25213. <?php declare(strict_types=1);
  25214. namespace Composer\Package\Loader;
  25215. use Composer\Package\CompletePackage;
  25216. use Composer\Package\CompleteAliasPackage;
  25217. use Composer\Package\RootAliasPackage;
  25218. use Composer\Package\RootPackage;
  25219. use Composer\Package\BasePackage;
  25220. interface LoaderInterface
  25221. {
  25222. public function load(array $config, string $class = 'Composer\Package\CompletePackage'): BasePackage;
  25223. }
  25224. <?php declare(strict_types=1);
  25225. namespace Composer\Package\Loader;
  25226. use Composer\Package\BasePackage;
  25227. use Composer\Config;
  25228. use Composer\IO\IOInterface;
  25229. use Composer\Package\RootAliasPackage;
  25230. use Composer\Pcre\Preg;
  25231. use Composer\Repository\RepositoryFactory;
  25232. use Composer\Package\Version\VersionGuesser;
  25233. use Composer\Package\Version\VersionParser;
  25234. use Composer\Package\RootPackage;
  25235. use Composer\Repository\RepositoryManager;
  25236. use Composer\Util\Platform;
  25237. use Composer\Util\ProcessExecutor;
  25238. class RootPackageLoader extends ArrayLoader
  25239. {
  25240. private $manager;
  25241. private $config;
  25242. private $versionGuesser;
  25243. private $io;
  25244. public function __construct(RepositoryManager $manager, Config $config, ?VersionParser $parser = null, ?VersionGuesser $versionGuesser = null, ?IOInterface $io = null)
  25245. {
  25246. parent::__construct($parser);
  25247. $this->manager = $manager;
  25248. $this->config = $config;
  25249. if (null === $versionGuesser) {
  25250. $processExecutor = new ProcessExecutor($io);
  25251. $processExecutor->enableAsync();
  25252. $versionGuesser = new VersionGuesser($config, $processExecutor, $this->versionParser);
  25253. }
  25254. $this->versionGuesser = $versionGuesser;
  25255. $this->io = $io;
  25256. }
  25257. public function load(array $config, string $class = 'Composer\Package\RootPackage', ?string $cwd = null): BasePackage
  25258. {
  25259. if ($class !== 'Composer\Package\RootPackage') {
  25260. trigger_error('The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.', E_USER_DEPRECATED);
  25261. }
  25262. if (!isset($config['name'])) {
  25263. $config['name'] = '__root__';
  25264. } elseif ($err = ValidatingArrayLoader::hasPackageNamingError($config['name'])) {
  25265. throw new \RuntimeException('Your package name '.$err);
  25266. }
  25267. $autoVersioned = false;
  25268. if (!isset($config['version'])) {
  25269. $commit = null;
  25270. if (Platform::getEnv('COMPOSER_ROOT_VERSION')) {
  25271. $config['version'] = $this->versionGuesser->getRootVersionFromEnv();
  25272. } else {
  25273. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?? Platform::getCwd(true));
  25274. if ($versionData) {
  25275. $config['version'] = $versionData['pretty_version'];
  25276. $config['version_normalized'] = $versionData['version'];
  25277. $commit = $versionData['commit'];
  25278. }
  25279. }
  25280. if (!isset($config['version'])) {
  25281. if ($this->io !== null && $config['name'] !== '__root__' && 'project' !== ($config['type'] ?? '')) {
  25282. $this->io->warning(
  25283. sprintf(
  25284. "Composer could not detect the root package (%s) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version",
  25285. $config['name']
  25286. )
  25287. );
  25288. }
  25289. $config['version'] = '1.0.0';
  25290. $autoVersioned = true;
  25291. }
  25292. if ($commit) {
  25293. $config['source'] = [
  25294. 'type' => '',
  25295. 'url' => '',
  25296. 'reference' => $commit,
  25297. ];
  25298. $config['dist'] = [
  25299. 'type' => '',
  25300. 'url' => '',
  25301. 'reference' => $commit,
  25302. ];
  25303. }
  25304. }
  25305. $package = parent::load($config, $class);
  25306. if ($package instanceof RootAliasPackage) {
  25307. $realPackage = $package->getAliasOf();
  25308. } else {
  25309. $realPackage = $package;
  25310. }
  25311. if (!$realPackage instanceof RootPackage) {
  25312. throw new \LogicException('Expecting a Composer\Package\RootPackage at this point');
  25313. }
  25314. if ($autoVersioned) {
  25315. $realPackage->replaceVersion($realPackage->getVersion(), RootPackage::DEFAULT_PRETTY_VERSION);
  25316. }
  25317. if (isset($config['minimum-stability'])) {
  25318. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  25319. }
  25320. $aliases = [];
  25321. $stabilityFlags = [];
  25322. $references = [];
  25323. foreach (['require', 'require-dev'] as $linkType) {
  25324. if (isset($config[$linkType])) {
  25325. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  25326. $method = 'get'.ucfirst($linkInfo['method']);
  25327. $links = [];
  25328. foreach ($realPackage->{$method}() as $link) {
  25329. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  25330. }
  25331. $aliases = $this->extractAliases($links, $aliases);
  25332. $stabilityFlags = self::extractStabilityFlags($links, $realPackage->getMinimumStability(), $stabilityFlags);
  25333. $references = self::extractReferences($links, $references);
  25334. if (isset($links[$config['name']])) {
  25335. throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  25336. 'Did you accidentally name your root package after an external package?', $config['name']));
  25337. }
  25338. }
  25339. }
  25340. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  25341. if (isset($config[$linkType])) {
  25342. foreach ($config[$linkType] as $linkName => $constraint) {
  25343. if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  25344. throw new \RuntimeException($linkType.'.'.$err);
  25345. }
  25346. }
  25347. }
  25348. }
  25349. $realPackage->setAliases($aliases);
  25350. $realPackage->setStabilityFlags($stabilityFlags);
  25351. $realPackage->setReferences($references);
  25352. if (isset($config['prefer-stable'])) {
  25353. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  25354. }
  25355. if (isset($config['config'])) {
  25356. $realPackage->setConfig($config['config']);
  25357. }
  25358. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  25359. foreach ($repos as $repo) {
  25360. $this->manager->addRepository($repo);
  25361. }
  25362. $realPackage->setRepositories($this->config->getRepositories());
  25363. return $package;
  25364. }
  25365. private function extractAliases(array $requires, array $aliases): array
  25366. {
  25367. foreach ($requires as $reqName => $reqVersion) {
  25368. if (Preg::isMatchStrictGroups('{(?:^|\| *|, *)([^,\s#|]+)(?:#[^ ]+)? +as +([^,\s|]+)(?:$| *\|| *,)}', $reqVersion, $match)) {
  25369. $aliases[] = [
  25370. 'package' => strtolower($reqName),
  25371. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  25372. 'alias' => $match[2],
  25373. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  25374. ];
  25375. } elseif (strpos($reqVersion, ' as ') !== false) {
  25376. throw new \UnexpectedValueException('Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". Aliases should be in the form "exact-version as other-exact-version".');
  25377. }
  25378. }
  25379. return $aliases;
  25380. }
  25381. public static function extractStabilityFlags(array $requires, string $minimumStability, array $stabilityFlags): array
  25382. {
  25383. $stabilities = BasePackage::STABILITIES;
  25384. $minimumStability = $stabilities[$minimumStability];
  25385. foreach ($requires as $reqName => $reqVersion) {
  25386. $constraints = [];
  25387. $orSplit = Preg::split('{\s*\|\|?\s*}', trim($reqVersion));
  25388. foreach ($orSplit as $orConstraint) {
  25389. $andSplit = Preg::split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  25390. foreach ($andSplit as $andConstraint) {
  25391. $constraints[] = $andConstraint;
  25392. }
  25393. }
  25394. $matched = false;
  25395. foreach ($constraints as $constraint) {
  25396. if (Preg::isMatchStrictGroups('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  25397. $name = strtolower($reqName);
  25398. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  25399. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  25400. continue;
  25401. }
  25402. $stabilityFlags[$name] = $stability;
  25403. $matched = true;
  25404. }
  25405. }
  25406. if ($matched) {
  25407. continue;
  25408. }
  25409. foreach ($constraints as $constraint) {
  25410. $reqVersion = Preg::replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  25411. if (Preg::isMatch('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  25412. $name = strtolower($reqName);
  25413. $stability = $stabilities[$stabilityName];
  25414. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  25415. continue;
  25416. }
  25417. $stabilityFlags[$name] = $stability;
  25418. }
  25419. }
  25420. }
  25421. return $stabilityFlags;
  25422. }
  25423. public static function extractReferences(array $requires, array $references): array
  25424. {
  25425. foreach ($requires as $reqName => $reqVersion) {
  25426. $reqVersion = Preg::replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  25427. if (Preg::isMatchStrictGroups('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  25428. $name = strtolower($reqName);
  25429. $references[$name] = $match[1];
  25430. }
  25431. }
  25432. return $references;
  25433. }
  25434. }
  25435. <?php declare(strict_types=1);
  25436. namespace Composer\Package\Loader;
  25437. use Composer\Package\BasePackage;
  25438. use Composer\Pcre\Preg;
  25439. use Composer\Semver\Constraint\Constraint;
  25440. use Composer\Package\Version\VersionParser;
  25441. use Composer\Repository\PlatformRepository;
  25442. use Composer\Semver\Constraint\MatchNoneConstraint;
  25443. use Composer\Semver\Intervals;
  25444. use Composer\Spdx\SpdxLicenses;
  25445. class ValidatingArrayLoader implements LoaderInterface
  25446. {
  25447. public const CHECK_ALL = 3;
  25448. public const CHECK_UNBOUND_CONSTRAINTS = 1;
  25449. public const CHECK_STRICT_CONSTRAINTS = 2;
  25450. private $loader;
  25451. private $versionParser;
  25452. private $errors;
  25453. private $warnings;
  25454. private $config;
  25455. private $flags;
  25456. public function __construct(LoaderInterface $loader, bool $strictName = true, ?VersionParser $parser = null, int $flags = 0)
  25457. {
  25458. $this->loader = $loader;
  25459. $this->versionParser = $parser ?? new VersionParser();
  25460. $this->flags = $flags;
  25461. if ($strictName !== true) {
  25462. 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);
  25463. }
  25464. }
  25465. public function load(array $config, string $class = 'Composer\Package\CompletePackage'): BasePackage
  25466. {
  25467. $this->errors = [];
  25468. $this->warnings = [];
  25469. $this->config = $config;
  25470. $this->validateString('name', true);
  25471. if (isset($config['name']) && null !== ($err = self::hasPackageNamingError($config['name']))) {
  25472. $this->errors[] = 'name : '.$err;
  25473. }
  25474. if (isset($this->config['version'])) {
  25475. if (!is_scalar($this->config['version'])) {
  25476. $this->validateString('version');
  25477. } else {
  25478. if (!is_string($this->config['version'])) {
  25479. $this->config['version'] = (string) $this->config['version'];
  25480. }
  25481. try {
  25482. $this->versionParser->normalize($this->config['version']);
  25483. } catch (\Exception $e) {
  25484. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  25485. unset($this->config['version']);
  25486. }
  25487. }
  25488. }
  25489. if (isset($this->config['config']['platform'])) {
  25490. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  25491. if (false === $platform) {
  25492. continue;
  25493. }
  25494. if (!is_string($platform)) {
  25495. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.gettype($platform).' '.var_export($platform, true).'): expected string or false';
  25496. continue;
  25497. }
  25498. try {
  25499. $this->versionParser->normalize($platform);
  25500. } catch (\Exception $e) {
  25501. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  25502. }
  25503. }
  25504. }
  25505. $this->validateRegex('type', '[A-Za-z0-9-]+');
  25506. $this->validateString('target-dir');
  25507. $this->validateArray('extra');
  25508. if (isset($this->config['bin'])) {
  25509. if (is_string($this->config['bin'])) {
  25510. $this->validateString('bin');
  25511. } else {
  25512. $this->validateFlatArray('bin');
  25513. }
  25514. }
  25515. $this->validateArray('scripts');
  25516. $this->validateString('description');
  25517. $this->validateUrl('homepage');
  25518. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  25519. $releaseDate = null;
  25520. $this->validateString('time');
  25521. if (isset($this->config['time'])) {
  25522. try {
  25523. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  25524. } catch (\Exception $e) {
  25525. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  25526. unset($this->config['time']);
  25527. }
  25528. }
  25529. if (isset($this->config['license'])) {
  25530. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  25531. $licenses = (array) $this->config['license'];
  25532. foreach ($licenses as $index => $license) {
  25533. if (!is_string($license)) {
  25534. $this->warnings[] = sprintf(
  25535. 'License %s should be a string.',
  25536. json_encode($license)
  25537. );
  25538. unset($licenses[$index]);
  25539. }
  25540. }
  25541. if (null === $releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days')) {
  25542. $licenseValidator = new SpdxLicenses();
  25543. foreach ($licenses as $license) {
  25544. if ('proprietary' === $license) {
  25545. continue;
  25546. }
  25547. $licenseToValidate = str_replace('proprietary', 'MIT', $license);
  25548. if (!$licenseValidator->validate($licenseToValidate)) {
  25549. if ($licenseValidator->validate(trim($licenseToValidate))) {
  25550. $this->warnings[] = sprintf(
  25551. 'License %s must not contain extra spaces, make sure to trim it.',
  25552. json_encode($license)
  25553. );
  25554. } else {
  25555. $this->warnings[] = sprintf(
  25556. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  25557. 'If the software is closed-source, you may use "proprietary" as license.',
  25558. json_encode($license)
  25559. );
  25560. }
  25561. }
  25562. }
  25563. }
  25564. $this->config['license'] = array_values($licenses);
  25565. } else {
  25566. $this->warnings[] = sprintf(
  25567. 'License must be a string or array of strings, got %s.',
  25568. json_encode($this->config['license'])
  25569. );
  25570. unset($this->config['license']);
  25571. }
  25572. }
  25573. if ($this->validateArray('authors')) {
  25574. foreach ($this->config['authors'] as $key => $author) {
  25575. if (!is_array($author)) {
  25576. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  25577. unset($this->config['authors'][$key]);
  25578. continue;
  25579. }
  25580. foreach (['homepage', 'email', 'name', 'role'] as $authorData) {
  25581. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  25582. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  25583. unset($this->config['authors'][$key][$authorData]);
  25584. }
  25585. }
  25586. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  25587. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  25588. unset($this->config['authors'][$key]['homepage']);
  25589. }
  25590. if (isset($author['email']) && false === filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  25591. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  25592. unset($this->config['authors'][$key]['email']);
  25593. }
  25594. if (\count($this->config['authors'][$key]) === 0) {
  25595. unset($this->config['authors'][$key]);
  25596. }
  25597. }
  25598. if (\count($this->config['authors']) === 0) {
  25599. unset($this->config['authors']);
  25600. }
  25601. }
  25602. if ($this->validateArray('support') && !empty($this->config['support'])) {
  25603. foreach (['issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat', 'security'] as $key) {
  25604. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  25605. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  25606. unset($this->config['support'][$key]);
  25607. }
  25608. }
  25609. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  25610. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  25611. unset($this->config['support']['email']);
  25612. }
  25613. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], ['irc', 'ircs'])) {
  25614. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> or ircs:// URL';
  25615. unset($this->config['support']['irc']);
  25616. }
  25617. foreach (['issues', 'forum', 'wiki', 'source', 'docs', 'chat', 'security'] as $key) {
  25618. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  25619. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  25620. unset($this->config['support'][$key]);
  25621. }
  25622. }
  25623. if (empty($this->config['support'])) {
  25624. unset($this->config['support']);
  25625. }
  25626. }
  25627. if ($this->validateArray('funding') && !empty($this->config['funding'])) {
  25628. foreach ($this->config['funding'] as $key => $fundingOption) {
  25629. if (!is_array($fundingOption)) {
  25630. $this->errors[] = 'funding.'.$key.' : should be an array, '.gettype($fundingOption).' given';
  25631. unset($this->config['funding'][$key]);
  25632. continue;
  25633. }
  25634. foreach (['type', 'url'] as $fundingData) {
  25635. if (isset($fundingOption[$fundingData]) && !is_string($fundingOption[$fundingData])) {
  25636. $this->errors[] = 'funding.'.$key.'.'.$fundingData.' : invalid value, must be a string';
  25637. unset($this->config['funding'][$key][$fundingData]);
  25638. }
  25639. }
  25640. if (isset($fundingOption['url']) && !$this->filterUrl($fundingOption['url'])) {
  25641. $this->warnings[] = 'funding.'.$key.'.url : invalid value ('.$fundingOption['url'].'), must be an http/https URL';
  25642. unset($this->config['funding'][$key]['url']);
  25643. }
  25644. if (empty($this->config['funding'][$key])) {
  25645. unset($this->config['funding'][$key]);
  25646. }
  25647. }
  25648. if (empty($this->config['funding'])) {
  25649. unset($this->config['funding']);
  25650. }
  25651. }
  25652. $this->validateArray('php-ext');
  25653. if (isset($this->config['php-ext']) && !in_array($this->config['type'] ?? '', ['php-ext', 'php-ext-zend'], true)) {
  25654. $this->errors[] = 'php-ext can only be set by packages of type "php-ext" or "php-ext-zend" which must be C extensions';
  25655. unset($this->config['php-ext']);
  25656. }
  25657. $unboundConstraint = new Constraint('=', '10000000-dev');
  25658. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  25659. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  25660. foreach ($this->config[$linkType] as $package => $constraint) {
  25661. $package = (string) $package;
  25662. if (isset($this->config['name']) && 0 === strcasecmp($package, $this->config['name'])) {
  25663. $this->errors[] = $linkType.'.'.$package.' : a package cannot set a '.$linkType.' on itself';
  25664. unset($this->config[$linkType][$package]);
  25665. continue;
  25666. }
  25667. if ($err = self::hasPackageNamingError($package, true)) {
  25668. $this->warnings[] = $linkType.'.'.$err;
  25669. } elseif (!Preg::isMatch('{^[A-Za-z0-9_./-]+$}', $package)) {
  25670. $this->errors[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  25671. }
  25672. if (!is_string($constraint)) {
  25673. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  25674. unset($this->config[$linkType][$package]);
  25675. } elseif ('self.version' !== $constraint) {
  25676. try {
  25677. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  25678. } catch (\Exception $e) {
  25679. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  25680. unset($this->config[$linkType][$package]);
  25681. continue;
  25682. }
  25683. if (
  25684. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  25685. && 'require' === $linkType
  25686. && $linkConstraint->matches($unboundConstraint)
  25687. && !PlatformRepository::isPlatformPackage($package)
  25688. ) {
  25689. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  25690. } elseif (
  25691. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  25692. && 'require' === $linkType
  25693. && $linkConstraint instanceof Constraint && in_array($linkConstraint->getOperator(), ['==', '='], true)
  25694. && (new Constraint('>=', '1.0.0.0-dev'))->matches($linkConstraint)
  25695. ) {
  25696. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  25697. }
  25698. $compacted = Intervals::compactConstraint($linkConstraint);
  25699. if ($compacted instanceof MatchNoneConstraint) {
  25700. $this->warnings[] = $linkType.'.'.$package.' : this version constraint cannot possibly match anything ('.$constraint.')';
  25701. }
  25702. }
  25703. if ($linkType === 'conflict' && isset($this->config['replace']) && $keys = array_intersect_key($this->config['replace'], $this->config['conflict'])) {
  25704. $this->errors[] = $linkType.'.'.$package.' : you cannot conflict with a package that is also replaced, as replace already creates an implicit conflict rule';
  25705. unset($this->config[$linkType][$package]);
  25706. }
  25707. }
  25708. }
  25709. }
  25710. if ($this->validateArray('suggest') && isset($this->config['suggest'])) {
  25711. foreach ($this->config['suggest'] as $package => $description) {
  25712. if (!is_string($description)) {
  25713. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  25714. unset($this->config['suggest'][$package]);
  25715. }
  25716. }
  25717. }
  25718. if ($this->validateString('minimum-stability') && isset($this->config['minimum-stability'])) {
  25719. if (!isset(BasePackage::STABILITIES[strtolower($this->config['minimum-stability'])]) && $this->config['minimum-stability'] !== 'RC') {
  25720. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::STABILITIES));
  25721. unset($this->config['minimum-stability']);
  25722. }
  25723. }
  25724. if ($this->validateArray('autoload') && isset($this->config['autoload'])) {
  25725. $types = ['psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap'];
  25726. foreach ($this->config['autoload'] as $type => $typeConfig) {
  25727. if (!in_array($type, $types)) {
  25728. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  25729. unset($this->config['autoload'][$type]);
  25730. }
  25731. if ($type === 'psr-4') {
  25732. foreach ($typeConfig as $namespace => $dirs) {
  25733. if ($namespace !== '' && '\\' !== substr((string) $namespace, -1)) {
  25734. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  25735. }
  25736. }
  25737. }
  25738. }
  25739. }
  25740. if (isset($this->config['autoload']['psr-4']) && isset($this->config['target-dir'])) {
  25741. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  25742. unset($this->config['autoload']['psr-4']);
  25743. }
  25744. foreach (['source', 'dist'] as $srcType) {
  25745. if ($this->validateArray($srcType) && !empty($this->config[$srcType])) {
  25746. if (!isset($this->config[$srcType]['type'])) {
  25747. $this->errors[] = $srcType . '.type : must be present';
  25748. }
  25749. if (!isset($this->config[$srcType]['url'])) {
  25750. $this->errors[] = $srcType . '.url : must be present';
  25751. }
  25752. if ($srcType === 'source' && !isset($this->config[$srcType]['reference'])) {
  25753. $this->errors[] = $srcType . '.reference : must be present';
  25754. }
  25755. if (isset($this->config[$srcType]['type']) && !is_string($this->config[$srcType]['type'])) {
  25756. $this->errors[] = $srcType . '.type : should be a string, '.gettype($this->config[$srcType]['type']).' given';
  25757. }
  25758. if (isset($this->config[$srcType]['url']) && !is_string($this->config[$srcType]['url'])) {
  25759. $this->errors[] = $srcType . '.url : should be a string, '.gettype($this->config[$srcType]['url']).' given';
  25760. }
  25761. if (isset($this->config[$srcType]['reference']) && !is_string($this->config[$srcType]['reference']) && !is_int($this->config[$srcType]['reference'])) {
  25762. $this->errors[] = $srcType . '.reference : should be a string or int, '.gettype($this->config[$srcType]['reference']).' given';
  25763. }
  25764. if (isset($this->config[$srcType]['reference']) && Preg::isMatch('{^\s*-}', (string) $this->config[$srcType]['reference'])) {
  25765. $this->errors[] = $srcType . '.reference : must not start with a "-", "'.$this->config[$srcType]['reference'].'" given';
  25766. }
  25767. if (isset($this->config[$srcType]['url']) && Preg::isMatch('{^\s*-}', (string) $this->config[$srcType]['url'])) {
  25768. $this->errors[] = $srcType . '.url : must not start with a "-", "'.$this->config[$srcType]['url'].'" given';
  25769. }
  25770. }
  25771. }
  25772. $this->validateFlatArray('include-path');
  25773. $this->validateArray('transport-options');
  25774. if (isset($this->config['extra']['branch-alias'])) {
  25775. if (!is_array($this->config['extra']['branch-alias'])) {
  25776. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  25777. } else {
  25778. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  25779. if (!is_string($targetBranch)) {
  25780. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.json_encode($targetBranch).') must be a string, "'.gettype($targetBranch).'" received.';
  25781. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  25782. continue;
  25783. }
  25784. if ('-dev' !== substr($targetBranch, -4)) {
  25785. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  25786. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  25787. continue;
  25788. }
  25789. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  25790. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  25791. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  25792. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  25793. continue;
  25794. }
  25795. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  25796. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  25797. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  25798. ) {
  25799. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  25800. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  25801. }
  25802. }
  25803. }
  25804. }
  25805. if ($this->errors) {
  25806. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  25807. }
  25808. $package = $this->loader->load($this->config, $class);
  25809. $this->config = [];
  25810. return $package;
  25811. }
  25812. public function getWarnings(): array
  25813. {
  25814. return $this->warnings;
  25815. }
  25816. public function getErrors(): array
  25817. {
  25818. return $this->errors;
  25819. }
  25820. public static function hasPackageNamingError(string $name, bool $isLink = false): ?string
  25821. {
  25822. if (PlatformRepository::isPlatformPackage($name)) {
  25823. return null;
  25824. }
  25825. if (!Preg::isMatch('{^[a-z0-9](?:[_.-]?[a-z0-9]++)*+/[a-z0-9](?:(?:[_.]|-{1,2})?[a-z0-9]++)*+$}iD', $name)) {
  25826. 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]+)*$".';
  25827. }
  25828. $reservedNames = ['nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9'];
  25829. $bits = explode('/', strtolower($name));
  25830. if (in_array($bits[0], $reservedNames, true) || in_array($bits[1], $reservedNames, true)) {
  25831. return $name.' is reserved, package and vendor names can not match any of: '.implode(', ', $reservedNames).'.';
  25832. }
  25833. if (Preg::isMatch('{\.json$}', $name)) {
  25834. return $name.' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.';
  25835. }
  25836. if (Preg::isMatch('{[A-Z]}', $name)) {
  25837. if ($isLink) {
  25838. return $name.' is invalid, it should not contain uppercase characters. Please use '.strtolower($name).' instead.';
  25839. }
  25840. $suggestName = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  25841. $suggestName = strtolower($suggestName);
  25842. return $name.' is invalid, it should not contain uppercase characters. We suggest using '.$suggestName.' instead.';
  25843. }
  25844. return null;
  25845. }
  25846. private function validateRegex(string $property, string $regex, bool $mandatory = false): bool
  25847. {
  25848. if (!$this->validateString($property, $mandatory)) {
  25849. return false;
  25850. }
  25851. if (!Preg::isMatch('{^'.$regex.'$}u', $this->config[$property])) {
  25852. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  25853. if ($mandatory) {
  25854. $this->errors[] = $message;
  25855. } else {
  25856. $this->warnings[] = $message;
  25857. }
  25858. unset($this->config[$property]);
  25859. return false;
  25860. }
  25861. return true;
  25862. }
  25863. private function validateString(string $property, bool $mandatory = false): bool
  25864. {
  25865. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  25866. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  25867. unset($this->config[$property]);
  25868. return false;
  25869. }
  25870. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  25871. if ($mandatory) {
  25872. $this->errors[] = $property.' : must be present';
  25873. }
  25874. unset($this->config[$property]);
  25875. return false;
  25876. }
  25877. return true;
  25878. }
  25879. private function validateArray(string $property, bool $mandatory = false): bool
  25880. {
  25881. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  25882. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  25883. unset($this->config[$property]);
  25884. return false;
  25885. }
  25886. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  25887. if ($mandatory) {
  25888. $this->errors[] = $property.' : must be present and contain at least one element';
  25889. }
  25890. unset($this->config[$property]);
  25891. return false;
  25892. }
  25893. return true;
  25894. }
  25895. private function validateFlatArray(string $property, ?string $regex = null, bool $mandatory = false): bool
  25896. {
  25897. if (!$this->validateArray($property, $mandatory)) {
  25898. return false;
  25899. }
  25900. $pass = true;
  25901. foreach ($this->config[$property] as $key => $value) {
  25902. if (!is_string($value) && !is_numeric($value)) {
  25903. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  25904. unset($this->config[$property][$key]);
  25905. $pass = false;
  25906. continue;
  25907. }
  25908. if ($regex && !Preg::isMatch('{^'.$regex.'$}u', (string) $value)) {
  25909. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  25910. unset($this->config[$property][$key]);
  25911. $pass = false;
  25912. }
  25913. }
  25914. return $pass;
  25915. }
  25916. private function validateUrl(string $property, bool $mandatory = false): bool
  25917. {
  25918. if (!$this->validateString($property, $mandatory)) {
  25919. return false;
  25920. }
  25921. if (!$this->filterUrl($this->config[$property])) {
  25922. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  25923. unset($this->config[$property]);
  25924. return false;
  25925. }
  25926. return true;
  25927. }
  25928. private function filterUrl($value, array $schemes = ['http', 'https']): bool
  25929. {
  25930. if ($value === '') {
  25931. return true;
  25932. }
  25933. $bits = parse_url($value);
  25934. if (empty($bits['scheme']) || empty($bits['host'])) {
  25935. return false;
  25936. }
  25937. if (!in_array($bits['scheme'], $schemes, true)) {
  25938. return false;
  25939. }
  25940. return true;
  25941. }
  25942. }
  25943. <?php declare(strict_types=1);
  25944. namespace Composer\Package;
  25945. use Composer\Json\JsonFile;
  25946. use Composer\Installer\InstallationManager;
  25947. use Composer\Pcre\Preg;
  25948. use Composer\Repository\InstalledRepository;
  25949. use Composer\Repository\LockArrayRepository;
  25950. use Composer\Repository\PlatformRepository;
  25951. use Composer\Repository\RootPackageRepository;
  25952. use Composer\Util\ProcessExecutor;
  25953. use Composer\Package\Dumper\ArrayDumper;
  25954. use Composer\Package\Loader\ArrayLoader;
  25955. use Composer\Package\Version\VersionParser;
  25956. use Composer\Plugin\PluginInterface;
  25957. use Composer\Util\Git as GitUtil;
  25958. use Composer\IO\IOInterface;
  25959. use Seld\JsonLint\ParsingException;
  25960. class Locker
  25961. {
  25962. private $lockFile;
  25963. private $installationManager;
  25964. private $hash;
  25965. private $contentHash;
  25966. private $loader;
  25967. private $dumper;
  25968. private $process;
  25969. private $lockDataCache = null;
  25970. private $virtualFileWritten = false;
  25971. public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, string $composerFileContents, ?ProcessExecutor $process = null)
  25972. {
  25973. $this->lockFile = $lockFile;
  25974. $this->installationManager = $installationManager;
  25975. $this->hash = hash('md5', $composerFileContents);
  25976. $this->contentHash = self::getContentHash($composerFileContents);
  25977. $this->loader = new ArrayLoader(null, true);
  25978. $this->dumper = new ArrayDumper();
  25979. $this->process = $process ?? new ProcessExecutor($io);
  25980. }
  25981. public function getJsonFile(): JsonFile
  25982. {
  25983. return $this->lockFile;
  25984. }
  25985. public static function getContentHash(string $composerFileContents): string
  25986. {
  25987. $content = JsonFile::parseJson($composerFileContents, 'composer.json');
  25988. $relevantKeys = [
  25989. 'name',
  25990. 'version',
  25991. 'require',
  25992. 'require-dev',
  25993. 'conflict',
  25994. 'replace',
  25995. 'provide',
  25996. 'minimum-stability',
  25997. 'prefer-stable',
  25998. 'repositories',
  25999. 'extra',
  26000. ];
  26001. $relevantContent = [];
  26002. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  26003. $relevantContent[$key] = $content[$key];
  26004. }
  26005. if (isset($content['config']['platform'])) {
  26006. $relevantContent['config']['platform'] = $content['config']['platform'];
  26007. }
  26008. ksort($relevantContent);
  26009. return hash('md5', JsonFile::encode($relevantContent, 0));
  26010. }
  26011. public function isLocked(): bool
  26012. {
  26013. if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
  26014. return false;
  26015. }
  26016. $data = $this->getLockData();
  26017. return isset($data['packages']);
  26018. }
  26019. public function isFresh(): bool
  26020. {
  26021. $lock = $this->lockFile->read();
  26022. if (!empty($lock['content-hash'])) {
  26023. return $this->contentHash === $lock['content-hash'];
  26024. }
  26025. if (!empty($lock['hash'])) {
  26026. return $this->hash === $lock['hash'];
  26027. }
  26028. return false;
  26029. }
  26030. public function getLockedRepository(bool $withDevReqs = false): LockArrayRepository
  26031. {
  26032. $lockData = $this->getLockData();
  26033. $packages = new LockArrayRepository();
  26034. $lockedPackages = $lockData['packages'];
  26035. if ($withDevReqs) {
  26036. if (isset($lockData['packages-dev'])) {
  26037. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  26038. } else {
  26039. 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.');
  26040. }
  26041. }
  26042. if (empty($lockedPackages)) {
  26043. return $packages;
  26044. }
  26045. if (isset($lockedPackages[0]['name'])) {
  26046. $packageByName = [];
  26047. foreach ($lockedPackages as $info) {
  26048. $package = $this->loader->load($info);
  26049. $packages->addPackage($package);
  26050. $packageByName[$package->getName()] = $package;
  26051. if ($package instanceof AliasPackage) {
  26052. $packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
  26053. }
  26054. }
  26055. if (isset($lockData['aliases'])) {
  26056. foreach ($lockData['aliases'] as $alias) {
  26057. if (isset($packageByName[$alias['package']])) {
  26058. $aliasPkg = new CompleteAliasPackage($packageByName[$alias['package']], $alias['alias_normalized'], $alias['alias']);
  26059. $aliasPkg->setRootPackageAlias(true);
  26060. $packages->addPackage($aliasPkg);
  26061. }
  26062. }
  26063. }
  26064. return $packages;
  26065. }
  26066. throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
  26067. }
  26068. public function getDevPackageNames(): array
  26069. {
  26070. $names = [];
  26071. $lockData = $this->getLockData();
  26072. if (isset($lockData['packages-dev'])) {
  26073. foreach ($lockData['packages-dev'] as $package) {
  26074. $names[] = strtolower($package['name']);
  26075. }
  26076. }
  26077. return $names;
  26078. }
  26079. public function getPlatformRequirements(bool $withDevReqs = false): array
  26080. {
  26081. $lockData = $this->getLockData();
  26082. $requirements = [];
  26083. if (!empty($lockData['platform'])) {
  26084. $requirements = $this->loader->parseLinks(
  26085. '__root__',
  26086. '1.0.0',
  26087. Link::TYPE_REQUIRE,
  26088. $lockData['platform'] ?? []
  26089. );
  26090. }
  26091. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  26092. $devRequirements = $this->loader->parseLinks(
  26093. '__root__',
  26094. '1.0.0',
  26095. Link::TYPE_REQUIRE,
  26096. $lockData['platform-dev'] ?? []
  26097. );
  26098. $requirements = array_merge($requirements, $devRequirements);
  26099. }
  26100. return $requirements;
  26101. }
  26102. public function getMinimumStability(): string
  26103. {
  26104. $lockData = $this->getLockData();
  26105. return $lockData['minimum-stability'] ?? 'stable';
  26106. }
  26107. public function getStabilityFlags(): array
  26108. {
  26109. $lockData = $this->getLockData();
  26110. return $lockData['stability-flags'] ?? [];
  26111. }
  26112. public function getPreferStable(): ?bool
  26113. {
  26114. $lockData = $this->getLockData();
  26115. return $lockData['prefer-stable'] ?? null;
  26116. }
  26117. public function getPreferLowest(): ?bool
  26118. {
  26119. $lockData = $this->getLockData();
  26120. return $lockData['prefer-lowest'] ?? null;
  26121. }
  26122. public function getPlatformOverrides(): array
  26123. {
  26124. $lockData = $this->getLockData();
  26125. return $lockData['platform-overrides'] ?? [];
  26126. }
  26127. public function getAliases(): array
  26128. {
  26129. $lockData = $this->getLockData();
  26130. return $lockData['aliases'] ?? [];
  26131. }
  26132. public function getPluginApi()
  26133. {
  26134. $lockData = $this->getLockData();
  26135. return $lockData['plugin-api-version'] ?? '1.1.0';
  26136. }
  26137. public function getLockData(): array
  26138. {
  26139. if (null !== $this->lockDataCache) {
  26140. return $this->lockDataCache;
  26141. }
  26142. if (!$this->lockFile->exists()) {
  26143. throw new \LogicException('No lockfile found. Unable to read locked packages');
  26144. }
  26145. return $this->lockDataCache = $this->lockFile->read();
  26146. }
  26147. 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
  26148. {
  26149. $aliases = array_map(static function ($alias): array {
  26150. if (in_array($alias['version'], ['dev-master', 'dev-trunk', 'dev-default'], true)) {
  26151. $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS;
  26152. }
  26153. return $alias;
  26154. }, $aliases);
  26155. $lock = [
  26156. '_readme' => ['This file locks the dependencies of your project to a known state',
  26157. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  26158. 'This file is @gener'.'ated automatically', ],
  26159. 'content-hash' => $this->contentHash,
  26160. 'packages' => $this->lockPackages($packages),
  26161. 'packages-dev' => null,
  26162. 'aliases' => $aliases,
  26163. 'minimum-stability' => $minimumStability,
  26164. 'stability-flags' => $stabilityFlags,
  26165. 'prefer-stable' => $preferStable,
  26166. 'prefer-lowest' => $preferLowest,
  26167. ];
  26168. if (null !== $devPackages) {
  26169. $lock['packages-dev'] = $this->lockPackages($devPackages);
  26170. }
  26171. $lock['platform'] = $platformReqs;
  26172. $lock['platform-dev'] = $platformDevReqs;
  26173. if (\count($platformOverrides) > 0) {
  26174. $lock['platform-overrides'] = $platformOverrides;
  26175. }
  26176. $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION;
  26177. $lock = $this->fixupJsonDataType($lock);
  26178. try {
  26179. $isLocked = $this->isLocked();
  26180. } catch (ParsingException $e) {
  26181. $isLocked = false;
  26182. }
  26183. if (!$isLocked || $lock !== $this->getLockData()) {
  26184. if ($write) {
  26185. $this->lockFile->write($lock);
  26186. $this->lockDataCache = null;
  26187. $this->virtualFileWritten = false;
  26188. } else {
  26189. $this->virtualFileWritten = true;
  26190. $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock));
  26191. }
  26192. return true;
  26193. }
  26194. return false;
  26195. }
  26196. public function updateHash(JsonFile $composerJson, ?callable $dataProcessor = null): void
  26197. {
  26198. $contents = file_get_contents($composerJson->getPath());
  26199. if (false === $contents) {
  26200. throw new \RuntimeException('Unable to read '.$composerJson->getPath().' contents to update the lock file hash.');
  26201. }
  26202. $lockMtime = filemtime($this->lockFile->getPath());
  26203. $lockData = $this->lockFile->read();
  26204. $lockData['content-hash'] = Locker::getContentHash($contents);
  26205. if ($dataProcessor !== null) {
  26206. $lockData = $dataProcessor($lockData);
  26207. }
  26208. $this->lockFile->write($this->fixupJsonDataType($lockData));
  26209. $this->lockDataCache = null;
  26210. $this->virtualFileWritten = false;
  26211. if (is_int($lockMtime)) {
  26212. @touch($this->lockFile->getPath(), $lockMtime);
  26213. }
  26214. }
  26215. private function fixupJsonDataType(array $lockData): array
  26216. {
  26217. foreach (['stability-flags', 'platform', 'platform-dev'] as $key) {
  26218. if (isset($lockData[$key]) && is_array($lockData[$key]) && \count($lockData[$key]) === 0) {
  26219. $lockData[$key] = new \stdClass();
  26220. }
  26221. }
  26222. if (is_array($lockData['stability-flags'])) {
  26223. ksort($lockData['stability-flags']);
  26224. }
  26225. return $lockData;
  26226. }
  26227. private function lockPackages(array $packages): array
  26228. {
  26229. $locked = [];
  26230. foreach ($packages as $package) {
  26231. if ($package instanceof AliasPackage) {
  26232. continue;
  26233. }
  26234. $name = $package->getPrettyName();
  26235. $version = $package->getPrettyVersion();
  26236. if (!$name || !$version) {
  26237. throw new \LogicException(sprintf(
  26238. 'Package "%s" has no version or name and can not be locked',
  26239. $package
  26240. ));
  26241. }
  26242. $spec = $this->dumper->dump($package);
  26243. unset($spec['version_normalized']);
  26244. $time = $spec['time'] ?? null;
  26245. unset($spec['time']);
  26246. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  26247. $time = $this->getPackageTime($package) ?: $time;
  26248. }
  26249. if (null !== $time) {
  26250. $spec['time'] = $time;
  26251. }
  26252. unset($spec['installation-source']);
  26253. $locked[] = $spec;
  26254. }
  26255. usort($locked, static function ($a, $b) {
  26256. $comparison = strcmp($a['name'], $b['name']);
  26257. if (0 !== $comparison) {
  26258. return $comparison;
  26259. }
  26260. return strcmp($a['version'], $b['version']);
  26261. });
  26262. return $locked;
  26263. }
  26264. private function getPackageTime(PackageInterface $package): ?string
  26265. {
  26266. if (!function_exists('proc_open')) {
  26267. return null;
  26268. }
  26269. $path = $this->installationManager->getInstallPath($package);
  26270. if ($path === null) {
  26271. return null;
  26272. }
  26273. $path = realpath($path);
  26274. $sourceType = $package->getSourceType();
  26275. $datetime = null;
  26276. if ($path && in_array($sourceType, ['git', 'hg'])) {
  26277. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  26278. switch ($sourceType) {
  26279. case 'git':
  26280. GitUtil::cleanEnv();
  26281. $command = array_merge(['git', 'log', '-n1', '--pretty=%ct', (string) $sourceRef], GitUtil::getNoShowSignatureFlags($this->process));
  26282. if (0 === $this->process->execute($command, $output, $path) && Preg::isMatch('{^\s*\d+\s*$}', $output)) {
  26283. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  26284. }
  26285. break;
  26286. case 'hg':
  26287. if (0 === $this->process->execute(['hg', 'log', '--template', '{date|hgdate}', '-r', (string) $sourceRef], $output, $path) && Preg::isMatch('{^\s*(\d+)\s*}', $output, $match)) {
  26288. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  26289. }
  26290. break;
  26291. }
  26292. }
  26293. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  26294. }
  26295. public function getMissingRequirementInfo(RootPackageInterface $package, bool $includeDev): array
  26296. {
  26297. $missingRequirementInfo = [];
  26298. $missingRequirements = false;
  26299. $sets = [['repo' => $this->getLockedRepository(false), 'method' => 'getRequires', 'description' => 'Required']];
  26300. if ($includeDev === true) {
  26301. $sets[] = ['repo' => $this->getLockedRepository(true), 'method' => 'getDevRequires', 'description' => 'Required (in require-dev)'];
  26302. }
  26303. $rootRepo = new RootPackageRepository(clone $package);
  26304. foreach ($sets as $set) {
  26305. $installedRepo = new InstalledRepository([$set['repo'], $rootRepo]);
  26306. foreach (call_user_func([$package, $set['method']]) as $link) {
  26307. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  26308. continue;
  26309. }
  26310. if ($link->getPrettyConstraint() === 'self.version') {
  26311. continue;
  26312. }
  26313. if ($installedRepo->findPackagesWithReplacersAndProviders($link->getTarget(), $link->getConstraint()) === []) {
  26314. $results = $installedRepo->findPackagesWithReplacersAndProviders($link->getTarget());
  26315. if ($results !== []) {
  26316. $provider = reset($results);
  26317. $description = $provider->getPrettyVersion();
  26318. if ($provider->getName() !== $link->getTarget()) {
  26319. foreach (['getReplaces' => 'replaced as %s by %s', 'getProvides' => 'provided as %s by %s'] as $method => $text) {
  26320. foreach (call_user_func([$provider, $method]) as $providerLink) {
  26321. if ($providerLink->getTarget() === $link->getTarget()) {
  26322. $description = sprintf($text, $providerLink->getPrettyConstraint(), $provider->getPrettyName().' '.$provider->getPrettyVersion());
  26323. break 2;
  26324. }
  26325. }
  26326. }
  26327. }
  26328. $missingRequirementInfo[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is in the lock file as "'.$description.'" but that does not satisfy your constraint "'.$link->getPrettyConstraint().'".';
  26329. } else {
  26330. $missingRequirementInfo[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is not present in the lock file.';
  26331. }
  26332. $missingRequirements = true;
  26333. }
  26334. }
  26335. }
  26336. if ($missingRequirements) {
  26337. $missingRequirementInfo[] = 'This usually happens when composer files are incorrectly merged or the composer.json file is manually edited.';
  26338. $missingRequirementInfo[] = 'Read more about correctly resolving merge conflicts https://getcomposer.org/doc/articles/resolving-merge-conflicts.md';
  26339. $missingRequirementInfo[] = 'and prefer using the "require" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require-r';
  26340. }
  26341. return $missingRequirementInfo;
  26342. }
  26343. }
  26344. <?php declare(strict_types=1);
  26345. namespace Composer\Package;
  26346. use Composer\Package\Version\VersionParser;
  26347. use Composer\Pcre\Preg;
  26348. use Composer\Util\ComposerMirror;
  26349. class Package extends BasePackage
  26350. {
  26351. protected $type;
  26352. protected $targetDir;
  26353. protected $installationSource;
  26354. protected $sourceType;
  26355. protected $sourceUrl;
  26356. protected $sourceReference;
  26357. protected $sourceMirrors;
  26358. protected $distType;
  26359. protected $distUrl;
  26360. protected $distReference;
  26361. protected $distSha1Checksum;
  26362. protected $distMirrors;
  26363. protected $version;
  26364. protected $prettyVersion;
  26365. protected $releaseDate;
  26366. protected $extra = [];
  26367. protected $binaries = [];
  26368. protected $dev;
  26369. protected $stability;
  26370. protected $notificationUrl;
  26371. protected $requires = [];
  26372. protected $conflicts = [];
  26373. protected $provides = [];
  26374. protected $replaces = [];
  26375. protected $devRequires = [];
  26376. protected $suggests = [];
  26377. protected $autoload = [];
  26378. protected $devAutoload = [];
  26379. protected $includePaths = [];
  26380. protected $isDefaultBranch = false;
  26381. protected $transportOptions = [];
  26382. protected $phpExt = null;
  26383. public function __construct(string $name, string $version, string $prettyVersion)
  26384. {
  26385. parent::__construct($name);
  26386. $this->version = $version;
  26387. $this->prettyVersion = $prettyVersion;
  26388. $this->stability = VersionParser::parseStability($version);
  26389. $this->dev = $this->stability === 'dev';
  26390. }
  26391. public function isDev(): bool
  26392. {
  26393. return $this->dev;
  26394. }
  26395. public function setType(string $type): void
  26396. {
  26397. $this->type = $type;
  26398. }
  26399. public function getType(): string
  26400. {
  26401. return $this->type ?: 'library';
  26402. }
  26403. public function getStability(): string
  26404. {
  26405. return $this->stability;
  26406. }
  26407. public function setTargetDir(?string $targetDir): void
  26408. {
  26409. $this->targetDir = $targetDir;
  26410. }
  26411. public function getTargetDir(): ?string
  26412. {
  26413. if (null === $this->targetDir) {
  26414. return null;
  26415. }
  26416. return ltrim(Preg::replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  26417. }
  26418. public function setExtra(array $extra): void
  26419. {
  26420. $this->extra = $extra;
  26421. }
  26422. public function getExtra(): array
  26423. {
  26424. return $this->extra;
  26425. }
  26426. public function setBinaries(array $binaries): void
  26427. {
  26428. $this->binaries = $binaries;
  26429. }
  26430. public function getBinaries(): array
  26431. {
  26432. return $this->binaries;
  26433. }
  26434. public function setInstallationSource(?string $type): void
  26435. {
  26436. $this->installationSource = $type;
  26437. }
  26438. public function getInstallationSource(): ?string
  26439. {
  26440. return $this->installationSource;
  26441. }
  26442. public function setSourceType(?string $type): void
  26443. {
  26444. $this->sourceType = $type;
  26445. }
  26446. public function getSourceType(): ?string
  26447. {
  26448. return $this->sourceType;
  26449. }
  26450. public function setSourceUrl(?string $url): void
  26451. {
  26452. $this->sourceUrl = $url;
  26453. }
  26454. public function getSourceUrl(): ?string
  26455. {
  26456. return $this->sourceUrl;
  26457. }
  26458. public function setSourceReference(?string $reference): void
  26459. {
  26460. $this->sourceReference = $reference;
  26461. }
  26462. public function getSourceReference(): ?string
  26463. {
  26464. return $this->sourceReference;
  26465. }
  26466. public function setSourceMirrors(?array $mirrors): void
  26467. {
  26468. $this->sourceMirrors = $mirrors;
  26469. }
  26470. public function getSourceMirrors(): ?array
  26471. {
  26472. return $this->sourceMirrors;
  26473. }
  26474. public function getSourceUrls(): array
  26475. {
  26476. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  26477. }
  26478. public function setDistType(?string $type): void
  26479. {
  26480. $this->distType = $type === '' ? null : $type;
  26481. }
  26482. public function getDistType(): ?string
  26483. {
  26484. return $this->distType;
  26485. }
  26486. public function setDistUrl(?string $url): void
  26487. {
  26488. $this->distUrl = $url === '' ? null : $url;
  26489. }
  26490. public function getDistUrl(): ?string
  26491. {
  26492. return $this->distUrl;
  26493. }
  26494. public function setDistReference(?string $reference): void
  26495. {
  26496. $this->distReference = $reference;
  26497. }
  26498. public function getDistReference(): ?string
  26499. {
  26500. return $this->distReference;
  26501. }
  26502. public function setDistSha1Checksum(?string $sha1checksum): void
  26503. {
  26504. $this->distSha1Checksum = $sha1checksum;
  26505. }
  26506. public function getDistSha1Checksum(): ?string
  26507. {
  26508. return $this->distSha1Checksum;
  26509. }
  26510. public function setDistMirrors(?array $mirrors): void
  26511. {
  26512. $this->distMirrors = $mirrors;
  26513. }
  26514. public function getDistMirrors(): ?array
  26515. {
  26516. return $this->distMirrors;
  26517. }
  26518. public function getDistUrls(): array
  26519. {
  26520. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  26521. }
  26522. public function getTransportOptions(): array
  26523. {
  26524. return $this->transportOptions;
  26525. }
  26526. public function setTransportOptions(array $options): void
  26527. {
  26528. $this->transportOptions = $options;
  26529. }
  26530. public function getVersion(): string
  26531. {
  26532. return $this->version;
  26533. }
  26534. public function getPrettyVersion(): string
  26535. {
  26536. return $this->prettyVersion;
  26537. }
  26538. public function setReleaseDate(?\DateTimeInterface $releaseDate): void
  26539. {
  26540. $this->releaseDate = $releaseDate;
  26541. }
  26542. public function getReleaseDate(): ?\DateTimeInterface
  26543. {
  26544. return $this->releaseDate;
  26545. }
  26546. public function setRequires(array $requires): void
  26547. {
  26548. if (isset($requires[0])) {
  26549. $requires = $this->convertLinksToMap($requires, 'setRequires');
  26550. }
  26551. $this->requires = $requires;
  26552. }
  26553. public function getRequires(): array
  26554. {
  26555. return $this->requires;
  26556. }
  26557. public function setConflicts(array $conflicts): void
  26558. {
  26559. if (isset($conflicts[0])) {
  26560. $conflicts = $this->convertLinksToMap($conflicts, 'setConflicts');
  26561. }
  26562. $this->conflicts = $conflicts;
  26563. }
  26564. public function getConflicts(): array
  26565. {
  26566. return $this->conflicts;
  26567. }
  26568. public function setProvides(array $provides): void
  26569. {
  26570. if (isset($provides[0])) {
  26571. $provides = $this->convertLinksToMap($provides, 'setProvides');
  26572. }
  26573. $this->provides = $provides;
  26574. }
  26575. public function getProvides(): array
  26576. {
  26577. return $this->provides;
  26578. }
  26579. public function setReplaces(array $replaces): void
  26580. {
  26581. if (isset($replaces[0])) {
  26582. $replaces = $this->convertLinksToMap($replaces, 'setReplaces');
  26583. }
  26584. $this->replaces = $replaces;
  26585. }
  26586. public function getReplaces(): array
  26587. {
  26588. return $this->replaces;
  26589. }
  26590. public function setDevRequires(array $devRequires): void
  26591. {
  26592. if (isset($devRequires[0])) {
  26593. $devRequires = $this->convertLinksToMap($devRequires, 'setDevRequires');
  26594. }
  26595. $this->devRequires = $devRequires;
  26596. }
  26597. public function getDevRequires(): array
  26598. {
  26599. return $this->devRequires;
  26600. }
  26601. public function setSuggests(array $suggests): void
  26602. {
  26603. $this->suggests = $suggests;
  26604. }
  26605. public function getSuggests(): array
  26606. {
  26607. return $this->suggests;
  26608. }
  26609. public function setAutoload(array $autoload): void
  26610. {
  26611. $this->autoload = $autoload;
  26612. }
  26613. public function getAutoload(): array
  26614. {
  26615. return $this->autoload;
  26616. }
  26617. public function setDevAutoload(array $devAutoload): void
  26618. {
  26619. $this->devAutoload = $devAutoload;
  26620. }
  26621. public function getDevAutoload(): array
  26622. {
  26623. return $this->devAutoload;
  26624. }
  26625. public function setIncludePaths(array $includePaths): void
  26626. {
  26627. $this->includePaths = $includePaths;
  26628. }
  26629. public function getIncludePaths(): array
  26630. {
  26631. return $this->includePaths;
  26632. }
  26633. public function setPhpExt(?array $phpExt): void
  26634. {
  26635. $this->phpExt = $phpExt;
  26636. }
  26637. public function getPhpExt(): ?array
  26638. {
  26639. return $this->phpExt;
  26640. }
  26641. public function setNotificationUrl(string $notificationUrl): void
  26642. {
  26643. $this->notificationUrl = $notificationUrl;
  26644. }
  26645. public function getNotificationUrl(): ?string
  26646. {
  26647. return $this->notificationUrl;
  26648. }
  26649. public function setIsDefaultBranch(bool $defaultBranch): void
  26650. {
  26651. $this->isDefaultBranch = $defaultBranch;
  26652. }
  26653. public function isDefaultBranch(): bool
  26654. {
  26655. return $this->isDefaultBranch;
  26656. }
  26657. public function setSourceDistReferences(string $reference): void
  26658. {
  26659. $this->setSourceReference($reference);
  26660. if (
  26661. $this->getDistUrl() !== null
  26662. && Preg::isMatch('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())
  26663. ) {
  26664. $this->setDistReference($reference);
  26665. $this->setDistUrl(Preg::replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
  26666. } elseif ($this->getDistReference()) {
  26667. $this->setDistReference($reference);
  26668. }
  26669. }
  26670. public function replaceVersion(string $version, string $prettyVersion): void
  26671. {
  26672. $this->version = $version;
  26673. $this->prettyVersion = $prettyVersion;
  26674. $this->stability = VersionParser::parseStability($version);
  26675. $this->dev = $this->stability === 'dev';
  26676. }
  26677. protected function getUrls(?string $url, ?array $mirrors, ?string $ref, ?string $type, string $urlType): array
  26678. {
  26679. if (!$url) {
  26680. return [];
  26681. }
  26682. if ($urlType === 'dist' && false !== strpos($url, '%')) {
  26683. $url = ComposerMirror::processUrl($url, $this->name, $this->version, $ref, $type, $this->prettyVersion);
  26684. }
  26685. $urls = [$url];
  26686. if ($mirrors) {
  26687. foreach ($mirrors as $mirror) {
  26688. if ($urlType === 'dist') {
  26689. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type, $this->prettyVersion);
  26690. } elseif ($urlType === 'source' && $type === 'git') {
  26691. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  26692. } elseif ($urlType === 'source' && $type === 'hg') {
  26693. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  26694. } else {
  26695. continue;
  26696. }
  26697. if (!\in_array($mirrorUrl, $urls)) {
  26698. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  26699. $func($urls, $mirrorUrl);
  26700. }
  26701. }
  26702. }
  26703. return $urls;
  26704. }
  26705. private function convertLinksToMap(array $links, string $source): array
  26706. {
  26707. 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.');
  26708. $newLinks = [];
  26709. foreach ($links as $link) {
  26710. $newLinks[$link->getTarget()] = $link;
  26711. }
  26712. return $newLinks;
  26713. }
  26714. }
  26715. <?php declare(strict_types=1);
  26716. namespace Composer\Package;
  26717. use Composer\Repository\RepositoryInterface;
  26718. interface PackageInterface
  26719. {
  26720. public const DISPLAY_SOURCE_REF_IF_DEV = 0;
  26721. public const DISPLAY_SOURCE_REF = 1;
  26722. public const DISPLAY_DIST_REF = 2;
  26723. public function getName(): string;
  26724. public function getPrettyName(): string;
  26725. public function getNames(bool $provides = true): array;
  26726. public function setId(int $id): void;
  26727. public function getId(): int;
  26728. public function isDev(): bool;
  26729. public function getType(): string;
  26730. public function getTargetDir(): ?string;
  26731. public function getExtra(): array;
  26732. public function setInstallationSource(?string $type): void;
  26733. public function getInstallationSource(): ?string;
  26734. public function getSourceType(): ?string;
  26735. public function getSourceUrl(): ?string;
  26736. public function getSourceUrls(): array;
  26737. public function getSourceReference(): ?string;
  26738. public function getSourceMirrors(): ?array;
  26739. public function setSourceMirrors(?array $mirrors): void;
  26740. public function getDistType(): ?string;
  26741. public function getDistUrl(): ?string;
  26742. public function getDistUrls(): array;
  26743. public function getDistReference(): ?string;
  26744. public function getDistSha1Checksum(): ?string;
  26745. public function getDistMirrors(): ?array;
  26746. public function setDistMirrors(?array $mirrors): void;
  26747. public function getVersion(): string;
  26748. public function getPrettyVersion(): string;
  26749. public function getFullPrettyVersion(bool $truncate = true, int $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV): string;
  26750. public function getReleaseDate(): ?\DateTimeInterface;
  26751. public function getStability(): string;
  26752. public function getRequires(): array;
  26753. public function getConflicts(): array;
  26754. public function getProvides(): array;
  26755. public function getReplaces(): array;
  26756. public function getDevRequires(): array;
  26757. public function getSuggests(): array;
  26758. public function getAutoload(): array;
  26759. public function getDevAutoload(): array;
  26760. public function getIncludePaths(): array;
  26761. public function getPhpExt(): ?array;
  26762. public function setRepository(RepositoryInterface $repository): void;
  26763. public function getRepository(): ?RepositoryInterface;
  26764. public function getBinaries(): array;
  26765. public function getUniqueName(): string;
  26766. public function getNotificationUrl(): ?string;
  26767. public function __toString(): string;
  26768. public function getPrettyString(): string;
  26769. public function isDefaultBranch(): bool;
  26770. public function getTransportOptions(): array;
  26771. public function setTransportOptions(array $options): void;
  26772. public function setSourceReference(?string $reference): void;
  26773. public function setDistUrl(?string $url): void;
  26774. public function setDistType(?string $type): void;
  26775. public function setDistReference(?string $reference): void;
  26776. public function setSourceDistReferences(string $reference): void;
  26777. }
  26778. <?php declare(strict_types=1);
  26779. namespace Composer\Package;
  26780. class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterface
  26781. {
  26782. protected $aliasOf;
  26783. public function __construct(RootPackage $aliasOf, string $version, string $prettyVersion)
  26784. {
  26785. parent::__construct($aliasOf, $version, $prettyVersion);
  26786. }
  26787. public function getAliasOf()
  26788. {
  26789. return $this->aliasOf;
  26790. }
  26791. public function getAliases(): array
  26792. {
  26793. return $this->aliasOf->getAliases();
  26794. }
  26795. public function getMinimumStability(): string
  26796. {
  26797. return $this->aliasOf->getMinimumStability();
  26798. }
  26799. public function getStabilityFlags(): array
  26800. {
  26801. return $this->aliasOf->getStabilityFlags();
  26802. }
  26803. public function getReferences(): array
  26804. {
  26805. return $this->aliasOf->getReferences();
  26806. }
  26807. public function getPreferStable(): bool
  26808. {
  26809. return $this->aliasOf->getPreferStable();
  26810. }
  26811. public function getConfig(): array
  26812. {
  26813. return $this->aliasOf->getConfig();
  26814. }
  26815. public function setRequires(array $requires): void
  26816. {
  26817. $this->requires = $this->replaceSelfVersionDependencies($requires, Link::TYPE_REQUIRE);
  26818. $this->aliasOf->setRequires($requires);
  26819. }
  26820. public function setDevRequires(array $devRequires): void
  26821. {
  26822. $this->devRequires = $this->replaceSelfVersionDependencies($devRequires, Link::TYPE_DEV_REQUIRE);
  26823. $this->aliasOf->setDevRequires($devRequires);
  26824. }
  26825. public function setConflicts(array $conflicts): void
  26826. {
  26827. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
  26828. $this->aliasOf->setConflicts($conflicts);
  26829. }
  26830. public function setProvides(array $provides): void
  26831. {
  26832. $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
  26833. $this->aliasOf->setProvides($provides);
  26834. }
  26835. public function setReplaces(array $replaces): void
  26836. {
  26837. $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
  26838. $this->aliasOf->setReplaces($replaces);
  26839. }
  26840. public function setAutoload(array $autoload): void
  26841. {
  26842. $this->aliasOf->setAutoload($autoload);
  26843. }
  26844. public function setDevAutoload(array $devAutoload): void
  26845. {
  26846. $this->aliasOf->setDevAutoload($devAutoload);
  26847. }
  26848. public function setStabilityFlags(array $stabilityFlags): void
  26849. {
  26850. $this->aliasOf->setStabilityFlags($stabilityFlags);
  26851. }
  26852. public function setMinimumStability(string $minimumStability): void
  26853. {
  26854. $this->aliasOf->setMinimumStability($minimumStability);
  26855. }
  26856. public function setPreferStable(bool $preferStable): void
  26857. {
  26858. $this->aliasOf->setPreferStable($preferStable);
  26859. }
  26860. public function setConfig(array $config): void
  26861. {
  26862. $this->aliasOf->setConfig($config);
  26863. }
  26864. public function setReferences(array $references): void
  26865. {
  26866. $this->aliasOf->setReferences($references);
  26867. }
  26868. public function setAliases(array $aliases): void
  26869. {
  26870. $this->aliasOf->setAliases($aliases);
  26871. }
  26872. public function setSuggests(array $suggests): void
  26873. {
  26874. $this->aliasOf->setSuggests($suggests);
  26875. }
  26876. public function setExtra(array $extra): void
  26877. {
  26878. $this->aliasOf->setExtra($extra);
  26879. }
  26880. public function __clone()
  26881. {
  26882. parent::__clone();
  26883. $this->aliasOf = clone $this->aliasOf;
  26884. }
  26885. }
  26886. <?php declare(strict_types=1);
  26887. namespace Composer\Package;
  26888. class RootPackage extends CompletePackage implements RootPackageInterface
  26889. {
  26890. public const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
  26891. protected $minimumStability = 'stable';
  26892. protected $preferStable = false;
  26893. protected $stabilityFlags = [];
  26894. protected $config = [];
  26895. protected $references = [];
  26896. protected $aliases = [];
  26897. public function setMinimumStability(string $minimumStability): void
  26898. {
  26899. $this->minimumStability = $minimumStability;
  26900. }
  26901. public function getMinimumStability(): string
  26902. {
  26903. return $this->minimumStability;
  26904. }
  26905. public function setStabilityFlags(array $stabilityFlags): void
  26906. {
  26907. $this->stabilityFlags = $stabilityFlags;
  26908. }
  26909. public function getStabilityFlags(): array
  26910. {
  26911. return $this->stabilityFlags;
  26912. }
  26913. public function setPreferStable(bool $preferStable): void
  26914. {
  26915. $this->preferStable = $preferStable;
  26916. }
  26917. public function getPreferStable(): bool
  26918. {
  26919. return $this->preferStable;
  26920. }
  26921. public function setConfig(array $config): void
  26922. {
  26923. $this->config = $config;
  26924. }
  26925. public function getConfig(): array
  26926. {
  26927. return $this->config;
  26928. }
  26929. public function setReferences(array $references): void
  26930. {
  26931. $this->references = $references;
  26932. }
  26933. public function getReferences(): array
  26934. {
  26935. return $this->references;
  26936. }
  26937. public function setAliases(array $aliases): void
  26938. {
  26939. $this->aliases = $aliases;
  26940. }
  26941. public function getAliases(): array
  26942. {
  26943. return $this->aliases;
  26944. }
  26945. }
  26946. <?php declare(strict_types=1);
  26947. namespace Composer\Package;
  26948. interface RootPackageInterface extends CompletePackageInterface
  26949. {
  26950. public function getAliases(): array;
  26951. public function getMinimumStability(): string;
  26952. public function getStabilityFlags(): array;
  26953. public function getReferences(): array;
  26954. public function getPreferStable(): bool;
  26955. public function getConfig(): array;
  26956. public function setRequires(array $requires): void;
  26957. public function setDevRequires(array $devRequires): void;
  26958. public function setConflicts(array $conflicts): void;
  26959. public function setProvides(array $provides): void;
  26960. public function setReplaces(array $replaces): void;
  26961. public function setAutoload(array $autoload): void;
  26962. public function setDevAutoload(array $devAutoload): void;
  26963. public function setStabilityFlags(array $stabilityFlags): void;
  26964. public function setMinimumStability(string $minimumStability): void;
  26965. public function setPreferStable(bool $preferStable): void;
  26966. public function setConfig(array $config): void;
  26967. public function setReferences(array $references): void;
  26968. public function setAliases(array $aliases): void;
  26969. public function setSuggests(array $suggests): void;
  26970. public function setExtra(array $extra): void;
  26971. }
  26972. <?php declare(strict_types=1);
  26973. namespace Composer\Package\Version;
  26974. use Composer\Package\BasePackage;
  26975. class StabilityFilter
  26976. {
  26977. public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, array $names, string $stability): bool
  26978. {
  26979. foreach ($names as $name) {
  26980. if (isset($stabilityFlags[$name])) {
  26981. if (BasePackage::STABILITIES[$stability] <= $stabilityFlags[$name]) {
  26982. return true;
  26983. }
  26984. } elseif (isset($acceptableStabilities[$stability])) {
  26985. return true;
  26986. }
  26987. }
  26988. return false;
  26989. }
  26990. }
  26991. <?php declare(strict_types=1);
  26992. namespace Composer\Package\Version;
  26993. use Composer\Package\PackageInterface;
  26994. use Composer\Package\Loader\ArrayLoader;
  26995. use Composer\Package\Dumper\ArrayDumper;
  26996. use Composer\Pcre\Preg;
  26997. use Composer\Semver\Constraint\Constraint;
  26998. use Composer\Semver\Constraint\ConstraintInterface;
  26999. use Composer\Semver\Intervals;
  27000. use Composer\Util\Platform;
  27001. class VersionBumper
  27002. {
  27003. public function bumpRequirement(ConstraintInterface $constraint, PackageInterface $package): string
  27004. {
  27005. $parser = new VersionParser();
  27006. $prettyConstraint = $constraint->getPrettyString();
  27007. if (str_starts_with($constraint->getPrettyString(), 'dev-')) {
  27008. return $prettyConstraint;
  27009. }
  27010. $version = $package->getVersion();
  27011. if (str_starts_with($package->getVersion(), 'dev-')) {
  27012. $loader = new ArrayLoader($parser);
  27013. $dumper = new ArrayDumper();
  27014. $extra = $loader->getBranchAlias($dumper->dump($package));
  27015. if (null === $extra || $extra === VersionParser::DEFAULT_BRANCH_ALIAS) {
  27016. return $prettyConstraint;
  27017. }
  27018. $version = $extra;
  27019. }
  27020. $intervals = Intervals::get($constraint);
  27021. if (\count($intervals['branches']['names']) > 0) {
  27022. return $prettyConstraint;
  27023. }
  27024. $major = Preg::replace('{^(\d+).*}', '$1', $version);
  27025. $versionWithoutSuffix = Preg::replace('{(?:\.(?:0|9999999))+(-dev)?$}', '', $version);
  27026. $newPrettyConstraint = '^'.$versionWithoutSuffix;
  27027. if (!Preg::isMatch('{^\^\d+(\.\d+)*$}', $newPrettyConstraint)) {
  27028. return $prettyConstraint;
  27029. }
  27030. $pattern = '{
  27031. (?<=,|\ |\||^) # leading separator
  27032. (?P<constraint>
  27033. \^v?'.$major.'(?:\.\d+)* # e.g. ^2.anything
  27034. | ~v?'.$major.'(?:\.\d+){1,3} # e.g. ~2.2 or ~2.2.2 or ~2.2.2.2
  27035. | v?'.$major.'(?:\.[*x])+ # e.g. 2.* or 2.*.* or 2.x.x.x etc
  27036. | >=v?\d(?:\.\d+)* # e.g. >=2 or >=1.2 etc
  27037. | \* # full wildcard
  27038. )
  27039. (?=,|$|\ |\||@) # trailing separator
  27040. }x';
  27041. if (Preg::isMatchAllWithOffsets($pattern, $prettyConstraint, $matches)) {
  27042. $modified = $prettyConstraint;
  27043. foreach (array_reverse($matches['constraint']) as $match) {
  27044. assert(is_string($match[0]));
  27045. $suffix = '';
  27046. if (substr_count($match[0], '.') === 2 && substr_count($versionWithoutSuffix, '.') === 1) {
  27047. $suffix = '.0';
  27048. }
  27049. if (str_starts_with($match[0], '~') && substr_count($match[0], '.') !== 1) {
  27050. $versionBits = explode('.', $versionWithoutSuffix);
  27051. $versionBits = array_pad($versionBits, substr_count($match[0], '.') + 1, '0');
  27052. $replacement = '~'.implode('.', array_slice($versionBits, 0, substr_count($match[0], '.') + 1));
  27053. } elseif ($match[0] === '*' || str_starts_with($match[0], '>=')) {
  27054. $replacement = '>='.$versionWithoutSuffix.$suffix;
  27055. } else {
  27056. $replacement = $newPrettyConstraint.$suffix;
  27057. }
  27058. $modified = substr_replace($modified, $replacement, $match[1], Platform::strlen($match[0]));
  27059. }
  27060. $newConstraint = $parser->parseConstraints($modified);
  27061. if (Intervals::isSubsetOf($newConstraint, $constraint) && Intervals::isSubsetOf($constraint, $newConstraint)) {
  27062. return $prettyConstraint;
  27063. }
  27064. return $modified;
  27065. }
  27066. return $prettyConstraint;
  27067. }
  27068. }
  27069. <?php declare(strict_types=1);
  27070. namespace Composer\Package\Version;
  27071. use Composer\Config;
  27072. use Composer\IO\IOInterface;
  27073. use Composer\Pcre\Preg;
  27074. use Composer\Repository\Vcs\HgDriver;
  27075. use Composer\IO\NullIO;
  27076. use Composer\Semver\VersionParser as SemverVersionParser;
  27077. use Composer\Util\Git as GitUtil;
  27078. use Composer\Util\HttpDownloader;
  27079. use Composer\Util\Platform;
  27080. use Composer\Util\ProcessExecutor;
  27081. use Composer\Util\Svn as SvnUtil;
  27082. use React\Promise\CancellablePromiseInterface;
  27083. use Symfony\Component\Process\Process;
  27084. class VersionGuesser
  27085. {
  27086. private $config;
  27087. private $process;
  27088. private $versionParser;
  27089. private $io;
  27090. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser, ?IOInterface $io = null)
  27091. {
  27092. $this->config = $config;
  27093. $this->process = $process;
  27094. $this->versionParser = $versionParser;
  27095. $this->io = $io;
  27096. }
  27097. public function guessVersion(array $packageConfig, string $path): ?array
  27098. {
  27099. if (!function_exists('proc_open')) {
  27100. return null;
  27101. }
  27102. if (Platform::isInputCompletionProcess()) {
  27103. return null;
  27104. }
  27105. $versionData = $this->guessGitVersion($packageConfig, $path);
  27106. if (null !== $versionData['version']) {
  27107. return $this->postprocess($versionData);
  27108. }
  27109. $versionData = $this->guessHgVersion($packageConfig, $path);
  27110. if (null !== $versionData && null !== $versionData['version']) {
  27111. return $this->postprocess($versionData);
  27112. }
  27113. $versionData = $this->guessFossilVersion($path);
  27114. if (null !== $versionData['version']) {
  27115. return $this->postprocess($versionData);
  27116. }
  27117. $versionData = $this->guessSvnVersion($packageConfig, $path);
  27118. if (null !== $versionData && null !== $versionData['version']) {
  27119. return $this->postprocess($versionData);
  27120. }
  27121. return null;
  27122. }
  27123. private function postprocess(array $versionData): array
  27124. {
  27125. if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
  27126. unset($versionData['feature_version'], $versionData['feature_pretty_version']);
  27127. }
  27128. if ('-dev' === substr($versionData['version'], -4) && Preg::isMatch('{\.9{7}}', $versionData['version'])) {
  27129. $versionData['pretty_version'] = Preg::replace('{(\.9{7})+}', '.x', $versionData['version']);
  27130. }
  27131. if (!empty($versionData['feature_version']) && '-dev' === substr($versionData['feature_version'], -4) && Preg::isMatch('{\.9{7}}', $versionData['feature_version'])) {
  27132. $versionData['feature_pretty_version'] = Preg::replace('{(\.9{7})+}', '.x', $versionData['feature_version']);
  27133. }
  27134. return $versionData;
  27135. }
  27136. private function guessGitVersion(array $packageConfig, string $path): array
  27137. {
  27138. GitUtil::cleanEnv();
  27139. $commit = null;
  27140. $version = null;
  27141. $prettyVersion = null;
  27142. $featureVersion = null;
  27143. $featurePrettyVersion = null;
  27144. $isDetached = false;
  27145. if (0 === $this->process->execute(['git', 'branch', '-a', '--no-color', '--no-abbrev', '-v'], $output, $path)) {
  27146. $branches = [];
  27147. $isFeatureBranch = false;
  27148. foreach ($this->process->splitLines($output) as $branch) {
  27149. if ($branch && Preg::isMatchStrictGroups('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  27150. if (
  27151. $match[1] === '(no branch)'
  27152. || strpos($match[1], '(detached ') === 0
  27153. || strpos($match[1], '(HEAD detached at') === 0
  27154. ) {
  27155. $version = 'dev-' . $match[2];
  27156. $prettyVersion = $version;
  27157. $isFeatureBranch = true;
  27158. $isDetached = true;
  27159. } else {
  27160. $version = $this->versionParser->normalizeBranch($match[1]);
  27161. $prettyVersion = 'dev-' . $match[1];
  27162. $isFeatureBranch = $this->isFeatureBranch($packageConfig, $match[1]);
  27163. }
  27164. $commit = $match[2];
  27165. }
  27166. if ($branch && !Preg::isMatchStrictGroups('{^ *.+/HEAD }', $branch)) {
  27167. if (Preg::isMatchStrictGroups('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
  27168. $branches[] = $match[1];
  27169. }
  27170. }
  27171. }
  27172. if ($isFeatureBranch) {
  27173. $featureVersion = $version;
  27174. $featurePrettyVersion = $prettyVersion;
  27175. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, ['git', 'rev-list', '%candidate%..%branch%'], $path);
  27176. $version = $result['version'];
  27177. $prettyVersion = $result['pretty_version'];
  27178. }
  27179. }
  27180. GitUtil::checkForRepoOwnershipError($this->process->getErrorOutput(), $path, $this->io);
  27181. if (!$version || $isDetached) {
  27182. $result = $this->versionFromGitTags($path);
  27183. if ($result) {
  27184. $version = $result['version'];
  27185. $prettyVersion = $result['pretty_version'];
  27186. $featureVersion = null;
  27187. $featurePrettyVersion = null;
  27188. }
  27189. }
  27190. if (null === $commit) {
  27191. $command = array_merge(['git', 'log', '--pretty=%H', '-n1', 'HEAD'], GitUtil::getNoShowSignatureFlags($this->process));
  27192. if (0 === $this->process->execute($command, $output, $path)) {
  27193. $commit = trim($output) ?: null;
  27194. }
  27195. }
  27196. if ($featureVersion) {
  27197. return ['version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion, 'feature_version' => $featureVersion, 'feature_pretty_version' => $featurePrettyVersion];
  27198. }
  27199. return ['version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion];
  27200. }
  27201. private function versionFromGitTags(string $path): ?array
  27202. {
  27203. if (0 === $this->process->execute(['git', 'describe', '--exact-match', '--tags'], $output, $path)) {
  27204. try {
  27205. $version = $this->versionParser->normalize(trim($output));
  27206. return ['version' => $version, 'pretty_version' => trim($output)];
  27207. } catch (\Exception $e) {
  27208. }
  27209. }
  27210. return null;
  27211. }
  27212. private function guessHgVersion(array $packageConfig, string $path): ?array
  27213. {
  27214. if (0 === $this->process->execute(['hg', 'branch'], $output, $path)) {
  27215. $branch = trim($output);
  27216. $version = $this->versionParser->normalizeBranch($branch);
  27217. $isFeatureBranch = 0 === strpos($version, 'dev-');
  27218. if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
  27219. return ['version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch];
  27220. }
  27221. if (!$isFeatureBranch) {
  27222. return ['version' => $version, 'commit' => null, 'pretty_version' => $version];
  27223. }
  27224. $io = new NullIO();
  27225. $driver = new HgDriver(['url' => $path], $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
  27226. $branches = array_map('strval', array_keys($driver->getBranches()));
  27227. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, ['hg', 'log', '-r', 'not ancestors(\'%candidate%\') and ancestors(\'%branch%\')', '--template', '"{node}\\n"'], $path);
  27228. $result['commit'] = '';
  27229. $result['feature_version'] = $version;
  27230. $result['feature_pretty_version'] = $version;
  27231. return $result;
  27232. }
  27233. return null;
  27234. }
  27235. private function guessFeatureVersion(array $packageConfig, ?string $version, array $branches, array $scmCmdline, string $path): array
  27236. {
  27237. $prettyVersion = $version;
  27238. if (!isset($packageConfig['extra']['branch-alias'][$version])
  27239. || strpos(json_encode($packageConfig), '"self.version"')
  27240. ) {
  27241. $branch = Preg::replace('{^dev-}', '', $version);
  27242. $length = PHP_INT_MAX;
  27243. if (!$this->isFeatureBranch($packageConfig, $branch)) {
  27244. return ['version' => $version, 'pretty_version' => $prettyVersion];
  27245. }
  27246. usort($branches, static function ($a, $b): int {
  27247. $aRemote = 0 === strpos($a, 'remotes/');
  27248. $bRemote = 0 === strpos($b, 'remotes/');
  27249. if ($aRemote !== $bRemote) {
  27250. return $aRemote ? 1 : -1;
  27251. }
  27252. return strnatcasecmp($b, $a);
  27253. });
  27254. $promises = [];
  27255. $this->process->setMaxJobs(30);
  27256. try {
  27257. $lastIndex = -1;
  27258. foreach ($branches as $index => $candidate) {
  27259. $candidateVersion = Preg::replace('{^remotes/\S+/}', '', $candidate);
  27260. if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
  27261. continue;
  27262. }
  27263. $cmdLine = array_map(static function (string $component) use ($candidate, $branch) {
  27264. return str_replace(['%candidate%', '%branch%'], [$candidate, $branch], $component);
  27265. }, $scmCmdline);
  27266. $promises[] = $this->process->executeAsync($cmdLine, $path)->then(function (Process $process) use (&$lastIndex, $index, &$length, &$version, &$prettyVersion, $candidateVersion, &$promises): void {
  27267. if (!$process->isSuccessful()) {
  27268. return;
  27269. }
  27270. $output = $process->getOutput();
  27271. if (strlen($output) < $length || (strlen($output) === $length && $lastIndex < $index)) {
  27272. $lastIndex = $index;
  27273. $length = strlen($output);
  27274. $version = $this->versionParser->normalizeBranch($candidateVersion);
  27275. $prettyVersion = 'dev-' . $candidateVersion;
  27276. if ($length === 0) {
  27277. foreach ($promises as $promise) {
  27278. \React\Promise\resolve($promise)->cancel();
  27279. }
  27280. }
  27281. }
  27282. });
  27283. }
  27284. $this->process->wait();
  27285. } finally {
  27286. $this->process->resetMaxJobs();
  27287. }
  27288. }
  27289. return ['version' => $version, 'pretty_version' => $prettyVersion];
  27290. }
  27291. private function isFeatureBranch(array $packageConfig, ?string $branchName): bool
  27292. {
  27293. $nonFeatureBranches = '';
  27294. if (!empty($packageConfig['non-feature-branches'])) {
  27295. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  27296. }
  27297. return !Preg::isMatch('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
  27298. }
  27299. private function guessFossilVersion(string $path): array
  27300. {
  27301. $version = null;
  27302. $prettyVersion = null;
  27303. if (0 === $this->process->execute(['fossil', 'branch', 'list'], $output, $path)) {
  27304. $branch = trim($output);
  27305. $version = $this->versionParser->normalizeBranch($branch);
  27306. $prettyVersion = 'dev-' . $branch;
  27307. }
  27308. if (0 === $this->process->execute(['fossil', 'tag', 'list'], $output, $path)) {
  27309. try {
  27310. $version = $this->versionParser->normalize(trim($output));
  27311. $prettyVersion = trim($output);
  27312. } catch (\Exception $e) {
  27313. }
  27314. }
  27315. return ['version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion];
  27316. }
  27317. private function guessSvnVersion(array $packageConfig, string $path): ?array
  27318. {
  27319. SvnUtil::cleanEnv();
  27320. if (0 === $this->process->execute(['svn', 'info', '--xml'], $output, $path)) {
  27321. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  27322. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  27323. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  27324. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  27325. if (Preg::isMatch($urlPattern, $output, $matches)) {
  27326. if (isset($matches[2], $matches[3]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  27327. $version = $this->versionParser->normalizeBranch($matches[3]);
  27328. $prettyVersion = 'dev-' . $matches[3];
  27329. return ['version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion];
  27330. }
  27331. assert(is_string($matches[1]));
  27332. $prettyVersion = trim($matches[1]);
  27333. if ($prettyVersion === 'trunk') {
  27334. $version = 'dev-trunk';
  27335. } else {
  27336. $version = $this->versionParser->normalize($prettyVersion);
  27337. }
  27338. return ['version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion];
  27339. }
  27340. }
  27341. return null;
  27342. }
  27343. public function getRootVersionFromEnv(): string
  27344. {
  27345. $version = Platform::getEnv('COMPOSER_ROOT_VERSION');
  27346. if (!is_string($version) || $version === '') {
  27347. throw new \RuntimeException('COMPOSER_ROOT_VERSION not set or empty');
  27348. }
  27349. if (Preg::isMatch('{^(\d+(?:\.\d+)*)-dev$}i', $version, $match)) {
  27350. $version = $match[1].'.x-dev';
  27351. }
  27352. return $version;
  27353. }
  27354. }
  27355. <?php declare(strict_types=1);
  27356. namespace Composer\Package\Version;
  27357. use Composer\Pcre\Preg;
  27358. use Composer\Repository\PlatformRepository;
  27359. use Composer\Semver\VersionParser as SemverVersionParser;
  27360. use Composer\Semver\Semver;
  27361. use Composer\Semver\Constraint\ConstraintInterface;
  27362. class VersionParser extends SemverVersionParser
  27363. {
  27364. public const DEFAULT_BRANCH_ALIAS = '9999999-dev';
  27365. private static $constraints = [];
  27366. public function parseConstraints($constraints): ConstraintInterface
  27367. {
  27368. if (!isset(self::$constraints[$constraints])) {
  27369. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  27370. }
  27371. return self::$constraints[$constraints];
  27372. }
  27373. public function parseNameVersionPairs(array $pairs): array
  27374. {
  27375. $pairs = array_values($pairs);
  27376. $result = [];
  27377. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  27378. $pair = Preg::replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  27379. 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])) {
  27380. $pair .= ' '.$pairs[$i + 1];
  27381. $i++;
  27382. }
  27383. if (strpos($pair, ' ')) {
  27384. [$name, $version] = explode(' ', $pair, 2);
  27385. $result[] = ['name' => $name, 'version' => $version];
  27386. } else {
  27387. $result[] = ['name' => $pair];
  27388. }
  27389. }
  27390. return $result;
  27391. }
  27392. public static function isUpgrade(string $normalizedFrom, string $normalizedTo): bool
  27393. {
  27394. if ($normalizedFrom === $normalizedTo) {
  27395. return true;
  27396. }
  27397. if (in_array($normalizedFrom, ['dev-master', 'dev-trunk', 'dev-default'], true)) {
  27398. $normalizedFrom = VersionParser::DEFAULT_BRANCH_ALIAS;
  27399. }
  27400. if (in_array($normalizedTo, ['dev-master', 'dev-trunk', 'dev-default'], true)) {
  27401. $normalizedTo = VersionParser::DEFAULT_BRANCH_ALIAS;
  27402. }
  27403. if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
  27404. return true;
  27405. }
  27406. $sorted = Semver::sort([$normalizedTo, $normalizedFrom]);
  27407. return $sorted[0] === $normalizedFrom;
  27408. }
  27409. }
  27410. <?php declare(strict_types=1);
  27411. namespace Composer\Package\Version;
  27412. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  27413. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  27414. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  27415. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  27416. use Composer\IO\IOInterface;
  27417. use Composer\Package\BasePackage;
  27418. use Composer\Package\AliasPackage;
  27419. use Composer\Package\PackageInterface;
  27420. use Composer\Composer;
  27421. use Composer\Package\Loader\ArrayLoader;
  27422. use Composer\Package\Dumper\ArrayDumper;
  27423. use Composer\Pcre\Preg;
  27424. use Composer\Repository\RepositorySet;
  27425. use Composer\Repository\PlatformRepository;
  27426. use Composer\Semver\Constraint\Constraint;
  27427. use Composer\Semver\Constraint\ConstraintInterface;
  27428. class VersionSelector
  27429. {
  27430. private $repositorySet;
  27431. private $platformConstraints = [];
  27432. private $parser;
  27433. public function __construct(RepositorySet $repositorySet, ?PlatformRepository $platformRepo = null)
  27434. {
  27435. $this->repositorySet = $repositorySet;
  27436. if ($platformRepo) {
  27437. foreach ($platformRepo->getPackages() as $package) {
  27438. $this->platformConstraints[$package->getName()][] = new Constraint('==', $package->getVersion());
  27439. }
  27440. }
  27441. }
  27442. public function findBestCandidate(string $packageName, ?string $targetPackageVersion = null, string $preferredStability = 'stable', $platformRequirementFilter = null, int $repoSetFlags = 0, ?IOInterface $io = null, $showWarnings = true)
  27443. {
  27444. if (!isset(BasePackage::STABILITIES[$preferredStability])) {
  27445. throw new \UnexpectedValueException('Expected a valid stability name as 3rd argument, got '.$preferredStability);
  27446. }
  27447. if (null === $platformRequirementFilter) {
  27448. $platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  27449. } elseif (!($platformRequirementFilter instanceof PlatformRequirementFilterInterface)) {
  27450. 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);
  27451. $platformRequirementFilter = PlatformRequirementFilterFactory::fromBoolOrList($platformRequirementFilter);
  27452. }
  27453. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  27454. $candidates = $this->repositorySet->findPackages(strtolower($packageName), $constraint, $repoSetFlags);
  27455. $minPriority = BasePackage::STABILITIES[$preferredStability];
  27456. usort($candidates, static function (PackageInterface $a, PackageInterface $b) use ($minPriority) {
  27457. $aPriority = $a->getStabilityPriority();
  27458. $bPriority = $b->getStabilityPriority();
  27459. if ($minPriority < $aPriority && $bPriority < $aPriority) {
  27460. return 1;
  27461. }
  27462. if ($minPriority < $aPriority && $aPriority < $bPriority) {
  27463. return -1;
  27464. }
  27465. if ($minPriority >= $aPriority && $minPriority < $bPriority) {
  27466. return -1;
  27467. }
  27468. return version_compare($b->getVersion(), $a->getVersion());
  27469. });
  27470. if (count($this->platformConstraints) > 0 && !($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter)) {
  27471. $alreadyWarnedNames = [];
  27472. $alreadySeenNames = [];
  27473. foreach ($candidates as $pkg) {
  27474. $reqs = $pkg->getRequires();
  27475. $skip = false;
  27476. foreach ($reqs as $name => $link) {
  27477. if (!PlatformRepository::isPlatformPackage($name) || $platformRequirementFilter->isIgnored($name)) {
  27478. continue;
  27479. }
  27480. if (isset($this->platformConstraints[$name])) {
  27481. foreach ($this->platformConstraints[$name] as $providedConstraint) {
  27482. if ($link->getConstraint()->matches($providedConstraint)) {
  27483. continue 2;
  27484. }
  27485. if ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter && $platformRequirementFilter->isUpperBoundIgnored($name)) {
  27486. $filteredConstraint = $platformRequirementFilter->filterConstraint($name, $link->getConstraint());
  27487. if ($filteredConstraint->matches($providedConstraint)) {
  27488. continue 2;
  27489. }
  27490. }
  27491. }
  27492. $reason = 'is not satisfied by your platform';
  27493. } else {
  27494. $reason = 'is missing from your platform';
  27495. }
  27496. $isLatestVersion = !isset($alreadySeenNames[$pkg->getName()]);
  27497. $alreadySeenNames[$pkg->getName()] = true;
  27498. if ($io !== null && ($showWarnings === true || (is_callable($showWarnings) && $showWarnings($pkg)))) {
  27499. $isFirstWarning = !isset($alreadyWarnedNames[$pkg->getName().'/'.$link->getTarget()]);
  27500. $alreadyWarnedNames[$pkg->getName().'/'.$link->getTarget()] = true;
  27501. $latest = $isLatestVersion ? "'s latest version" : '';
  27502. $io->writeError(
  27503. '<warning>Cannot use '.$pkg->getPrettyName().$latest.' '.$pkg->getPrettyVersion().' as it '.$link->getDescription().' '.$link->getTarget().' '.$link->getPrettyConstraint().' which '.$reason.'.</>',
  27504. true,
  27505. $isFirstWarning ? IOInterface::NORMAL : IOInterface::VERBOSE
  27506. );
  27507. }
  27508. $skip = true;
  27509. }
  27510. if ($skip) {
  27511. continue;
  27512. }
  27513. $package = $pkg;
  27514. break;
  27515. }
  27516. } else {
  27517. $package = count($candidates) > 0 ? $candidates[0] : null;
  27518. }
  27519. if (!isset($package)) {
  27520. return false;
  27521. }
  27522. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  27523. $package = $package->getAliasOf();
  27524. }
  27525. return $package;
  27526. }
  27527. public function findRecommendedRequireVersion(PackageInterface $package): string
  27528. {
  27529. if (0 === strpos($package->getName(), 'ext-')) {
  27530. $phpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  27531. $extVersion = implode('.', array_slice(explode('.', $package->getVersion()), 0, 3));
  27532. if ($phpVersion === $extVersion) {
  27533. return '*';
  27534. }
  27535. }
  27536. $version = $package->getVersion();
  27537. if (!$package->isDev()) {
  27538. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  27539. }
  27540. $loader = new ArrayLoader($this->getParser());
  27541. $dumper = new ArrayDumper();
  27542. $extra = $loader->getBranchAlias($dumper->dump($package));
  27543. if ($extra && $extra !== VersionParser::DEFAULT_BRANCH_ALIAS) {
  27544. $extra = Preg::replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  27545. if ($count > 0) {
  27546. $extra = str_replace('.9999999', '.0', $extra);
  27547. return $this->transformVersion($extra, $extra, 'dev');
  27548. }
  27549. }
  27550. return $package->getPrettyVersion();
  27551. }
  27552. private function transformVersion(string $version, string $prettyVersion, string $stability): string
  27553. {
  27554. $semanticVersionParts = explode('.', $version);
  27555. if (count($semanticVersionParts) === 4 && Preg::isMatch('{^\d+\D?}', $semanticVersionParts[3])) {
  27556. if ($semanticVersionParts[0] === '0') {
  27557. unset($semanticVersionParts[3]);
  27558. } else {
  27559. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  27560. }
  27561. $version = implode('.', $semanticVersionParts);
  27562. } else {
  27563. return $prettyVersion;
  27564. }
  27565. if ($stability !== 'stable') {
  27566. $version .= '@'.$stability;
  27567. }
  27568. return '^' . $version;
  27569. }
  27570. private function getParser(): VersionParser
  27571. {
  27572. if ($this->parser === null) {
  27573. $this->parser = new VersionParser();
  27574. }
  27575. return $this->parser;
  27576. }
  27577. }
  27578. <?php declare(strict_types=1);
  27579. namespace Composer;
  27580. use Composer\Package\RootPackageInterface;
  27581. use Composer\Util\Loop;
  27582. use Composer\Repository\RepositoryManager;
  27583. use Composer\Installer\InstallationManager;
  27584. use Composer\EventDispatcher\EventDispatcher;
  27585. class PartialComposer
  27586. {
  27587. private $global = false;
  27588. private $package;
  27589. private $loop;
  27590. private $repositoryManager;
  27591. private $installationManager;
  27592. private $config;
  27593. private $eventDispatcher;
  27594. public function setPackage(RootPackageInterface $package): void
  27595. {
  27596. $this->package = $package;
  27597. }
  27598. public function getPackage(): RootPackageInterface
  27599. {
  27600. return $this->package;
  27601. }
  27602. public function setConfig(Config $config): void
  27603. {
  27604. $this->config = $config;
  27605. }
  27606. public function getConfig(): Config
  27607. {
  27608. return $this->config;
  27609. }
  27610. public function setLoop(Loop $loop): void
  27611. {
  27612. $this->loop = $loop;
  27613. }
  27614. public function getLoop(): Loop
  27615. {
  27616. return $this->loop;
  27617. }
  27618. public function setRepositoryManager(RepositoryManager $manager): void
  27619. {
  27620. $this->repositoryManager = $manager;
  27621. }
  27622. public function getRepositoryManager(): RepositoryManager
  27623. {
  27624. return $this->repositoryManager;
  27625. }
  27626. public function setInstallationManager(InstallationManager $manager): void
  27627. {
  27628. $this->installationManager = $manager;
  27629. }
  27630. public function getInstallationManager(): InstallationManager
  27631. {
  27632. return $this->installationManager;
  27633. }
  27634. public function setEventDispatcher(EventDispatcher $eventDispatcher): void
  27635. {
  27636. $this->eventDispatcher = $eventDispatcher;
  27637. }
  27638. public function getEventDispatcher(): EventDispatcher
  27639. {
  27640. return $this->eventDispatcher;
  27641. }
  27642. public function isGlobal(): bool
  27643. {
  27644. return $this->global;
  27645. }
  27646. public function setGlobal(): void
  27647. {
  27648. $this->global = true;
  27649. }
  27650. }
  27651. <?php declare(strict_types=1);
  27652. namespace Composer\Platform;
  27653. use Composer\Util\Platform;
  27654. use Composer\Util\ProcessExecutor;
  27655. use Symfony\Component\Process\ExecutableFinder;
  27656. class HhvmDetector
  27657. {
  27658. private static $hhvmVersion = null;
  27659. private $executableFinder;
  27660. private $processExecutor;
  27661. public function __construct(?ExecutableFinder $executableFinder = null, ?ProcessExecutor $processExecutor = null)
  27662. {
  27663. $this->executableFinder = $executableFinder;
  27664. $this->processExecutor = $processExecutor;
  27665. }
  27666. public function reset(): void
  27667. {
  27668. self::$hhvmVersion = null;
  27669. }
  27670. public function getVersion(): ?string
  27671. {
  27672. if (null !== self::$hhvmVersion) {
  27673. return self::$hhvmVersion ?: null;
  27674. }
  27675. self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
  27676. if (self::$hhvmVersion === null && !Platform::isWindows()) {
  27677. self::$hhvmVersion = false;
  27678. $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
  27679. $hhvmPath = $this->executableFinder->find('hhvm');
  27680. if ($hhvmPath !== null) {
  27681. $this->processExecutor = $this->processExecutor ?? new ProcessExecutor();
  27682. $exitCode = $this->processExecutor->execute([$hhvmPath, '--php', '-d', 'hhvm.jit=0', '-r', 'echo HHVM_VERSION;'], self::$hhvmVersion);
  27683. if ($exitCode !== 0) {
  27684. self::$hhvmVersion = false;
  27685. }
  27686. }
  27687. }
  27688. return self::$hhvmVersion ?: null;
  27689. }
  27690. }
  27691. <?php declare(strict_types=1);
  27692. namespace Composer\Platform;
  27693. class Runtime
  27694. {
  27695. public function hasConstant(string $constant, ?string $class = null): bool
  27696. {
  27697. return defined(ltrim($class.'::'.$constant, ':'));
  27698. }
  27699. public function getConstant(string $constant, ?string $class = null)
  27700. {
  27701. return constant(ltrim($class.'::'.$constant, ':'));
  27702. }
  27703. public function hasFunction(string $fn): bool
  27704. {
  27705. return function_exists($fn);
  27706. }
  27707. public function invoke(callable $callable, array $arguments = [])
  27708. {
  27709. return $callable(...$arguments);
  27710. }
  27711. public function hasClass(string $class): bool
  27712. {
  27713. return class_exists($class, false);
  27714. }
  27715. public function construct(string $class, array $arguments = []): object
  27716. {
  27717. if (empty($arguments)) {
  27718. return new $class;
  27719. }
  27720. $refl = new \ReflectionClass($class);
  27721. return $refl->newInstanceArgs($arguments);
  27722. }
  27723. public function getExtensions(): array
  27724. {
  27725. return get_loaded_extensions();
  27726. }
  27727. public function getExtensionVersion(string $extension): string
  27728. {
  27729. $version = phpversion($extension);
  27730. if ($version === false) {
  27731. $version = '0';
  27732. }
  27733. return $version;
  27734. }
  27735. public function getExtensionInfo(string $extension): string
  27736. {
  27737. $reflector = new \ReflectionExtension($extension);
  27738. ob_start();
  27739. $reflector->info();
  27740. return ob_get_clean();
  27741. }
  27742. }
  27743. <?php declare(strict_types=1);
  27744. namespace Composer\Platform;
  27745. use Composer\Pcre\Preg;
  27746. class Version
  27747. {
  27748. public static function parseOpenssl(string $opensslVersion, ?bool &$isFips): ?string
  27749. {
  27750. $isFips = false;
  27751. if (!Preg::isMatchStrictGroups('/^(?<version>[0-9.]+)(?<patch>[a-z]{0,2})(?<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)(?:-\w+)?(?: \(.+?\))?$/', $opensslVersion, $matches)) {
  27752. return null;
  27753. }
  27754. $patch = '';
  27755. if (version_compare($matches['version'], '3.0.0', '<')) {
  27756. $patch = '.'.self::convertAlphaVersionToIntVersion($matches['patch']);
  27757. }
  27758. $isFips = strpos($matches['suffix'], 'fips') !== false;
  27759. $suffix = strtr('-'.ltrim($matches['suffix'], '-'), ['-fips' => '', '-pre' => '-alpha']);
  27760. return rtrim($matches['version'].$patch.$suffix, '-');
  27761. }
  27762. public static function parseLibjpeg(string $libjpegVersion): ?string
  27763. {
  27764. if (!Preg::isMatchStrictGroups('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
  27765. return null;
  27766. }
  27767. return $matches['major'].'.'.self::convertAlphaVersionToIntVersion($matches['minor']);
  27768. }
  27769. public static function parseZoneinfoVersion(string $zoneinfoVersion): ?string
  27770. {
  27771. if (!Preg::isMatchStrictGroups('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
  27772. return null;
  27773. }
  27774. return $matches['year'].'.'.self::convertAlphaVersionToIntVersion($matches['revision']);
  27775. }
  27776. private static function convertAlphaVersionToIntVersion(string $alpha): int
  27777. {
  27778. return strlen($alpha) * (-ord('a') + 1) + array_sum(array_map('ord', str_split($alpha)));
  27779. }
  27780. public static function convertLibxpmVersionId(int $versionId): string
  27781. {
  27782. return self::convertVersionId($versionId, 100);
  27783. }
  27784. public static function convertOpenldapVersionId(int $versionId): string
  27785. {
  27786. return self::convertVersionId($versionId, 100);
  27787. }
  27788. private static function convertVersionId(int $versionId, int $base): string
  27789. {
  27790. return sprintf(
  27791. '%d.%d.%d',
  27792. $versionId / ($base * $base),
  27793. (int) ($versionId / $base) % $base,
  27794. $versionId % $base
  27795. );
  27796. }
  27797. }
  27798. <?php declare(strict_types=1);
  27799. namespace Composer\Plugin\Capability;
  27800. interface Capability
  27801. {
  27802. }
  27803. <?php declare(strict_types=1);
  27804. namespace Composer\Plugin\Capability;
  27805. interface CommandProvider extends Capability
  27806. {
  27807. public function getCommands();
  27808. }
  27809. <?php declare(strict_types=1);
  27810. namespace Composer\Plugin;
  27811. interface Capable
  27812. {
  27813. public function getCapabilities();
  27814. }
  27815. <?php declare(strict_types=1);
  27816. namespace Composer\Plugin;
  27817. use Composer\EventDispatcher\Event;
  27818. use Symfony\Component\Console\Input\InputInterface;
  27819. use Symfony\Component\Console\Output\OutputInterface;
  27820. class CommandEvent extends Event
  27821. {
  27822. private $commandName;
  27823. private $input;
  27824. private $output;
  27825. public function __construct(string $name, string $commandName, InputInterface $input, OutputInterface $output, array $args = [], array $flags = [])
  27826. {
  27827. parent::__construct($name, $args, $flags);
  27828. $this->commandName = $commandName;
  27829. $this->input = $input;
  27830. $this->output = $output;
  27831. }
  27832. public function getInput(): InputInterface
  27833. {
  27834. return $this->input;
  27835. }
  27836. public function getOutput(): OutputInterface
  27837. {
  27838. return $this->output;
  27839. }
  27840. public function getCommandName(): string
  27841. {
  27842. return $this->commandName;
  27843. }
  27844. }
  27845. <?php declare(strict_types=1);
  27846. namespace Composer\Plugin;
  27847. use UnexpectedValueException;
  27848. class PluginBlockedException extends UnexpectedValueException
  27849. {
  27850. }
  27851. <?php declare(strict_types=1);
  27852. namespace Composer\Plugin;
  27853. class PluginEvents
  27854. {
  27855. public const INIT = 'init';
  27856. public const COMMAND = 'command';
  27857. public const PRE_FILE_DOWNLOAD = 'pre-file-download';
  27858. public const POST_FILE_DOWNLOAD = 'post-file-download';
  27859. public const PRE_COMMAND_RUN = 'pre-command-run';
  27860. public const PRE_POOL_CREATE = 'pre-pool-create';
  27861. }
  27862. <?php declare(strict_types=1);
  27863. namespace Composer\Plugin;
  27864. use Composer\Composer;
  27865. use Composer\IO\IOInterface;
  27866. interface PluginInterface
  27867. {
  27868. public const PLUGIN_API_VERSION = '2.6.0';
  27869. public function activate(Composer $composer, IOInterface $io);
  27870. public function deactivate(Composer $composer, IOInterface $io);
  27871. public function uninstall(Composer $composer, IOInterface $io);
  27872. }
  27873. <?php declare(strict_types=1);
  27874. namespace Composer\Plugin;
  27875. use Composer\Composer;
  27876. use Composer\EventDispatcher\EventSubscriberInterface;
  27877. use Composer\Installer\InstallerInterface;
  27878. use Composer\IO\IOInterface;
  27879. use Composer\Package\BasePackage;
  27880. use Composer\Package\CompletePackage;
  27881. use Composer\Package\Locker;
  27882. use Composer\Package\Package;
  27883. use Composer\Package\RootPackageInterface;
  27884. use Composer\Package\Version\VersionParser;
  27885. use Composer\PartialComposer;
  27886. use Composer\Pcre\Preg;
  27887. use Composer\Repository\RepositoryInterface;
  27888. use Composer\Repository\InstalledRepository;
  27889. use Composer\Repository\RepositoryUtils;
  27890. use Composer\Repository\RootPackageRepository;
  27891. use Composer\Package\PackageInterface;
  27892. use Composer\Package\Link;
  27893. use Composer\Semver\Constraint\Constraint;
  27894. use Composer\Plugin\Capability\Capability;
  27895. use Composer\Util\PackageSorter;
  27896. class PluginManager
  27897. {
  27898. protected $composer;
  27899. protected $io;
  27900. protected $globalComposer;
  27901. protected $versionParser;
  27902. protected $disablePlugins = false;
  27903. protected $plugins = [];
  27904. protected $registeredPlugins = [];
  27905. private $allowPluginRules;
  27906. private $allowGlobalPluginRules;
  27907. private $runningInGlobalDir = false;
  27908. private static $classCounter = 0;
  27909. public function __construct(IOInterface $io, Composer $composer, ?PartialComposer $globalComposer = null, $disablePlugins = false)
  27910. {
  27911. $this->io = $io;
  27912. $this->composer = $composer;
  27913. $this->globalComposer = $globalComposer;
  27914. $this->versionParser = new VersionParser();
  27915. $this->disablePlugins = $disablePlugins;
  27916. $this->allowPluginRules = $this->parseAllowedPlugins($composer->getConfig()->get('allow-plugins'), $composer->getLocker());
  27917. $this->allowGlobalPluginRules = $this->parseAllowedPlugins($globalComposer !== null ? $globalComposer->getConfig()->get('allow-plugins') : false);
  27918. }
  27919. public function setRunningInGlobalDir(bool $runningInGlobalDir): void
  27920. {
  27921. $this->runningInGlobalDir = $runningInGlobalDir;
  27922. }
  27923. public function loadInstalledPlugins(): void
  27924. {
  27925. if (!$this->arePluginsDisabled('local')) {
  27926. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  27927. $this->loadRepository($repo, false, $this->composer->getPackage());
  27928. }
  27929. if ($this->globalComposer !== null && !$this->arePluginsDisabled('global')) {
  27930. $this->loadRepository($this->globalComposer->getRepositoryManager()->getLocalRepository(), true);
  27931. }
  27932. }
  27933. public function deactivateInstalledPlugins(): void
  27934. {
  27935. if (!$this->arePluginsDisabled('local')) {
  27936. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  27937. $this->deactivateRepository($repo, false);
  27938. }
  27939. if ($this->globalComposer !== null && !$this->arePluginsDisabled('global')) {
  27940. $this->deactivateRepository($this->globalComposer->getRepositoryManager()->getLocalRepository(), true);
  27941. }
  27942. }
  27943. public function getPlugins(): array
  27944. {
  27945. return $this->plugins;
  27946. }
  27947. public function getGlobalComposer(): ?PartialComposer
  27948. {
  27949. return $this->globalComposer;
  27950. }
  27951. public function registerPackage(PackageInterface $package, bool $failOnMissingClasses = false, bool $isGlobalPlugin = false): void
  27952. {
  27953. if ($this->arePluginsDisabled($isGlobalPlugin ? 'global' : 'local')) {
  27954. $this->io->writeError('<warning>The "'.$package->getName().'" plugin was not loaded as plugins are disabled.</warning>');
  27955. return;
  27956. }
  27957. if ($package->getType() === 'composer-plugin') {
  27958. $requiresComposer = null;
  27959. foreach ($package->getRequires() as $link) {
  27960. if ('composer-plugin-api' === $link->getTarget()) {
  27961. $requiresComposer = $link->getConstraint();
  27962. break;
  27963. }
  27964. }
  27965. if (!$requiresComposer) {
  27966. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  27967. }
  27968. $currentPluginApiVersion = $this->getPluginApiVersion();
  27969. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  27970. if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
  27971. $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>');
  27972. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  27973. $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>');
  27974. return;
  27975. }
  27976. if ($package->getName() === 'symfony/flex' && Preg::isMatch('{^[0-9.]+$}', $package->getVersion()) && version_compare($package->getVersion(), '1.9.8', '<')) {
  27977. $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>');
  27978. return;
  27979. }
  27980. }
  27981. if (!$this->isPluginAllowed($package->getName(), $isGlobalPlugin, true === ($package->getExtra()['plugin-optional'] ?? false))) {
  27982. $this->io->writeError('Skipped loading "'.$package->getName() . '" '.($isGlobalPlugin || $this->runningInGlobalDir ? '(installed globally) ' : '').'as it is not in config.allow-plugins', true, IOInterface::DEBUG);
  27983. return;
  27984. }
  27985. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  27986. if (isset($this->registeredPlugins[$package->getName()])) {
  27987. return;
  27988. }
  27989. $this->registeredPlugins[$package->getName()] = [];
  27990. $extra = $package->getExtra();
  27991. if (empty($extra['class'])) {
  27992. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  27993. }
  27994. $classes = is_array($extra['class']) ? $extra['class'] : [$extra['class']];
  27995. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  27996. $globalRepo = $this->globalComposer !== null ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  27997. $rootPackage = clone $this->composer->getPackage();
  27998. $rootPackageAutoloads = $rootPackage->getAutoload();
  27999. $rootPackageAutoloads['files'] = [];
  28000. $rootPackage->setAutoload($rootPackageAutoloads);
  28001. $rootPackageAutoloads = $rootPackage->getDevAutoload();
  28002. $rootPackageAutoloads['files'] = [];
  28003. $rootPackage->setDevAutoload($rootPackageAutoloads);
  28004. unset($rootPackageAutoloads);
  28005. $rootPackageRepo = new RootPackageRepository($rootPackage);
  28006. $installedRepo = new InstalledRepository([$localRepo, $rootPackageRepo]);
  28007. if ($globalRepo) {
  28008. $installedRepo->addRepository($globalRepo);
  28009. }
  28010. $autoloadPackages = [$package->getName() => $package];
  28011. $autoloadPackages = $this->collectDependencies($installedRepo, $autoloadPackages, $package);
  28012. $generator = $this->composer->getAutoloadGenerator();
  28013. $autoloads = [[$rootPackage, '']];
  28014. foreach ($autoloadPackages as $autoloadPackage) {
  28015. if ($autoloadPackage === $rootPackage) {
  28016. continue;
  28017. }
  28018. $installPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  28019. if ($installPath === null) {
  28020. continue;
  28021. }
  28022. $autoloads[] = [$autoloadPackage, $installPath];
  28023. }
  28024. $map = $generator->parseAutoloads($autoloads, $rootPackage);
  28025. $classLoader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  28026. $classLoader->register(false);
  28027. foreach ($map['files'] as $fileIdentifier => $file) {
  28028. if ($fileIdentifier === '7e9bd612cc444b3eed788ebbe46263a0') {
  28029. continue;
  28030. }
  28031. \Composer\Autoload\composerRequire($fileIdentifier, $file);
  28032. }
  28033. foreach ($classes as $class) {
  28034. if (class_exists($class, false)) {
  28035. $class = trim($class, '\\');
  28036. $path = $classLoader->findFile($class);
  28037. $code = file_get_contents($path);
  28038. $separatorPos = strrpos($class, '\\');
  28039. $className = $class;
  28040. if ($separatorPos) {
  28041. $className = substr($class, $separatorPos + 1);
  28042. }
  28043. $code = Preg::replace('{^((?:(?:final|readonly)\s+)*(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  28044. $code = strtr($code, [
  28045. '__FILE__' => var_export($path, true),
  28046. '__DIR__' => var_export(dirname($path), true),
  28047. '__CLASS__' => var_export($class, true),
  28048. ]);
  28049. $code = Preg::replace('/^\s*<\?(php)?/i', '', $code, 1);
  28050. eval($code);
  28051. $class .= '_composer_tmp'.self::$classCounter;
  28052. self::$classCounter++;
  28053. }
  28054. if ($oldInstallerPlugin) {
  28055. if (!is_a($class, 'Composer\Installer\InstallerInterface', true)) {
  28056. throw new \RuntimeException('Could not activate plugin "'.$package->getName().'" as "'.$class.'" does not implement Composer\Installer\InstallerInterface');
  28057. }
  28058. $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>');
  28059. $installer = new $class($this->io, $this->composer);
  28060. $this->composer->getInstallationManager()->addInstaller($installer);
  28061. $this->registeredPlugins[$package->getName()][] = $installer;
  28062. } elseif (class_exists($class)) {
  28063. if (!is_a($class, 'Composer\Plugin\PluginInterface', true)) {
  28064. throw new \RuntimeException('Could not activate plugin "'.$package->getName().'" as "'.$class.'" does not implement Composer\Plugin\PluginInterface');
  28065. }
  28066. $plugin = new $class();
  28067. $this->addPlugin($plugin, $isGlobalPlugin, $package);
  28068. $this->registeredPlugins[$package->getName()][] = $plugin;
  28069. } elseif ($failOnMissingClasses) {
  28070. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  28071. }
  28072. }
  28073. }
  28074. public function deactivatePackage(PackageInterface $package): void
  28075. {
  28076. if (!isset($this->registeredPlugins[$package->getName()])) {
  28077. return;
  28078. }
  28079. $plugins = $this->registeredPlugins[$package->getName()];
  28080. foreach ($plugins as $plugin) {
  28081. if ($plugin instanceof InstallerInterface) {
  28082. $this->composer->getInstallationManager()->removeInstaller($plugin);
  28083. } else {
  28084. $this->removePlugin($plugin);
  28085. }
  28086. }
  28087. unset($this->registeredPlugins[$package->getName()]);
  28088. }
  28089. public function uninstallPackage(PackageInterface $package): void
  28090. {
  28091. if (!isset($this->registeredPlugins[$package->getName()])) {
  28092. return;
  28093. }
  28094. $plugins = $this->registeredPlugins[$package->getName()];
  28095. foreach ($plugins as $plugin) {
  28096. if ($plugin instanceof InstallerInterface) {
  28097. $this->composer->getInstallationManager()->removeInstaller($plugin);
  28098. } else {
  28099. $this->removePlugin($plugin);
  28100. $this->uninstallPlugin($plugin);
  28101. }
  28102. }
  28103. unset($this->registeredPlugins[$package->getName()]);
  28104. }
  28105. protected function getPluginApiVersion(): string
  28106. {
  28107. return PluginInterface::PLUGIN_API_VERSION;
  28108. }
  28109. public function addPlugin(PluginInterface $plugin, bool $isGlobalPlugin = false, ?PackageInterface $sourcePackage = null): void
  28110. {
  28111. if ($this->arePluginsDisabled($isGlobalPlugin ? 'global' : 'local')) {
  28112. return;
  28113. }
  28114. if ($sourcePackage === null) {
  28115. 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);
  28116. } elseif (!$this->isPluginAllowed($sourcePackage->getName(), $isGlobalPlugin, true === ($sourcePackage->getExtra()['plugin-optional'] ?? false))) {
  28117. $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);
  28118. return;
  28119. }
  28120. $details = [];
  28121. if ($sourcePackage) {
  28122. $details[] = 'from '.$sourcePackage->getName();
  28123. }
  28124. if ($isGlobalPlugin || $this->runningInGlobalDir) {
  28125. $details[] = 'installed globally';
  28126. }
  28127. $this->io->writeError('Loading plugin '.get_class($plugin).($details ? ' ('.implode(', ', $details).')' : ''), true, IOInterface::DEBUG);
  28128. $this->plugins[] = $plugin;
  28129. $plugin->activate($this->composer, $this->io);
  28130. if ($plugin instanceof EventSubscriberInterface) {
  28131. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  28132. }
  28133. }
  28134. public function removePlugin(PluginInterface $plugin): void
  28135. {
  28136. $index = array_search($plugin, $this->plugins, true);
  28137. if ($index === false) {
  28138. return;
  28139. }
  28140. $this->io->writeError('Unloading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  28141. unset($this->plugins[$index]);
  28142. $plugin->deactivate($this->composer, $this->io);
  28143. $this->composer->getEventDispatcher()->removeListener($plugin);
  28144. }
  28145. public function uninstallPlugin(PluginInterface $plugin): void
  28146. {
  28147. $this->io->writeError('Uninstalling plugin '.get_class($plugin), true, IOInterface::DEBUG);
  28148. $plugin->uninstall($this->composer, $this->io);
  28149. }
  28150. private function loadRepository(RepositoryInterface $repo, bool $isGlobalRepo, ?RootPackageInterface $rootPackage = null): void
  28151. {
  28152. $packages = $repo->getPackages();
  28153. $weights = [];
  28154. foreach ($packages as $package) {
  28155. if ($package->getType() === 'composer-plugin') {
  28156. $extra = $package->getExtra();
  28157. if ($package->getName() === 'composer/installers' || true === ($extra['plugin-modifies-install-path'] ?? false)) {
  28158. $weights[$package->getName()] = -10000;
  28159. }
  28160. }
  28161. }
  28162. $sortedPackages = PackageSorter::sortPackages($packages, $weights);
  28163. if (!$isGlobalRepo) {
  28164. $requiredPackages = RepositoryUtils::filterRequiredPackages($packages, $rootPackage, true);
  28165. }
  28166. foreach ($sortedPackages as $package) {
  28167. if (!($package instanceof CompletePackage)) {
  28168. continue;
  28169. }
  28170. if (!in_array($package->getType(), ['composer-plugin', 'composer-installer'], true)) {
  28171. continue;
  28172. }
  28173. if (
  28174. !$isGlobalRepo
  28175. && !in_array($package, $requiredPackages, true)
  28176. && !$this->isPluginAllowed($package->getName(), false, true, false)
  28177. ) {
  28178. $this->io->writeError('<warning>The "'.$package->getName().'" plugin was not loaded as it is not listed in allow-plugins and is not required by the root package anymore.</warning>');
  28179. continue;
  28180. }
  28181. if ('composer-plugin' === $package->getType()) {
  28182. $this->registerPackage($package, false, $isGlobalRepo);
  28183. } elseif ('composer-installer' === $package->getType()) {
  28184. $this->registerPackage($package, false, $isGlobalRepo);
  28185. }
  28186. }
  28187. }
  28188. private function deactivateRepository(RepositoryInterface $repo, bool $isGlobalRepo): void
  28189. {
  28190. $packages = $repo->getPackages();
  28191. $sortedPackages = array_reverse(PackageSorter::sortPackages($packages));
  28192. foreach ($sortedPackages as $package) {
  28193. if (!($package instanceof CompletePackage)) {
  28194. continue;
  28195. }
  28196. if ('composer-plugin' === $package->getType()) {
  28197. $this->deactivatePackage($package);
  28198. } elseif ('composer-installer' === $package->getType()) {
  28199. $this->deactivatePackage($package);
  28200. }
  28201. }
  28202. }
  28203. private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package): array
  28204. {
  28205. foreach ($package->getRequires() as $requireLink) {
  28206. foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget()) as $requiredPackage) {
  28207. if (!isset($collected[$requiredPackage->getName()])) {
  28208. $collected[$requiredPackage->getName()] = $requiredPackage;
  28209. $collected = $this->collectDependencies($installedRepo, $collected, $requiredPackage);
  28210. }
  28211. }
  28212. }
  28213. return $collected;
  28214. }
  28215. private function getInstallPath(PackageInterface $package, bool $global = false): ?string
  28216. {
  28217. if (!$global) {
  28218. return $this->composer->getInstallationManager()->getInstallPath($package);
  28219. }
  28220. assert(null !== $this->globalComposer);
  28221. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  28222. }
  28223. protected function getCapabilityImplementationClassName(PluginInterface $plugin, string $capability): ?string
  28224. {
  28225. if (!($plugin instanceof Capable)) {
  28226. return null;
  28227. }
  28228. $capabilities = (array) $plugin->getCapabilities();
  28229. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  28230. return trim($capabilities[$capability]);
  28231. }
  28232. if (
  28233. array_key_exists($capability, $capabilities)
  28234. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  28235. ) {
  28236. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], true));
  28237. }
  28238. return null;
  28239. }
  28240. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = []): ?Capability
  28241. {
  28242. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  28243. if (!class_exists($capabilityClass)) {
  28244. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  28245. }
  28246. $ctorArgs['plugin'] = $plugin;
  28247. $capabilityObj = new $capabilityClass($ctorArgs);
  28248. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  28249. throw new \RuntimeException(
  28250. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  28251. );
  28252. }
  28253. return $capabilityObj;
  28254. }
  28255. return null;
  28256. }
  28257. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = []): array
  28258. {
  28259. $capabilities = [];
  28260. foreach ($this->getPlugins() as $plugin) {
  28261. $capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs);
  28262. if (null !== $capability) {
  28263. $capabilities[] = $capability;
  28264. }
  28265. }
  28266. return $capabilities;
  28267. }
  28268. private function parseAllowedPlugins($allowPluginsConfig, ?Locker $locker = null): ?array
  28269. {
  28270. if ([] === $allowPluginsConfig && $locker !== null && $locker->isLocked() && version_compare($locker->getPluginApi(), '2.2.0', '<')) {
  28271. return null;
  28272. }
  28273. if (true === $allowPluginsConfig) {
  28274. return ['{}' => true];
  28275. }
  28276. if (false === $allowPluginsConfig) {
  28277. return ['{}' => false];
  28278. }
  28279. $rules = [];
  28280. foreach ($allowPluginsConfig as $pattern => $allow) {
  28281. $rules[BasePackage::packageNameToRegexp($pattern)] = $allow;
  28282. }
  28283. return $rules;
  28284. }
  28285. public function arePluginsDisabled($type)
  28286. {
  28287. return $this->disablePlugins === true || $this->disablePlugins === $type;
  28288. }
  28289. public function disablePlugins(): void
  28290. {
  28291. $this->disablePlugins = true;
  28292. }
  28293. public function isPluginAllowed(string $package, bool $isGlobalPlugin, bool $optional = false, bool $prompt = true): bool
  28294. {
  28295. if ($isGlobalPlugin) {
  28296. $rules = &$this->allowGlobalPluginRules;
  28297. } else {
  28298. $rules = &$this->allowPluginRules;
  28299. }
  28300. if ($rules === null) {
  28301. if (!$this->io->isInteractive()) {
  28302. $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>');
  28303. $this->io->writeError('<warning>This warning will become an exception once you run composer update!</warning>');
  28304. $rules = ['{}' => true];
  28305. return true;
  28306. }
  28307. $rules = [];
  28308. }
  28309. foreach ($rules as $pattern => $allow) {
  28310. if (Preg::isMatch($pattern, $package)) {
  28311. return $allow === true;
  28312. }
  28313. }
  28314. if ($package === 'composer/package-versions-deprecated') {
  28315. return false;
  28316. }
  28317. if ($this->io->isInteractive() && $prompt) {
  28318. $composer = $isGlobalPlugin && $this->globalComposer !== null ? $this->globalComposer : $this->composer;
  28319. $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>');
  28320. $attempts = 0;
  28321. while (true) {
  28322. $default = '?';
  28323. if ($attempts > 5) {
  28324. $this->io->writeError('Too many failed prompts, aborting.');
  28325. break;
  28326. }
  28327. 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)) {
  28328. case 'y':
  28329. case 'n':
  28330. case 'd':
  28331. $allow = $answer === 'y';
  28332. $rules[BasePackage::packageNameToRegexp($package)] = $allow;
  28333. if ($answer === 'y' || $answer === 'n') {
  28334. $allowPlugins = $composer->getConfig()->get('allow-plugins');
  28335. if (is_array($allowPlugins)) {
  28336. $allowPlugins[$package] = $allow;
  28337. if ($composer->getConfig()->get('sort-packages')) {
  28338. ksort($allowPlugins);
  28339. }
  28340. $composer->getConfig()->getConfigSource()->addConfigSetting('allow-plugins', $allowPlugins);
  28341. $composer->getConfig()->merge(['config' => ['allow-plugins' => $allowPlugins]]);
  28342. }
  28343. }
  28344. return $allow;
  28345. case '?':
  28346. default:
  28347. $attempts++;
  28348. $this->io->writeError([
  28349. 'y - add package to allow-plugins in composer.json and let it run immediately',
  28350. 'n - add package (as disallowed) to allow-plugins in composer.json to suppress further prompts',
  28351. 'd - discard this, do not change composer.json and do not allow the plugin to run',
  28352. '? - print help',
  28353. ]);
  28354. break;
  28355. }
  28356. }
  28357. } elseif ($optional) {
  28358. return false;
  28359. }
  28360. throw new PluginBlockedException(
  28361. $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.
  28362. '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.
  28363. 'See https://getcomposer.org/allow-plugins'
  28364. );
  28365. }
  28366. }
  28367. <?php declare(strict_types=1);
  28368. namespace Composer\Plugin;
  28369. use Composer\EventDispatcher\Event;
  28370. use Composer\Package\PackageInterface;
  28371. class PostFileDownloadEvent extends Event
  28372. {
  28373. private $fileName;
  28374. private $checksum;
  28375. private $url;
  28376. private $context;
  28377. private $type;
  28378. public function __construct(string $name, ?string $fileName, ?string $checksum, string $url, string $type, $context = null)
  28379. {
  28380. if ($context === null && $type instanceof PackageInterface) {
  28381. $context = $type;
  28382. $type = 'package';
  28383. trigger_error('PostFileDownloadEvent::__construct should receive a $type=package and the package object in $context since Composer 2.1.', E_USER_DEPRECATED);
  28384. }
  28385. parent::__construct($name);
  28386. $this->fileName = $fileName;
  28387. $this->checksum = $checksum;
  28388. $this->url = $url;
  28389. $this->context = $context;
  28390. $this->type = $type;
  28391. }
  28392. public function getFileName(): ?string
  28393. {
  28394. return $this->fileName;
  28395. }
  28396. public function getChecksum(): ?string
  28397. {
  28398. return $this->checksum;
  28399. }
  28400. public function getUrl(): string
  28401. {
  28402. return $this->url;
  28403. }
  28404. public function getContext()
  28405. {
  28406. return $this->context;
  28407. }
  28408. public function getPackage(): ?PackageInterface
  28409. {
  28410. trigger_error('PostFileDownloadEvent::getPackage is deprecated since Composer 2.1, use getContext instead.', E_USER_DEPRECATED);
  28411. $context = $this->getContext();
  28412. return $context instanceof PackageInterface ? $context : null;
  28413. }
  28414. public function getType(): string
  28415. {
  28416. return $this->type;
  28417. }
  28418. }
  28419. <?php declare(strict_types=1);
  28420. namespace Composer\Plugin;
  28421. use Composer\EventDispatcher\Event;
  28422. use Symfony\Component\Console\Input\InputInterface;
  28423. class PreCommandRunEvent extends Event
  28424. {
  28425. private $input;
  28426. private $command;
  28427. public function __construct(string $name, InputInterface $input, string $command)
  28428. {
  28429. parent::__construct($name);
  28430. $this->input = $input;
  28431. $this->command = $command;
  28432. }
  28433. public function getInput(): InputInterface
  28434. {
  28435. return $this->input;
  28436. }
  28437. public function getCommand(): string
  28438. {
  28439. return $this->command;
  28440. }
  28441. }
  28442. <?php declare(strict_types=1);
  28443. namespace Composer\Plugin;
  28444. use Composer\EventDispatcher\Event;
  28445. use Composer\Util\HttpDownloader;
  28446. class PreFileDownloadEvent extends Event
  28447. {
  28448. private $httpDownloader;
  28449. private $processedUrl;
  28450. private $customCacheKey;
  28451. private $type;
  28452. private $context;
  28453. private $transportOptions = [];
  28454. public function __construct(string $name, HttpDownloader $httpDownloader, string $processedUrl, string $type, $context = null)
  28455. {
  28456. parent::__construct($name);
  28457. $this->httpDownloader = $httpDownloader;
  28458. $this->processedUrl = $processedUrl;
  28459. $this->type = $type;
  28460. $this->context = $context;
  28461. }
  28462. public function getHttpDownloader(): HttpDownloader
  28463. {
  28464. return $this->httpDownloader;
  28465. }
  28466. public function getProcessedUrl(): string
  28467. {
  28468. return $this->processedUrl;
  28469. }
  28470. public function setProcessedUrl(string $processedUrl): void
  28471. {
  28472. $this->processedUrl = $processedUrl;
  28473. }
  28474. public function getCustomCacheKey(): ?string
  28475. {
  28476. return $this->customCacheKey;
  28477. }
  28478. public function setCustomCacheKey(?string $customCacheKey): void
  28479. {
  28480. $this->customCacheKey = $customCacheKey;
  28481. }
  28482. public function getType(): string
  28483. {
  28484. return $this->type;
  28485. }
  28486. public function getContext()
  28487. {
  28488. return $this->context;
  28489. }
  28490. public function getTransportOptions(): array
  28491. {
  28492. return $this->transportOptions;
  28493. }
  28494. public function setTransportOptions(array $options): void
  28495. {
  28496. $this->transportOptions = $options;
  28497. }
  28498. }
  28499. <?php declare(strict_types=1);
  28500. namespace Composer\Plugin;
  28501. use Composer\EventDispatcher\Event;
  28502. use Composer\Repository\RepositoryInterface;
  28503. use Composer\DependencyResolver\Request;
  28504. use Composer\Package\BasePackage;
  28505. class PrePoolCreateEvent extends Event
  28506. {
  28507. private $repositories;
  28508. private $request;
  28509. private $acceptableStabilities;
  28510. private $stabilityFlags;
  28511. private $rootAliases;
  28512. private $rootReferences;
  28513. private $packages;
  28514. private $unacceptableFixedPackages;
  28515. public function __construct(string $name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
  28516. {
  28517. parent::__construct($name);
  28518. $this->repositories = $repositories;
  28519. $this->request = $request;
  28520. $this->acceptableStabilities = $acceptableStabilities;
  28521. $this->stabilityFlags = $stabilityFlags;
  28522. $this->rootAliases = $rootAliases;
  28523. $this->rootReferences = $rootReferences;
  28524. $this->packages = $packages;
  28525. $this->unacceptableFixedPackages = $unacceptableFixedPackages;
  28526. }
  28527. public function getRepositories(): array
  28528. {
  28529. return $this->repositories;
  28530. }
  28531. public function getRequest(): Request
  28532. {
  28533. return $this->request;
  28534. }
  28535. public function getAcceptableStabilities(): array
  28536. {
  28537. return $this->acceptableStabilities;
  28538. }
  28539. public function getStabilityFlags(): array
  28540. {
  28541. return $this->stabilityFlags;
  28542. }
  28543. public function getRootAliases(): array
  28544. {
  28545. return $this->rootAliases;
  28546. }
  28547. public function getRootReferences(): array
  28548. {
  28549. return $this->rootReferences;
  28550. }
  28551. public function getPackages(): array
  28552. {
  28553. return $this->packages;
  28554. }
  28555. public function getUnacceptableFixedPackages(): array
  28556. {
  28557. return $this->unacceptableFixedPackages;
  28558. }
  28559. public function setPackages(array $packages): void
  28560. {
  28561. $this->packages = $packages;
  28562. }
  28563. public function setUnacceptableFixedPackages(array $packages): void
  28564. {
  28565. $this->unacceptableFixedPackages = $packages;
  28566. }
  28567. }
  28568. <?php declare(strict_types=1);
  28569. namespace Composer\Question;
  28570. use Composer\Pcre\Preg;
  28571. use Symfony\Component\Console\Exception\InvalidArgumentException;
  28572. use Symfony\Component\Console\Question\Question;
  28573. class StrictConfirmationQuestion extends Question
  28574. {
  28575. private $trueAnswerRegex;
  28576. private $falseAnswerRegex;
  28577. public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y(?:es)?$/i', string $falseAnswerRegex = '/^no?$/i')
  28578. {
  28579. parent::__construct($question, $default);
  28580. $this->trueAnswerRegex = $trueAnswerRegex;
  28581. $this->falseAnswerRegex = $falseAnswerRegex;
  28582. $this->setNormalizer($this->getDefaultNormalizer());
  28583. $this->setValidator($this->getDefaultValidator());
  28584. }
  28585. private function getDefaultNormalizer(): callable
  28586. {
  28587. $default = $this->getDefault();
  28588. $trueRegex = $this->trueAnswerRegex;
  28589. $falseRegex = $this->falseAnswerRegex;
  28590. return static function ($answer) use ($default, $trueRegex, $falseRegex) {
  28591. if (is_bool($answer)) {
  28592. return $answer;
  28593. }
  28594. if (empty($answer) && !empty($default)) {
  28595. return $default;
  28596. }
  28597. if (Preg::isMatch($trueRegex, $answer)) {
  28598. return true;
  28599. }
  28600. if (Preg::isMatch($falseRegex, $answer)) {
  28601. return false;
  28602. }
  28603. return null;
  28604. };
  28605. }
  28606. private function getDefaultValidator(): callable
  28607. {
  28608. return static function ($answer): bool {
  28609. if (!is_bool($answer)) {
  28610. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  28611. }
  28612. return $answer;
  28613. };
  28614. }
  28615. }
  28616. <?php declare(strict_types=1);
  28617. namespace Composer\Repository;
  28618. use Composer\Semver\Constraint\ConstraintInterface;
  28619. use Composer\Advisory\PartialSecurityAdvisory;
  28620. use Composer\Advisory\SecurityAdvisory;
  28621. interface AdvisoryProviderInterface
  28622. {
  28623. public function hasSecurityAdvisories(): bool;
  28624. public function getSecurityAdvisories(array $packageConstraintMap, bool $allowPartialAdvisories = false): array;
  28625. }
  28626. <?php declare(strict_types=1);
  28627. namespace Composer\Repository;
  28628. use Composer\Package\AliasPackage;
  28629. use Composer\Package\BasePackage;
  28630. use Composer\Package\CompleteAliasPackage;
  28631. use Composer\Package\CompletePackage;
  28632. use Composer\Package\PackageInterface;
  28633. use Composer\Package\CompletePackageInterface;
  28634. use Composer\Package\Version\VersionParser;
  28635. use Composer\Package\Version\StabilityFilter;
  28636. use Composer\Pcre\Preg;
  28637. use Composer\Semver\Constraint\ConstraintInterface;
  28638. use Composer\Semver\Constraint\Constraint;
  28639. class ArrayRepository implements RepositoryInterface
  28640. {
  28641. protected $packages = null;
  28642. protected $packageMap = null;
  28643. public function __construct(array $packages = [])
  28644. {
  28645. foreach ($packages as $package) {
  28646. $this->addPackage($package);
  28647. }
  28648. }
  28649. public function getRepoName()
  28650. {
  28651. return 'array repo (defining '.$this->count().' package'.($this->count() > 1 ? 's' : '').')';
  28652. }
  28653. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = [])
  28654. {
  28655. $packages = $this->getPackages();
  28656. $result = [];
  28657. $namesFound = [];
  28658. foreach ($packages as $package) {
  28659. if (array_key_exists($package->getName(), $packageNameMap)) {
  28660. if (
  28661. (!$packageNameMap[$package->getName()] || $packageNameMap[$package->getName()]->matches(new Constraint('==', $package->getVersion())))
  28662. && StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, $package->getNames(), $package->getStability())
  28663. && !isset($alreadyLoaded[$package->getName()][$package->getVersion()])
  28664. ) {
  28665. $result[spl_object_hash($package)] = $package;
  28666. if ($package instanceof AliasPackage && !isset($result[spl_object_hash($package->getAliasOf())])) {
  28667. $result[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  28668. }
  28669. }
  28670. $namesFound[$package->getName()] = true;
  28671. }
  28672. }
  28673. foreach ($packages as $package) {
  28674. if ($package instanceof AliasPackage) {
  28675. if (isset($result[spl_object_hash($package->getAliasOf())])) {
  28676. $result[spl_object_hash($package)] = $package;
  28677. }
  28678. }
  28679. }
  28680. return ['namesFound' => array_keys($namesFound), 'packages' => $result];
  28681. }
  28682. public function findPackage(string $name, $constraint)
  28683. {
  28684. $name = strtolower($name);
  28685. if (!$constraint instanceof ConstraintInterface) {
  28686. $versionParser = new VersionParser();
  28687. $constraint = $versionParser->parseConstraints($constraint);
  28688. }
  28689. foreach ($this->getPackages() as $package) {
  28690. if ($name === $package->getName()) {
  28691. $pkgConstraint = new Constraint('==', $package->getVersion());
  28692. if ($constraint->matches($pkgConstraint)) {
  28693. return $package;
  28694. }
  28695. }
  28696. }
  28697. return null;
  28698. }
  28699. public function findPackages(string $name, $constraint = null)
  28700. {
  28701. $name = strtolower($name);
  28702. $packages = [];
  28703. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  28704. $versionParser = new VersionParser();
  28705. $constraint = $versionParser->parseConstraints($constraint);
  28706. }
  28707. foreach ($this->getPackages() as $package) {
  28708. if ($name === $package->getName()) {
  28709. if (null === $constraint || $constraint->matches(new Constraint('==', $package->getVersion()))) {
  28710. $packages[] = $package;
  28711. }
  28712. }
  28713. }
  28714. return $packages;
  28715. }
  28716. public function search(string $query, int $mode = 0, ?string $type = null)
  28717. {
  28718. if ($mode === self::SEARCH_FULLTEXT) {
  28719. $regex = '{(?:'.implode('|', Preg::split('{\s+}', preg_quote($query))).')}i';
  28720. } else {
  28721. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  28722. }
  28723. $matches = [];
  28724. foreach ($this->getPackages() as $package) {
  28725. $name = $package->getName();
  28726. if ($mode === self::SEARCH_VENDOR) {
  28727. [$name] = explode('/', $name);
  28728. }
  28729. if (isset($matches[$name])) {
  28730. continue;
  28731. }
  28732. if (null !== $type && $package->getType() !== $type) {
  28733. continue;
  28734. }
  28735. if (Preg::isMatch($regex, $name)
  28736. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && Preg::isMatch($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  28737. ) {
  28738. if ($mode === self::SEARCH_VENDOR) {
  28739. $matches[$name] = [
  28740. 'name' => $name,
  28741. 'description' => null,
  28742. ];
  28743. } else {
  28744. $matches[$name] = [
  28745. 'name' => $package->getPrettyName(),
  28746. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  28747. ];
  28748. if ($package instanceof CompletePackageInterface && $package->isAbandoned()) {
  28749. $matches[$name]['abandoned'] = $package->getReplacementPackage() ?: true;
  28750. }
  28751. }
  28752. }
  28753. }
  28754. return array_values($matches);
  28755. }
  28756. public function hasPackage(PackageInterface $package)
  28757. {
  28758. if ($this->packageMap === null) {
  28759. $this->packageMap = [];
  28760. foreach ($this->getPackages() as $repoPackage) {
  28761. $this->packageMap[$repoPackage->getUniqueName()] = $repoPackage;
  28762. }
  28763. }
  28764. return isset($this->packageMap[$package->getUniqueName()]);
  28765. }
  28766. public function addPackage(PackageInterface $package)
  28767. {
  28768. if (!$package instanceof BasePackage) {
  28769. throw new \InvalidArgumentException('Only subclasses of BasePackage are supported');
  28770. }
  28771. if (null === $this->packages) {
  28772. $this->initialize();
  28773. }
  28774. $package->setRepository($this);
  28775. $this->packages[] = $package;
  28776. if ($package instanceof AliasPackage) {
  28777. $aliasedPackage = $package->getAliasOf();
  28778. if (null === $aliasedPackage->getRepository()) {
  28779. $this->addPackage($aliasedPackage);
  28780. }
  28781. }
  28782. $this->packageMap = null;
  28783. }
  28784. public function getProviders(string $packageName)
  28785. {
  28786. $result = [];
  28787. foreach ($this->getPackages() as $candidate) {
  28788. if (isset($result[$candidate->getName()])) {
  28789. continue;
  28790. }
  28791. foreach ($candidate->getProvides() as $link) {
  28792. if ($packageName === $link->getTarget()) {
  28793. $result[$candidate->getName()] = [
  28794. 'name' => $candidate->getName(),
  28795. 'description' => $candidate instanceof CompletePackageInterface ? $candidate->getDescription() : null,
  28796. 'type' => $candidate->getType(),
  28797. ];
  28798. continue 2;
  28799. }
  28800. }
  28801. }
  28802. return $result;
  28803. }
  28804. protected function createAliasPackage(BasePackage $package, string $alias, string $prettyAlias)
  28805. {
  28806. while ($package instanceof AliasPackage) {
  28807. $package = $package->getAliasOf();
  28808. }
  28809. if ($package instanceof CompletePackage) {
  28810. return new CompleteAliasPackage($package, $alias, $prettyAlias);
  28811. }
  28812. return new AliasPackage($package, $alias, $prettyAlias);
  28813. }
  28814. public function removePackage(PackageInterface $package)
  28815. {
  28816. $packageId = $package->getUniqueName();
  28817. foreach ($this->getPackages() as $key => $repoPackage) {
  28818. if ($packageId === $repoPackage->getUniqueName()) {
  28819. array_splice($this->packages, $key, 1);
  28820. $this->packageMap = null;
  28821. return;
  28822. }
  28823. }
  28824. }
  28825. public function getPackages()
  28826. {
  28827. if (null === $this->packages) {
  28828. $this->initialize();
  28829. }
  28830. if (null === $this->packages) {
  28831. throw new \LogicException('initialize failed to initialize the packages array');
  28832. }
  28833. return $this->packages;
  28834. }
  28835. public function count(): int
  28836. {
  28837. if (null === $this->packages) {
  28838. $this->initialize();
  28839. }
  28840. return count($this->packages);
  28841. }
  28842. protected function initialize()
  28843. {
  28844. $this->packages = [];
  28845. }
  28846. }
  28847. <?php declare(strict_types=1);
  28848. namespace Composer\Repository;
  28849. use Composer\IO\IOInterface;
  28850. use Composer\Json\JsonFile;
  28851. use Composer\Package\BasePackage;
  28852. use Composer\Package\Loader\ArrayLoader;
  28853. use Composer\Package\Loader\LoaderInterface;
  28854. use Composer\Util\Platform;
  28855. use Composer\Util\Tar;
  28856. use Composer\Util\Zip;
  28857. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  28858. {
  28859. protected $loader;
  28860. protected $lookup;
  28861. protected $repoConfig;
  28862. private $io;
  28863. public function __construct(array $repoConfig, IOInterface $io)
  28864. {
  28865. parent::__construct();
  28866. if (!extension_loaded('zip')) {
  28867. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  28868. }
  28869. $this->loader = new ArrayLoader();
  28870. $this->lookup = Platform::expandPath($repoConfig['url']);
  28871. $this->io = $io;
  28872. $this->repoConfig = $repoConfig;
  28873. }
  28874. public function getRepoName()
  28875. {
  28876. return 'artifact repo ('.$this->lookup.')';
  28877. }
  28878. public function getRepoConfig()
  28879. {
  28880. return $this->repoConfig;
  28881. }
  28882. protected function initialize()
  28883. {
  28884. parent::initialize();
  28885. $this->scanDirectory($this->lookup);
  28886. }
  28887. private function scanDirectory(string $path): void
  28888. {
  28889. $io = $this->io;
  28890. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  28891. $iterator = new \RecursiveIteratorIterator($directory);
  28892. $regex = new \RegexIterator($iterator, '/^.+\.(zip|tar|gz|tgz)$/i');
  28893. foreach ($regex as $file) {
  28894. if (!$file->isFile()) {
  28895. continue;
  28896. }
  28897. $package = $this->getComposerInformation($file);
  28898. if (!$package) {
  28899. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  28900. continue;
  28901. }
  28902. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  28903. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  28904. $this->addPackage($package);
  28905. }
  28906. }
  28907. private function getComposerInformation(\SplFileInfo $file): ?BasePackage
  28908. {
  28909. $json = null;
  28910. $fileType = null;
  28911. $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
  28912. if (in_array($fileExtension, ['gz', 'tar', 'tgz'], true)) {
  28913. $fileType = 'tar';
  28914. } elseif ($fileExtension === 'zip') {
  28915. $fileType = 'zip';
  28916. } else {
  28917. throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');
  28918. }
  28919. try {
  28920. if ($fileType === 'tar') {
  28921. $json = Tar::getComposerJson($file->getPathname());
  28922. } else {
  28923. $json = Zip::getComposerJson($file->getPathname());
  28924. }
  28925. } catch (\Exception $exception) {
  28926. $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE);
  28927. }
  28928. if (null === $json) {
  28929. return null;
  28930. }
  28931. $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
  28932. $package['dist'] = [
  28933. 'type' => $fileType,
  28934. 'url' => strtr($file->getPathname(), '\\', '/'),
  28935. 'shasum' => hash_file('sha1', $file->getRealPath()),
  28936. ];
  28937. try {
  28938. $package = $this->loader->load($package);
  28939. } catch (\UnexpectedValueException $e) {
  28940. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  28941. }
  28942. return $package;
  28943. }
  28944. }
  28945. <?php declare(strict_types=1);
  28946. namespace Composer\Repository;
  28947. use Composer\Package\AliasPackage;
  28948. use Composer\Package\PackageInterface;
  28949. trait CanonicalPackagesTrait
  28950. {
  28951. public function getCanonicalPackages()
  28952. {
  28953. $packages = $this->getPackages();
  28954. $packagesByName = [];
  28955. foreach ($packages as $package) {
  28956. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  28957. $packagesByName[$package->getName()] = $package;
  28958. }
  28959. }
  28960. $canonicalPackages = [];
  28961. foreach ($packagesByName as $package) {
  28962. while ($package instanceof AliasPackage) {
  28963. $package = $package->getAliasOf();
  28964. }
  28965. $canonicalPackages[] = $package;
  28966. }
  28967. return $canonicalPackages;
  28968. }
  28969. }
  28970. <?php declare(strict_types=1);
  28971. namespace Composer\Repository;
  28972. use Composer\Advisory\PartialSecurityAdvisory;
  28973. use Composer\Advisory\SecurityAdvisory;
  28974. use Composer\Package\BasePackage;
  28975. use Composer\Package\Loader\ArrayLoader;
  28976. use Composer\Package\PackageInterface;
  28977. use Composer\Package\AliasPackage;
  28978. use Composer\Package\CompletePackage;
  28979. use Composer\Package\CompleteAliasPackage;
  28980. use Composer\Package\Version\VersionParser;
  28981. use Composer\Package\Version\StabilityFilter;
  28982. use Composer\Json\JsonFile;
  28983. use Composer\Cache;
  28984. use Composer\Config;
  28985. use Composer\IO\IOInterface;
  28986. use Composer\Pcre\Preg;
  28987. use Composer\Plugin\PostFileDownloadEvent;
  28988. use Composer\Semver\CompilingMatcher;
  28989. use Composer\Util\HttpDownloader;
  28990. use Composer\Util\Loop;
  28991. use Composer\Plugin\PluginEvents;
  28992. use Composer\Plugin\PreFileDownloadEvent;
  28993. use Composer\EventDispatcher\EventDispatcher;
  28994. use Composer\Downloader\TransportException;
  28995. use Composer\Semver\Constraint\ConstraintInterface;
  28996. use Composer\Semver\Constraint\Constraint;
  28997. use Composer\Semver\Constraint\MatchAllConstraint;
  28998. use Composer\Util\Http\Response;
  28999. use Composer\MetadataMinifier\MetadataMinifier;
  29000. use Composer\Util\Url;
  29001. use React\Promise\PromiseInterface;
  29002. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface, AdvisoryProviderInterface
  29003. {
  29004. private $repoConfig;
  29005. private $options;
  29006. private $url;
  29007. private $baseUrl;
  29008. private $io;
  29009. private $httpDownloader;
  29010. private $loop;
  29011. protected $cache;
  29012. protected $notifyUrl = null;
  29013. protected $searchUrl = null;
  29014. protected $providersApiUrl = null;
  29015. protected $hasProviders = false;
  29016. protected $providersUrl = null;
  29017. protected $listUrl = null;
  29018. protected $hasAvailablePackageList = false;
  29019. protected $availablePackages = null;
  29020. protected $availablePackagePatterns = null;
  29021. protected $lazyProvidersUrl = null;
  29022. protected $providerListing;
  29023. protected $loader;
  29024. private $allowSslDowngrade = false;
  29025. private $eventDispatcher;
  29026. private $sourceMirrors;
  29027. private $distMirrors;
  29028. private $degradedMode = false;
  29029. private $rootData;
  29030. private $hasPartialPackages = false;
  29031. private $partialPackagesByName = null;
  29032. private $displayedWarningAboutNonMatchingPackageIndex = false;
  29033. private $securityAdvisoryConfig = null;
  29034. private $freshMetadataUrls = [];
  29035. private $packagesNotFoundCache = [];
  29036. private $versionParser;
  29037. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ?EventDispatcher $eventDispatcher = null)
  29038. {
  29039. parent::__construct();
  29040. if (!Preg::isMatch('{^[\w.]+\??://}', $repoConfig['url'])) {
  29041. if (($localFilePath = realpath($repoConfig['url'])) !== false) {
  29042. $repoConfig['url'] = 'file://'.$localFilePath;
  29043. } else {
  29044. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  29045. }
  29046. }
  29047. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  29048. if ($repoConfig['url'] === '') {
  29049. throw new \InvalidArgumentException('The repository url must not be an empty string');
  29050. }
  29051. if (str_starts_with($repoConfig['url'], 'https?')) {
  29052. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  29053. }
  29054. $urlBits = parse_url(strtr($repoConfig['url'], '\\', '/'));
  29055. if ($urlBits === false || empty($urlBits['scheme'])) {
  29056. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  29057. }
  29058. if (!isset($repoConfig['options'])) {
  29059. $repoConfig['options'] = [];
  29060. }
  29061. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  29062. $this->allowSslDowngrade = true;
  29063. }
  29064. $this->options = $repoConfig['options'];
  29065. $this->url = $repoConfig['url'];
  29066. if (Preg::isMatch('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  29067. $this->url = $match['proto'].'://repo.packagist.org';
  29068. }
  29069. $baseUrl = rtrim(Preg::replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  29070. assert($baseUrl !== '');
  29071. $this->baseUrl = $baseUrl;
  29072. $this->io = $io;
  29073. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)), 'a-z0-9.$~_');
  29074. $this->cache->setReadOnly($config->get('cache-read-only'));
  29075. $this->versionParser = new VersionParser();
  29076. $this->loader = new ArrayLoader($this->versionParser);
  29077. $this->httpDownloader = $httpDownloader;
  29078. $this->eventDispatcher = $eventDispatcher;
  29079. $this->repoConfig = $repoConfig;
  29080. $this->loop = new Loop($this->httpDownloader);
  29081. }
  29082. public function getRepoName()
  29083. {
  29084. return 'composer repo ('.Url::sanitize($this->url).')';
  29085. }
  29086. public function getRepoConfig()
  29087. {
  29088. return $this->repoConfig;
  29089. }
  29090. public function findPackage(string $name, $constraint)
  29091. {
  29092. $hasProviders = $this->hasProviders();
  29093. $name = strtolower($name);
  29094. if (!$constraint instanceof ConstraintInterface) {
  29095. $constraint = $this->versionParser->parseConstraints($constraint);
  29096. }
  29097. if ($this->lazyProvidersUrl) {
  29098. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  29099. return $this->filterPackages($this->whatProvides($name), $constraint, true);
  29100. }
  29101. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  29102. return null;
  29103. }
  29104. $packages = $this->loadAsyncPackages([$name => $constraint]);
  29105. if (count($packages['packages']) > 0) {
  29106. return reset($packages['packages']);
  29107. }
  29108. return null;
  29109. }
  29110. if ($hasProviders) {
  29111. foreach ($this->getProviderNames() as $providerName) {
  29112. if ($name === $providerName) {
  29113. return $this->filterPackages($this->whatProvides($providerName), $constraint, true);
  29114. }
  29115. }
  29116. return null;
  29117. }
  29118. return parent::findPackage($name, $constraint);
  29119. }
  29120. public function findPackages(string $name, $constraint = null)
  29121. {
  29122. $hasProviders = $this->hasProviders();
  29123. $name = strtolower($name);
  29124. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  29125. $constraint = $this->versionParser->parseConstraints($constraint);
  29126. }
  29127. if ($this->lazyProvidersUrl) {
  29128. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  29129. return $this->filterPackages($this->whatProvides($name), $constraint);
  29130. }
  29131. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  29132. return [];
  29133. }
  29134. $result = $this->loadAsyncPackages([$name => $constraint]);
  29135. return $result['packages'];
  29136. }
  29137. if ($hasProviders) {
  29138. foreach ($this->getProviderNames() as $providerName) {
  29139. if ($name === $providerName) {
  29140. return $this->filterPackages($this->whatProvides($providerName), $constraint);
  29141. }
  29142. }
  29143. return [];
  29144. }
  29145. return parent::findPackages($name, $constraint);
  29146. }
  29147. private function filterPackages(array $packages, ?ConstraintInterface $constraint = null, bool $returnFirstMatch = false)
  29148. {
  29149. if (null === $constraint) {
  29150. if ($returnFirstMatch) {
  29151. return reset($packages);
  29152. }
  29153. return $packages;
  29154. }
  29155. $filteredPackages = [];
  29156. foreach ($packages as $package) {
  29157. $pkgConstraint = new Constraint('==', $package->getVersion());
  29158. if ($constraint->matches($pkgConstraint)) {
  29159. if ($returnFirstMatch) {
  29160. return $package;
  29161. }
  29162. $filteredPackages[] = $package;
  29163. }
  29164. }
  29165. if ($returnFirstMatch) {
  29166. return null;
  29167. }
  29168. return $filteredPackages;
  29169. }
  29170. public function getPackages()
  29171. {
  29172. $hasProviders = $this->hasProviders();
  29173. if ($this->lazyProvidersUrl) {
  29174. if (is_array($this->availablePackages) && !$this->availablePackagePatterns) {
  29175. $packageMap = [];
  29176. foreach ($this->availablePackages as $name) {
  29177. $packageMap[$name] = new MatchAllConstraint();
  29178. }
  29179. $result = $this->loadAsyncPackages($packageMap);
  29180. return array_values($result['packages']);
  29181. }
  29182. if ($this->hasPartialPackages()) {
  29183. if (!is_array($this->partialPackagesByName)) {
  29184. throw new \LogicException('hasPartialPackages failed to initialize $this->partialPackagesByName');
  29185. }
  29186. return $this->createPackages($this->partialPackagesByName, 'packages.json inline packages');
  29187. }
  29188. 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.');
  29189. }
  29190. if ($hasProviders) {
  29191. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
  29192. }
  29193. return parent::getPackages();
  29194. }
  29195. public function getPackageNames(?string $packageFilter = null)
  29196. {
  29197. $hasProviders = $this->hasProviders();
  29198. $filterResults =
  29199. static function (array $results): array {
  29200. return $results;
  29201. }
  29202. ;
  29203. if (null !== $packageFilter && '' !== $packageFilter) {
  29204. $packageFilterRegex = BasePackage::packageNameToRegexp($packageFilter);
  29205. $filterResults =
  29206. static function (array $results) use ($packageFilterRegex): array {
  29207. return Preg::grep($packageFilterRegex, $results);
  29208. }
  29209. ;
  29210. }
  29211. if ($this->lazyProvidersUrl) {
  29212. if (is_array($this->availablePackages)) {
  29213. return $filterResults(array_keys($this->availablePackages));
  29214. }
  29215. if ($this->listUrl) {
  29216. return $this->loadPackageList($packageFilter);
  29217. }
  29218. if ($this->hasPartialPackages() && $this->partialPackagesByName !== null) {
  29219. return $filterResults(array_keys($this->partialPackagesByName));
  29220. }
  29221. return [];
  29222. }
  29223. if ($hasProviders) {
  29224. return $filterResults($this->getProviderNames());
  29225. }
  29226. $names = [];
  29227. foreach ($this->getPackages() as $package) {
  29228. $names[] = $package->getPrettyName();
  29229. }
  29230. return $filterResults($names);
  29231. }
  29232. private function getVendorNames(): array
  29233. {
  29234. $cacheKey = 'vendor-list.txt';
  29235. $cacheAge = $this->cache->getAge($cacheKey);
  29236. if (false !== $cacheAge && $cacheAge < 600 && ($cachedData = $this->cache->read($cacheKey)) !== false) {
  29237. $cachedData = explode("\n", $cachedData);
  29238. return $cachedData;
  29239. }
  29240. $names = $this->getPackageNames();
  29241. $uniques = [];
  29242. foreach ($names as $name) {
  29243. $uniques[explode('/', $name, 2)[0]] = true;
  29244. }
  29245. $vendors = array_keys($uniques);
  29246. if (!$this->cache->isReadOnly()) {
  29247. $this->cache->write($cacheKey, implode("\n", $vendors));
  29248. }
  29249. return $vendors;
  29250. }
  29251. private function loadPackageList(?string $packageFilter = null): array
  29252. {
  29253. if (null === $this->listUrl) {
  29254. throw new \LogicException('Make sure to call loadRootServerFile before loadPackageList');
  29255. }
  29256. $url = $this->listUrl;
  29257. if (is_string($packageFilter) && $packageFilter !== '') {
  29258. $url .= '?filter='.urlencode($packageFilter);
  29259. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  29260. return $result['packageNames'];
  29261. }
  29262. $cacheKey = 'package-list.txt';
  29263. $cacheAge = $this->cache->getAge($cacheKey);
  29264. if (false !== $cacheAge && $cacheAge < 600 && ($cachedData = $this->cache->read($cacheKey)) !== false) {
  29265. $cachedData = explode("\n", $cachedData);
  29266. return $cachedData;
  29267. }
  29268. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  29269. if (!$this->cache->isReadOnly()) {
  29270. $this->cache->write($cacheKey, implode("\n", $result['packageNames']));
  29271. }
  29272. return $result['packageNames'];
  29273. }
  29274. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = [])
  29275. {
  29276. $hasProviders = $this->hasProviders();
  29277. if (!$hasProviders && !$this->hasPartialPackages() && null === $this->lazyProvidersUrl) {
  29278. return parent::loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  29279. }
  29280. $packages = [];
  29281. $namesFound = [];
  29282. if ($hasProviders || $this->hasPartialPackages()) {
  29283. foreach ($packageNameMap as $name => $constraint) {
  29284. $matches = [];
  29285. if (!$hasProviders && !isset($this->partialPackagesByName[$name])) {
  29286. continue;
  29287. }
  29288. $candidates = $this->whatProvides($name, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  29289. foreach ($candidates as $candidate) {
  29290. if ($candidate->getName() !== $name) {
  29291. throw new \LogicException('whatProvides should never return a package with a different name than the requested one');
  29292. }
  29293. $namesFound[$name] = true;
  29294. if (!$constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  29295. $matches[spl_object_hash($candidate)] = $candidate;
  29296. if ($candidate instanceof AliasPackage && !isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  29297. $matches[spl_object_hash($candidate->getAliasOf())] = $candidate->getAliasOf();
  29298. }
  29299. }
  29300. }
  29301. foreach ($candidates as $candidate) {
  29302. if ($candidate instanceof AliasPackage) {
  29303. if (isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  29304. $matches[spl_object_hash($candidate)] = $candidate;
  29305. }
  29306. }
  29307. }
  29308. $packages = array_merge($packages, $matches);
  29309. unset($packageNameMap[$name]);
  29310. }
  29311. }
  29312. if ($this->lazyProvidersUrl && count($packageNameMap)) {
  29313. if ($this->hasAvailablePackageList) {
  29314. foreach ($packageNameMap as $name => $constraint) {
  29315. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  29316. unset($packageNameMap[$name]);
  29317. }
  29318. }
  29319. }
  29320. $result = $this->loadAsyncPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  29321. $packages = array_merge($packages, $result['packages']);
  29322. $namesFound = array_merge($namesFound, $result['namesFound']);
  29323. }
  29324. return ['namesFound' => array_keys($namesFound), 'packages' => $packages];
  29325. }
  29326. public function search(string $query, int $mode = 0, ?string $type = null)
  29327. {
  29328. $this->loadRootServerFile(600);
  29329. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  29330. $url = str_replace(['%query%', '%type%'], [urlencode($query), $type], $this->searchUrl);
  29331. $search = $this->httpDownloader->get($url, $this->options)->decodeJson();
  29332. if (empty($search['results'])) {
  29333. return [];
  29334. }
  29335. $results = [];
  29336. foreach ($search['results'] as $result) {
  29337. if (!empty($result['virtual'])) {
  29338. continue;
  29339. }
  29340. $results[] = $result;
  29341. }
  29342. return $results;
  29343. }
  29344. if ($mode === self::SEARCH_VENDOR) {
  29345. $results = [];
  29346. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  29347. $vendorNames = $this->getVendorNames();
  29348. foreach (Preg::grep($regex, $vendorNames) as $name) {
  29349. $results[] = ['name' => $name, 'description' => ''];
  29350. }
  29351. return $results;
  29352. }
  29353. if ($this->hasProviders() || $this->lazyProvidersUrl) {
  29354. if (Preg::isMatchStrictGroups('{^\^(?P<query>(?P<vendor>[a-z0-9_.-]+)/[a-z0-9_.-]*)\*?$}i', $query, $match) && $this->listUrl !== null) {
  29355. $url = $this->listUrl . '?vendor='.urlencode($match['vendor']).'&filter='.urlencode($match['query'].'*');
  29356. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  29357. $results = [];
  29358. foreach ($result['packageNames'] as $name) {
  29359. $results[] = ['name' => $name, 'description' => ''];
  29360. }
  29361. return $results;
  29362. }
  29363. $results = [];
  29364. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  29365. $packageNames = $this->getPackageNames();
  29366. foreach (Preg::grep($regex, $packageNames) as $name) {
  29367. $results[] = ['name' => $name, 'description' => ''];
  29368. }
  29369. return $results;
  29370. }
  29371. return parent::search($query, $mode);
  29372. }
  29373. public function hasSecurityAdvisories(): bool
  29374. {
  29375. $this->loadRootServerFile(600);
  29376. return $this->securityAdvisoryConfig !== null && ($this->securityAdvisoryConfig['metadata'] || $this->securityAdvisoryConfig['api-url'] !== null);
  29377. }
  29378. public function getSecurityAdvisories(array $packageConstraintMap, bool $allowPartialAdvisories = false): array
  29379. {
  29380. $this->loadRootServerFile(600);
  29381. if (null === $this->securityAdvisoryConfig) {
  29382. return ['namesFound' => [], 'advisories' => []];
  29383. }
  29384. $advisories = [];
  29385. $namesFound = [];
  29386. $apiUrl = $this->securityAdvisoryConfig['api-url'];
  29387. if ($this->hasAvailablePackageList) {
  29388. foreach ($packageConstraintMap as $name => $constraint) {
  29389. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  29390. unset($packageConstraintMap[$name]);
  29391. }
  29392. }
  29393. }
  29394. $parser = new VersionParser();
  29395. $create = function (array $data, string $name) use ($parser, $allowPartialAdvisories, &$packageConstraintMap): ?PartialSecurityAdvisory {
  29396. $advisory = PartialSecurityAdvisory::create($name, $data, $parser);
  29397. if (!$allowPartialAdvisories && !$advisory instanceof SecurityAdvisory) {
  29398. throw new \RuntimeException('Advisory for '.$name.' could not be loaded as a full advisory from '.$this->getRepoName() . PHP_EOL . var_export($data, true));
  29399. }
  29400. if (!$advisory->affectedVersions->matches($packageConstraintMap[$name])) {
  29401. return null;
  29402. }
  29403. return $advisory;
  29404. };
  29405. if ($this->securityAdvisoryConfig['metadata'] && ($allowPartialAdvisories || $apiUrl === null)) {
  29406. $promises = [];
  29407. foreach ($packageConstraintMap as $name => $constraint) {
  29408. $name = strtolower($name);
  29409. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  29410. continue;
  29411. }
  29412. $promises[] = $this->startCachedAsyncDownload($name, $name)
  29413. ->then(static function (array $spec) use (&$advisories, &$namesFound, &$packageConstraintMap, $name, $create): void {
  29414. [$response, ] = $spec;
  29415. if (!isset($response['security-advisories']) || !is_array($response['security-advisories'])) {
  29416. return;
  29417. }
  29418. $namesFound[$name] = true;
  29419. if (count($response['security-advisories']) > 0) {
  29420. $advisories[$name] = array_filter(array_map(
  29421. static function ($data) use ($name, $create) {
  29422. return $create($data, $name);
  29423. },
  29424. $response['security-advisories']
  29425. ));
  29426. }
  29427. unset($packageConstraintMap[$name]);
  29428. });
  29429. }
  29430. $this->loop->wait($promises);
  29431. }
  29432. if ($apiUrl !== null && count($packageConstraintMap) > 0) {
  29433. $options = $this->options;
  29434. $options['http']['method'] = 'POST';
  29435. if (isset($options['http']['header'])) {
  29436. $options['http']['header'] = (array) $options['http']['header'];
  29437. }
  29438. $options['http']['header'][] = 'Content-type: application/x-www-form-urlencoded';
  29439. $options['http']['timeout'] = 10;
  29440. $options['http']['content'] = http_build_query(['packages' => array_keys($packageConstraintMap)]);
  29441. $response = $this->httpDownloader->get($apiUrl, $options);
  29442. $warned = false;
  29443. foreach ($response->decodeJson()['advisories'] as $name => $list) {
  29444. if (!isset($packageConstraintMap[$name])) {
  29445. if (!$warned) {
  29446. $this->io->writeError('<warning>'.$this->getRepoName().' returned names which were not requested in response to the security-advisories API. '.$name.' was not requested but is present in the response. Requested names were: '.implode(', ', array_keys($packageConstraintMap)).'</warning>');
  29447. $warned = true;
  29448. }
  29449. continue;
  29450. }
  29451. if (count($list) > 0) {
  29452. $advisories[$name] = array_filter(array_map(
  29453. static function ($data) use ($name, $create) {
  29454. return $create($data, $name);
  29455. },
  29456. $list
  29457. ));
  29458. }
  29459. $namesFound[$name] = true;
  29460. }
  29461. }
  29462. return ['namesFound' => array_keys($namesFound), 'advisories' => array_filter($advisories)];
  29463. }
  29464. public function getProviders(string $packageName)
  29465. {
  29466. $this->loadRootServerFile();
  29467. $result = [];
  29468. if ($this->providersApiUrl) {
  29469. try {
  29470. $apiResult = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson();
  29471. } catch (TransportException $e) {
  29472. if ($e->getStatusCode() === 404) {
  29473. return $result;
  29474. }
  29475. throw $e;
  29476. }
  29477. foreach ($apiResult['providers'] as $provider) {
  29478. $result[$provider['name']] = $provider;
  29479. }
  29480. return $result;
  29481. }
  29482. if ($this->hasPartialPackages()) {
  29483. if (!is_array($this->partialPackagesByName)) {
  29484. throw new \LogicException('hasPartialPackages failed to initialize $this->partialPackagesByName');
  29485. }
  29486. foreach ($this->partialPackagesByName as $versions) {
  29487. foreach ($versions as $candidate) {
  29488. if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
  29489. continue;
  29490. }
  29491. $result[$candidate['name']] = [
  29492. 'name' => $candidate['name'],
  29493. 'description' => $candidate['description'] ?? '',
  29494. 'type' => $candidate['type'] ?? '',
  29495. ];
  29496. }
  29497. }
  29498. }
  29499. if ($this->packages) {
  29500. $result = array_merge($result, parent::getProviders($packageName));
  29501. }
  29502. return $result;
  29503. }
  29504. private function getProviderNames(): array
  29505. {
  29506. $this->loadRootServerFile();
  29507. if (null === $this->providerListing) {
  29508. $data = $this->loadRootServerFile();
  29509. if (is_array($data)) {
  29510. $this->loadProviderListings($data);
  29511. }
  29512. }
  29513. if ($this->lazyProvidersUrl) {
  29514. return [];
  29515. }
  29516. if (null !== $this->providersUrl && null !== $this->providerListing) {
  29517. return array_keys($this->providerListing);
  29518. }
  29519. return [];
  29520. }
  29521. protected function configurePackageTransportOptions(PackageInterface $package): void
  29522. {
  29523. foreach ($package->getDistUrls() as $url) {
  29524. if (strpos($url, $this->baseUrl) === 0) {
  29525. $package->setTransportOptions($this->options);
  29526. return;
  29527. }
  29528. }
  29529. }
  29530. private function hasProviders(): bool
  29531. {
  29532. $this->loadRootServerFile();
  29533. return $this->hasProviders;
  29534. }
  29535. private function whatProvides(string $name, ?array $acceptableStabilities = null, ?array $stabilityFlags = null, array $alreadyLoaded = []): array
  29536. {
  29537. $packagesSource = null;
  29538. if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
  29539. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  29540. return [];
  29541. }
  29542. if (null === $this->providerListing) {
  29543. $data = $this->loadRootServerFile();
  29544. if (is_array($data)) {
  29545. $this->loadProviderListings($data);
  29546. }
  29547. }
  29548. $useLastModifiedCheck = false;
  29549. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  29550. $hash = null;
  29551. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  29552. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  29553. $useLastModifiedCheck = true;
  29554. } elseif ($this->providersUrl) {
  29555. if (!isset($this->providerListing[$name])) {
  29556. return [];
  29557. }
  29558. $hash = $this->providerListing[$name]['sha256'];
  29559. $url = str_replace(['%package%', '%hash%'], [$name, $hash], $this->providersUrl);
  29560. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  29561. } else {
  29562. return [];
  29563. }
  29564. $packages = null;
  29565. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  29566. $packages = json_decode($this->cache->read($cacheKey), true);
  29567. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  29568. } elseif ($useLastModifiedCheck) {
  29569. if ($contents = $this->cache->read($cacheKey)) {
  29570. $contents = json_decode($contents, true);
  29571. if (isset($alreadyLoaded[$name])) {
  29572. $packages = $contents;
  29573. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  29574. } elseif (isset($contents['last-modified'])) {
  29575. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  29576. $packages = true === $response ? $contents : $response;
  29577. $packagesSource = true === $response ? 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')' : 'downloaded file ('.Url::sanitize($url).')';
  29578. }
  29579. }
  29580. }
  29581. if (!$packages) {
  29582. try {
  29583. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  29584. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  29585. } catch (TransportException $e) {
  29586. if ($this->lazyProvidersUrl && in_array($e->getStatusCode(), [404, 499], true)) {
  29587. $packages = ['packages' => []];
  29588. $packagesSource = 'not-found file ('.Url::sanitize($url).')';
  29589. if ($e->getStatusCode() === 499) {
  29590. $this->io->error('<warning>' . $e->getMessage() . '</warning>');
  29591. }
  29592. } else {
  29593. throw $e;
  29594. }
  29595. }
  29596. }
  29597. $loadingPartialPackage = false;
  29598. } else {
  29599. $packages = ['packages' => ['versions' => $this->partialPackagesByName[$name]]];
  29600. $packagesSource = 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')';
  29601. $loadingPartialPackage = true;
  29602. }
  29603. $result = [];
  29604. $versionsToLoad = [];
  29605. foreach ($packages['packages'] as $versions) {
  29606. foreach ($versions as $version) {
  29607. $normalizedName = strtolower($version['name']);
  29608. if ($normalizedName !== $name) {
  29609. continue;
  29610. }
  29611. if (!$loadingPartialPackage && $this->hasPartialPackages() && isset($this->partialPackagesByName[$normalizedName])) {
  29612. continue;
  29613. }
  29614. if (!isset($versionsToLoad[$version['uid']])) {
  29615. if (!isset($version['version_normalized'])) {
  29616. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  29617. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  29618. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  29619. }
  29620. if (isset($alreadyLoaded[$name][$version['version_normalized']])) {
  29621. continue;
  29622. }
  29623. if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) {
  29624. $versionsToLoad[$version['uid']] = $version;
  29625. }
  29626. }
  29627. }
  29628. }
  29629. $loadedPackages = $this->createPackages($versionsToLoad, $packagesSource);
  29630. $uids = array_keys($versionsToLoad);
  29631. foreach ($loadedPackages as $index => $package) {
  29632. $package->setRepository($this);
  29633. $uid = $uids[$index];
  29634. if ($package instanceof AliasPackage) {
  29635. $aliased = $package->getAliasOf();
  29636. $aliased->setRepository($this);
  29637. $result[$uid] = $aliased;
  29638. $result[$uid.'-alias'] = $package;
  29639. } else {
  29640. $result[$uid] = $package;
  29641. }
  29642. }
  29643. return $result;
  29644. }
  29645. protected function initialize()
  29646. {
  29647. parent::initialize();
  29648. $repoData = $this->loadDataFromServer();
  29649. foreach ($this->createPackages($repoData, 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')') as $package) {
  29650. $this->addPackage($package);
  29651. }
  29652. }
  29653. public function addPackage(PackageInterface $package)
  29654. {
  29655. parent::addPackage($package);
  29656. $this->configurePackageTransportOptions($package);
  29657. }
  29658. private function loadAsyncPackages(array $packageNames, ?array $acceptableStabilities = null, ?array $stabilityFlags = null, array $alreadyLoaded = []): array
  29659. {
  29660. $this->loadRootServerFile();
  29661. $packages = [];
  29662. $namesFound = [];
  29663. $promises = [];
  29664. if (null === $this->lazyProvidersUrl) {
  29665. throw new \LogicException('loadAsyncPackages only supports v2 protocol composer repos with a metadata-url');
  29666. }
  29667. foreach ($packageNames as $name => $constraint) {
  29668. if ($acceptableStabilities === null || $stabilityFlags === null || StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, [$name], 'dev')) {
  29669. $packageNames[$name.'~dev'] = $constraint;
  29670. }
  29671. if (isset($acceptableStabilities['dev']) && count($acceptableStabilities) === 1 && count($stabilityFlags) === 0) {
  29672. unset($packageNames[$name]);
  29673. }
  29674. }
  29675. foreach ($packageNames as $name => $constraint) {
  29676. $name = strtolower($name);
  29677. $realName = Preg::replace('{~dev$}', '', $name);
  29678. if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
  29679. continue;
  29680. }
  29681. $promises[] = $this->startCachedAsyncDownload($name, $realName)
  29682. ->then(function (array $spec) use (&$packages, &$namesFound, $realName, $constraint, $acceptableStabilities, $stabilityFlags, $alreadyLoaded): void {
  29683. [$response, $packagesSource] = $spec;
  29684. if (null === $response || !isset($response['packages'][$realName])) {
  29685. return;
  29686. }
  29687. $versions = $response['packages'][$realName];
  29688. if (isset($response['minified']) && $response['minified'] === 'composer/2.0') {
  29689. $versions = MetadataMinifier::expand($versions);
  29690. }
  29691. $namesFound[$realName] = true;
  29692. $versionsToLoad = [];
  29693. foreach ($versions as $version) {
  29694. if (!isset($version['version_normalized'])) {
  29695. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  29696. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  29697. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  29698. }
  29699. if (isset($alreadyLoaded[$realName][$version['version_normalized']])) {
  29700. continue;
  29701. }
  29702. if ($this->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) {
  29703. $versionsToLoad[] = $version;
  29704. }
  29705. }
  29706. $loadedPackages = $this->createPackages($versionsToLoad, $packagesSource);
  29707. foreach ($loadedPackages as $package) {
  29708. $package->setRepository($this);
  29709. $packages[spl_object_hash($package)] = $package;
  29710. if ($package instanceof AliasPackage && !isset($packages[spl_object_hash($package->getAliasOf())])) {
  29711. $package->getAliasOf()->setRepository($this);
  29712. $packages[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  29713. }
  29714. }
  29715. });
  29716. }
  29717. $this->loop->wait($promises);
  29718. return ['namesFound' => $namesFound, 'packages' => $packages];
  29719. }
  29720. private function startCachedAsyncDownload(string $fileName, ?string $packageName = null): PromiseInterface
  29721. {
  29722. if (null === $this->lazyProvidersUrl) {
  29723. throw new \LogicException('startCachedAsyncDownload only supports v2 protocol composer repos with a metadata-url');
  29724. }
  29725. $name = strtolower($fileName);
  29726. $packageName = $packageName ?? $name;
  29727. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  29728. $cacheKey = 'provider-'.strtr($name, '/', '~').'.json';
  29729. $lastModified = null;
  29730. if ($contents = $this->cache->read($cacheKey)) {
  29731. $contents = json_decode($contents, true);
  29732. $lastModified = $contents['last-modified'] ?? null;
  29733. }
  29734. return $this->asyncFetchFile($url, $cacheKey, $lastModified)
  29735. ->then(static function ($response) use ($url, $cacheKey, $contents, $packageName): array {
  29736. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  29737. if (true === $response) {
  29738. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  29739. $response = $contents;
  29740. }
  29741. if (!isset($response['packages'][$packageName]) && !isset($response['security-advisories'])) {
  29742. return [null, $packagesSource];
  29743. }
  29744. return [$response, $packagesSource];
  29745. });
  29746. }
  29747. private function isVersionAcceptable(?ConstraintInterface $constraint, string $name, array $versionData, ?array $acceptableStabilities = null, ?array $stabilityFlags = null): bool
  29748. {
  29749. $versions = [$versionData['version_normalized']];
  29750. if ($alias = $this->loader->getBranchAlias($versionData)) {
  29751. $versions[] = $alias;
  29752. }
  29753. foreach ($versions as $version) {
  29754. if (null !== $acceptableStabilities && null !== $stabilityFlags && !StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, [$name], VersionParser::parseStability($version))) {
  29755. continue;
  29756. }
  29757. if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) {
  29758. continue;
  29759. }
  29760. return true;
  29761. }
  29762. return false;
  29763. }
  29764. private function getPackagesJsonUrl(): string
  29765. {
  29766. $jsonUrlParts = parse_url(strtr($this->url, '\\', '/'));
  29767. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  29768. return $this->url;
  29769. }
  29770. return $this->url . '/packages.json';
  29771. }
  29772. protected function loadRootServerFile(?int $rootMaxAge = null)
  29773. {
  29774. if (null !== $this->rootData) {
  29775. return $this->rootData;
  29776. }
  29777. if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
  29778. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  29779. }
  29780. if ($cachedData = $this->cache->read('packages.json')) {
  29781. $cachedData = json_decode($cachedData, true);
  29782. if ($rootMaxAge !== null && ($age = $this->cache->getAge('packages.json')) !== false && $age <= $rootMaxAge) {
  29783. $data = $cachedData;
  29784. } elseif (isset($cachedData['last-modified'])) {
  29785. $response = $this->fetchFileIfLastModified($this->getPackagesJsonUrl(), 'packages.json', $cachedData['last-modified']);
  29786. $data = true === $response ? $cachedData : $response;
  29787. }
  29788. }
  29789. if (!isset($data)) {
  29790. $data = $this->fetchFile($this->getPackagesJsonUrl(), 'packages.json', null, true);
  29791. }
  29792. if (!empty($data['notify-batch'])) {
  29793. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  29794. } elseif (!empty($data['notify'])) {
  29795. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  29796. }
  29797. if (!empty($data['search'])) {
  29798. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  29799. }
  29800. if (!empty($data['mirrors'])) {
  29801. foreach ($data['mirrors'] as $mirror) {
  29802. if (!empty($mirror['git-url'])) {
  29803. $this->sourceMirrors['git'][] = ['url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred'])];
  29804. }
  29805. if (!empty($mirror['hg-url'])) {
  29806. $this->sourceMirrors['hg'][] = ['url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred'])];
  29807. }
  29808. if (!empty($mirror['dist-url'])) {
  29809. $this->distMirrors[] = [
  29810. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  29811. 'preferred' => !empty($mirror['preferred']),
  29812. ];
  29813. }
  29814. }
  29815. }
  29816. if (!empty($data['providers-lazy-url'])) {
  29817. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  29818. $this->hasProviders = true;
  29819. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  29820. }
  29821. if (!empty($data['metadata-url'])) {
  29822. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']);
  29823. $this->providersUrl = null;
  29824. $this->hasProviders = false;
  29825. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  29826. $this->allowSslDowngrade = false;
  29827. if (!empty($data['available-packages'])) {
  29828. $availPackages = array_map('strtolower', $data['available-packages']);
  29829. $this->availablePackages = array_combine($availPackages, $availPackages);
  29830. $this->hasAvailablePackageList = true;
  29831. }
  29832. if (!empty($data['available-package-patterns'])) {
  29833. $this->availablePackagePatterns = array_map(static function ($pattern): string {
  29834. return BasePackage::packageNameToRegexp($pattern);
  29835. }, $data['available-package-patterns']);
  29836. $this->hasAvailablePackageList = true;
  29837. }
  29838. unset($data['providers-url'], $data['providers'], $data['providers-includes']);
  29839. if (isset($data['security-advisories']) && is_array($data['security-advisories'])) {
  29840. $this->securityAdvisoryConfig = [
  29841. 'metadata' => $data['security-advisories']['metadata'] ?? false,
  29842. 'api-url' => isset($data['security-advisories']['api-url']) && is_string($data['security-advisories']['api-url']) ? $this->canonicalizeUrl($data['security-advisories']['api-url']) : null,
  29843. ];
  29844. if ($this->securityAdvisoryConfig['api-url'] === null && !$this->hasAvailablePackageList) {
  29845. throw new \UnexpectedValueException('Invalid security advisory configuration on '.$this->getRepoName().': If the repository does not provide a security-advisories.api-url then available-packages or available-package-patterns are required to be provided for performance reason.');
  29846. }
  29847. }
  29848. }
  29849. if ($this->allowSslDowngrade) {
  29850. $this->url = str_replace('https://', 'http://', $this->url);
  29851. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  29852. }
  29853. if (!empty($data['providers-url'])) {
  29854. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  29855. $this->hasProviders = true;
  29856. }
  29857. if (!empty($data['list'])) {
  29858. $this->listUrl = $this->canonicalizeUrl($data['list']);
  29859. }
  29860. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  29861. $this->hasProviders = true;
  29862. }
  29863. if (!empty($data['providers-api'])) {
  29864. $this->providersApiUrl = $this->canonicalizeUrl($data['providers-api']);
  29865. }
  29866. return $this->rootData = $data;
  29867. }
  29868. private function canonicalizeUrl(string $url): string
  29869. {
  29870. if (strlen($url) === 0) {
  29871. throw new \InvalidArgumentException('Expected a string with a value and not an empty string');
  29872. }
  29873. if (str_starts_with($url, '/')) {
  29874. if (Preg::isMatch('{^[^:]++://[^/]*+}', $this->url, $matches)) {
  29875. return $matches[0] . $url;
  29876. }
  29877. return $this->url;
  29878. }
  29879. return $url;
  29880. }
  29881. private function loadDataFromServer(): array
  29882. {
  29883. $data = $this->loadRootServerFile();
  29884. if (true === $data) {
  29885. throw new \LogicException('loadRootServerFile should not return true during initialization');
  29886. }
  29887. return $this->loadIncludes($data);
  29888. }
  29889. private function hasPartialPackages(): bool
  29890. {
  29891. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  29892. $this->initializePartialPackages();
  29893. }
  29894. return $this->hasPartialPackages;
  29895. }
  29896. private function loadProviderListings($data): void
  29897. {
  29898. if (isset($data['providers'])) {
  29899. if (!is_array($this->providerListing)) {
  29900. $this->providerListing = [];
  29901. }
  29902. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  29903. }
  29904. if ($this->providersUrl && isset($data['provider-includes'])) {
  29905. $includes = $data['provider-includes'];
  29906. foreach ($includes as $include => $metadata) {
  29907. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  29908. $cacheKey = str_replace(['%hash%','$'], '', $include);
  29909. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  29910. $includedData = json_decode($this->cache->read($cacheKey), true);
  29911. } else {
  29912. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  29913. }
  29914. $this->loadProviderListings($includedData);
  29915. }
  29916. }
  29917. }
  29918. private function loadIncludes(array $data): array
  29919. {
  29920. $packages = [];
  29921. if (!isset($data['packages']) && !isset($data['includes'])) {
  29922. foreach ($data as $pkg) {
  29923. if (isset($pkg['versions']) && is_array($pkg['versions'])) {
  29924. foreach ($pkg['versions'] as $metadata) {
  29925. $packages[] = $metadata;
  29926. }
  29927. }
  29928. }
  29929. return $packages;
  29930. }
  29931. if (isset($data['packages'])) {
  29932. foreach ($data['packages'] as $package => $versions) {
  29933. $packageName = strtolower((string) $package);
  29934. foreach ($versions as $version => $metadata) {
  29935. $packages[] = $metadata;
  29936. if (!$this->displayedWarningAboutNonMatchingPackageIndex && $packageName !== strtolower((string) ($metadata['name'] ?? ''))) {
  29937. $this->displayedWarningAboutNonMatchingPackageIndex = true;
  29938. $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));
  29939. }
  29940. }
  29941. }
  29942. }
  29943. if (isset($data['includes'])) {
  29944. foreach ($data['includes'] as $include => $metadata) {
  29945. if (isset($metadata['sha1']) && $this->cache->sha1((string) $include) === $metadata['sha1']) {
  29946. $includedData = json_decode($this->cache->read((string) $include), true);
  29947. } else {
  29948. $includedData = $this->fetchFile($include);
  29949. }
  29950. $packages = array_merge($packages, $this->loadIncludes($includedData));
  29951. }
  29952. }
  29953. return $packages;
  29954. }
  29955. private function createPackages(array $packages, ?string $source = null): array
  29956. {
  29957. if (!$packages) {
  29958. return [];
  29959. }
  29960. try {
  29961. foreach ($packages as &$data) {
  29962. if (!isset($data['notification-url'])) {
  29963. $data['notification-url'] = $this->notifyUrl;
  29964. }
  29965. }
  29966. $packageInstances = $this->loader->loadPackages($packages);
  29967. foreach ($packageInstances as $package) {
  29968. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  29969. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  29970. }
  29971. $package->setDistMirrors($this->distMirrors);
  29972. $this->configurePackageTransportOptions($package);
  29973. }
  29974. return $packageInstances;
  29975. } catch (\Exception $e) {
  29976. 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);
  29977. }
  29978. }
  29979. protected function fetchFile(string $filename, ?string $cacheKey = null, ?string $sha256 = null, bool $storeLastModifiedTime = false)
  29980. {
  29981. if ('' === $filename) {
  29982. throw new \InvalidArgumentException('$filename should not be an empty string');
  29983. }
  29984. if (null === $cacheKey) {
  29985. $cacheKey = $filename;
  29986. $filename = $this->baseUrl.'/'.$filename;
  29987. }
  29988. if (($pos = strpos($filename, '$')) && Preg::isMatch('{^https?://}i', $filename)) {
  29989. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  29990. }
  29991. $retries = 3;
  29992. while ($retries--) {
  29993. try {
  29994. $options = $this->options;
  29995. if ($this->eventDispatcher) {
  29996. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', ['repository' => $this]);
  29997. $preFileDownloadEvent->setTransportOptions($this->options);
  29998. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  29999. $filename = $preFileDownloadEvent->getProcessedUrl();
  30000. $options = $preFileDownloadEvent->getTransportOptions();
  30001. }
  30002. $response = $this->httpDownloader->get($filename, $options);
  30003. $json = (string) $response->getBody();
  30004. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  30005. if ($this->allowSslDowngrade) {
  30006. $this->url = str_replace('http://', 'https://', $this->url);
  30007. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  30008. $filename = str_replace('http://', 'https://', $filename);
  30009. }
  30010. if ($retries > 0) {
  30011. usleep(100000);
  30012. continue;
  30013. }
  30014. 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.');
  30015. }
  30016. if ($this->eventDispatcher) {
  30017. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, $sha256, $filename, 'metadata', ['response' => $response, 'repository' => $this]);
  30018. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  30019. }
  30020. $data = $response->decodeJson();
  30021. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  30022. if ($cacheKey && !$this->cache->isReadOnly()) {
  30023. if ($storeLastModifiedTime) {
  30024. $lastModifiedDate = $response->getHeader('last-modified');
  30025. if ($lastModifiedDate) {
  30026. $data['last-modified'] = $lastModifiedDate;
  30027. $json = JsonFile::encode($data, 0);
  30028. }
  30029. }
  30030. $this->cache->write($cacheKey, $json);
  30031. }
  30032. $response->collect();
  30033. break;
  30034. } catch (\Exception $e) {
  30035. if ($e instanceof \LogicException) {
  30036. throw $e;
  30037. }
  30038. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  30039. throw $e;
  30040. }
  30041. if ($e instanceof RepositorySecurityException) {
  30042. throw $e;
  30043. }
  30044. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  30045. if (!$this->degradedMode) {
  30046. $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>');
  30047. }
  30048. $this->degradedMode = true;
  30049. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  30050. break;
  30051. }
  30052. throw $e;
  30053. }
  30054. }
  30055. if (!isset($data)) {
  30056. throw new \LogicException("ComposerRepository: Undefined \$data. Please report at https://github.com/composer/composer/issues/new.");
  30057. }
  30058. return $data;
  30059. }
  30060. private function fetchFileIfLastModified(string $filename, string $cacheKey, string $lastModifiedTime)
  30061. {
  30062. if ('' === $filename) {
  30063. throw new \InvalidArgumentException('$filename should not be an empty string');
  30064. }
  30065. try {
  30066. $options = $this->options;
  30067. if ($this->eventDispatcher) {
  30068. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', ['repository' => $this]);
  30069. $preFileDownloadEvent->setTransportOptions($this->options);
  30070. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  30071. $filename = $preFileDownloadEvent->getProcessedUrl();
  30072. $options = $preFileDownloadEvent->getTransportOptions();
  30073. }
  30074. if (isset($options['http']['header'])) {
  30075. $options['http']['header'] = (array) $options['http']['header'];
  30076. }
  30077. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  30078. $response = $this->httpDownloader->get($filename, $options);
  30079. $json = (string) $response->getBody();
  30080. if ($json === '' && $response->getStatusCode() === 304) {
  30081. return true;
  30082. }
  30083. if ($this->eventDispatcher) {
  30084. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', ['response' => $response, 'repository' => $this]);
  30085. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  30086. }
  30087. $data = $response->decodeJson();
  30088. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  30089. $lastModifiedDate = $response->getHeader('last-modified');
  30090. $response->collect();
  30091. if ($lastModifiedDate) {
  30092. $data['last-modified'] = $lastModifiedDate;
  30093. $json = JsonFile::encode($data, 0);
  30094. }
  30095. if (!$this->cache->isReadOnly()) {
  30096. $this->cache->write($cacheKey, $json);
  30097. }
  30098. return $data;
  30099. } catch (\Exception $e) {
  30100. if ($e instanceof \LogicException) {
  30101. throw $e;
  30102. }
  30103. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  30104. throw $e;
  30105. }
  30106. if (!$this->degradedMode) {
  30107. $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>');
  30108. }
  30109. $this->degradedMode = true;
  30110. return true;
  30111. }
  30112. }
  30113. private function asyncFetchFile(string $filename, string $cacheKey, ?string $lastModifiedTime = null): PromiseInterface
  30114. {
  30115. if ('' === $filename) {
  30116. throw new \InvalidArgumentException('$filename should not be an empty string');
  30117. }
  30118. if (isset($this->packagesNotFoundCache[$filename])) {
  30119. return \React\Promise\resolve(['packages' => []]);
  30120. }
  30121. if (isset($this->freshMetadataUrls[$filename]) && $lastModifiedTime) {
  30122. $promise = \React\Promise\resolve(true);
  30123. return $promise;
  30124. }
  30125. $httpDownloader = $this->httpDownloader;
  30126. $options = $this->options;
  30127. if ($this->eventDispatcher) {
  30128. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', ['repository' => $this]);
  30129. $preFileDownloadEvent->setTransportOptions($this->options);
  30130. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  30131. $filename = $preFileDownloadEvent->getProcessedUrl();
  30132. $options = $preFileDownloadEvent->getTransportOptions();
  30133. }
  30134. if ($lastModifiedTime) {
  30135. if (isset($options['http']['header'])) {
  30136. $options['http']['header'] = (array) $options['http']['header'];
  30137. }
  30138. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  30139. }
  30140. $io = $this->io;
  30141. $url = $this->url;
  30142. $cache = $this->cache;
  30143. $degradedMode = &$this->degradedMode;
  30144. $eventDispatcher = $this->eventDispatcher;
  30145. $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $eventDispatcher) {
  30146. if ($response->getStatusCode() === 404) {
  30147. $this->packagesNotFoundCache[$filename] = true;
  30148. return ['packages' => []];
  30149. }
  30150. $json = (string) $response->getBody();
  30151. if ($json === '' && $response->getStatusCode() === 304) {
  30152. $this->freshMetadataUrls[$filename] = true;
  30153. return true;
  30154. }
  30155. if ($eventDispatcher) {
  30156. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', ['response' => $response, 'repository' => $this]);
  30157. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  30158. }
  30159. $data = $response->decodeJson();
  30160. HttpDownloader::outputWarnings($io, $url, $data);
  30161. $lastModifiedDate = $response->getHeader('last-modified');
  30162. $response->collect();
  30163. if ($lastModifiedDate) {
  30164. $data['last-modified'] = $lastModifiedDate;
  30165. $json = JsonFile::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
  30166. }
  30167. if (!$cache->isReadOnly()) {
  30168. $cache->write($cacheKey, $json);
  30169. }
  30170. $this->freshMetadataUrls[$filename] = true;
  30171. return $data;
  30172. };
  30173. $reject = function ($e) use ($filename, $accept, $io, $url, &$degradedMode, $lastModifiedTime) {
  30174. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  30175. $this->packagesNotFoundCache[$filename] = true;
  30176. return false;
  30177. }
  30178. if (!$degradedMode) {
  30179. $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>');
  30180. }
  30181. $degradedMode = true;
  30182. if ($lastModifiedTime) {
  30183. return $accept(new Response(['url' => $url], 304, [], ''));
  30184. }
  30185. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  30186. return $accept(new Response(['url' => $url], 404, [], ''));
  30187. }
  30188. throw $e;
  30189. };
  30190. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  30191. }
  30192. private function initializePartialPackages(): void
  30193. {
  30194. $rootData = $this->loadRootServerFile();
  30195. if ($rootData === true) {
  30196. return;
  30197. }
  30198. $this->partialPackagesByName = [];
  30199. foreach ($rootData['packages'] as $package => $versions) {
  30200. foreach ($versions as $version) {
  30201. $versionPackageName = strtolower((string) ($version['name'] ?? ''));
  30202. $this->partialPackagesByName[$versionPackageName][] = $version;
  30203. if (!$this->displayedWarningAboutNonMatchingPackageIndex && $versionPackageName !== strtolower($package)) {
  30204. $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));
  30205. $this->displayedWarningAboutNonMatchingPackageIndex = true;
  30206. }
  30207. }
  30208. }
  30209. $this->rootData = true;
  30210. }
  30211. protected function lazyProvidersRepoContains(string $name)
  30212. {
  30213. if (!$this->hasAvailablePackageList) {
  30214. throw new \LogicException('lazyProvidersRepoContains should not be called unless hasAvailablePackageList is true');
  30215. }
  30216. if (is_array($this->availablePackages) && isset($this->availablePackages[$name])) {
  30217. return true;
  30218. }
  30219. if (is_array($this->availablePackagePatterns)) {
  30220. foreach ($this->availablePackagePatterns as $providerRegex) {
  30221. if (Preg::isMatch($providerRegex, $name)) {
  30222. return true;
  30223. }
  30224. }
  30225. }
  30226. return false;
  30227. }
  30228. }
  30229. <?php declare(strict_types=1);
  30230. namespace Composer\Repository;
  30231. use Composer\Package\BasePackage;
  30232. use Composer\Package\PackageInterface;
  30233. class CompositeRepository implements RepositoryInterface
  30234. {
  30235. private $repositories;
  30236. public function __construct(array $repositories)
  30237. {
  30238. $this->repositories = [];
  30239. foreach ($repositories as $repo) {
  30240. $this->addRepository($repo);
  30241. }
  30242. }
  30243. public function getRepoName(): string
  30244. {
  30245. return 'composite repo ('.implode(', ', array_map(static function ($repo): string {
  30246. return $repo->getRepoName();
  30247. }, $this->repositories)).')';
  30248. }
  30249. public function getRepositories(): array
  30250. {
  30251. return $this->repositories;
  30252. }
  30253. public function hasPackage(PackageInterface $package): bool
  30254. {
  30255. foreach ($this->repositories as $repository) {
  30256. if ($repository->hasPackage($package)) {
  30257. return true;
  30258. }
  30259. }
  30260. return false;
  30261. }
  30262. public function findPackage($name, $constraint): ?BasePackage
  30263. {
  30264. foreach ($this->repositories as $repository) {
  30265. $package = $repository->findPackage($name, $constraint);
  30266. if (null !== $package) {
  30267. return $package;
  30268. }
  30269. }
  30270. return null;
  30271. }
  30272. public function findPackages($name, $constraint = null): array
  30273. {
  30274. $packages = [];
  30275. foreach ($this->repositories as $repository) {
  30276. $packages[] = $repository->findPackages($name, $constraint);
  30277. }
  30278. return $packages ? array_merge(...$packages) : [];
  30279. }
  30280. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = []): array
  30281. {
  30282. $packages = [];
  30283. $namesFound = [];
  30284. foreach ($this->repositories as $repository) {
  30285. $result = $repository->loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  30286. $packages[] = $result['packages'];
  30287. $namesFound[] = $result['namesFound'];
  30288. }
  30289. return [
  30290. 'packages' => $packages ? array_merge(...$packages) : [],
  30291. 'namesFound' => $namesFound ? array_unique(array_merge(...$namesFound)) : [],
  30292. ];
  30293. }
  30294. public function search(string $query, int $mode = 0, ?string $type = null): array
  30295. {
  30296. $matches = [];
  30297. foreach ($this->repositories as $repository) {
  30298. $matches[] = $repository->search($query, $mode, $type);
  30299. }
  30300. return \count($matches) > 0 ? array_merge(...$matches) : [];
  30301. }
  30302. public function getPackages(): array
  30303. {
  30304. $packages = [];
  30305. foreach ($this->repositories as $repository) {
  30306. $packages[] = $repository->getPackages();
  30307. }
  30308. return $packages ? array_merge(...$packages) : [];
  30309. }
  30310. public function getProviders($packageName): array
  30311. {
  30312. $results = [];
  30313. foreach ($this->repositories as $repository) {
  30314. $results[] = $repository->getProviders($packageName);
  30315. }
  30316. return $results ? array_merge(...$results) : [];
  30317. }
  30318. public function removePackage(PackageInterface $package): void
  30319. {
  30320. foreach ($this->repositories as $repository) {
  30321. if ($repository instanceof WritableRepositoryInterface) {
  30322. $repository->removePackage($package);
  30323. }
  30324. }
  30325. }
  30326. public function count(): int
  30327. {
  30328. $total = 0;
  30329. foreach ($this->repositories as $repository) {
  30330. $total += $repository->count();
  30331. }
  30332. return $total;
  30333. }
  30334. public function addRepository(RepositoryInterface $repository): void
  30335. {
  30336. if ($repository instanceof self) {
  30337. foreach ($repository->getRepositories() as $repo) {
  30338. $this->addRepository($repo);
  30339. }
  30340. } else {
  30341. $this->repositories[] = $repository;
  30342. }
  30343. }
  30344. }
  30345. <?php declare(strict_types=1);
  30346. namespace Composer\Repository;
  30347. interface ConfigurableRepositoryInterface
  30348. {
  30349. public function getRepoConfig();
  30350. }
  30351. <?php declare(strict_types=1);
  30352. namespace Composer\Repository;
  30353. use Composer\Json\JsonFile;
  30354. use Composer\Package\Loader\ArrayLoader;
  30355. use Composer\Package\PackageInterface;
  30356. use Composer\Package\RootAliasPackage;
  30357. use Composer\Package\RootPackageInterface;
  30358. use Composer\Package\AliasPackage;
  30359. use Composer\Package\Dumper\ArrayDumper;
  30360. use Composer\Installer\InstallationManager;
  30361. use Composer\Pcre\Preg;
  30362. use Composer\Util\Filesystem;
  30363. use Composer\Util\Platform;
  30364. class FilesystemRepository extends WritableArrayRepository
  30365. {
  30366. protected $file;
  30367. private $dumpVersions;
  30368. private $rootPackage;
  30369. private $filesystem;
  30370. private $devMode = null;
  30371. public function __construct(JsonFile $repositoryFile, bool $dumpVersions = false, ?RootPackageInterface $rootPackage = null, ?Filesystem $filesystem = null)
  30372. {
  30373. parent::__construct();
  30374. $this->file = $repositoryFile;
  30375. $this->dumpVersions = $dumpVersions;
  30376. $this->rootPackage = $rootPackage;
  30377. $this->filesystem = $filesystem ?: new Filesystem;
  30378. if ($dumpVersions && !$rootPackage) {
  30379. throw new \InvalidArgumentException('Expected a root package instance if $dumpVersions is true');
  30380. }
  30381. }
  30382. public function getDevMode()
  30383. {
  30384. return $this->devMode;
  30385. }
  30386. protected function initialize()
  30387. {
  30388. parent::initialize();
  30389. if (!$this->file->exists()) {
  30390. return;
  30391. }
  30392. try {
  30393. $data = $this->file->read();
  30394. if (isset($data['packages'])) {
  30395. $packages = $data['packages'];
  30396. } else {
  30397. $packages = $data;
  30398. }
  30399. if (isset($data['dev-package-names'])) {
  30400. $this->setDevPackageNames($data['dev-package-names']);
  30401. }
  30402. if (isset($data['dev'])) {
  30403. $this->devMode = $data['dev'];
  30404. }
  30405. if (!is_array($packages)) {
  30406. throw new \UnexpectedValueException('Could not parse package list from the repository');
  30407. }
  30408. } catch (\Exception $e) {
  30409. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  30410. }
  30411. $loader = new ArrayLoader(null, true);
  30412. foreach ($packages as $packageData) {
  30413. $package = $loader->load($packageData);
  30414. $this->addPackage($package);
  30415. }
  30416. }
  30417. public function reload()
  30418. {
  30419. $this->packages = null;
  30420. $this->initialize();
  30421. }
  30422. public function write(bool $devMode, InstallationManager $installationManager)
  30423. {
  30424. $data = ['packages' => [], 'dev' => $devMode, 'dev-package-names' => []];
  30425. $dumper = new ArrayDumper();
  30426. $repoDir = dirname($this->file->getPath());
  30427. $this->filesystem->ensureDirectoryExists($repoDir);
  30428. $repoDir = $this->filesystem->normalizePath(realpath($repoDir));
  30429. $installPaths = [];
  30430. foreach ($this->getCanonicalPackages() as $package) {
  30431. $pkgArray = $dumper->dump($package);
  30432. $path = $installationManager->getInstallPath($package);
  30433. $installPath = null;
  30434. if ('' !== $path && null !== $path) {
  30435. $normalizedPath = $this->filesystem->normalizePath($this->filesystem->isAbsolutePath($path) ? $path : Platform::getCwd() . '/' . $path);
  30436. $installPath = $this->filesystem->findShortestPath($repoDir, $normalizedPath, true);
  30437. }
  30438. $installPaths[$package->getName()] = $installPath;
  30439. $pkgArray['install-path'] = $installPath;
  30440. $data['packages'][] = $pkgArray;
  30441. if (in_array($package->getName(), $this->devPackageNames, true)) {
  30442. $data['dev-package-names'][] = $package->getName();
  30443. }
  30444. }
  30445. sort($data['dev-package-names']);
  30446. usort($data['packages'], static function ($a, $b): int {
  30447. return strcmp($a['name'], $b['name']);
  30448. });
  30449. $this->file->write($data);
  30450. if ($this->dumpVersions) {
  30451. $versions = $this->generateInstalledVersions($installationManager, $installPaths, $devMode, $repoDir);
  30452. $this->filesystem->filePutContentsIfModified($repoDir.'/installed.php', '<?php return ' . $this->dumpToPhpCode($versions) . ';'."\n");
  30453. $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
  30454. if ($installedVersionsClass !== false) {
  30455. $this->filesystem->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
  30456. \Composer\InstalledVersions::reload($versions);
  30457. try {
  30458. $reflProp = new \ReflectionProperty(\Composer\InstalledVersions::class, 'selfDir');
  30459. $reflProp->setAccessible(true);
  30460. $reflProp->setValue(null, strtr($repoDir, '\\', '/'));
  30461. $reflProp = new \ReflectionProperty(\Composer\InstalledVersions::class, 'installedIsLocalDir');
  30462. $reflProp->setAccessible(true);
  30463. $reflProp->setValue(null, true);
  30464. } catch (\ReflectionException $e) {
  30465. if (!Preg::isMatch('{Property .*? does not exist}i', $e->getMessage())) {
  30466. throw $e;
  30467. }
  30468. }
  30469. }
  30470. }
  30471. }
  30472. public static function safelyLoadInstalledVersions(string $path): bool
  30473. {
  30474. $installedVersionsData = @file_get_contents($path);
  30475. $pattern = <<<'REGEX'
  30476. {(?(DEFINE)
  30477. (?<number> -? \s*+ \d++ (?:\.\d++)? )
  30478. (?<boolean> true | false | null )
  30479. (?<strings> (?&string) (?: \s*+ \. \s*+ (?&string))*+ )
  30480. (?<string> (?: " (?:[^"\\$]*+ | \\ ["\\0] )* " | ' (?:[^'\\]*+ | \\ ['\\] )* ' ) )
  30481. (?<array> array\( \s*+ (?: (?:(?&number)|(?&strings)) \s*+ => \s*+ (?: (?:__DIR__ \s*+ \. \s*+)? (?&strings) | (?&value) ) \s*+, \s*+ )*+ \s*+ \) )
  30482. (?<value> (?: (?&number) | (?&boolean) | (?&strings) | (?&array) ) )
  30483. )
  30484. ^<\?php\s++return\s++(?&array)\s*+;$}ix
  30485. REGEX;
  30486. if (is_string($installedVersionsData) && Preg::isMatch($pattern, trim($installedVersionsData))) {
  30487. \Composer\InstalledVersions::reload(eval('?>'.Preg::replace('{=>\s*+__DIR__\s*+\.\s*+([\'"])}', '=> '.var_export(dirname($path), true).' . $1', $installedVersionsData)));
  30488. return true;
  30489. }
  30490. return false;
  30491. }
  30492. private function dumpToPhpCode(array $array = [], int $level = 0): string
  30493. {
  30494. $lines = "array(\n";
  30495. $level++;
  30496. foreach ($array as $key => $value) {
  30497. $lines .= str_repeat(' ', $level);
  30498. $lines .= is_int($key) ? $key . ' => ' : var_export($key, true) . ' => ';
  30499. if (is_array($value)) {
  30500. if (!empty($value)) {
  30501. $lines .= $this->dumpToPhpCode($value, $level);
  30502. } else {
  30503. $lines .= "array(),\n";
  30504. }
  30505. } elseif ($key === 'install_path' && is_string($value)) {
  30506. if ($this->filesystem->isAbsolutePath($value)) {
  30507. $lines .= var_export($value, true) . ",\n";
  30508. } else {
  30509. $lines .= "__DIR__ . " . var_export('/' . $value, true) . ",\n";
  30510. }
  30511. } elseif (is_string($value)) {
  30512. $lines .= var_export($value, true) . ",\n";
  30513. } elseif (is_bool($value)) {
  30514. $lines .= ($value ? 'true' : 'false') . ",\n";
  30515. } elseif (is_null($value)) {
  30516. $lines .= "null,\n";
  30517. } else {
  30518. throw new \UnexpectedValueException('Unexpected type '.gettype($value));
  30519. }
  30520. }
  30521. $lines .= str_repeat(' ', $level - 1) . ')' . ($level - 1 === 0 ? '' : ",\n");
  30522. return $lines;
  30523. }
  30524. private function generateInstalledVersions(InstallationManager $installationManager, array $installPaths, bool $devMode, string $repoDir): array
  30525. {
  30526. $devPackages = array_flip($this->devPackageNames);
  30527. $packages = $this->getPackages();
  30528. if (null === $this->rootPackage) {
  30529. throw new \LogicException('It should not be possible to dump packages if no root package is given');
  30530. }
  30531. $packages[] = $rootPackage = $this->rootPackage;
  30532. while ($rootPackage instanceof RootAliasPackage) {
  30533. $rootPackage = $rootPackage->getAliasOf();
  30534. $packages[] = $rootPackage;
  30535. }
  30536. $versions = [
  30537. 'root' => $this->dumpRootPackage($rootPackage, $installPaths, $devMode, $repoDir, $devPackages),
  30538. 'versions' => [],
  30539. ];
  30540. foreach ($packages as $package) {
  30541. if ($package instanceof AliasPackage) {
  30542. continue;
  30543. }
  30544. $versions['versions'][$package->getName()] = $this->dumpInstalledPackage($package, $installPaths, $repoDir, $devPackages);
  30545. }
  30546. foreach ($packages as $package) {
  30547. $isDevPackage = isset($devPackages[$package->getName()]);
  30548. foreach ($package->getReplaces() as $replace) {
  30549. if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
  30550. continue;
  30551. }
  30552. if (!isset($versions['versions'][$replace->getTarget()]['dev_requirement'])) {
  30553. $versions['versions'][$replace->getTarget()]['dev_requirement'] = $isDevPackage;
  30554. } elseif (!$isDevPackage) {
  30555. $versions['versions'][$replace->getTarget()]['dev_requirement'] = false;
  30556. }
  30557. $replaced = $replace->getPrettyConstraint();
  30558. if ($replaced === 'self.version') {
  30559. $replaced = $package->getPrettyVersion();
  30560. }
  30561. if (!isset($versions['versions'][$replace->getTarget()]['replaced']) || !in_array($replaced, $versions['versions'][$replace->getTarget()]['replaced'], true)) {
  30562. $versions['versions'][$replace->getTarget()]['replaced'][] = $replaced;
  30563. }
  30564. }
  30565. foreach ($package->getProvides() as $provide) {
  30566. if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
  30567. continue;
  30568. }
  30569. if (!isset($versions['versions'][$provide->getTarget()]['dev_requirement'])) {
  30570. $versions['versions'][$provide->getTarget()]['dev_requirement'] = $isDevPackage;
  30571. } elseif (!$isDevPackage) {
  30572. $versions['versions'][$provide->getTarget()]['dev_requirement'] = false;
  30573. }
  30574. $provided = $provide->getPrettyConstraint();
  30575. if ($provided === 'self.version') {
  30576. $provided = $package->getPrettyVersion();
  30577. }
  30578. if (!isset($versions['versions'][$provide->getTarget()]['provided']) || !in_array($provided, $versions['versions'][$provide->getTarget()]['provided'], true)) {
  30579. $versions['versions'][$provide->getTarget()]['provided'][] = $provided;
  30580. }
  30581. }
  30582. }
  30583. foreach ($packages as $package) {
  30584. if (!$package instanceof AliasPackage) {
  30585. continue;
  30586. }
  30587. $versions['versions'][$package->getName()]['aliases'][] = $package->getPrettyVersion();
  30588. if ($package instanceof RootPackageInterface) {
  30589. $versions['root']['aliases'][] = $package->getPrettyVersion();
  30590. }
  30591. }
  30592. ksort($versions['versions']);
  30593. ksort($versions);
  30594. foreach ($versions['versions'] as $name => $version) {
  30595. foreach (['aliases', 'replaced', 'provided'] as $key) {
  30596. if (isset($versions['versions'][$name][$key])) {
  30597. sort($versions['versions'][$name][$key], SORT_NATURAL);
  30598. }
  30599. }
  30600. }
  30601. return $versions;
  30602. }
  30603. private function dumpInstalledPackage(PackageInterface $package, array $installPaths, string $repoDir, array $devPackages): array
  30604. {
  30605. $reference = null;
  30606. if ($package->getInstallationSource()) {
  30607. $reference = $package->getInstallationSource() === 'source' ? $package->getSourceReference() : $package->getDistReference();
  30608. }
  30609. if (null === $reference) {
  30610. $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null;
  30611. }
  30612. if ($package instanceof RootPackageInterface) {
  30613. $to = $this->filesystem->normalizePath(realpath(Platform::getCwd()));
  30614. $installPath = $this->filesystem->findShortestPath($repoDir, $to, true);
  30615. } else {
  30616. $installPath = $installPaths[$package->getName()];
  30617. }
  30618. $data = [
  30619. 'pretty_version' => $package->getPrettyVersion(),
  30620. 'version' => $package->getVersion(),
  30621. 'reference' => $reference,
  30622. 'type' => $package->getType(),
  30623. 'install_path' => $installPath,
  30624. 'aliases' => [],
  30625. 'dev_requirement' => isset($devPackages[$package->getName()]),
  30626. ];
  30627. return $data;
  30628. }
  30629. private function dumpRootPackage(RootPackageInterface $package, array $installPaths, bool $devMode, string $repoDir, array $devPackages)
  30630. {
  30631. $data = $this->dumpInstalledPackage($package, $installPaths, $repoDir, $devPackages);
  30632. return [
  30633. 'name' => $package->getName(),
  30634. 'pretty_version' => $data['pretty_version'],
  30635. 'version' => $data['version'],
  30636. 'reference' => $data['reference'],
  30637. 'type' => $data['type'],
  30638. 'install_path' => $data['install_path'],
  30639. 'aliases' => $data['aliases'],
  30640. 'dev' => $devMode,
  30641. ];
  30642. }
  30643. }
  30644. <?php declare(strict_types=1);
  30645. namespace Composer\Repository;
  30646. use Composer\Package\PackageInterface;
  30647. use Composer\Package\BasePackage;
  30648. use Composer\Pcre\Preg;
  30649. class FilterRepository implements RepositoryInterface, AdvisoryProviderInterface
  30650. {
  30651. private $only = null;
  30652. private $exclude = null;
  30653. private $canonical = true;
  30654. private $repo;
  30655. public function __construct(RepositoryInterface $repo, array $options)
  30656. {
  30657. if (isset($options['only'])) {
  30658. if (!is_array($options['only'])) {
  30659. throw new \InvalidArgumentException('"only" key for repository '.$repo->getRepoName().' should be an array');
  30660. }
  30661. $this->only = BasePackage::packageNamesToRegexp($options['only']);
  30662. }
  30663. if (isset($options['exclude'])) {
  30664. if (!is_array($options['exclude'])) {
  30665. throw new \InvalidArgumentException('"exclude" key for repository '.$repo->getRepoName().' should be an array');
  30666. }
  30667. $this->exclude = BasePackage::packageNamesToRegexp($options['exclude']);
  30668. }
  30669. if ($this->exclude && $this->only) {
  30670. throw new \InvalidArgumentException('Only one of "only" and "exclude" can be specified for repository '.$repo->getRepoName());
  30671. }
  30672. if (isset($options['canonical'])) {
  30673. if (!is_bool($options['canonical'])) {
  30674. throw new \InvalidArgumentException('"canonical" key for repository '.$repo->getRepoName().' should be a boolean');
  30675. }
  30676. $this->canonical = $options['canonical'];
  30677. }
  30678. $this->repo = $repo;
  30679. }
  30680. public function getRepoName(): string
  30681. {
  30682. return $this->repo->getRepoName();
  30683. }
  30684. public function getRepository(): RepositoryInterface
  30685. {
  30686. return $this->repo;
  30687. }
  30688. public function hasPackage(PackageInterface $package): bool
  30689. {
  30690. return $this->repo->hasPackage($package);
  30691. }
  30692. public function findPackage($name, $constraint): ?BasePackage
  30693. {
  30694. if (!$this->isAllowed($name)) {
  30695. return null;
  30696. }
  30697. return $this->repo->findPackage($name, $constraint);
  30698. }
  30699. public function findPackages($name, $constraint = null): array
  30700. {
  30701. if (!$this->isAllowed($name)) {
  30702. return [];
  30703. }
  30704. return $this->repo->findPackages($name, $constraint);
  30705. }
  30706. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = []): array
  30707. {
  30708. foreach ($packageNameMap as $name => $constraint) {
  30709. if (!$this->isAllowed($name)) {
  30710. unset($packageNameMap[$name]);
  30711. }
  30712. }
  30713. if (!$packageNameMap) {
  30714. return ['namesFound' => [], 'packages' => []];
  30715. }
  30716. $result = $this->repo->loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  30717. if (!$this->canonical) {
  30718. $result['namesFound'] = [];
  30719. }
  30720. return $result;
  30721. }
  30722. public function search(string $query, int $mode = 0, ?string $type = null): array
  30723. {
  30724. $result = [];
  30725. foreach ($this->repo->search($query, $mode, $type) as $package) {
  30726. if ($this->isAllowed($package['name'])) {
  30727. $result[] = $package;
  30728. }
  30729. }
  30730. return $result;
  30731. }
  30732. public function getPackages(): array
  30733. {
  30734. $result = [];
  30735. foreach ($this->repo->getPackages() as $package) {
  30736. if ($this->isAllowed($package->getName())) {
  30737. $result[] = $package;
  30738. }
  30739. }
  30740. return $result;
  30741. }
  30742. public function getProviders($packageName): array
  30743. {
  30744. $result = [];
  30745. foreach ($this->repo->getProviders($packageName) as $name => $provider) {
  30746. if ($this->isAllowed($provider['name'])) {
  30747. $result[$name] = $provider;
  30748. }
  30749. }
  30750. return $result;
  30751. }
  30752. public function count(): int
  30753. {
  30754. if ($this->repo->count() > 0) {
  30755. return count($this->getPackages());
  30756. }
  30757. return 0;
  30758. }
  30759. public function hasSecurityAdvisories(): bool
  30760. {
  30761. if (!$this->repo instanceof AdvisoryProviderInterface) {
  30762. return false;
  30763. }
  30764. return $this->repo->hasSecurityAdvisories();
  30765. }
  30766. public function getSecurityAdvisories(array $packageConstraintMap, bool $allowPartialAdvisories = false): array
  30767. {
  30768. if (!$this->repo instanceof AdvisoryProviderInterface) {
  30769. return ['namesFound' => [], 'advisories' => []];
  30770. }
  30771. foreach ($packageConstraintMap as $name => $constraint) {
  30772. if (!$this->isAllowed($name)) {
  30773. unset($packageConstraintMap[$name]);
  30774. }
  30775. }
  30776. return $this->repo->getSecurityAdvisories($packageConstraintMap, $allowPartialAdvisories);
  30777. }
  30778. private function isAllowed(string $name): bool
  30779. {
  30780. if (!$this->only && !$this->exclude) {
  30781. return true;
  30782. }
  30783. if ($this->only) {
  30784. return Preg::isMatch($this->only, $name);
  30785. }
  30786. if ($this->exclude === null) {
  30787. return true;
  30788. }
  30789. return !Preg::isMatch($this->exclude, $name);
  30790. }
  30791. }
  30792. <?php declare(strict_types=1);
  30793. namespace Composer\Repository;
  30794. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  30795. {
  30796. public function getRepoName(): string
  30797. {
  30798. return 'installed '.parent::getRepoName();
  30799. }
  30800. public function isFresh(): bool
  30801. {
  30802. return $this->count() === 0;
  30803. }
  30804. }
  30805. <?php declare(strict_types=1);
  30806. namespace Composer\Repository;
  30807. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  30808. {
  30809. public function getRepoName()
  30810. {
  30811. return 'installed '.parent::getRepoName();
  30812. }
  30813. public function isFresh()
  30814. {
  30815. return !$this->file->exists();
  30816. }
  30817. }
  30818. <?php declare(strict_types=1);
  30819. namespace Composer\Repository;
  30820. use Composer\Package\BasePackage;
  30821. use Composer\Package\PackageInterface;
  30822. use Composer\Package\Version\VersionParser;
  30823. use Composer\Semver\Constraint\ConstraintInterface;
  30824. use Composer\Semver\Constraint\Constraint;
  30825. use Composer\Semver\Constraint\MatchAllConstraint;
  30826. use Composer\Package\RootPackageInterface;
  30827. use Composer\Package\Link;
  30828. class InstalledRepository extends CompositeRepository
  30829. {
  30830. public function findPackagesWithReplacersAndProviders(string $name, $constraint = null): array
  30831. {
  30832. $name = strtolower($name);
  30833. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  30834. $versionParser = new VersionParser();
  30835. $constraint = $versionParser->parseConstraints($constraint);
  30836. }
  30837. $matches = [];
  30838. foreach ($this->getRepositories() as $repo) {
  30839. foreach ($repo->getPackages() as $candidate) {
  30840. if ($name === $candidate->getName()) {
  30841. if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  30842. $matches[] = $candidate;
  30843. }
  30844. continue;
  30845. }
  30846. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  30847. if (
  30848. $name === $link->getTarget()
  30849. && ($constraint === null || $constraint->matches($link->getConstraint()))
  30850. ) {
  30851. $matches[] = $candidate;
  30852. continue 2;
  30853. }
  30854. }
  30855. }
  30856. }
  30857. return $matches;
  30858. }
  30859. public function getDependents($needle, ?ConstraintInterface $constraint = null, bool $invert = false, bool $recurse = true, ?array $packagesFound = null): array
  30860. {
  30861. $needles = array_map('strtolower', (array) $needle);
  30862. $results = [];
  30863. if (null === $packagesFound) {
  30864. $packagesFound = $needles;
  30865. }
  30866. $rootPackage = null;
  30867. foreach ($this->getPackages() as $package) {
  30868. if ($package instanceof RootPackageInterface) {
  30869. $rootPackage = $package;
  30870. break;
  30871. }
  30872. }
  30873. foreach ($this->getPackages() as $package) {
  30874. $links = $package->getRequires();
  30875. $packagesInTree = $packagesFound;
  30876. if (!$invert) {
  30877. $links += $package->getReplaces();
  30878. foreach ($package->getReplaces() as $link) {
  30879. foreach ($needles as $needle) {
  30880. if ($link->getSource() === $needle) {
  30881. if ($constraint === null || ($link->getConstraint()->matches($constraint) === true)) {
  30882. if (in_array($link->getTarget(), $packagesInTree)) {
  30883. $results[] = [$package, $link, false];
  30884. continue;
  30885. }
  30886. $packagesInTree[] = $link->getTarget();
  30887. $dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : [];
  30888. $results[] = [$package, $link, $dependents];
  30889. $needles[] = $link->getTarget();
  30890. }
  30891. }
  30892. }
  30893. }
  30894. unset($needle);
  30895. }
  30896. if ($package instanceof RootPackageInterface) {
  30897. $links += $package->getDevRequires();
  30898. }
  30899. foreach ($links as $link) {
  30900. foreach ($needles as $needle) {
  30901. if ($link->getTarget() === $needle) {
  30902. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  30903. if (in_array($link->getSource(), $packagesInTree)) {
  30904. $results[] = [$package, $link, false];
  30905. continue;
  30906. }
  30907. $packagesInTree[] = $link->getSource();
  30908. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : [];
  30909. $results[] = [$package, $link, $dependents];
  30910. }
  30911. }
  30912. }
  30913. }
  30914. if ($invert && in_array($package->getName(), $needles, true)) {
  30915. foreach ($package->getConflicts() as $link) {
  30916. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  30917. $version = new Constraint('=', $pkg->getVersion());
  30918. if ($link->getConstraint()->matches($version) === $invert) {
  30919. $results[] = [$package, $link, false];
  30920. }
  30921. }
  30922. }
  30923. }
  30924. foreach ($package->getConflicts() as $link) {
  30925. if (in_array($link->getTarget(), $needles, true)) {
  30926. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  30927. $version = new Constraint('=', $pkg->getVersion());
  30928. if ($link->getConstraint()->matches($version) === $invert) {
  30929. $results[] = [$package, $link, false];
  30930. }
  30931. }
  30932. }
  30933. }
  30934. if ($invert && $constraint && in_array($package->getName(), $needles, true) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  30935. foreach ($package->getRequires() as $link) {
  30936. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  30937. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  30938. continue;
  30939. }
  30940. $platformPkg = $this->findPackage($link->getTarget(), '*');
  30941. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  30942. $results[] = [$package, new Link($package->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false];
  30943. continue;
  30944. }
  30945. foreach ($this->getPackages() as $pkg) {
  30946. if (!in_array($link->getTarget(), $pkg->getNames())) {
  30947. continue;
  30948. }
  30949. $version = new Constraint('=', $pkg->getVersion());
  30950. if ($link->getTarget() !== $pkg->getName()) {
  30951. foreach (array_merge($pkg->getReplaces(), $pkg->getProvides()) as $prov) {
  30952. if ($link->getTarget() === $prov->getTarget()) {
  30953. $version = $prov->getConstraint();
  30954. break;
  30955. }
  30956. }
  30957. }
  30958. if (!$link->getConstraint()->matches($version)) {
  30959. if ($rootPackage) {
  30960. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  30961. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  30962. $results[] = [$package, $link, false];
  30963. $results[] = [$rootPackage, $rootReq, false];
  30964. continue 3;
  30965. }
  30966. }
  30967. $results[] = [$package, $link, false];
  30968. $results[] = [$rootPackage, new Link($rootPackage->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_DOES_NOT_REQUIRE, 'but ' . $pkg->getPrettyVersion() . ' is installed'), false];
  30969. } else {
  30970. $results[] = [$package, $link, false];
  30971. }
  30972. }
  30973. continue 2;
  30974. }
  30975. }
  30976. }
  30977. }
  30978. ksort($results);
  30979. return $results;
  30980. }
  30981. public function getRepoName(): string
  30982. {
  30983. return 'installed repo ('.implode(', ', array_map(static function ($repo): string {
  30984. return $repo->getRepoName();
  30985. }, $this->getRepositories())).')';
  30986. }
  30987. public function addRepository(RepositoryInterface $repository): void
  30988. {
  30989. if (
  30990. $repository instanceof LockArrayRepository
  30991. || $repository instanceof InstalledRepositoryInterface
  30992. || $repository instanceof RootPackageRepository
  30993. || $repository instanceof PlatformRepository
  30994. ) {
  30995. parent::addRepository($repository);
  30996. return;
  30997. }
  30998. throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
  30999. }
  31000. }
  31001. <?php declare(strict_types=1);
  31002. namespace Composer\Repository;
  31003. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  31004. {
  31005. public function getDevMode();
  31006. public function isFresh();
  31007. }
  31008. <?php declare(strict_types=1);
  31009. namespace Composer\Repository;
  31010. class InvalidRepositoryException extends \Exception
  31011. {
  31012. }
  31013. <?php declare(strict_types=1);
  31014. namespace Composer\Repository;
  31015. class LockArrayRepository extends ArrayRepository
  31016. {
  31017. use CanonicalPackagesTrait;
  31018. public function getRepoName(): string
  31019. {
  31020. return 'lock repo';
  31021. }
  31022. }
  31023. <?php declare(strict_types=1);
  31024. namespace Composer\Repository;
  31025. use Composer\Package\Loader\ArrayLoader;
  31026. use Composer\Package\Loader\ValidatingArrayLoader;
  31027. use Composer\Pcre\Preg;
  31028. class PackageRepository extends ArrayRepository
  31029. {
  31030. private $config;
  31031. public function __construct(array $config)
  31032. {
  31033. parent::__construct();
  31034. $this->config = $config['package'];
  31035. if (!is_numeric(key($this->config))) {
  31036. $this->config = [$this->config];
  31037. }
  31038. }
  31039. protected function initialize(): void
  31040. {
  31041. parent::initialize();
  31042. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), true);
  31043. foreach ($this->config as $package) {
  31044. try {
  31045. $package = $loader->load($package);
  31046. } catch (\Exception $e) {
  31047. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  31048. }
  31049. $this->addPackage($package);
  31050. }
  31051. }
  31052. public function getRepoName(): string
  31053. {
  31054. return Preg::replace('{^array }', 'package ', parent::getRepoName());
  31055. }
  31056. }
  31057. <?php declare(strict_types=1);
  31058. namespace Composer\Repository;
  31059. use Composer\Config;
  31060. use Composer\EventDispatcher\EventDispatcher;
  31061. use Composer\IO\IOInterface;
  31062. use Composer\Json\JsonFile;
  31063. use Composer\Package\Loader\ArrayLoader;
  31064. use Composer\Package\Version\VersionGuesser;
  31065. use Composer\Package\Version\VersionParser;
  31066. use Composer\Pcre\Preg;
  31067. use Composer\Util\HttpDownloader;
  31068. use Composer\Util\Platform;
  31069. use Composer\Util\ProcessExecutor;
  31070. use Composer\Util\Filesystem;
  31071. use Composer\Util\Url;
  31072. use Composer\Util\Git as GitUtil;
  31073. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  31074. {
  31075. private $loader;
  31076. private $versionGuesser;
  31077. private $url;
  31078. private $repoConfig;
  31079. private $process;
  31080. private $options;
  31081. public function __construct(array $repoConfig, IOInterface $io, Config $config, ?HttpDownloader $httpDownloader = null, ?EventDispatcher $dispatcher = null, ?ProcessExecutor $process = null)
  31082. {
  31083. if (!isset($repoConfig['url'])) {
  31084. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  31085. }
  31086. $this->loader = new ArrayLoader(null, true);
  31087. $this->url = Platform::expandPath($repoConfig['url']);
  31088. $this->process = $process ?? new ProcessExecutor($io);
  31089. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser(), $io);
  31090. $this->repoConfig = $repoConfig;
  31091. $this->options = $repoConfig['options'] ?? [];
  31092. if (!isset($this->options['relative'])) {
  31093. $filesystem = new Filesystem();
  31094. $this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
  31095. }
  31096. parent::__construct();
  31097. }
  31098. public function getRepoName(): string
  31099. {
  31100. return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
  31101. }
  31102. public function getRepoConfig(): array
  31103. {
  31104. return $this->repoConfig;
  31105. }
  31106. protected function initialize(): void
  31107. {
  31108. parent::initialize();
  31109. $urlMatches = $this->getUrlMatches();
  31110. if (empty($urlMatches)) {
  31111. if (Preg::isMatch('{[*{}]}', $this->url)) {
  31112. $url = $this->url;
  31113. while (Preg::isMatch('{[*{}]}', $url)) {
  31114. $url = dirname($url);
  31115. }
  31116. if (is_dir($url)) {
  31117. return;
  31118. }
  31119. }
  31120. throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
  31121. }
  31122. foreach ($urlMatches as $url) {
  31123. $path = realpath($url) . DIRECTORY_SEPARATOR;
  31124. $composerFilePath = $path.'composer.json';
  31125. if (!file_exists($composerFilePath)) {
  31126. continue;
  31127. }
  31128. $json = file_get_contents($composerFilePath);
  31129. $package = JsonFile::parseJson($json, $composerFilePath);
  31130. $package['dist'] = [
  31131. 'type' => 'path',
  31132. 'url' => $url,
  31133. ];
  31134. $reference = $this->options['reference'] ?? 'auto';
  31135. if ('none' === $reference) {
  31136. $package['dist']['reference'] = null;
  31137. } elseif ('config' === $reference || 'auto' === $reference) {
  31138. $package['dist']['reference'] = hash('sha1', $json . serialize($this->options));
  31139. }
  31140. $package['transport-options'] = array_intersect_key($this->options, ['symlink' => true, 'relative' => true]);
  31141. if (isset($package['name'], $this->options['versions'][$package['name']])) {
  31142. $package['version'] = $this->options['versions'][$package['name']];
  31143. }
  31144. if (!isset($package['version']) && ($rootVersion = Platform::getEnv('COMPOSER_ROOT_VERSION'))) {
  31145. if (
  31146. 0 === $this->process->execute(['git', 'rev-parse', 'HEAD'], $ref1, $path)
  31147. && 0 === $this->process->execute(['git', 'rev-parse', 'HEAD'], $ref2)
  31148. && $ref1 === $ref2
  31149. ) {
  31150. $package['version'] = $this->versionGuesser->getRootVersionFromEnv();
  31151. }
  31152. }
  31153. $output = '';
  31154. if ('auto' === $reference && is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute(array_merge(['git', 'log', '-n1', '--pretty=%H'], GitUtil::getNoShowSignatureFlags($this->process)), $output, $path)) {
  31155. $package['dist']['reference'] = trim($output);
  31156. }
  31157. if (!isset($package['version'])) {
  31158. $versionData = $this->versionGuesser->guessVersion($package, $path);
  31159. if (is_array($versionData) && $versionData['pretty_version']) {
  31160. if (!empty($versionData['feature_pretty_version'])) {
  31161. $package['version'] = $versionData['feature_pretty_version'];
  31162. $this->addPackage($this->loader->load($package));
  31163. }
  31164. $package['version'] = $versionData['pretty_version'];
  31165. } else {
  31166. $package['version'] = 'dev-main';
  31167. }
  31168. }
  31169. try {
  31170. $this->addPackage($this->loader->load($package));
  31171. } catch (\Exception $e) {
  31172. throw new \RuntimeException('Failed loading the package in '.$composerFilePath, 0, $e);
  31173. }
  31174. }
  31175. }
  31176. private function getUrlMatches(): array
  31177. {
  31178. $flags = GLOB_MARK | GLOB_ONLYDIR;
  31179. if (defined('GLOB_BRACE')) {
  31180. $flags |= GLOB_BRACE;
  31181. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  31182. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  31183. }
  31184. return array_map(static function ($val): string {
  31185. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  31186. }, glob($this->url, $flags));
  31187. }
  31188. }
  31189. <?php declare(strict_types=1);
  31190. namespace Composer\Repository;
  31191. class PearRepository extends ArrayRepository
  31192. {
  31193. public function __construct()
  31194. {
  31195. throw new \InvalidArgumentException('The PEAR repository has been removed from Composer 2.x');
  31196. }
  31197. }
  31198. <?php declare(strict_types=1);
  31199. namespace Composer\Repository;
  31200. use Composer\Composer;
  31201. use Composer\Package\CompletePackage;
  31202. use Composer\Package\CompletePackageInterface;
  31203. use Composer\Package\Link;
  31204. use Composer\Package\PackageInterface;
  31205. use Composer\Package\Version\VersionParser;
  31206. use Composer\Pcre\Preg;
  31207. use Composer\Platform\HhvmDetector;
  31208. use Composer\Platform\Runtime;
  31209. use Composer\Platform\Version;
  31210. use Composer\Plugin\PluginInterface;
  31211. use Composer\Semver\Constraint\Constraint;
  31212. use Composer\Util\Silencer;
  31213. use Composer\XdebugHandler\XdebugHandler;
  31214. class PlatformRepository extends ArrayRepository
  31215. {
  31216. public const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer(?:-(?:plugin|runtime)-api)?)$}iD';
  31217. private static $lastSeenPlatformPhp = null;
  31218. private $versionParser;
  31219. private $overrides = [];
  31220. private $disabledPackages = [];
  31221. private $runtime;
  31222. private $hhvmDetector;
  31223. public function __construct(array $packages = [], array $overrides = [], ?Runtime $runtime = null, ?HhvmDetector $hhvmDetector = null)
  31224. {
  31225. $this->runtime = $runtime ?: new Runtime();
  31226. $this->hhvmDetector = $hhvmDetector ?: new HhvmDetector();
  31227. foreach ($overrides as $name => $version) {
  31228. if (!is_string($version) && false !== $version) {
  31229. throw new \UnexpectedValueException('config.platform.'.$name.' should be a string or false, but got '.gettype($version).' '.var_export($version, true));
  31230. }
  31231. if ($name === 'php' && $version === false) {
  31232. throw new \UnexpectedValueException('config.platform.'.$name.' cannot be set to false as you cannot disable php entirely.');
  31233. }
  31234. $this->overrides[strtolower($name)] = ['name' => $name, 'version' => $version];
  31235. }
  31236. parent::__construct($packages);
  31237. }
  31238. public function getRepoName(): string
  31239. {
  31240. return 'platform repo';
  31241. }
  31242. public function isPlatformPackageDisabled(string $name): bool
  31243. {
  31244. return isset($this->disabledPackages[$name]);
  31245. }
  31246. public function getDisabledPackages(): array
  31247. {
  31248. return $this->disabledPackages;
  31249. }
  31250. protected function initialize(): void
  31251. {
  31252. parent::initialize();
  31253. $libraries = [];
  31254. $this->versionParser = new VersionParser();
  31255. foreach ($this->overrides as $override) {
  31256. if (!self::isPlatformPackage($override['name'])) {
  31257. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  31258. }
  31259. if ($override['version'] !== false) {
  31260. $this->addOverriddenPackage($override);
  31261. }
  31262. }
  31263. $prettyVersion = Composer::getVersion();
  31264. $version = $this->versionParser->normalize($prettyVersion);
  31265. $composer = new CompletePackage('composer', $version, $prettyVersion);
  31266. $composer->setDescription('Composer package');
  31267. $this->addPackage($composer);
  31268. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  31269. $version = $this->versionParser->normalize($prettyVersion);
  31270. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  31271. $composerPluginApi->setDescription('The Composer Plugin API');
  31272. $this->addPackage($composerPluginApi);
  31273. $prettyVersion = Composer::RUNTIME_API_VERSION;
  31274. $version = $this->versionParser->normalize($prettyVersion);
  31275. $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
  31276. $composerRuntimeApi->setDescription('The Composer Runtime API');
  31277. $this->addPackage($composerRuntimeApi);
  31278. try {
  31279. $prettyVersion = $this->runtime->getConstant('PHP_VERSION');
  31280. $version = $this->versionParser->normalize($prettyVersion);
  31281. } catch (\UnexpectedValueException $e) {
  31282. $prettyVersion = Preg::replace('#^([^~+-]+).*$#', '$1', $this->runtime->getConstant('PHP_VERSION'));
  31283. $version = $this->versionParser->normalize($prettyVersion);
  31284. }
  31285. $php = new CompletePackage('php', $version, $prettyVersion);
  31286. $php->setDescription('The PHP interpreter');
  31287. $this->addPackage($php);
  31288. if ($this->runtime->getConstant('PHP_DEBUG')) {
  31289. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  31290. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  31291. $this->addPackage($phpdebug);
  31292. }
  31293. if ($this->runtime->hasConstant('PHP_ZTS') && $this->runtime->getConstant('PHP_ZTS')) {
  31294. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  31295. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  31296. $this->addPackage($phpzts);
  31297. }
  31298. if ($this->runtime->getConstant('PHP_INT_SIZE') === 8) {
  31299. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  31300. $php64->setDescription('The PHP interpreter, 64bit');
  31301. $this->addPackage($php64);
  31302. }
  31303. if ($this->runtime->hasConstant('AF_INET6') || Silencer::call([$this->runtime, 'invoke'], 'inet_pton', ['::']) !== false) {
  31304. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  31305. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  31306. $this->addPackage($phpIpv6);
  31307. }
  31308. $loadedExtensions = $this->runtime->getExtensions();
  31309. foreach ($loadedExtensions as $name) {
  31310. if (in_array($name, ['standard', 'Core'])) {
  31311. continue;
  31312. }
  31313. $this->addExtension($name, $this->runtime->getExtensionVersion($name));
  31314. }
  31315. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  31316. $this->addExtension('xdebug', $prettyVersion);
  31317. }
  31318. foreach ($loadedExtensions as $name) {
  31319. switch ($name) {
  31320. case 'amqp':
  31321. $info = $this->runtime->getExtensionInfo($name);
  31322. if (Preg::isMatch('/^librabbitmq version => (?<version>.+)$/im', $info, $librabbitmqMatches)) {
  31323. $this->addLibrary($libraries, $name.'-librabbitmq', $librabbitmqMatches['version'], 'AMQP librabbitmq version');
  31324. }
  31325. if (Preg::isMatchStrictGroups('/^AMQP protocol version => (?<version>.+)$/im', $info, $protocolMatches)) {
  31326. $this->addLibrary($libraries, $name.'-protocol', str_replace('-', '.', $protocolMatches['version']), 'AMQP protocol version');
  31327. }
  31328. break;
  31329. case 'bz2':
  31330. $info = $this->runtime->getExtensionInfo($name);
  31331. if (Preg::isMatch('/^BZip2 Version => (?<version>.*),/im', $info, $matches)) {
  31332. $this->addLibrary($libraries, $name, $matches['version']);
  31333. }
  31334. break;
  31335. case 'curl':
  31336. $curlVersion = $this->runtime->invoke('curl_version');
  31337. $this->addLibrary($libraries, $name, $curlVersion['version']);
  31338. $info = $this->runtime->getExtensionInfo($name);
  31339. if (Preg::isMatchStrictGroups('{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im', $info, $sslMatches)) {
  31340. $library = strtolower($sslMatches['library']);
  31341. if ($library === 'openssl') {
  31342. $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
  31343. $this->addLibrary($libraries, $name.'-openssl'.($isFips ? '-fips' : ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', [], $isFips ? ['curl-openssl'] : []);
  31344. } else {
  31345. if ($library === '(securetransport) openssl') {
  31346. $shortlib = 'securetransport';
  31347. } else {
  31348. $shortlib = $library;
  31349. }
  31350. $this->addLibrary($libraries, $name.'-'.$shortlib, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', ['curl-openssl']);
  31351. }
  31352. }
  31353. if (Preg::isMatchStrictGroups('{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im', $info, $sshMatches)) {
  31354. $this->addLibrary($libraries, $name.'-'.strtolower($sshMatches['library']), $sshMatches['version'], 'curl '.$sshMatches['library'].' version');
  31355. }
  31356. if (Preg::isMatchStrictGroups('{^ZLib Version => (?<version>.+)$}im', $info, $zlibMatches)) {
  31357. $this->addLibrary($libraries, $name.'-zlib', $zlibMatches['version'], 'curl zlib version');
  31358. }
  31359. break;
  31360. case 'date':
  31361. $info = $this->runtime->getExtensionInfo($name);
  31362. if (Preg::isMatchStrictGroups('/^timelib version => (?<version>.+)$/im', $info, $timelibMatches)) {
  31363. $this->addLibrary($libraries, $name.'-timelib', $timelibMatches['version'], 'date timelib version');
  31364. }
  31365. if (Preg::isMatchStrictGroups('/^Timezone Database => (?<source>internal|external)$/im', $info, $zoneinfoSourceMatches)) {
  31366. $external = $zoneinfoSourceMatches['source'] === 'external';
  31367. if (Preg::isMatchStrictGroups('/^"Olson" Timezone Database Version => (?<version>.+?)(?:\.system)?$/im', $info, $zoneinfoMatches)) {
  31368. if ($external && in_array('timezonedb', $loadedExtensions, true)) {
  31369. $this->addLibrary($libraries, 'timezonedb-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date (replaced by timezonedb)', [$name.'-zoneinfo']);
  31370. } else {
  31371. $this->addLibrary($libraries, $name.'-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date');
  31372. }
  31373. }
  31374. }
  31375. break;
  31376. case 'fileinfo':
  31377. $info = $this->runtime->getExtensionInfo($name);
  31378. if (Preg::isMatch('/^libmagic => (?<version>.+)$/im', $info, $magicMatches)) {
  31379. $this->addLibrary($libraries, $name.'-libmagic', $magicMatches['version'], 'fileinfo libmagic version');
  31380. }
  31381. break;
  31382. case 'gd':
  31383. $this->addLibrary($libraries, $name, $this->runtime->getConstant('GD_VERSION'));
  31384. $info = $this->runtime->getExtensionInfo($name);
  31385. if (Preg::isMatchStrictGroups('/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im', $info, $libjpegMatches)) {
  31386. $this->addLibrary($libraries, $name.'-libjpeg', Version::parseLibjpeg($libjpegMatches['version']), 'libjpeg version for gd');
  31387. }
  31388. if (Preg::isMatchStrictGroups('/^libPNG Version => (?<version>.+)$/im', $info, $libpngMatches)) {
  31389. $this->addLibrary($libraries, $name.'-libpng', $libpngMatches['version'], 'libpng version for gd');
  31390. }
  31391. if (Preg::isMatchStrictGroups('/^FreeType Version => (?<version>.+)$/im', $info, $freetypeMatches)) {
  31392. $this->addLibrary($libraries, $name.'-freetype', $freetypeMatches['version'], 'freetype version for gd');
  31393. }
  31394. if (Preg::isMatchStrictGroups('/^libXpm Version => (?<versionId>\d+)$/im', $info, $libxpmMatches)) {
  31395. $this->addLibrary($libraries, $name.'-libxpm', Version::convertLibxpmVersionId((int) $libxpmMatches['versionId']), 'libxpm version for gd');
  31396. }
  31397. break;
  31398. case 'gmp':
  31399. $this->addLibrary($libraries, $name, $this->runtime->getConstant('GMP_VERSION'));
  31400. break;
  31401. case 'iconv':
  31402. $this->addLibrary($libraries, $name, $this->runtime->getConstant('ICONV_VERSION'));
  31403. break;
  31404. case 'intl':
  31405. $info = $this->runtime->getExtensionInfo($name);
  31406. $description = 'The ICU unicode and globalization support library';
  31407. if ($this->runtime->hasConstant('INTL_ICU_VERSION')) {
  31408. $this->addLibrary($libraries, 'icu', $this->runtime->getConstant('INTL_ICU_VERSION'), $description);
  31409. } elseif (Preg::isMatch('/^ICU version => (?<version>.+)$/im', $info, $matches)) {
  31410. $this->addLibrary($libraries, 'icu', $matches['version'], $description);
  31411. }
  31412. if (Preg::isMatchStrictGroups('/^ICU TZData version => (?<version>.*)$/im', $info, $zoneinfoMatches) && null !== ($version = Version::parseZoneinfoVersion($zoneinfoMatches['version']))) {
  31413. $this->addLibrary($libraries, 'icu-zoneinfo', $version, 'zoneinfo ("Olson") database for icu');
  31414. }
  31415. if ($this->runtime->hasClass('ResourceBundle')) {
  31416. $resourceBundle = $this->runtime->invoke(['ResourceBundle', 'create'], ['root', 'ICUDATA', false]);
  31417. if ($resourceBundle !== null) {
  31418. $this->addLibrary($libraries, 'icu-cldr', $resourceBundle->get('Version'), 'ICU CLDR project version');
  31419. }
  31420. }
  31421. if ($this->runtime->hasClass('IntlChar')) {
  31422. $this->addLibrary($libraries, 'icu-unicode', implode('.', array_slice($this->runtime->invoke(['IntlChar', 'getUnicodeVersion']), 0, 3)), 'ICU unicode version');
  31423. }
  31424. break;
  31425. case 'imagick':
  31426. $imageMagickVersion = $this->runtime->construct('Imagick')->getVersion();
  31427. if (Preg::isMatch('/^ImageMagick (?<version>[\d.]+)(?:-(?<patch>\d+))?/', $imageMagickVersion['versionString'], $matches)) {
  31428. $version = $matches['version'];
  31429. if (isset($matches['patch'])) {
  31430. $version .= '.'.$matches['patch'];
  31431. }
  31432. $this->addLibrary($libraries, $name.'-imagemagick', $version, null, ['imagick']);
  31433. }
  31434. break;
  31435. case 'ldap':
  31436. $info = $this->runtime->getExtensionInfo($name);
  31437. if (Preg::isMatchStrictGroups('/^Vendor Version => (?<versionId>\d+)$/im', $info, $matches) && Preg::isMatchStrictGroups('/^Vendor Name => (?<vendor>.+)$/im', $info, $vendorMatches)) {
  31438. $this->addLibrary($libraries, $name.'-'.strtolower($vendorMatches['vendor']), Version::convertOpenldapVersionId((int) $matches['versionId']), $vendorMatches['vendor'].' version of ldap');
  31439. }
  31440. break;
  31441. case 'libxml':
  31442. $libxmlProvides = array_map(static function ($extension): string {
  31443. return $extension . '-libxml';
  31444. }, array_intersect($loadedExtensions, ['dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter']));
  31445. $this->addLibrary($libraries, $name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', [], $libxmlProvides);
  31446. break;
  31447. case 'mbstring':
  31448. $info = $this->runtime->getExtensionInfo($name);
  31449. if (Preg::isMatch('/^libmbfl version => (?<version>.+)$/im', $info, $libmbflMatches)) {
  31450. $this->addLibrary($libraries, $name.'-libmbfl', $libmbflMatches['version'], 'mbstring libmbfl version');
  31451. }
  31452. if ($this->runtime->hasConstant('MB_ONIGURUMA_VERSION')) {
  31453. $this->addLibrary($libraries, $name.'-oniguruma', $this->runtime->getConstant('MB_ONIGURUMA_VERSION'), 'mbstring oniguruma version');
  31454. } elseif (Preg::isMatch('/^(?:oniguruma|Multibyte regex \(oniguruma\)) version => (?<version>.+)$/im', $info, $onigurumaMatches)) {
  31455. $this->addLibrary($libraries, $name.'-oniguruma', $onigurumaMatches['version'], 'mbstring oniguruma version');
  31456. }
  31457. break;
  31458. case 'memcached':
  31459. $info = $this->runtime->getExtensionInfo($name);
  31460. if (Preg::isMatch('/^libmemcached version => (?<version>.+)$/im', $info, $matches)) {
  31461. $this->addLibrary($libraries, $name.'-libmemcached', $matches['version'], 'libmemcached version');
  31462. }
  31463. break;
  31464. case 'openssl':
  31465. if (Preg::isMatchStrictGroups('{^(?:OpenSSL|LibreSSL)?\s*(?<version>\S+)}i', $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), $matches)) {
  31466. $parsedVersion = Version::parseOpenssl($matches['version'], $isFips);
  31467. $this->addLibrary($libraries, $name.($isFips ? '-fips' : ''), $parsedVersion, $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), [], $isFips ? [$name] : []);
  31468. }
  31469. break;
  31470. case 'pcre':
  31471. $this->addLibrary($libraries, $name, Preg::replace('{^(\S+).*}', '$1', $this->runtime->getConstant('PCRE_VERSION')));
  31472. $info = $this->runtime->getExtensionInfo($name);
  31473. if (Preg::isMatchStrictGroups('/^PCRE Unicode Version => (?<version>.+)$/im', $info, $pcreUnicodeMatches)) {
  31474. $this->addLibrary($libraries, $name.'-unicode', $pcreUnicodeMatches['version'], 'PCRE Unicode version support');
  31475. }
  31476. break;
  31477. case 'mysqlnd':
  31478. case 'pdo_mysql':
  31479. $info = $this->runtime->getExtensionInfo($name);
  31480. if (Preg::isMatchStrictGroups('/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi', $info, $matches)) {
  31481. $this->addLibrary($libraries, $name.'-mysqlnd', $matches['version'], 'mysqlnd library version for '.$name);
  31482. }
  31483. break;
  31484. case 'mongodb':
  31485. $info = $this->runtime->getExtensionInfo($name);
  31486. if (Preg::isMatchStrictGroups('/^libmongoc bundled version => (?<version>.+)$/im', $info, $libmongocMatches)) {
  31487. $this->addLibrary($libraries, $name.'-libmongoc', $libmongocMatches['version'], 'libmongoc version of mongodb');
  31488. }
  31489. if (Preg::isMatchStrictGroups('/^libbson bundled version => (?<version>.+)$/im', $info, $libbsonMatches)) {
  31490. $this->addLibrary($libraries, $name.'-libbson', $libbsonMatches['version'], 'libbson version of mongodb');
  31491. }
  31492. break;
  31493. case 'pgsql':
  31494. if ($this->runtime->hasConstant('PGSQL_LIBPQ_VERSION')) {
  31495. $this->addLibrary($libraries, 'pgsql-libpq', $this->runtime->getConstant('PGSQL_LIBPQ_VERSION'), 'libpq for pgsql');
  31496. break;
  31497. }
  31498. case 'pdo_pgsql':
  31499. $info = $this->runtime->getExtensionInfo($name);
  31500. if (Preg::isMatch('/^PostgreSQL\(libpq\) Version => (?<version>.*)$/im', $info, $matches)) {
  31501. $this->addLibrary($libraries, $name.'-libpq', $matches['version'], 'libpq for '.$name);
  31502. }
  31503. break;
  31504. case 'pq':
  31505. $info = $this->runtime->getExtensionInfo($name);
  31506. if (Preg::isMatch('/^libpq => (?<compiled>.+) => (?<linked>.+)$/im', $info, $matches)) {
  31507. $this->addLibrary($libraries, $name.'-libpq', $matches['linked'], 'libpq for '.$name);
  31508. }
  31509. break;
  31510. case 'rdkafka':
  31511. if ($this->runtime->hasConstant('RD_KAFKA_VERSION')) {
  31512. $libRdKafkaVersionInt = $this->runtime->getConstant('RD_KAFKA_VERSION');
  31513. $this->addLibrary($libraries, $name.'-librdkafka', sprintf('%d.%d.%d', ($libRdKafkaVersionInt & 0x7F000000) >> 24, ($libRdKafkaVersionInt & 0x00FF0000) >> 16, ($libRdKafkaVersionInt & 0x0000FF00) >> 8), 'librdkafka for '.$name);
  31514. }
  31515. break;
  31516. case 'libsodium':
  31517. case 'sodium':
  31518. if ($this->runtime->hasConstant('SODIUM_LIBRARY_VERSION')) {
  31519. $this->addLibrary($libraries, 'libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  31520. $this->addLibrary($libraries, 'libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  31521. }
  31522. break;
  31523. case 'sqlite3':
  31524. case 'pdo_sqlite':
  31525. $info = $this->runtime->getExtensionInfo($name);
  31526. if (Preg::isMatch('/^SQLite Library => (?<version>.+)$/im', $info, $matches)) {
  31527. $this->addLibrary($libraries, $name.'-sqlite', $matches['version']);
  31528. }
  31529. break;
  31530. case 'ssh2':
  31531. $info = $this->runtime->getExtensionInfo($name);
  31532. if (Preg::isMatch('/^libssh2 version => (?<version>.+)$/im', $info, $matches)) {
  31533. $this->addLibrary($libraries, $name.'-libssh2', $matches['version']);
  31534. }
  31535. break;
  31536. case 'xsl':
  31537. $this->addLibrary($libraries, 'libxslt', $this->runtime->getConstant('LIBXSLT_DOTTED_VERSION'), null, ['xsl']);
  31538. $info = $this->runtime->getExtensionInfo('xsl');
  31539. if (Preg::isMatch('/^libxslt compiled against libxml Version => (?<version>.+)$/im', $info, $matches)) {
  31540. $this->addLibrary($libraries, 'libxslt-libxml', $matches['version'], 'libxml version libxslt is compiled against');
  31541. }
  31542. break;
  31543. case 'yaml':
  31544. $info = $this->runtime->getExtensionInfo('yaml');
  31545. if (Preg::isMatch('/^LibYAML Version => (?<version>.+)$/im', $info, $matches)) {
  31546. $this->addLibrary($libraries, $name.'-libyaml', $matches['version'], 'libyaml version of yaml');
  31547. }
  31548. break;
  31549. case 'zip':
  31550. if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
  31551. $this->addLibrary($libraries, $name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION', 'ZipArchive'), null, ['zip']);
  31552. }
  31553. break;
  31554. case 'zlib':
  31555. if ($this->runtime->hasConstant('ZLIB_VERSION')) {
  31556. $this->addLibrary($libraries, $name, $this->runtime->getConstant('ZLIB_VERSION'));
  31557. } elseif (Preg::isMatch('/^Linked Version => (?<version>.+)$/im', $this->runtime->getExtensionInfo($name), $matches)) {
  31558. $this->addLibrary($libraries, $name, $matches['version']);
  31559. }
  31560. break;
  31561. default:
  31562. break;
  31563. }
  31564. }
  31565. $hhvmVersion = $this->hhvmDetector->getVersion();
  31566. if ($hhvmVersion) {
  31567. try {
  31568. $prettyVersion = $hhvmVersion;
  31569. $version = $this->versionParser->normalize($prettyVersion);
  31570. } catch (\UnexpectedValueException $e) {
  31571. $prettyVersion = Preg::replace('#^([^~+-]+).*$#', '$1', $hhvmVersion);
  31572. $version = $this->versionParser->normalize($prettyVersion);
  31573. }
  31574. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  31575. $hhvm->setDescription('The HHVM Runtime (64bit)');
  31576. $this->addPackage($hhvm);
  31577. }
  31578. }
  31579. public function addPackage(PackageInterface $package): void
  31580. {
  31581. if (!$package instanceof CompletePackage) {
  31582. throw new \UnexpectedValueException('Expected CompletePackage but got '.get_class($package));
  31583. }
  31584. if (isset($this->overrides[$package->getName()])) {
  31585. if ($this->overrides[$package->getName()]['version'] === false) {
  31586. $this->addDisabledPackage($package);
  31587. return;
  31588. }
  31589. $overrider = $this->findPackage($package->getName(), '*');
  31590. if ($package->getVersion() === $overrider->getVersion()) {
  31591. $actualText = 'same as actual';
  31592. } else {
  31593. $actualText = 'actual: '.$package->getPrettyVersion();
  31594. }
  31595. if ($overrider instanceof CompletePackageInterface) {
  31596. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  31597. }
  31598. return;
  31599. }
  31600. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  31601. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  31602. if ($package->getVersion() === $overrider->getVersion()) {
  31603. $actualText = 'same as actual';
  31604. } else {
  31605. $actualText = 'actual: '.$package->getPrettyVersion();
  31606. }
  31607. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  31608. return;
  31609. }
  31610. parent::addPackage($package);
  31611. }
  31612. private function addOverriddenPackage(array $override, ?string $name = null): CompletePackage
  31613. {
  31614. $version = $this->versionParser->normalize($override['version']);
  31615. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  31616. $package->setDescription('Package overridden via config.platform');
  31617. $package->setExtra(['config.platform' => true]);
  31618. parent::addPackage($package);
  31619. if ($package->getName() === 'php') {
  31620. self::$lastSeenPlatformPhp = implode('.', array_slice(explode('.', $package->getVersion()), 0, 3));
  31621. }
  31622. return $package;
  31623. }
  31624. private function addDisabledPackage(CompletePackage $package): void
  31625. {
  31626. $package->setDescription($package->getDescription().'. <warning>Package disabled via config.platform</warning>');
  31627. $package->setExtra(['config.platform' => true]);
  31628. $this->disabledPackages[$package->getName()] = $package;
  31629. }
  31630. private function addExtension(string $name, string $prettyVersion): void
  31631. {
  31632. $extraDescription = null;
  31633. try {
  31634. $version = $this->versionParser->normalize($prettyVersion);
  31635. } catch (\UnexpectedValueException $e) {
  31636. $extraDescription = ' (actual version: '.$prettyVersion.')';
  31637. if (Preg::isMatchStrictGroups('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  31638. $prettyVersion = $match[1];
  31639. } else {
  31640. $prettyVersion = '0';
  31641. }
  31642. $version = $this->versionParser->normalize($prettyVersion);
  31643. }
  31644. $packageName = $this->buildPackageName($name);
  31645. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  31646. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  31647. $ext->setType('php-ext');
  31648. if ($name === 'uuid') {
  31649. $ext->setReplaces([
  31650. 'lib-uuid' => new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion()),
  31651. ]);
  31652. }
  31653. $this->addPackage($ext);
  31654. }
  31655. private function buildPackageName(string $name): string
  31656. {
  31657. return 'ext-' . str_replace(' ', '-', strtolower($name));
  31658. }
  31659. private function addLibrary(array &$libraries, string $name, ?string $prettyVersion, ?string $description = null, array $replaces = [], array $provides = []): void
  31660. {
  31661. if (null === $prettyVersion) {
  31662. return;
  31663. }
  31664. try {
  31665. $version = $this->versionParser->normalize($prettyVersion);
  31666. } catch (\UnexpectedValueException $e) {
  31667. return;
  31668. }
  31669. if (isset($libraries['lib-'.$name])) {
  31670. return;
  31671. }
  31672. $libraries['lib-'.$name] = true;
  31673. if ($description === null) {
  31674. $description = 'The '.$name.' library';
  31675. }
  31676. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  31677. $lib->setDescription($description);
  31678. $replaceLinks = [];
  31679. foreach ($replaces as $replace) {
  31680. $replace = strtolower($replace);
  31681. $replaceLinks[$replace] = new Link('lib-'.$name, 'lib-'.$replace, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
  31682. }
  31683. $provideLinks = [];
  31684. foreach ($provides as $provide) {
  31685. $provide = strtolower($provide);
  31686. $provideLinks[$provide] = new Link('lib-'.$name, 'lib-'.$provide, new Constraint('=', $version), Link::TYPE_PROVIDE, $lib->getPrettyVersion());
  31687. }
  31688. $lib->setReplaces($replaceLinks);
  31689. $lib->setProvides($provideLinks);
  31690. $this->addPackage($lib);
  31691. }
  31692. public static function isPlatformPackage(string $name): bool
  31693. {
  31694. static $cache = [];
  31695. if (isset($cache[$name])) {
  31696. return $cache[$name];
  31697. }
  31698. return $cache[$name] = Preg::isMatch(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name);
  31699. }
  31700. public static function getPlatformPhpVersion(): ?string
  31701. {
  31702. return self::$lastSeenPlatformPhp;
  31703. }
  31704. public function search(string $query, int $mode = 0, ?string $type = null): array
  31705. {
  31706. if ($mode === self::SEARCH_VENDOR) {
  31707. return [];
  31708. }
  31709. return parent::search($query, $mode, $type);
  31710. }
  31711. }
  31712. <?php declare(strict_types=1);
  31713. namespace Composer\Repository;
  31714. use Composer\Factory;
  31715. use Composer\IO\IOInterface;
  31716. use Composer\Config;
  31717. use Composer\EventDispatcher\EventDispatcher;
  31718. use Composer\Pcre\Preg;
  31719. use Composer\Util\HttpDownloader;
  31720. use Composer\Util\ProcessExecutor;
  31721. use Composer\Json\JsonFile;
  31722. class RepositoryFactory
  31723. {
  31724. public static function configFromString(IOInterface $io, Config $config, string $repository, bool $allowFilesystem = false)
  31725. {
  31726. if (0 === strpos($repository, 'http')) {
  31727. $repoConfig = ['type' => 'composer', 'url' => $repository];
  31728. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  31729. $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));
  31730. $data = $json->read();
  31731. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  31732. $repoConfig = ['type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/')];
  31733. } elseif ($allowFilesystem) {
  31734. $repoConfig = ['type' => 'filesystem', 'json' => $json];
  31735. } else {
  31736. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  31737. }
  31738. } elseif (strpos($repository, '{') === 0) {
  31739. $repoConfig = JsonFile::parseJson($repository);
  31740. } else {
  31741. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  31742. }
  31743. return $repoConfig;
  31744. }
  31745. public static function fromString(IOInterface $io, Config $config, string $repository, bool $allowFilesystem = false, ?RepositoryManager $rm = null): RepositoryInterface
  31746. {
  31747. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  31748. return static::createRepo($io, $config, $repoConfig, $rm);
  31749. }
  31750. public static function createRepo(IOInterface $io, Config $config, array $repoConfig, ?RepositoryManager $rm = null): RepositoryInterface
  31751. {
  31752. if (!$rm) {
  31753. @trigger_error('Not passing a repository manager when calling createRepo is deprecated since Composer 2.3.6', E_USER_DEPRECATED);
  31754. $rm = static::manager($io, $config);
  31755. }
  31756. $repos = self::createRepos($rm, [$repoConfig]);
  31757. return reset($repos);
  31758. }
  31759. public static function defaultRepos(?IOInterface $io = null, ?Config $config = null, ?RepositoryManager $rm = null): array
  31760. {
  31761. if (null === $rm) {
  31762. @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);
  31763. }
  31764. if (null === $config) {
  31765. $config = Factory::createConfig($io);
  31766. }
  31767. if (null !== $io) {
  31768. $io->loadConfiguration($config);
  31769. }
  31770. if (null === $rm) {
  31771. if (null === $io) {
  31772. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  31773. }
  31774. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  31775. }
  31776. return self::createRepos($rm, $config->getRepositories());
  31777. }
  31778. public static function manager(IOInterface $io, Config $config, ?HttpDownloader $httpDownloader = null, ?EventDispatcher $eventDispatcher = null, ?ProcessExecutor $process = null): RepositoryManager
  31779. {
  31780. if ($httpDownloader === null) {
  31781. $httpDownloader = Factory::createHttpDownloader($io, $config);
  31782. }
  31783. if ($process === null) {
  31784. $process = new ProcessExecutor($io);
  31785. $process->enableAsync();
  31786. }
  31787. $rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
  31788. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  31789. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  31790. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  31791. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  31792. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  31793. $rm->setRepositoryClass('bitbucket', 'Composer\Repository\VcsRepository');
  31794. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  31795. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  31796. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  31797. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  31798. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  31799. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  31800. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  31801. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  31802. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  31803. return $rm;
  31804. }
  31805. public static function defaultReposWithDefaultManager(IOInterface $io): array
  31806. {
  31807. $manager = RepositoryFactory::manager($io, $config = Factory::createConfig($io));
  31808. $io->loadConfiguration($config);
  31809. return RepositoryFactory::defaultRepos($io, $config, $manager);
  31810. }
  31811. private static function createRepos(RepositoryManager $rm, array $repoConfigs): array
  31812. {
  31813. $repos = [];
  31814. foreach ($repoConfigs as $index => $repo) {
  31815. if (is_string($repo)) {
  31816. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  31817. }
  31818. if (!is_array($repo)) {
  31819. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  31820. }
  31821. if (!isset($repo['type'])) {
  31822. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  31823. }
  31824. $name = self::generateRepositoryName($index, $repo, $repos);
  31825. if ($repo['type'] === 'filesystem') {
  31826. $repos[$name] = new FilesystemRepository($repo['json']);
  31827. } else {
  31828. $repos[$name] = $rm->createRepository($repo['type'], $repo, (string) $index);
  31829. }
  31830. }
  31831. return $repos;
  31832. }
  31833. public static function generateRepositoryName($index, array $repo, array $existingRepos): string
  31834. {
  31835. $name = is_int($index) && isset($repo['url']) ? Preg::replace('{^https?://}i', '', $repo['url']) : (string) $index;
  31836. while (isset($existingRepos[$name])) {
  31837. $name .= '2';
  31838. }
  31839. return $name;
  31840. }
  31841. }
  31842. <?php declare(strict_types=1);
  31843. namespace Composer\Repository;
  31844. use Composer\Package\PackageInterface;
  31845. use Composer\Package\BasePackage;
  31846. use Composer\Semver\Constraint\ConstraintInterface;
  31847. interface RepositoryInterface extends \Countable
  31848. {
  31849. public const SEARCH_FULLTEXT = 0;
  31850. public const SEARCH_NAME = 1;
  31851. public const SEARCH_VENDOR = 2;
  31852. public function hasPackage(PackageInterface $package);
  31853. public function findPackage(string $name, $constraint);
  31854. public function findPackages(string $name, $constraint = null);
  31855. public function getPackages();
  31856. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = []);
  31857. public function search(string $query, int $mode = 0, ?string $type = null);
  31858. public function getProviders(string $packageName);
  31859. public function getRepoName();
  31860. }
  31861. <?php declare(strict_types=1);
  31862. namespace Composer\Repository;
  31863. use Composer\IO\IOInterface;
  31864. use Composer\Config;
  31865. use Composer\EventDispatcher\EventDispatcher;
  31866. use Composer\Package\PackageInterface;
  31867. use Composer\Util\HttpDownloader;
  31868. use Composer\Util\ProcessExecutor;
  31869. class RepositoryManager
  31870. {
  31871. private $localRepository;
  31872. private $repositories = [];
  31873. private $repositoryClasses = [];
  31874. private $io;
  31875. private $config;
  31876. private $httpDownloader;
  31877. private $eventDispatcher;
  31878. private $process;
  31879. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ?EventDispatcher $eventDispatcher = null, ?ProcessExecutor $process = null)
  31880. {
  31881. $this->io = $io;
  31882. $this->config = $config;
  31883. $this->httpDownloader = $httpDownloader;
  31884. $this->eventDispatcher = $eventDispatcher;
  31885. $this->process = $process ?? new ProcessExecutor($io);
  31886. }
  31887. public function findPackage(string $name, $constraint): ?PackageInterface
  31888. {
  31889. foreach ($this->repositories as $repository) {
  31890. if ($package = $repository->findPackage($name, $constraint)) {
  31891. return $package;
  31892. }
  31893. }
  31894. return null;
  31895. }
  31896. public function findPackages(string $name, $constraint): array
  31897. {
  31898. $packages = [];
  31899. foreach ($this->getRepositories() as $repository) {
  31900. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  31901. }
  31902. return $packages;
  31903. }
  31904. public function addRepository(RepositoryInterface $repository): void
  31905. {
  31906. $this->repositories[] = $repository;
  31907. }
  31908. public function prependRepository(RepositoryInterface $repository): void
  31909. {
  31910. array_unshift($this->repositories, $repository);
  31911. }
  31912. public function createRepository(string $type, array $config, ?string $name = null): RepositoryInterface
  31913. {
  31914. if (!isset($this->repositoryClasses[$type])) {
  31915. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  31916. }
  31917. if (isset($config['packagist']) && false === $config['packagist']) {
  31918. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  31919. }
  31920. $class = $this->repositoryClasses[$type];
  31921. if (isset($config['only']) || isset($config['exclude']) || isset($config['canonical'])) {
  31922. $filterConfig = $config;
  31923. unset($config['only'], $config['exclude'], $config['canonical']);
  31924. }
  31925. $repository = new $class($config, $this->io, $this->config, $this->httpDownloader, $this->eventDispatcher, $this->process);
  31926. if (isset($filterConfig)) {
  31927. $repository = new FilterRepository($repository, $filterConfig);
  31928. }
  31929. return $repository;
  31930. }
  31931. public function setRepositoryClass(string $type, $class): void
  31932. {
  31933. $this->repositoryClasses[$type] = $class;
  31934. }
  31935. public function getRepositories(): array
  31936. {
  31937. return $this->repositories;
  31938. }
  31939. public function setLocalRepository(InstalledRepositoryInterface $repository): void
  31940. {
  31941. $this->localRepository = $repository;
  31942. }
  31943. public function getLocalRepository(): InstalledRepositoryInterface
  31944. {
  31945. return $this->localRepository;
  31946. }
  31947. }
  31948. <?php declare(strict_types=1);
  31949. namespace Composer\Repository;
  31950. class RepositorySecurityException extends \Exception
  31951. {
  31952. }
  31953. <?php declare(strict_types=1);
  31954. namespace Composer\Repository;
  31955. use Composer\DependencyResolver\PoolOptimizer;
  31956. use Composer\DependencyResolver\Pool;
  31957. use Composer\DependencyResolver\PoolBuilder;
  31958. use Composer\DependencyResolver\Request;
  31959. use Composer\EventDispatcher\EventDispatcher;
  31960. use Composer\Advisory\SecurityAdvisory;
  31961. use Composer\Advisory\PartialSecurityAdvisory;
  31962. use Composer\IO\IOInterface;
  31963. use Composer\IO\NullIO;
  31964. use Composer\Package\BasePackage;
  31965. use Composer\Package\AliasPackage;
  31966. use Composer\Package\CompleteAliasPackage;
  31967. use Composer\Package\CompletePackage;
  31968. use Composer\Package\PackageInterface;
  31969. use Composer\Semver\Constraint\Constraint;
  31970. use Composer\Semver\Constraint\ConstraintInterface;
  31971. use Composer\Package\Version\StabilityFilter;
  31972. use Composer\Semver\Constraint\MatchAllConstraint;
  31973. use Composer\Semver\Constraint\MultiConstraint;
  31974. class RepositorySet
  31975. {
  31976. public const ALLOW_UNACCEPTABLE_STABILITIES = 1;
  31977. public const ALLOW_SHADOWED_REPOSITORIES = 2;
  31978. private $rootAliases;
  31979. private $rootReferences;
  31980. private $repositories = [];
  31981. private $acceptableStabilities;
  31982. private $stabilityFlags;
  31983. private $rootRequires;
  31984. private $temporaryConstraints;
  31985. private $locked = false;
  31986. private $allowInstalledRepositories = false;
  31987. public function __construct(string $minimumStability = 'stable', array $stabilityFlags = [], array $rootAliases = [], array $rootReferences = [], array $rootRequires = [], array $temporaryConstraints = [])
  31988. {
  31989. $this->rootAliases = self::getRootAliasesPerPackage($rootAliases);
  31990. $this->rootReferences = $rootReferences;
  31991. $this->acceptableStabilities = [];
  31992. foreach (BasePackage::STABILITIES as $stability => $value) {
  31993. if ($value <= BasePackage::STABILITIES[$minimumStability]) {
  31994. $this->acceptableStabilities[$stability] = $value;
  31995. }
  31996. }
  31997. $this->stabilityFlags = $stabilityFlags;
  31998. $this->rootRequires = $rootRequires;
  31999. foreach ($rootRequires as $name => $constraint) {
  32000. if (PlatformRepository::isPlatformPackage($name)) {
  32001. unset($this->rootRequires[$name]);
  32002. }
  32003. }
  32004. $this->temporaryConstraints = $temporaryConstraints;
  32005. }
  32006. public function allowInstalledRepositories(bool $allow = true): void
  32007. {
  32008. $this->allowInstalledRepositories = $allow;
  32009. }
  32010. public function getRootRequires(): array
  32011. {
  32012. return $this->rootRequires;
  32013. }
  32014. public function getTemporaryConstraints(): array
  32015. {
  32016. return $this->temporaryConstraints;
  32017. }
  32018. public function addRepository(RepositoryInterface $repo): void
  32019. {
  32020. if ($this->locked) {
  32021. throw new \RuntimeException("Pool has already been created from this repository set, it cannot be modified anymore.");
  32022. }
  32023. if ($repo instanceof CompositeRepository) {
  32024. $repos = $repo->getRepositories();
  32025. } else {
  32026. $repos = [$repo];
  32027. }
  32028. foreach ($repos as $repo) {
  32029. $this->repositories[] = $repo;
  32030. }
  32031. }
  32032. public function findPackages(string $name, ?ConstraintInterface $constraint = null, int $flags = 0): array
  32033. {
  32034. $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
  32035. $loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
  32036. $packages = [];
  32037. if ($loadFromAllRepos) {
  32038. foreach ($this->repositories as $repository) {
  32039. $packages[] = $repository->findPackages($name, $constraint) ?: [];
  32040. }
  32041. } else {
  32042. foreach ($this->repositories as $repository) {
  32043. $result = $repository->loadPackages([$name => $constraint], $ignoreStability ? BasePackage::STABILITIES : $this->acceptableStabilities, $ignoreStability ? [] : $this->stabilityFlags);
  32044. $packages[] = $result['packages'];
  32045. foreach ($result['namesFound'] as $nameFound) {
  32046. if ($name === $nameFound) {
  32047. break 2;
  32048. }
  32049. }
  32050. }
  32051. }
  32052. $candidates = $packages ? array_merge(...$packages) : [];
  32053. if ($ignoreStability || !$loadFromAllRepos) {
  32054. return $candidates;
  32055. }
  32056. $result = [];
  32057. foreach ($candidates as $candidate) {
  32058. if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
  32059. $result[] = $candidate;
  32060. }
  32061. }
  32062. return $result;
  32063. }
  32064. public function getSecurityAdvisories(array $packageNames, bool $allowPartialAdvisories = false): array
  32065. {
  32066. $map = [];
  32067. foreach ($packageNames as $name) {
  32068. $map[$name] = new MatchAllConstraint();
  32069. }
  32070. return $this->getSecurityAdvisoriesForConstraints($map, $allowPartialAdvisories);
  32071. }
  32072. public function getMatchingSecurityAdvisories(array $packages, bool $allowPartialAdvisories = false): array
  32073. {
  32074. $map = [];
  32075. foreach ($packages as $package) {
  32076. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  32077. continue;
  32078. }
  32079. if (isset($map[$package->getName()])) {
  32080. $map[$package->getName()] = new MultiConstraint([new Constraint('=', $package->getVersion()), $map[$package->getName()]], false);
  32081. } else {
  32082. $map[$package->getName()] = new Constraint('=', $package->getVersion());
  32083. }
  32084. }
  32085. return $this->getSecurityAdvisoriesForConstraints($map, $allowPartialAdvisories);
  32086. }
  32087. private function getSecurityAdvisoriesForConstraints(array $packageConstraintMap, bool $allowPartialAdvisories): array
  32088. {
  32089. $repoAdvisories = [];
  32090. foreach ($this->repositories as $repository) {
  32091. if (!$repository instanceof AdvisoryProviderInterface || !$repository->hasSecurityAdvisories()) {
  32092. continue;
  32093. }
  32094. $repoAdvisories[] = $repository->getSecurityAdvisories($packageConstraintMap, $allowPartialAdvisories)['advisories'];
  32095. }
  32096. $advisories = array_merge_recursive([], ...$repoAdvisories);
  32097. ksort($advisories);
  32098. return $advisories;
  32099. }
  32100. public function getProviders(string $packageName): array
  32101. {
  32102. $providers = [];
  32103. foreach ($this->repositories as $repository) {
  32104. if ($repoProviders = $repository->getProviders($packageName)) {
  32105. $providers = array_merge($providers, $repoProviders);
  32106. }
  32107. }
  32108. return $providers;
  32109. }
  32110. public function isPackageAcceptable(array $names, string $stability): bool
  32111. {
  32112. return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
  32113. }
  32114. public function createPool(Request $request, IOInterface $io, ?EventDispatcher $eventDispatcher = null, ?PoolOptimizer $poolOptimizer = null, array $ignoredTypes = [], ?array $allowedTypes = null): Pool
  32115. {
  32116. $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher, $poolOptimizer, $this->temporaryConstraints);
  32117. $poolBuilder->setIgnoredTypes($ignoredTypes);
  32118. $poolBuilder->setAllowedTypes($allowedTypes);
  32119. foreach ($this->repositories as $repo) {
  32120. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  32121. throw new \LogicException('The pool can not accept packages from an installed repository');
  32122. }
  32123. }
  32124. $this->locked = true;
  32125. return $poolBuilder->buildPool($this->repositories, $request);
  32126. }
  32127. public function createPoolWithAllPackages(): Pool
  32128. {
  32129. foreach ($this->repositories as $repo) {
  32130. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  32131. throw new \LogicException('The pool can not accept packages from an installed repository');
  32132. }
  32133. }
  32134. $this->locked = true;
  32135. $packages = [];
  32136. foreach ($this->repositories as $repository) {
  32137. foreach ($repository->getPackages() as $package) {
  32138. $packages[] = $package;
  32139. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  32140. $alias = $this->rootAliases[$package->getName()][$package->getVersion()];
  32141. while ($package instanceof AliasPackage) {
  32142. $package = $package->getAliasOf();
  32143. }
  32144. if ($package instanceof CompletePackage) {
  32145. $aliasPackage = new CompleteAliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  32146. } else {
  32147. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  32148. }
  32149. $aliasPackage->setRootPackageAlias(true);
  32150. $packages[] = $aliasPackage;
  32151. }
  32152. }
  32153. }
  32154. return new Pool($packages);
  32155. }
  32156. public function createPoolForPackage(string $packageName, ?LockArrayRepository $lockedRepo = null): Pool
  32157. {
  32158. return $this->createPoolForPackages([$packageName], $lockedRepo);
  32159. }
  32160. public function createPoolForPackages(array $packageNames, ?LockArrayRepository $lockedRepo = null): Pool
  32161. {
  32162. $request = new Request($lockedRepo);
  32163. $allowedPackages = [];
  32164. foreach ($packageNames as $packageName) {
  32165. if (PlatformRepository::isPlatformPackage($packageName)) {
  32166. 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.');
  32167. }
  32168. $request->requireName($packageName);
  32169. $allowedPackages[] = strtolower($packageName);
  32170. }
  32171. if (count($allowedPackages) > 0) {
  32172. $request->restrictPackages($allowedPackages);
  32173. }
  32174. return $this->createPool($request, new NullIO());
  32175. }
  32176. private static function getRootAliasesPerPackage(array $aliases): array
  32177. {
  32178. $normalizedAliases = [];
  32179. foreach ($aliases as $alias) {
  32180. $normalizedAliases[$alias['package']][$alias['version']] = [
  32181. 'alias' => $alias['alias'],
  32182. 'alias_normalized' => $alias['alias_normalized'],
  32183. ];
  32184. }
  32185. return $normalizedAliases;
  32186. }
  32187. }
  32188. <?php declare(strict_types=1);
  32189. namespace Composer\Repository;
  32190. use Composer\Package\PackageInterface;
  32191. class RepositoryUtils
  32192. {
  32193. public static function filterRequiredPackages(array $packages, PackageInterface $requirer, bool $includeRequireDev = false, array $bucket = []): array
  32194. {
  32195. $requires = $requirer->getRequires();
  32196. if ($includeRequireDev) {
  32197. $requires = array_merge($requires, $requirer->getDevRequires());
  32198. }
  32199. foreach ($packages as $candidate) {
  32200. foreach ($candidate->getNames() as $name) {
  32201. if (isset($requires[$name])) {
  32202. if (!in_array($candidate, $bucket, true)) {
  32203. $bucket[] = $candidate;
  32204. $bucket = self::filterRequiredPackages($packages, $candidate, false, $bucket);
  32205. }
  32206. break;
  32207. }
  32208. }
  32209. }
  32210. return $bucket;
  32211. }
  32212. public static function flattenRepositories(RepositoryInterface $repo, bool $unwrapFilterRepos = true): array
  32213. {
  32214. if ($unwrapFilterRepos && $repo instanceof FilterRepository) {
  32215. $repo = $repo->getRepository();
  32216. }
  32217. if (!$repo instanceof CompositeRepository) {
  32218. return [$repo];
  32219. }
  32220. $repos = [];
  32221. foreach ($repo->getRepositories() as $r) {
  32222. foreach (self::flattenRepositories($r, $unwrapFilterRepos) as $r2) {
  32223. $repos[] = $r2;
  32224. }
  32225. }
  32226. return $repos;
  32227. }
  32228. }
  32229. <?php declare(strict_types=1);
  32230. namespace Composer\Repository;
  32231. use Composer\Package\RootPackageInterface;
  32232. class RootPackageRepository extends ArrayRepository
  32233. {
  32234. public function __construct(RootPackageInterface $package)
  32235. {
  32236. parent::__construct([$package]);
  32237. }
  32238. public function getRepoName(): string
  32239. {
  32240. return 'root package repo';
  32241. }
  32242. }
  32243. <?php declare(strict_types=1);
  32244. namespace Composer\Repository\Vcs;
  32245. use Composer\Cache;
  32246. use Composer\Config;
  32247. use Composer\Pcre\Preg;
  32248. use Composer\Util\ProcessExecutor;
  32249. use Composer\Util\Filesystem;
  32250. use Composer\IO\IOInterface;
  32251. class FossilDriver extends VcsDriver
  32252. {
  32253. protected $tags;
  32254. protected $branches;
  32255. protected $rootIdentifier = null;
  32256. protected $repoFile = null;
  32257. protected $checkoutDir;
  32258. public function initialize(): void
  32259. {
  32260. $this->checkFossil();
  32261. $this->config->prohibitUrlByConfig($this->url, $this->io);
  32262. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  32263. $this->checkoutDir = $this->url;
  32264. } else {
  32265. if (!Cache::isUsable($this->config->get('cache-repo-dir')) || !Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  32266. throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
  32267. }
  32268. $localName = Preg::replace('{[^a-z0-9]}i', '-', $this->url);
  32269. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  32270. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  32271. $this->updateLocalRepo();
  32272. }
  32273. $this->getTags();
  32274. $this->getBranches();
  32275. }
  32276. protected function checkFossil(): void
  32277. {
  32278. if (0 !== $this->process->execute(['fossil', 'version'], $ignoredOutput)) {
  32279. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  32280. }
  32281. }
  32282. protected function updateLocalRepo(): void
  32283. {
  32284. assert($this->repoFile !== null);
  32285. $fs = new Filesystem();
  32286. $fs->ensureDirectoryExists($this->checkoutDir);
  32287. if (!is_writable(dirname($this->checkoutDir))) {
  32288. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  32289. }
  32290. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute(['fossil', 'info'], $output, $this->checkoutDir)) {
  32291. if (0 !== $this->process->execute(['fossil', 'pull'], $output, $this->checkoutDir)) {
  32292. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  32293. }
  32294. } else {
  32295. $fs->removeDirectory($this->checkoutDir);
  32296. $fs->remove($this->repoFile);
  32297. $fs->ensureDirectoryExists($this->checkoutDir);
  32298. if (0 !== $this->process->execute(['fossil', 'clone', '--', $this->url, $this->repoFile], $output)) {
  32299. $output = $this->process->getErrorOutput();
  32300. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  32301. }
  32302. if (0 !== $this->process->execute(['fossil', 'open', '--nested', '--', $this->repoFile], $output, $this->checkoutDir)) {
  32303. $output = $this->process->getErrorOutput();
  32304. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  32305. }
  32306. }
  32307. }
  32308. public function getRootIdentifier(): string
  32309. {
  32310. if (null === $this->rootIdentifier) {
  32311. $this->rootIdentifier = 'trunk';
  32312. }
  32313. return $this->rootIdentifier;
  32314. }
  32315. public function getUrl(): string
  32316. {
  32317. return $this->url;
  32318. }
  32319. public function getSource(string $identifier): array
  32320. {
  32321. return ['type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier];
  32322. }
  32323. public function getDist(string $identifier): ?array
  32324. {
  32325. return null;
  32326. }
  32327. public function getFileContent(string $file, string $identifier): ?string
  32328. {
  32329. $this->process->execute(['fossil', 'cat', '-r', $identifier, '--', $file], $content, $this->checkoutDir);
  32330. if ('' === trim($content)) {
  32331. return null;
  32332. }
  32333. return $content;
  32334. }
  32335. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  32336. {
  32337. $this->process->execute(['fossil', 'finfo', '-b', '-n', '1', 'composer.json'], $output, $this->checkoutDir);
  32338. [, $date] = explode(' ', trim($output), 3);
  32339. return new \DateTimeImmutable($date, new \DateTimeZone('UTC'));
  32340. }
  32341. public function getTags(): array
  32342. {
  32343. if (null === $this->tags) {
  32344. $tags = [];
  32345. $this->process->execute(['fossil', 'tag', 'list'], $output, $this->checkoutDir);
  32346. foreach ($this->process->splitLines($output) as $tag) {
  32347. $tags[$tag] = $tag;
  32348. }
  32349. $this->tags = $tags;
  32350. }
  32351. return $this->tags;
  32352. }
  32353. public function getBranches(): array
  32354. {
  32355. if (null === $this->branches) {
  32356. $branches = [];
  32357. $this->process->execute(['fossil', 'branch', 'list'], $output, $this->checkoutDir);
  32358. foreach ($this->process->splitLines($output) as $branch) {
  32359. $branch = trim(Preg::replace('/^\*/', '', trim($branch)));
  32360. $branches[$branch] = $branch;
  32361. }
  32362. $this->branches = $branches;
  32363. }
  32364. return $this->branches;
  32365. }
  32366. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  32367. {
  32368. if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  32369. return true;
  32370. }
  32371. if (Preg::isMatch('!/fossil/|\.fossil!', $url)) {
  32372. return true;
  32373. }
  32374. if (Filesystem::isLocalPath($url)) {
  32375. $url = Filesystem::getPlatformPath($url);
  32376. if (!is_dir($url)) {
  32377. return false;
  32378. }
  32379. $process = new ProcessExecutor($io);
  32380. if ($process->execute(['fossil', 'info'], $output, $url) === 0) {
  32381. return true;
  32382. }
  32383. }
  32384. return false;
  32385. }
  32386. }
  32387. <?php declare(strict_types=1);
  32388. namespace Composer\Repository\Vcs;
  32389. use Composer\Config;
  32390. use Composer\IO\IOInterface;
  32391. use Composer\Cache;
  32392. use Composer\Downloader\TransportException;
  32393. use Composer\Json\JsonFile;
  32394. use Composer\Pcre\Preg;
  32395. use Composer\Util\Bitbucket;
  32396. use Composer\Util\Http\Response;
  32397. class GitBitbucketDriver extends VcsDriver
  32398. {
  32399. protected $owner;
  32400. protected $repository;
  32401. private $hasIssues = false;
  32402. private $rootIdentifier;
  32403. private $tags;
  32404. private $branches;
  32405. private $branchesUrl = '';
  32406. private $tagsUrl = '';
  32407. private $homeUrl = '';
  32408. private $website = '';
  32409. private $cloneHttpsUrl = '';
  32410. private $repoData;
  32411. protected $fallbackDriver = null;
  32412. private $vcsType;
  32413. public function initialize(): void
  32414. {
  32415. if (!Preg::isMatchStrictGroups('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(?:\.git|/?)?$#i', $this->url, $match)) {
  32416. throw new \InvalidArgumentException(sprintf('The Bitbucket repository URL %s is invalid. It must be the HTTPS URL of a Bitbucket repository.', $this->url));
  32417. }
  32418. $this->owner = $match[1];
  32419. $this->repository = $match[2];
  32420. $this->originUrl = 'bitbucket.org';
  32421. $this->cache = new Cache(
  32422. $this->io,
  32423. implode('/', [
  32424. $this->config->get('cache-repo-dir'),
  32425. $this->originUrl,
  32426. $this->owner,
  32427. $this->repository,
  32428. ])
  32429. );
  32430. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  32431. }
  32432. public function getUrl(): string
  32433. {
  32434. if ($this->fallbackDriver) {
  32435. return $this->fallbackDriver->getUrl();
  32436. }
  32437. return $this->cloneHttpsUrl;
  32438. }
  32439. protected function getRepoData(): bool
  32440. {
  32441. $resource = sprintf(
  32442. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  32443. $this->owner,
  32444. $this->repository,
  32445. http_build_query(
  32446. ['fields' => '-project,-owner'],
  32447. '',
  32448. '&'
  32449. )
  32450. );
  32451. $repoData = $this->fetchWithOAuthCredentials($resource, true)->decodeJson();
  32452. if ($this->fallbackDriver) {
  32453. return false;
  32454. }
  32455. $this->parseCloneUrls($repoData['links']['clone']);
  32456. $this->hasIssues = !empty($repoData['has_issues']);
  32457. $this->branchesUrl = $repoData['links']['branches']['href'];
  32458. $this->tagsUrl = $repoData['links']['tags']['href'];
  32459. $this->homeUrl = $repoData['links']['html']['href'];
  32460. $this->website = $repoData['website'];
  32461. $this->vcsType = $repoData['scm'];
  32462. $this->repoData = $repoData;
  32463. return true;
  32464. }
  32465. public function getComposerInformation(string $identifier): ?array
  32466. {
  32467. if ($this->fallbackDriver) {
  32468. return $this->fallbackDriver->getComposerInformation($identifier);
  32469. }
  32470. if (!isset($this->infoCache[$identifier])) {
  32471. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  32472. $composer = JsonFile::parseJson($res);
  32473. } else {
  32474. $composer = $this->getBaseComposerInformation($identifier);
  32475. if ($this->shouldCache($identifier)) {
  32476. $this->cache->write($identifier, json_encode($composer));
  32477. }
  32478. }
  32479. if ($composer !== null) {
  32480. if (isset($composer['support']) && !is_array($composer['support'])) {
  32481. $composer['support'] = [];
  32482. }
  32483. if (!isset($composer['support']['source'])) {
  32484. $label = array_search(
  32485. $identifier,
  32486. $this->getTags()
  32487. ) ?: array_search(
  32488. $identifier,
  32489. $this->getBranches()
  32490. ) ?: $identifier;
  32491. if (array_key_exists($label, $tags = $this->getTags())) {
  32492. $hash = $tags[$label];
  32493. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  32494. $hash = $branches[$label];
  32495. }
  32496. if (!isset($hash)) {
  32497. $composer['support']['source'] = sprintf(
  32498. 'https://%s/%s/%s/src',
  32499. $this->originUrl,
  32500. $this->owner,
  32501. $this->repository
  32502. );
  32503. } else {
  32504. $composer['support']['source'] = sprintf(
  32505. 'https://%s/%s/%s/src/%s/?at=%s',
  32506. $this->originUrl,
  32507. $this->owner,
  32508. $this->repository,
  32509. $hash,
  32510. $label
  32511. );
  32512. }
  32513. }
  32514. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  32515. $composer['support']['issues'] = sprintf(
  32516. 'https://%s/%s/%s/issues',
  32517. $this->originUrl,
  32518. $this->owner,
  32519. $this->repository
  32520. );
  32521. }
  32522. if (!isset($composer['homepage'])) {
  32523. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  32524. }
  32525. }
  32526. $this->infoCache[$identifier] = $composer;
  32527. }
  32528. return $this->infoCache[$identifier];
  32529. }
  32530. public function getFileContent(string $file, string $identifier): ?string
  32531. {
  32532. if ($this->fallbackDriver) {
  32533. return $this->fallbackDriver->getFileContent($file, $identifier);
  32534. }
  32535. if (strpos($identifier, '/') !== false) {
  32536. $branches = $this->getBranches();
  32537. if (isset($branches[$identifier])) {
  32538. $identifier = $branches[$identifier];
  32539. }
  32540. }
  32541. $resource = sprintf(
  32542. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  32543. $this->owner,
  32544. $this->repository,
  32545. $identifier,
  32546. $file
  32547. );
  32548. return $this->fetchWithOAuthCredentials($resource)->getBody();
  32549. }
  32550. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  32551. {
  32552. if ($this->fallbackDriver) {
  32553. return $this->fallbackDriver->getChangeDate($identifier);
  32554. }
  32555. if (strpos($identifier, '/') !== false) {
  32556. $branches = $this->getBranches();
  32557. if (isset($branches[$identifier])) {
  32558. $identifier = $branches[$identifier];
  32559. }
  32560. }
  32561. $resource = sprintf(
  32562. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  32563. $this->owner,
  32564. $this->repository,
  32565. $identifier
  32566. );
  32567. $commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  32568. return new \DateTimeImmutable($commit['date']);
  32569. }
  32570. public function getSource(string $identifier): array
  32571. {
  32572. if ($this->fallbackDriver) {
  32573. return $this->fallbackDriver->getSource($identifier);
  32574. }
  32575. return ['type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier];
  32576. }
  32577. public function getDist(string $identifier): ?array
  32578. {
  32579. if ($this->fallbackDriver) {
  32580. return $this->fallbackDriver->getDist($identifier);
  32581. }
  32582. $url = sprintf(
  32583. 'https://bitbucket.org/%s/%s/get/%s.zip',
  32584. $this->owner,
  32585. $this->repository,
  32586. $identifier
  32587. );
  32588. return ['type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => ''];
  32589. }
  32590. public function getTags(): array
  32591. {
  32592. if ($this->fallbackDriver) {
  32593. return $this->fallbackDriver->getTags();
  32594. }
  32595. if (null === $this->tags) {
  32596. $tags = [];
  32597. $resource = sprintf(
  32598. '%s?%s',
  32599. $this->tagsUrl,
  32600. http_build_query(
  32601. [
  32602. 'pagelen' => 100,
  32603. 'fields' => 'values.name,values.target.hash,next',
  32604. 'sort' => '-target.date',
  32605. ],
  32606. '',
  32607. '&'
  32608. )
  32609. );
  32610. $hasNext = true;
  32611. while ($hasNext) {
  32612. $tagsData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  32613. foreach ($tagsData['values'] as $data) {
  32614. $tags[$data['name']] = $data['target']['hash'];
  32615. }
  32616. if (empty($tagsData['next'])) {
  32617. $hasNext = false;
  32618. } else {
  32619. $resource = $tagsData['next'];
  32620. }
  32621. }
  32622. $this->tags = $tags;
  32623. }
  32624. return $this->tags;
  32625. }
  32626. public function getBranches(): array
  32627. {
  32628. if ($this->fallbackDriver) {
  32629. return $this->fallbackDriver->getBranches();
  32630. }
  32631. if (null === $this->branches) {
  32632. $branches = [];
  32633. $resource = sprintf(
  32634. '%s?%s',
  32635. $this->branchesUrl,
  32636. http_build_query(
  32637. [
  32638. 'pagelen' => 100,
  32639. 'fields' => 'values.name,values.target.hash,values.heads,next',
  32640. 'sort' => '-target.date',
  32641. ],
  32642. '',
  32643. '&'
  32644. )
  32645. );
  32646. $hasNext = true;
  32647. while ($hasNext) {
  32648. $branchData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  32649. foreach ($branchData['values'] as $data) {
  32650. $branches[$data['name']] = $data['target']['hash'];
  32651. }
  32652. if (empty($branchData['next'])) {
  32653. $hasNext = false;
  32654. } else {
  32655. $resource = $branchData['next'];
  32656. }
  32657. }
  32658. $this->branches = $branches;
  32659. }
  32660. return $this->branches;
  32661. }
  32662. protected function fetchWithOAuthCredentials(string $url, bool $fetchingRepoData = false): Response
  32663. {
  32664. try {
  32665. return parent::getContents($url);
  32666. } catch (TransportException $e) {
  32667. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  32668. if (in_array($e->getCode(), [403, 404], true) || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  32669. if (!$this->io->hasAuthentication($this->originUrl)
  32670. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  32671. ) {
  32672. return parent::getContents($url);
  32673. }
  32674. if (!$this->io->isInteractive() && $fetchingRepoData) {
  32675. $this->attemptCloneFallback();
  32676. return new Response(['url' => 'dummy'], 200, [], 'null');
  32677. }
  32678. }
  32679. throw $e;
  32680. }
  32681. }
  32682. protected function generateSshUrl(): string
  32683. {
  32684. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  32685. }
  32686. protected function attemptCloneFallback(): bool
  32687. {
  32688. try {
  32689. $this->setupFallbackDriver($this->generateSshUrl());
  32690. return true;
  32691. } catch (\RuntimeException $e) {
  32692. $this->fallbackDriver = null;
  32693. $this->io->writeError(
  32694. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  32695. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  32696. );
  32697. throw $e;
  32698. }
  32699. }
  32700. protected function setupFallbackDriver(string $url): void
  32701. {
  32702. $this->fallbackDriver = new GitDriver(
  32703. ['url' => $url],
  32704. $this->io,
  32705. $this->config,
  32706. $this->httpDownloader,
  32707. $this->process
  32708. );
  32709. $this->fallbackDriver->initialize();
  32710. }
  32711. protected function parseCloneUrls(array $cloneLinks): void
  32712. {
  32713. foreach ($cloneLinks as $cloneLink) {
  32714. if ($cloneLink['name'] === 'https') {
  32715. $this->cloneHttpsUrl = Preg::replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  32716. }
  32717. }
  32718. }
  32719. public function getRootIdentifier(): string
  32720. {
  32721. if ($this->fallbackDriver) {
  32722. return $this->fallbackDriver->getRootIdentifier();
  32723. }
  32724. if (null === $this->rootIdentifier) {
  32725. if (!$this->getRepoData()) {
  32726. if (!$this->fallbackDriver) {
  32727. throw new \LogicException('A fallback driver should be setup if getRepoData returns false');
  32728. }
  32729. return $this->fallbackDriver->getRootIdentifier();
  32730. }
  32731. if ($this->vcsType !== 'git') {
  32732. throw new \RuntimeException(
  32733. $this->url.' does not appear to be a git repository, use '.
  32734. $this->cloneHttpsUrl.' but remember that Bitbucket no longer supports the mercurial repositories. '.
  32735. 'https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket'
  32736. );
  32737. }
  32738. $this->rootIdentifier = $this->repoData['mainbranch']['name'] ?? 'master';
  32739. }
  32740. return $this->rootIdentifier;
  32741. }
  32742. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  32743. {
  32744. if (!Preg::isMatch('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)?$#i', $url)) {
  32745. return false;
  32746. }
  32747. if (!extension_loaded('openssl')) {
  32748. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  32749. return false;
  32750. }
  32751. return true;
  32752. }
  32753. }
  32754. <?php declare(strict_types=1);
  32755. namespace Composer\Repository\Vcs;
  32756. use Composer\Pcre\Preg;
  32757. use Composer\Util\ProcessExecutor;
  32758. use Composer\Util\Filesystem;
  32759. use Composer\Util\Url;
  32760. use Composer\Util\Git as GitUtil;
  32761. use Composer\IO\IOInterface;
  32762. use Composer\Cache;
  32763. use Composer\Config;
  32764. class GitDriver extends VcsDriver
  32765. {
  32766. protected $tags;
  32767. protected $branches;
  32768. protected $rootIdentifier;
  32769. protected $repoDir;
  32770. public function initialize(): void
  32771. {
  32772. if (Filesystem::isLocalPath($this->url)) {
  32773. $this->url = Preg::replace('{[\\/]\.git/?$}', '', $this->url);
  32774. if (!is_dir($this->url)) {
  32775. throw new \RuntimeException('Failed to read package information from '.$this->url.' as the path does not exist');
  32776. }
  32777. $this->repoDir = $this->url;
  32778. $cacheUrl = realpath($this->url);
  32779. } else {
  32780. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  32781. throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
  32782. }
  32783. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)) . '/';
  32784. GitUtil::cleanEnv();
  32785. $fs = new Filesystem();
  32786. $fs->ensureDirectoryExists(dirname($this->repoDir));
  32787. if (!is_writable(dirname($this->repoDir))) {
  32788. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  32789. }
  32790. if (Preg::isMatch('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  32791. 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.');
  32792. }
  32793. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  32794. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  32795. if (!is_dir($this->repoDir)) {
  32796. throw new \RuntimeException('Failed to clone '.$this->url.' to read package information from it');
  32797. }
  32798. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  32799. }
  32800. $cacheUrl = $this->url;
  32801. }
  32802. $this->getTags();
  32803. $this->getBranches();
  32804. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($cacheUrl)));
  32805. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  32806. }
  32807. public function getRootIdentifier(): string
  32808. {
  32809. if (null === $this->rootIdentifier) {
  32810. $this->rootIdentifier = 'master';
  32811. $gitUtil = new GitUtil($this->io, $this->config, $this->process, new Filesystem());
  32812. if (!Filesystem::isLocalPath($this->url)) {
  32813. $defaultBranch = $gitUtil->getMirrorDefaultBranch($this->url, $this->repoDir, false);
  32814. if ($defaultBranch !== null) {
  32815. return $this->rootIdentifier = $defaultBranch;
  32816. }
  32817. }
  32818. $this->process->execute(['git', 'branch', '--no-color'], $output, $this->repoDir);
  32819. $branches = $this->process->splitLines($output);
  32820. if (!in_array('* master', $branches)) {
  32821. foreach ($branches as $branch) {
  32822. if ($branch && Preg::isMatchStrictGroups('{^\* +(\S+)}', $branch, $match)) {
  32823. $this->rootIdentifier = $match[1];
  32824. break;
  32825. }
  32826. }
  32827. }
  32828. }
  32829. return $this->rootIdentifier;
  32830. }
  32831. public function getUrl(): string
  32832. {
  32833. return $this->url;
  32834. }
  32835. public function getSource(string $identifier): array
  32836. {
  32837. return ['type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier];
  32838. }
  32839. public function getDist(string $identifier): ?array
  32840. {
  32841. return null;
  32842. }
  32843. public function getFileContent(string $file, string $identifier): ?string
  32844. {
  32845. if (isset($identifier[0]) && $identifier[0] === '-') {
  32846. throw new \RuntimeException('Invalid git identifier detected. Identifier must not start with a -, given: ' . $identifier);
  32847. }
  32848. $this->process->execute(['git', 'show', $identifier.':'.$file], $content, $this->repoDir);
  32849. if (trim($content) === '') {
  32850. return null;
  32851. }
  32852. return $content;
  32853. }
  32854. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  32855. {
  32856. $this->process->execute(['git', '-c', 'log.showSignature=false', 'log', '-1', '--format=%at', $identifier], $output, $this->repoDir);
  32857. return new \DateTimeImmutable('@'.trim($output), new \DateTimeZone('UTC'));
  32858. }
  32859. public function getTags(): array
  32860. {
  32861. if (null === $this->tags) {
  32862. $this->tags = [];
  32863. $this->process->execute(['git', 'show-ref', '--tags', '--dereference'], $output, $this->repoDir);
  32864. foreach ($this->process->splitLines($output) as $tag) {
  32865. if ($tag !== '' && Preg::isMatch('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  32866. $this->tags[$match[2]] = $match[1];
  32867. }
  32868. }
  32869. }
  32870. return $this->tags;
  32871. }
  32872. public function getBranches(): array
  32873. {
  32874. if (null === $this->branches) {
  32875. $branches = [];
  32876. $this->process->execute(['git', 'branch', '--no-color', '--no-abbrev', '-v'], $output, $this->repoDir);
  32877. foreach ($this->process->splitLines($output) as $branch) {
  32878. if ($branch !== '' && !Preg::isMatch('{^ *[^/]+/HEAD }', $branch)) {
  32879. if (Preg::isMatchStrictGroups('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match) && $match[1][0] !== '-') {
  32880. $branches[$match[1]] = $match[2];
  32881. }
  32882. }
  32883. }
  32884. $this->branches = $branches;
  32885. }
  32886. return $this->branches;
  32887. }
  32888. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  32889. {
  32890. if (Preg::isMatch('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  32891. return true;
  32892. }
  32893. if (Filesystem::isLocalPath($url)) {
  32894. $url = Filesystem::getPlatformPath($url);
  32895. if (!is_dir($url)) {
  32896. return false;
  32897. }
  32898. $process = new ProcessExecutor($io);
  32899. if ($process->execute(['git', 'tag'], $output, $url) === 0) {
  32900. return true;
  32901. }
  32902. GitUtil::checkForRepoOwnershipError($process->getErrorOutput(), $url);
  32903. }
  32904. if (!$deep) {
  32905. return false;
  32906. }
  32907. $gitUtil = new GitUtil($io, $config, new ProcessExecutor($io), new Filesystem());
  32908. GitUtil::cleanEnv();
  32909. try {
  32910. $gitUtil->runCommands([['git', 'ls-remote', '--heads', '--', '%url%']], $url, sys_get_temp_dir());
  32911. } catch (\RuntimeException $e) {
  32912. return false;
  32913. }
  32914. return true;
  32915. }
  32916. }
  32917. <?php declare(strict_types=1);
  32918. namespace Composer\Repository\Vcs;
  32919. use Composer\Config;
  32920. use Composer\Downloader\TransportException;
  32921. use Composer\Json\JsonFile;
  32922. use Composer\Cache;
  32923. use Composer\IO\IOInterface;
  32924. use Composer\Pcre\Preg;
  32925. use Composer\Util\GitHub;
  32926. use Composer\Util\Http\Response;
  32927. class GitHubDriver extends VcsDriver
  32928. {
  32929. protected $owner;
  32930. protected $repository;
  32931. protected $tags;
  32932. protected $branches;
  32933. protected $rootIdentifier;
  32934. protected $repoData;
  32935. protected $hasIssues = false;
  32936. protected $isPrivate = false;
  32937. private $isArchived = false;
  32938. private $fundingInfo;
  32939. protected $gitDriver = null;
  32940. public function initialize(): void
  32941. {
  32942. if (!Preg::isMatch('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#', $this->url, $match)) {
  32943. throw new \InvalidArgumentException(sprintf('The GitHub repository URL %s is invalid.', $this->url));
  32944. }
  32945. $this->owner = $match[3];
  32946. $this->repository = $match[4];
  32947. $this->originUrl = strtolower($match[1] ?? (string) $match[2]);
  32948. if ($this->originUrl === 'www.github.com') {
  32949. $this->originUrl = 'github.com';
  32950. }
  32951. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  32952. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  32953. if ($this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'])) {
  32954. $this->setupGitDriver($this->url);
  32955. return;
  32956. }
  32957. $this->fetchRootIdentifier();
  32958. }
  32959. public function getRepositoryUrl(): string
  32960. {
  32961. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  32962. }
  32963. public function getRootIdentifier(): string
  32964. {
  32965. if ($this->gitDriver) {
  32966. return $this->gitDriver->getRootIdentifier();
  32967. }
  32968. return $this->rootIdentifier;
  32969. }
  32970. public function getUrl(): string
  32971. {
  32972. if ($this->gitDriver) {
  32973. return $this->gitDriver->getUrl();
  32974. }
  32975. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  32976. }
  32977. protected function getApiUrl(): string
  32978. {
  32979. if ('github.com' === $this->originUrl) {
  32980. $apiUrl = 'api.github.com';
  32981. } else {
  32982. $apiUrl = $this->originUrl . '/api/v3';
  32983. }
  32984. return 'https://' . $apiUrl;
  32985. }
  32986. public function getSource(string $identifier): array
  32987. {
  32988. if ($this->gitDriver) {
  32989. return $this->gitDriver->getSource($identifier);
  32990. }
  32991. if ($this->isPrivate) {
  32992. $url = $this->generateSshUrl();
  32993. } else {
  32994. $url = $this->getUrl();
  32995. }
  32996. return ['type' => 'git', 'url' => $url, 'reference' => $identifier];
  32997. }
  32998. public function getDist(string $identifier): ?array
  32999. {
  33000. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  33001. return ['type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => ''];
  33002. }
  33003. public function getComposerInformation(string $identifier): ?array
  33004. {
  33005. if ($this->gitDriver) {
  33006. return $this->gitDriver->getComposerInformation($identifier);
  33007. }
  33008. if (!isset($this->infoCache[$identifier])) {
  33009. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  33010. $composer = JsonFile::parseJson($res);
  33011. } else {
  33012. $composer = $this->getBaseComposerInformation($identifier);
  33013. if ($this->shouldCache($identifier)) {
  33014. $this->cache->write($identifier, json_encode($composer));
  33015. }
  33016. }
  33017. if ($composer !== null) {
  33018. if (isset($composer['support']) && !is_array($composer['support'])) {
  33019. $composer['support'] = [];
  33020. }
  33021. if (!isset($composer['support']['source'])) {
  33022. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  33023. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  33024. }
  33025. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  33026. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  33027. }
  33028. if (!isset($composer['abandoned']) && $this->isArchived) {
  33029. $composer['abandoned'] = true;
  33030. }
  33031. if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) {
  33032. $composer['funding'] = $funding;
  33033. }
  33034. }
  33035. $this->infoCache[$identifier] = $composer;
  33036. }
  33037. return $this->infoCache[$identifier];
  33038. }
  33039. private function getFundingInfo()
  33040. {
  33041. if (null !== $this->fundingInfo) {
  33042. return $this->fundingInfo;
  33043. }
  33044. if ($this->originUrl !== 'github.com') {
  33045. return $this->fundingInfo = false;
  33046. }
  33047. foreach ([$this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml'] as $file) {
  33048. try {
  33049. $response = $this->httpDownloader->get($file, [
  33050. 'retry-auth-failure' => false,
  33051. ])->decodeJson();
  33052. } catch (TransportException $e) {
  33053. continue;
  33054. }
  33055. if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) {
  33056. continue;
  33057. }
  33058. break;
  33059. }
  33060. if (empty($funding)) {
  33061. return $this->fundingInfo = false;
  33062. }
  33063. $result = [];
  33064. $key = null;
  33065. foreach (Preg::split('{\r?\n}', $funding) as $line) {
  33066. $line = trim($line);
  33067. if (Preg::isMatchStrictGroups('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
  33068. if ($match[2] === '[') {
  33069. $key = $match[1];
  33070. continue;
  33071. }
  33072. if (Preg::isMatchStrictGroups('{^\[(.*?)\](?:\s*#.*)?$}', $match[2], $match2)) {
  33073. foreach (array_map('trim', Preg::split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
  33074. $result[] = ['type' => $match[1], 'url' => trim($item, '"\' ')];
  33075. }
  33076. } elseif (Preg::isMatchStrictGroups('{^([^#].*?)(?:\s+#.*)?$}', $match[2], $match2)) {
  33077. $result[] = ['type' => $match[1], 'url' => trim($match2[1], '"\' ')];
  33078. }
  33079. $key = null;
  33080. } elseif (Preg::isMatchStrictGroups('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
  33081. $key = $match[1];
  33082. } elseif ($key !== null && (
  33083. Preg::isMatchStrictGroups('{^-\s*(.+)(?:\s+#.*)?$}', $line, $match)
  33084. || Preg::isMatchStrictGroups('{^(.+),(?:\s*#.*)?$}', $line, $match)
  33085. )) {
  33086. $result[] = ['type' => $key, 'url' => trim($match[1], '"\' ')];
  33087. } elseif ($key !== null && $line === ']') {
  33088. $key = null;
  33089. }
  33090. }
  33091. foreach ($result as $key => $item) {
  33092. switch ($item['type']) {
  33093. case 'community_bridge':
  33094. $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']);
  33095. break;
  33096. case 'github':
  33097. $result[$key]['url'] = 'https://github.com/' . basename($item['url']);
  33098. break;
  33099. case 'issuehunt':
  33100. $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url'];
  33101. break;
  33102. case 'ko_fi':
  33103. $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']);
  33104. break;
  33105. case 'liberapay':
  33106. $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']);
  33107. break;
  33108. case 'open_collective':
  33109. $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']);
  33110. break;
  33111. case 'patreon':
  33112. $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']);
  33113. break;
  33114. case 'tidelift':
  33115. $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url'];
  33116. break;
  33117. case 'polar':
  33118. $result[$key]['url'] = 'https://polar.sh/' . basename($item['url']);
  33119. break;
  33120. case 'buy_me_a_coffee':
  33121. $result[$key]['url'] = 'https://www.buymeacoffee.com/' . basename($item['url']);
  33122. break;
  33123. case 'thanks_dev':
  33124. $result[$key]['url'] = 'https://thanks.dev/' . $item['url'];
  33125. break;
  33126. case 'otechie':
  33127. $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']);
  33128. break;
  33129. case 'custom':
  33130. $bits = parse_url($item['url']);
  33131. if ($bits === false) {
  33132. unset($result[$key]);
  33133. break;
  33134. }
  33135. if (!array_key_exists('scheme', $bits) && !array_key_exists('host', $bits)) {
  33136. if (Preg::isMatch('{^[a-z0-9-]++\.[a-z]{2,3}$}', $item['url'])) {
  33137. $result[$key]['url'] = 'https://'.$item['url'];
  33138. break;
  33139. }
  33140. $this->io->writeError('<warning>Funding URL '.$item['url'].' not in a supported format.</warning>');
  33141. unset($result[$key]);
  33142. break;
  33143. }
  33144. break;
  33145. }
  33146. }
  33147. return $this->fundingInfo = $result;
  33148. }
  33149. public function getFileContent(string $file, string $identifier): ?string
  33150. {
  33151. if ($this->gitDriver) {
  33152. return $this->gitDriver->getFileContent($file, $identifier);
  33153. }
  33154. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  33155. $resource = $this->getContents($resource)->decodeJson();
  33156. if ((!isset($resource['content']) || $resource['content'] === '') && $resource['encoding'] === 'none' && isset($resource['git_url'])) {
  33157. $resource = $this->getContents($resource['git_url'])->decodeJson();
  33158. }
  33159. if (!isset($resource['content']) || $resource['encoding'] !== 'base64' || false === ($content = base64_decode($resource['content']))) {
  33160. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  33161. }
  33162. return $content;
  33163. }
  33164. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  33165. {
  33166. if ($this->gitDriver) {
  33167. return $this->gitDriver->getChangeDate($identifier);
  33168. }
  33169. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  33170. $commit = $this->getContents($resource)->decodeJson();
  33171. return new \DateTimeImmutable($commit['commit']['committer']['date']);
  33172. }
  33173. public function getTags(): array
  33174. {
  33175. if ($this->gitDriver) {
  33176. return $this->gitDriver->getTags();
  33177. }
  33178. if (null === $this->tags) {
  33179. $tags = [];
  33180. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  33181. do {
  33182. $response = $this->getContents($resource);
  33183. $tagsData = $response->decodeJson();
  33184. foreach ($tagsData as $tag) {
  33185. $tags[$tag['name']] = $tag['commit']['sha'];
  33186. }
  33187. $resource = $this->getNextPage($response);
  33188. } while ($resource);
  33189. $this->tags = $tags;
  33190. }
  33191. return $this->tags;
  33192. }
  33193. public function getBranches(): array
  33194. {
  33195. if ($this->gitDriver) {
  33196. return $this->gitDriver->getBranches();
  33197. }
  33198. if (null === $this->branches) {
  33199. $branches = [];
  33200. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  33201. do {
  33202. $response = $this->getContents($resource);
  33203. $branchData = $response->decodeJson();
  33204. foreach ($branchData as $branch) {
  33205. $name = substr($branch['ref'], 11);
  33206. if ($name !== 'gh-pages') {
  33207. $branches[$name] = $branch['object']['sha'];
  33208. }
  33209. }
  33210. $resource = $this->getNextPage($response);
  33211. } while ($resource);
  33212. $this->branches = $branches;
  33213. }
  33214. return $this->branches;
  33215. }
  33216. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  33217. {
  33218. if (!Preg::isMatch('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/([^/]+?)(?:\.git|/)?$#', $url, $matches)) {
  33219. return false;
  33220. }
  33221. $originUrl = $matches[2] ?? (string) $matches[3];
  33222. if (!in_array(strtolower(Preg::replace('{^www\.}i', '', $originUrl)), $config->get('github-domains'))) {
  33223. return false;
  33224. }
  33225. if (!extension_loaded('openssl')) {
  33226. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  33227. return false;
  33228. }
  33229. return true;
  33230. }
  33231. public function getRepoData(): ?array
  33232. {
  33233. $this->fetchRootIdentifier();
  33234. return $this->repoData;
  33235. }
  33236. protected function generateSshUrl(): string
  33237. {
  33238. if (false !== strpos($this->originUrl, ':')) {
  33239. return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  33240. }
  33241. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  33242. }
  33243. protected function getContents(string $url, bool $fetchingRepoData = false): Response
  33244. {
  33245. try {
  33246. return parent::getContents($url);
  33247. } catch (TransportException $e) {
  33248. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->httpDownloader);
  33249. switch ($e->getCode()) {
  33250. case 401:
  33251. case 404:
  33252. if (!$fetchingRepoData) {
  33253. throw $e;
  33254. }
  33255. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  33256. return parent::getContents($url);
  33257. }
  33258. if (!$this->io->isInteractive()) {
  33259. $this->attemptCloneFallback();
  33260. return new Response(['url' => 'dummy'], 200, [], 'null');
  33261. }
  33262. $scopesIssued = [];
  33263. $scopesNeeded = [];
  33264. if ($headers = $e->getHeaders()) {
  33265. if ($scopes = Response::findHeaderValue($headers, 'X-OAuth-Scopes')) {
  33266. $scopesIssued = explode(' ', $scopes);
  33267. }
  33268. if ($scopes = Response::findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  33269. $scopesNeeded = explode(' ', $scopes);
  33270. }
  33271. }
  33272. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  33273. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  33274. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  33275. }
  33276. return parent::getContents($url);
  33277. case 403:
  33278. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  33279. return parent::getContents($url);
  33280. }
  33281. if (!$this->io->isInteractive() && $fetchingRepoData) {
  33282. $this->attemptCloneFallback();
  33283. return new Response(['url' => 'dummy'], 200, [], 'null');
  33284. }
  33285. $rateLimited = $gitHubUtil->isRateLimited((array) $e->getHeaders());
  33286. if (!$this->io->hasAuthentication($this->originUrl)) {
  33287. if (!$this->io->isInteractive()) {
  33288. $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>');
  33289. throw $e;
  33290. }
  33291. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  33292. return parent::getContents($url);
  33293. }
  33294. if ($rateLimited) {
  33295. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  33296. $this->io->writeError(sprintf(
  33297. '<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>',
  33298. $rateLimit['limit'],
  33299. $rateLimit['reset']
  33300. ));
  33301. }
  33302. throw $e;
  33303. default:
  33304. throw $e;
  33305. }
  33306. }
  33307. }
  33308. protected function fetchRootIdentifier(): void
  33309. {
  33310. if ($this->repoData) {
  33311. return;
  33312. }
  33313. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  33314. try {
  33315. $this->repoData = $this->getContents($repoDataUrl, true)->decodeJson();
  33316. } catch (TransportException $e) {
  33317. if ($e->getCode() === 499) {
  33318. $this->attemptCloneFallback();
  33319. } else {
  33320. throw $e;
  33321. }
  33322. }
  33323. if (null === $this->repoData && null !== $this->gitDriver) {
  33324. return;
  33325. }
  33326. $this->owner = $this->repoData['owner']['login'];
  33327. $this->repository = $this->repoData['name'];
  33328. $this->isPrivate = !empty($this->repoData['private']);
  33329. if (isset($this->repoData['default_branch'])) {
  33330. $this->rootIdentifier = $this->repoData['default_branch'];
  33331. } elseif (isset($this->repoData['master_branch'])) {
  33332. $this->rootIdentifier = $this->repoData['master_branch'];
  33333. } else {
  33334. $this->rootIdentifier = 'master';
  33335. }
  33336. $this->hasIssues = !empty($this->repoData['has_issues']);
  33337. $this->isArchived = !empty($this->repoData['archived']);
  33338. }
  33339. protected function attemptCloneFallback(): bool
  33340. {
  33341. $this->isPrivate = true;
  33342. try {
  33343. $this->setupGitDriver($this->generateSshUrl());
  33344. return true;
  33345. } catch (\RuntimeException $e) {
  33346. $this->gitDriver = null;
  33347. $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>');
  33348. throw $e;
  33349. }
  33350. }
  33351. protected function setupGitDriver(string $url): void
  33352. {
  33353. $this->gitDriver = new GitDriver(
  33354. ['url' => $url],
  33355. $this->io,
  33356. $this->config,
  33357. $this->httpDownloader,
  33358. $this->process
  33359. );
  33360. $this->gitDriver->initialize();
  33361. }
  33362. protected function getNextPage(Response $response): ?string
  33363. {
  33364. $header = $response->getHeader('link');
  33365. if (!$header) {
  33366. return null;
  33367. }
  33368. $links = explode(',', $header);
  33369. foreach ($links as $link) {
  33370. if (Preg::isMatch('{<(.+?)>; *rel="next"}', $link, $match)) {
  33371. return $match[1];
  33372. }
  33373. }
  33374. return null;
  33375. }
  33376. }
  33377. <?php declare(strict_types=1);
  33378. namespace Composer\Repository\Vcs;
  33379. use Composer\Config;
  33380. use Composer\Cache;
  33381. use Composer\IO\IOInterface;
  33382. use Composer\Json\JsonFile;
  33383. use Composer\Downloader\TransportException;
  33384. use Composer\Pcre\Preg;
  33385. use Composer\Util\HttpDownloader;
  33386. use Composer\Util\GitLab;
  33387. use Composer\Util\Http\Response;
  33388. class GitLabDriver extends VcsDriver
  33389. {
  33390. private $scheme;
  33391. private $namespace;
  33392. private $repository;
  33393. private $project = null;
  33394. private $commits = [];
  33395. private $tags;
  33396. private $branches;
  33397. protected $gitDriver = null;
  33398. protected $protocol;
  33399. private $isPrivate = true;
  33400. private $hasNonstandardOrigin = false;
  33401. public const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  33402. public function initialize(): void
  33403. {
  33404. if (!Preg::isMatch(self::URL_REGEX, $this->url, $match)) {
  33405. throw new \InvalidArgumentException(sprintf('The GitLab repository URL %s is invalid. It must be the HTTP URL of a GitLab project.', $this->url));
  33406. }
  33407. $guessedDomain = $match['domain'] ?? (string) $match['domain2'];
  33408. $configuredDomains = $this->config->get('gitlab-domains');
  33409. $urlParts = explode('/', $match['parts']);
  33410. $this->scheme = in_array($match['scheme'], ['https', 'http'], true)
  33411. ? $match['scheme']
  33412. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  33413. ;
  33414. $origin = self::determineOrigin($configuredDomains, $guessedDomain, $urlParts, $match['port']);
  33415. if (false === $origin) {
  33416. throw new \LogicException('It should not be possible to create a gitlab driver with an unparsable origin URL ('.$this->url.')');
  33417. }
  33418. $this->originUrl = $origin;
  33419. if (is_string($protocol = $this->config->get('gitlab-protocol'))) {
  33420. if (!in_array($protocol, ['git', 'http', 'https'], true)) {
  33421. throw new \RuntimeException('gitlab-protocol must be one of git, http.');
  33422. }
  33423. $this->protocol = $protocol === 'git' ? 'ssh' : 'http';
  33424. }
  33425. if (false !== strpos($this->originUrl, ':') || false !== strpos($this->originUrl, '/')) {
  33426. $this->hasNonstandardOrigin = true;
  33427. }
  33428. $this->namespace = implode('/', $urlParts);
  33429. $this->repository = Preg::replace('#(\.git)$#', '', $match['repo']);
  33430. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  33431. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  33432. $this->fetchProject();
  33433. }
  33434. public function setHttpDownloader(HttpDownloader $httpDownloader): void
  33435. {
  33436. $this->httpDownloader = $httpDownloader;
  33437. }
  33438. public function getComposerInformation(string $identifier): ?array
  33439. {
  33440. if ($this->gitDriver) {
  33441. return $this->gitDriver->getComposerInformation($identifier);
  33442. }
  33443. if (!isset($this->infoCache[$identifier])) {
  33444. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  33445. $composer = JsonFile::parseJson($res);
  33446. } else {
  33447. $composer = $this->getBaseComposerInformation($identifier);
  33448. if ($this->shouldCache($identifier)) {
  33449. $this->cache->write($identifier, json_encode($composer));
  33450. }
  33451. }
  33452. if (null !== $composer) {
  33453. if (isset($composer['support']) && !is_array($composer['support'])) {
  33454. $composer['support'] = [];
  33455. }
  33456. if (!isset($composer['support']['source']) && isset($this->project['web_url'])) {
  33457. $label = array_search($identifier, $this->getTags(), true) ?: array_search($identifier, $this->getBranches(), true) ?: $identifier;
  33458. $composer['support']['source'] = sprintf('%s/-/tree/%s', $this->project['web_url'], $label);
  33459. }
  33460. if (!isset($composer['support']['issues']) && !empty($this->project['issues_enabled']) && isset($this->project['web_url'])) {
  33461. $composer['support']['issues'] = sprintf('%s/-/issues', $this->project['web_url']);
  33462. }
  33463. if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
  33464. $composer['abandoned'] = true;
  33465. }
  33466. }
  33467. $this->infoCache[$identifier] = $composer;
  33468. }
  33469. return $this->infoCache[$identifier];
  33470. }
  33471. public function getFileContent(string $file, string $identifier): ?string
  33472. {
  33473. if ($this->gitDriver) {
  33474. return $this->gitDriver->getFileContent($file, $identifier);
  33475. }
  33476. if (!Preg::isMatch('{[a-f0-9]{40}}i', $identifier)) {
  33477. $branches = $this->getBranches();
  33478. if (isset($branches[$identifier])) {
  33479. $identifier = $branches[$identifier];
  33480. }
  33481. }
  33482. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  33483. try {
  33484. $content = $this->getContents($resource)->getBody();
  33485. } catch (TransportException $e) {
  33486. if ($e->getCode() !== 404) {
  33487. throw $e;
  33488. }
  33489. return null;
  33490. }
  33491. return $content;
  33492. }
  33493. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  33494. {
  33495. if ($this->gitDriver) {
  33496. return $this->gitDriver->getChangeDate($identifier);
  33497. }
  33498. if (isset($this->commits[$identifier])) {
  33499. return new \DateTimeImmutable($this->commits[$identifier]['committed_date']);
  33500. }
  33501. return null;
  33502. }
  33503. public function getRepositoryUrl(): string
  33504. {
  33505. if ($this->protocol) {
  33506. return $this->project["{$this->protocol}_url_to_repo"];
  33507. }
  33508. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  33509. }
  33510. public function getUrl(): string
  33511. {
  33512. if ($this->gitDriver) {
  33513. return $this->gitDriver->getUrl();
  33514. }
  33515. return $this->project['web_url'];
  33516. }
  33517. public function getDist(string $identifier): ?array
  33518. {
  33519. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  33520. return ['type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => ''];
  33521. }
  33522. public function getSource(string $identifier): array
  33523. {
  33524. if ($this->gitDriver) {
  33525. return $this->gitDriver->getSource($identifier);
  33526. }
  33527. return ['type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier];
  33528. }
  33529. public function getRootIdentifier(): string
  33530. {
  33531. if ($this->gitDriver) {
  33532. return $this->gitDriver->getRootIdentifier();
  33533. }
  33534. return $this->project['default_branch'];
  33535. }
  33536. public function getBranches(): array
  33537. {
  33538. if ($this->gitDriver) {
  33539. return $this->gitDriver->getBranches();
  33540. }
  33541. if (null === $this->branches) {
  33542. $this->branches = $this->getReferences('branches');
  33543. }
  33544. return $this->branches;
  33545. }
  33546. public function getTags(): array
  33547. {
  33548. if ($this->gitDriver) {
  33549. return $this->gitDriver->getTags();
  33550. }
  33551. if (null === $this->tags) {
  33552. $this->tags = $this->getReferences('tags');
  33553. }
  33554. return $this->tags;
  33555. }
  33556. public function getApiUrl(): string
  33557. {
  33558. return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  33559. }
  33560. private function urlEncodeAll(string $string): string
  33561. {
  33562. $encoded = '';
  33563. for ($i = 0; isset($string[$i]); $i++) {
  33564. $character = $string[$i];
  33565. if (!ctype_alnum($character) && !in_array($character, ['-', '_'], true)) {
  33566. $character = '%' . sprintf('%02X', ord($character));
  33567. }
  33568. $encoded .= $character;
  33569. }
  33570. return $encoded;
  33571. }
  33572. protected function getReferences(string $type): array
  33573. {
  33574. $perPage = 100;
  33575. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  33576. $references = [];
  33577. do {
  33578. $response = $this->getContents($resource);
  33579. $data = $response->decodeJson();
  33580. foreach ($data as $datum) {
  33581. $references[$datum['name']] = $datum['commit']['id'];
  33582. $this->commits[$datum['commit']['id']] = $datum['commit'];
  33583. }
  33584. if (count($data) >= $perPage) {
  33585. $resource = $this->getNextPage($response);
  33586. } else {
  33587. $resource = false;
  33588. }
  33589. } while ($resource);
  33590. return $references;
  33591. }
  33592. protected function fetchProject(): void
  33593. {
  33594. if (!is_null($this->project)) {
  33595. return;
  33596. }
  33597. $resource = $this->getApiUrl();
  33598. $this->project = $this->getContents($resource, true)->decodeJson();
  33599. if (isset($this->project['visibility'])) {
  33600. $this->isPrivate = $this->project['visibility'] !== 'public';
  33601. } else {
  33602. $this->isPrivate = false;
  33603. }
  33604. }
  33605. protected function attemptCloneFallback(): bool
  33606. {
  33607. if ($this->isPrivate === false) {
  33608. $url = $this->generatePublicUrl();
  33609. } else {
  33610. $url = $this->generateSshUrl();
  33611. }
  33612. try {
  33613. $this->setupGitDriver($url);
  33614. return true;
  33615. } catch (\RuntimeException $e) {
  33616. $this->gitDriver = null;
  33617. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  33618. throw $e;
  33619. }
  33620. }
  33621. protected function generateSshUrl(): string
  33622. {
  33623. if ($this->hasNonstandardOrigin) {
  33624. return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
  33625. }
  33626. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  33627. }
  33628. protected function generatePublicUrl(): string
  33629. {
  33630. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  33631. }
  33632. protected function setupGitDriver(string $url): void
  33633. {
  33634. $this->gitDriver = new GitDriver(
  33635. ['url' => $url],
  33636. $this->io,
  33637. $this->config,
  33638. $this->httpDownloader,
  33639. $this->process
  33640. );
  33641. $this->gitDriver->initialize();
  33642. }
  33643. protected function getContents(string $url, bool $fetchingRepoData = false): Response
  33644. {
  33645. try {
  33646. $response = parent::getContents($url);
  33647. if ($fetchingRepoData) {
  33648. $json = $response->decodeJson();
  33649. if (!isset($json['default_branch']) && isset($json['permissions'])) {
  33650. $this->isPrivate = $json['visibility'] !== 'public';
  33651. $moreThanGuestAccess = false;
  33652. foreach ($json['permissions'] as $permission) {
  33653. if ($permission && $permission['access_level'] > 10) {
  33654. $moreThanGuestAccess = true;
  33655. }
  33656. }
  33657. if (!$moreThanGuestAccess) {
  33658. $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
  33659. $this->attemptCloneFallback();
  33660. return new Response(['url' => 'dummy'], 200, [], 'null');
  33661. }
  33662. }
  33663. if (!isset($json['default_branch'])) {
  33664. if (isset($json['repository_access_level']) && $json['repository_access_level'] === 'disabled') {
  33665. throw new TransportException('The GitLab repository is disabled in the project', 400);
  33666. }
  33667. if (!empty($json['id'])) {
  33668. $this->isPrivate = false;
  33669. }
  33670. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  33671. }
  33672. }
  33673. return $response;
  33674. } catch (TransportException $e) {
  33675. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->httpDownloader);
  33676. switch ($e->getCode()) {
  33677. case 401:
  33678. case 404:
  33679. if (!$fetchingRepoData) {
  33680. throw $e;
  33681. }
  33682. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  33683. return parent::getContents($url);
  33684. }
  33685. if ($gitLabUtil->isOAuthExpired($this->originUrl) && $gitLabUtil->authorizeOAuthRefresh($this->scheme, $this->originUrl)) {
  33686. return parent::getContents($url);
  33687. }
  33688. if (!$this->io->isInteractive()) {
  33689. $this->attemptCloneFallback();
  33690. return new Response(['url' => 'dummy'], 200, [], 'null');
  33691. }
  33692. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  33693. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  33694. return parent::getContents($url);
  33695. case 403:
  33696. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  33697. return parent::getContents($url);
  33698. }
  33699. if (!$this->io->isInteractive() && $fetchingRepoData) {
  33700. $this->attemptCloneFallback();
  33701. return new Response(['url' => 'dummy'], 200, [], 'null');
  33702. }
  33703. throw $e;
  33704. default:
  33705. throw $e;
  33706. }
  33707. }
  33708. }
  33709. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  33710. {
  33711. if (!Preg::isMatch(self::URL_REGEX, $url, $match)) {
  33712. return false;
  33713. }
  33714. $scheme = $match['scheme'];
  33715. $guessedDomain = $match['domain'] ?? (string) $match['domain2'];
  33716. $urlParts = explode('/', $match['parts']);
  33717. if (false === self::determineOrigin($config->get('gitlab-domains'), $guessedDomain, $urlParts, $match['port'])) {
  33718. return false;
  33719. }
  33720. if ('https' === $scheme && !extension_loaded('openssl')) {
  33721. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  33722. return false;
  33723. }
  33724. return true;
  33725. }
  33726. public function getRepoData(): ?array
  33727. {
  33728. $this->fetchProject();
  33729. return $this->project;
  33730. }
  33731. protected function getNextPage(Response $response): ?string
  33732. {
  33733. $header = $response->getHeader('link');
  33734. $links = explode(',', $header);
  33735. foreach ($links as $link) {
  33736. if (Preg::isMatchStrictGroups('{<(.+?)>; *rel="next"}', $link, $match)) {
  33737. return $match[1];
  33738. }
  33739. }
  33740. return null;
  33741. }
  33742. private static function determineOrigin(array $configuredDomains, string $guessedDomain, array &$urlParts, ?string $portNumber)
  33743. {
  33744. $guessedDomain = strtolower($guessedDomain);
  33745. if (in_array($guessedDomain, $configuredDomains) || (null !== $portNumber && in_array($guessedDomain.':'.$portNumber, $configuredDomains))) {
  33746. if (null !== $portNumber) {
  33747. return $guessedDomain.':'.$portNumber;
  33748. }
  33749. return $guessedDomain;
  33750. }
  33751. if (null !== $portNumber) {
  33752. $guessedDomain .= ':'.$portNumber;
  33753. }
  33754. while (null !== ($part = array_shift($urlParts))) {
  33755. $guessedDomain .= '/' . $part;
  33756. if (in_array($guessedDomain, $configuredDomains) || (null !== $portNumber && in_array(Preg::replace('{:\d+}', '', $guessedDomain), $configuredDomains))) {
  33757. return $guessedDomain;
  33758. }
  33759. }
  33760. return false;
  33761. }
  33762. }
  33763. <?php declare(strict_types=1);
  33764. namespace Composer\Repository\Vcs;
  33765. use Composer\Config;
  33766. use Composer\Cache;
  33767. use Composer\Pcre\Preg;
  33768. use Composer\Util\Hg as HgUtils;
  33769. use Composer\Util\ProcessExecutor;
  33770. use Composer\Util\Filesystem;
  33771. use Composer\IO\IOInterface;
  33772. use Composer\Util\Url;
  33773. class HgDriver extends VcsDriver
  33774. {
  33775. protected $tags;
  33776. protected $branches;
  33777. protected $rootIdentifier;
  33778. protected $repoDir;
  33779. public function initialize(): void
  33780. {
  33781. if (Filesystem::isLocalPath($this->url)) {
  33782. $this->repoDir = $this->url;
  33783. } else {
  33784. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  33785. throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
  33786. }
  33787. $cacheDir = $this->config->get('cache-vcs-dir');
  33788. $this->repoDir = $cacheDir . '/' . Preg::replace('{[^a-z0-9]}i', '-', Url::sanitize($this->url)) . '/';
  33789. $fs = new Filesystem();
  33790. $fs->ensureDirectoryExists($cacheDir);
  33791. if (!is_writable(dirname($this->repoDir))) {
  33792. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  33793. }
  33794. $this->config->prohibitUrlByConfig($this->url, $this->io);
  33795. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  33796. if (is_dir($this->repoDir) && 0 === $this->process->execute(['hg', 'summary'], $output, $this->repoDir)) {
  33797. if (0 !== $this->process->execute(['hg', 'pull'], $output, $this->repoDir)) {
  33798. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  33799. }
  33800. } else {
  33801. $fs->removeDirectory($this->repoDir);
  33802. $repoDir = $this->repoDir;
  33803. $command = static function ($url) use ($repoDir): array {
  33804. return ['hg', 'clone', '--noupdate', '--', $url, $repoDir];
  33805. };
  33806. $hgUtils->runCommand($command, $this->url, null);
  33807. }
  33808. }
  33809. $this->getTags();
  33810. $this->getBranches();
  33811. }
  33812. public function getRootIdentifier(): string
  33813. {
  33814. if (null === $this->rootIdentifier) {
  33815. $this->process->execute(['hg', 'tip', '--template', '{node}'], $output, $this->repoDir);
  33816. $output = $this->process->splitLines($output);
  33817. $this->rootIdentifier = $output[0];
  33818. }
  33819. return $this->rootIdentifier;
  33820. }
  33821. public function getUrl(): string
  33822. {
  33823. return $this->url;
  33824. }
  33825. public function getSource(string $identifier): array
  33826. {
  33827. return ['type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier];
  33828. }
  33829. public function getDist(string $identifier): ?array
  33830. {
  33831. return null;
  33832. }
  33833. public function getFileContent(string $file, string $identifier): ?string
  33834. {
  33835. if (isset($identifier[0]) && $identifier[0] === '-') {
  33836. throw new \RuntimeException('Invalid hg identifier detected. Identifier must not start with a -, given: ' . $identifier);
  33837. }
  33838. $resource = ['hg', 'cat', '-r', $identifier, '--', $file];
  33839. $this->process->execute($resource, $content, $this->repoDir);
  33840. if (!trim($content)) {
  33841. return null;
  33842. }
  33843. return $content;
  33844. }
  33845. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  33846. {
  33847. $this->process->execute(
  33848. ['hg', 'log', '--template', '{date|rfc3339date}', '-r', $identifier],
  33849. $output,
  33850. $this->repoDir
  33851. );
  33852. return new \DateTimeImmutable(trim($output), new \DateTimeZone('UTC'));
  33853. }
  33854. public function getTags(): array
  33855. {
  33856. if (null === $this->tags) {
  33857. $tags = [];
  33858. $this->process->execute(['hg', 'tags'], $output, $this->repoDir);
  33859. foreach ($this->process->splitLines($output) as $tag) {
  33860. if ($tag && Preg::isMatchStrictGroups('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  33861. $tags[$match[1]] = $match[2];
  33862. }
  33863. }
  33864. unset($tags['tip']);
  33865. $this->tags = $tags;
  33866. }
  33867. return $this->tags;
  33868. }
  33869. public function getBranches(): array
  33870. {
  33871. if (null === $this->branches) {
  33872. $branches = [];
  33873. $bookmarks = [];
  33874. $this->process->execute(['hg', 'branches'], $output, $this->repoDir);
  33875. foreach ($this->process->splitLines($output) as $branch) {
  33876. if ($branch && Preg::isMatchStrictGroups('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match) && $match[1][0] !== '-') {
  33877. $branches[$match[1]] = $match[2];
  33878. }
  33879. }
  33880. $this->process->execute(['hg', 'bookmarks'], $output, $this->repoDir);
  33881. foreach ($this->process->splitLines($output) as $branch) {
  33882. if ($branch && Preg::isMatchStrictGroups('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match) && $match[1][0] !== '-') {
  33883. $bookmarks[$match[1]] = $match[2];
  33884. }
  33885. }
  33886. $this->branches = array_merge($bookmarks, $branches);
  33887. }
  33888. return $this->branches;
  33889. }
  33890. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  33891. {
  33892. if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  33893. return true;
  33894. }
  33895. if (Filesystem::isLocalPath($url)) {
  33896. $url = Filesystem::getPlatformPath($url);
  33897. if (!is_dir($url)) {
  33898. return false;
  33899. }
  33900. $process = new ProcessExecutor($io);
  33901. if ($process->execute(['hg', 'summary'], $output, $url) === 0) {
  33902. return true;
  33903. }
  33904. }
  33905. if (!$deep) {
  33906. return false;
  33907. }
  33908. $process = new ProcessExecutor($io);
  33909. $exit = $process->execute(['hg', 'identify', '--', $url], $ignored);
  33910. return $exit === 0;
  33911. }
  33912. }
  33913. <?php declare(strict_types=1);
  33914. namespace Composer\Repository\Vcs;
  33915. use Composer\Config;
  33916. use Composer\Cache;
  33917. use Composer\IO\IOInterface;
  33918. use Composer\Pcre\Preg;
  33919. use Composer\Util\ProcessExecutor;
  33920. use Composer\Util\Perforce;
  33921. use Composer\Util\Http\Response;
  33922. class PerforceDriver extends VcsDriver
  33923. {
  33924. protected $depot;
  33925. protected $branch;
  33926. protected $perforce = null;
  33927. public function initialize(): void
  33928. {
  33929. $this->depot = $this->repoConfig['depot'];
  33930. $this->branch = '';
  33931. if (!empty($this->repoConfig['branch'])) {
  33932. $this->branch = $this->repoConfig['branch'];
  33933. }
  33934. $this->initPerforce($this->repoConfig);
  33935. $this->perforce->p4Login();
  33936. $this->perforce->checkStream();
  33937. $this->perforce->writeP4ClientSpec();
  33938. $this->perforce->connectClient();
  33939. }
  33940. private function initPerforce(array $repoConfig): void
  33941. {
  33942. if (!empty($this->perforce)) {
  33943. return;
  33944. }
  33945. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  33946. throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
  33947. }
  33948. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  33949. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  33950. }
  33951. public function getFileContent(string $file, string $identifier): ?string
  33952. {
  33953. return $this->perforce->getFileContent($file, $identifier);
  33954. }
  33955. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  33956. {
  33957. return null;
  33958. }
  33959. public function getRootIdentifier(): string
  33960. {
  33961. return $this->branch;
  33962. }
  33963. public function getBranches(): array
  33964. {
  33965. return $this->perforce->getBranches();
  33966. }
  33967. public function getTags(): array
  33968. {
  33969. return $this->perforce->getTags();
  33970. }
  33971. public function getDist(string $identifier): ?array
  33972. {
  33973. return null;
  33974. }
  33975. public function getSource(string $identifier): array
  33976. {
  33977. return [
  33978. 'type' => 'perforce',
  33979. 'url' => $this->repoConfig['url'],
  33980. 'reference' => $identifier,
  33981. 'p4user' => $this->perforce->getUser(),
  33982. ];
  33983. }
  33984. public function getUrl(): string
  33985. {
  33986. return $this->url;
  33987. }
  33988. public function hasComposerFile(string $identifier): bool
  33989. {
  33990. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  33991. return !empty($composerInfo);
  33992. }
  33993. public function getContents(string $url): Response
  33994. {
  33995. throw new \BadMethodCallException('Not implemented/used in PerforceDriver');
  33996. }
  33997. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  33998. {
  33999. if ($deep || Preg::isMatch('#\b(perforce|p4)\b#i', $url)) {
  34000. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  34001. }
  34002. return false;
  34003. }
  34004. public function cleanup(): void
  34005. {
  34006. $this->perforce->cleanupClientSpec();
  34007. $this->perforce = null;
  34008. }
  34009. public function getDepot(): string
  34010. {
  34011. return $this->depot;
  34012. }
  34013. public function getBranch(): string
  34014. {
  34015. return $this->branch;
  34016. }
  34017. }
  34018. <?php declare(strict_types=1);
  34019. namespace Composer\Repository\Vcs;
  34020. use Composer\Cache;
  34021. use Composer\Config;
  34022. use Composer\Json\JsonFile;
  34023. use Composer\Pcre\Preg;
  34024. use Composer\Util\ProcessExecutor;
  34025. use Composer\Util\Filesystem;
  34026. use Composer\Util\Url;
  34027. use Composer\Util\Svn as SvnUtil;
  34028. use Composer\IO\IOInterface;
  34029. use Composer\Downloader\TransportException;
  34030. class SvnDriver extends VcsDriver
  34031. {
  34032. protected $baseUrl;
  34033. protected $tags;
  34034. protected $branches;
  34035. protected $rootIdentifier;
  34036. protected $trunkPath = 'trunk';
  34037. protected $branchesPath = 'branches';
  34038. protected $tagsPath = 'tags';
  34039. protected $packagePath = '';
  34040. protected $cacheCredentials = true;
  34041. private $util;
  34042. public function initialize(): void
  34043. {
  34044. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  34045. SvnUtil::cleanEnv();
  34046. if (isset($this->repoConfig['trunk-path'])) {
  34047. $this->trunkPath = $this->repoConfig['trunk-path'];
  34048. }
  34049. if (isset($this->repoConfig['branches-path'])) {
  34050. $this->branchesPath = $this->repoConfig['branches-path'];
  34051. }
  34052. if (isset($this->repoConfig['tags-path'])) {
  34053. $this->tagsPath = $this->repoConfig['tags-path'];
  34054. }
  34055. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  34056. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  34057. }
  34058. if (isset($this->repoConfig['package-path'])) {
  34059. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  34060. }
  34061. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  34062. $this->baseUrl = substr($this->url, 0, $pos);
  34063. }
  34064. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->baseUrl)));
  34065. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  34066. $this->getBranches();
  34067. $this->getTags();
  34068. }
  34069. public function getRootIdentifier(): string
  34070. {
  34071. return $this->rootIdentifier ?: $this->trunkPath;
  34072. }
  34073. public function getUrl(): string
  34074. {
  34075. return $this->url;
  34076. }
  34077. public function getSource(string $identifier): array
  34078. {
  34079. return ['type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier];
  34080. }
  34081. public function getDist(string $identifier): ?array
  34082. {
  34083. return null;
  34084. }
  34085. protected function shouldCache(string $identifier): bool
  34086. {
  34087. return $this->cache && Preg::isMatch('{@\d+$}', $identifier);
  34088. }
  34089. public function getComposerInformation(string $identifier): ?array
  34090. {
  34091. if (!isset($this->infoCache[$identifier])) {
  34092. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  34093. if ($res === '""') {
  34094. $res = 'null';
  34095. $this->cache->write($identifier.'.json', json_encode(null));
  34096. }
  34097. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  34098. }
  34099. try {
  34100. $composer = $this->getBaseComposerInformation($identifier);
  34101. } catch (TransportException $e) {
  34102. $message = $e->getMessage();
  34103. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  34104. throw $e;
  34105. }
  34106. $composer = null;
  34107. }
  34108. if ($this->shouldCache($identifier)) {
  34109. $this->cache->write($identifier.'.json', json_encode($composer));
  34110. }
  34111. $this->infoCache[$identifier] = $composer;
  34112. }
  34113. if (!is_array($this->infoCache[$identifier])) {
  34114. return null;
  34115. }
  34116. return $this->infoCache[$identifier];
  34117. }
  34118. public function getFileContent(string $file, string $identifier): ?string
  34119. {
  34120. $identifier = '/' . trim($identifier, '/') . '/';
  34121. if (Preg::isMatch('{^(.+?)(@\d+)?/$}', $identifier, $match) && $match[2] !== null) {
  34122. $path = $match[1];
  34123. $rev = $match[2];
  34124. } else {
  34125. $path = $identifier;
  34126. $rev = '';
  34127. }
  34128. try {
  34129. $resource = $path.$file;
  34130. $output = $this->execute(['svn', 'cat'], $this->baseUrl . $resource . $rev);
  34131. if ('' === trim($output)) {
  34132. return null;
  34133. }
  34134. } catch (\RuntimeException $e) {
  34135. throw new TransportException($e->getMessage());
  34136. }
  34137. return $output;
  34138. }
  34139. public function getChangeDate(string $identifier): ?\DateTimeImmutable
  34140. {
  34141. $identifier = '/' . trim($identifier, '/') . '/';
  34142. if (Preg::isMatch('{^(.+?)(@\d+)?/$}', $identifier, $match) && null !== $match[2]) {
  34143. $path = $match[1];
  34144. $rev = $match[2];
  34145. } else {
  34146. $path = $identifier;
  34147. $rev = '';
  34148. }
  34149. $output = $this->execute(['svn', 'info'], $this->baseUrl . $path . $rev);
  34150. foreach ($this->process->splitLines($output) as $line) {
  34151. if ($line !== '' && Preg::isMatchStrictGroups('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  34152. return new \DateTimeImmutable($match[1], new \DateTimeZone('UTC'));
  34153. }
  34154. }
  34155. return null;
  34156. }
  34157. public function getTags(): array
  34158. {
  34159. if (null === $this->tags) {
  34160. $tags = [];
  34161. if ($this->tagsPath !== false) {
  34162. $output = $this->execute(['svn', 'ls', '--verbose'], $this->baseUrl . '/' . $this->tagsPath);
  34163. if ($output !== '') {
  34164. $lastRev = 0;
  34165. foreach ($this->process->splitLines($output) as $line) {
  34166. $line = trim($line);
  34167. if ($line !== '' && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  34168. if ($match[2] === './') {
  34169. $lastRev = (int) $match[1];
  34170. } else {
  34171. $tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  34172. '/' . $this->tagsPath . '/' . $match[2],
  34173. max($lastRev, (int) $match[1])
  34174. );
  34175. }
  34176. }
  34177. }
  34178. }
  34179. }
  34180. $this->tags = $tags;
  34181. }
  34182. return $this->tags;
  34183. }
  34184. public function getBranches(): array
  34185. {
  34186. if (null === $this->branches) {
  34187. $branches = [];
  34188. if (false === $this->trunkPath) {
  34189. $trunkParent = $this->baseUrl . '/';
  34190. } else {
  34191. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  34192. }
  34193. $output = $this->execute(['svn', 'ls', '--verbose'], $trunkParent);
  34194. if ($output !== '') {
  34195. foreach ($this->process->splitLines($output) as $line) {
  34196. $line = trim($line);
  34197. if ($line !== '' && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  34198. if ($match[2] === './') {
  34199. $branches['trunk'] = $this->buildIdentifier(
  34200. '/' . $this->trunkPath,
  34201. (int) $match[1]
  34202. );
  34203. $this->rootIdentifier = $branches['trunk'];
  34204. break;
  34205. }
  34206. }
  34207. }
  34208. }
  34209. unset($output);
  34210. if ($this->branchesPath !== false) {
  34211. $output = $this->execute(['svn', 'ls', '--verbose'], $this->baseUrl . '/' . $this->branchesPath);
  34212. if ($output !== '') {
  34213. $lastRev = 0;
  34214. foreach ($this->process->splitLines(trim($output)) as $line) {
  34215. $line = trim($line);
  34216. if ($line !== '' && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  34217. if ($match[2] === './') {
  34218. $lastRev = (int) $match[1];
  34219. } else {
  34220. $branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  34221. '/' . $this->branchesPath . '/' . $match[2],
  34222. max($lastRev, (int) $match[1])
  34223. );
  34224. }
  34225. }
  34226. }
  34227. }
  34228. }
  34229. $this->branches = $branches;
  34230. }
  34231. return $this->branches;
  34232. }
  34233. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool
  34234. {
  34235. $url = self::normalizeUrl($url);
  34236. if (Preg::isMatch('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  34237. return true;
  34238. }
  34239. if (!$deep && !Filesystem::isLocalPath($url)) {
  34240. return false;
  34241. }
  34242. $process = new ProcessExecutor($io);
  34243. $exit = $process->execute(['svn', 'info', '--non-interactive', '--', $url], $ignoredOutput);
  34244. if ($exit === 0) {
  34245. return true;
  34246. }
  34247. if (false !== stripos($process->getErrorOutput(), 'authorization failed:')) {
  34248. return true;
  34249. }
  34250. if (false !== stripos($process->getErrorOutput(), 'Authentication failed')) {
  34251. return true;
  34252. }
  34253. return false;
  34254. }
  34255. protected static function normalizeUrl(string $url): string
  34256. {
  34257. $fs = new Filesystem();
  34258. if ($fs->isAbsolutePath($url)) {
  34259. return 'file://' . strtr($url, '\\', '/');
  34260. }
  34261. return $url;
  34262. }
  34263. protected function execute(array $command, string $url): string
  34264. {
  34265. if (null === $this->util) {
  34266. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  34267. $this->util->setCacheCredentials($this->cacheCredentials);
  34268. }
  34269. try {
  34270. return $this->util->execute($command, $url);
  34271. } catch (\RuntimeException $e) {
  34272. if (null === $this->util->binaryVersion()) {
  34273. 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());
  34274. }
  34275. throw new \RuntimeException(
  34276. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  34277. );
  34278. }
  34279. }
  34280. protected function buildIdentifier(string $baseDir, int $revision): string
  34281. {
  34282. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  34283. }
  34284. }
  34285. <?php declare(strict_types=1);
  34286. namespace Composer\Repository\Vcs;
  34287. use Composer\Cache;
  34288. use Composer\Downloader\TransportException;
  34289. use Composer\Config;
  34290. use Composer\IO\IOInterface;
  34291. use Composer\Json\JsonFile;
  34292. use Composer\Pcre\Preg;
  34293. use Composer\Util\ProcessExecutor;
  34294. use Composer\Util\HttpDownloader;
  34295. use Composer\Util\Filesystem;
  34296. use Composer\Util\Http\Response;
  34297. abstract class VcsDriver implements VcsDriverInterface
  34298. {
  34299. protected $url;
  34300. protected $originUrl;
  34301. protected $repoConfig;
  34302. protected $io;
  34303. protected $config;
  34304. protected $process;
  34305. protected $httpDownloader;
  34306. protected $infoCache = [];
  34307. protected $cache;
  34308. final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process)
  34309. {
  34310. if (Filesystem::isLocalPath($repoConfig['url'])) {
  34311. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  34312. }
  34313. $this->url = $repoConfig['url'];
  34314. $this->originUrl = $repoConfig['url'];
  34315. $this->repoConfig = $repoConfig;
  34316. $this->io = $io;
  34317. $this->config = $config;
  34318. $this->httpDownloader = $httpDownloader;
  34319. $this->process = $process;
  34320. }
  34321. protected function shouldCache(string $identifier): bool
  34322. {
  34323. return $this->cache && Preg::isMatch('{^[a-f0-9]{40}$}iD', $identifier);
  34324. }
  34325. public function getComposerInformation(string $identifier): ?array
  34326. {
  34327. if (!isset($this->infoCache[$identifier])) {
  34328. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  34329. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  34330. }
  34331. $composer = $this->getBaseComposerInformation($identifier);
  34332. if ($this->shouldCache($identifier)) {
  34333. $this->cache->write($identifier, JsonFile::encode($composer, 0));
  34334. }
  34335. $this->infoCache[$identifier] = $composer;
  34336. }
  34337. return $this->infoCache[$identifier];
  34338. }
  34339. protected function getBaseComposerInformation(string $identifier): ?array
  34340. {
  34341. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  34342. if (!$composerFileContent) {
  34343. return null;
  34344. }
  34345. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  34346. if ([] === $composer || !is_array($composer)) {
  34347. return null;
  34348. }
  34349. if (empty($composer['time']) && null !== ($changeDate = $this->getChangeDate($identifier))) {
  34350. $composer['time'] = $changeDate->format(DATE_RFC3339);
  34351. }
  34352. return $composer;
  34353. }
  34354. public function hasComposerFile(string $identifier): bool
  34355. {
  34356. try {
  34357. return null !== $this->getComposerInformation($identifier);
  34358. } catch (TransportException $e) {
  34359. }
  34360. return false;
  34361. }
  34362. protected function getScheme(): string
  34363. {
  34364. if (extension_loaded('openssl')) {
  34365. return 'https';
  34366. }
  34367. return 'http';
  34368. }
  34369. protected function getContents(string $url): Response
  34370. {
  34371. $options = $this->repoConfig['options'] ?? [];
  34372. return $this->httpDownloader->get($url, $options);
  34373. }
  34374. public function cleanup(): void
  34375. {
  34376. }
  34377. }
  34378. <?php declare(strict_types=1);
  34379. namespace Composer\Repository\Vcs;
  34380. use Composer\Config;
  34381. use Composer\IO\IOInterface;
  34382. interface VcsDriverInterface
  34383. {
  34384. public function initialize(): void;
  34385. public function getComposerInformation(string $identifier): ?array;
  34386. public function getFileContent(string $file, string $identifier): ?string;
  34387. public function getChangeDate(string $identifier): ?\DateTimeImmutable;
  34388. public function getRootIdentifier(): string;
  34389. public function getBranches(): array;
  34390. public function getTags(): array;
  34391. public function getDist(string $identifier): ?array;
  34392. public function getSource(string $identifier): array;
  34393. public function getUrl(): string;
  34394. public function hasComposerFile(string $identifier): bool;
  34395. public function cleanup(): void;
  34396. public static function supports(IOInterface $io, Config $config, string $url, bool $deep = false): bool;
  34397. }
  34398. <?php declare(strict_types=1);
  34399. namespace Composer\Repository;
  34400. use Composer\Downloader\TransportException;
  34401. use Composer\Pcre\Preg;
  34402. use Composer\Repository\Vcs\VcsDriverInterface;
  34403. use Composer\Package\Version\VersionParser;
  34404. use Composer\Package\Loader\ArrayLoader;
  34405. use Composer\Package\Loader\ValidatingArrayLoader;
  34406. use Composer\Package\Loader\InvalidPackageException;
  34407. use Composer\Package\Loader\LoaderInterface;
  34408. use Composer\EventDispatcher\EventDispatcher;
  34409. use Composer\Util\Platform;
  34410. use Composer\Util\ProcessExecutor;
  34411. use Composer\Util\HttpDownloader;
  34412. use Composer\Util\Url;
  34413. use Composer\Semver\Constraint\Constraint;
  34414. use Composer\IO\IOInterface;
  34415. use Composer\Config;
  34416. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  34417. {
  34418. protected $url;
  34419. protected $packageName;
  34420. protected $isVerbose;
  34421. protected $isVeryVerbose;
  34422. protected $io;
  34423. protected $config;
  34424. protected $versionParser;
  34425. protected $type;
  34426. protected $loader;
  34427. protected $repoConfig;
  34428. protected $httpDownloader;
  34429. protected $processExecutor;
  34430. protected $branchErrorOccurred = false;
  34431. private $drivers;
  34432. private $driver;
  34433. private $versionCache;
  34434. private $emptyReferences = [];
  34435. private $versionTransportExceptions = [];
  34436. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ?EventDispatcher $dispatcher = null, ?ProcessExecutor $process = null, ?array $drivers = null, ?VersionCacheInterface $versionCache = null)
  34437. {
  34438. parent::__construct();
  34439. $this->drivers = $drivers ?: [
  34440. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  34441. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  34442. 'bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  34443. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  34444. 'git' => 'Composer\Repository\Vcs\GitDriver',
  34445. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  34446. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  34447. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  34448. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  34449. ];
  34450. $this->url = $repoConfig['url'] = Platform::expandPath($repoConfig['url']);
  34451. $this->io = $io;
  34452. $this->type = $repoConfig['type'] ?? 'vcs';
  34453. $this->isVerbose = $io->isVerbose();
  34454. $this->isVeryVerbose = $io->isVeryVerbose();
  34455. $this->config = $config;
  34456. $this->repoConfig = $repoConfig;
  34457. $this->versionCache = $versionCache;
  34458. $this->httpDownloader = $httpDownloader;
  34459. $this->processExecutor = $process ?? new ProcessExecutor($io);
  34460. }
  34461. public function getRepoName()
  34462. {
  34463. $driverClass = get_class($this->getDriver());
  34464. $driverType = array_search($driverClass, $this->drivers);
  34465. if (!$driverType) {
  34466. $driverType = $driverClass;
  34467. }
  34468. return 'vcs repo ('.$driverType.' '.Url::sanitize($this->url).')';
  34469. }
  34470. public function getRepoConfig()
  34471. {
  34472. return $this->repoConfig;
  34473. }
  34474. public function setLoader(LoaderInterface $loader): void
  34475. {
  34476. $this->loader = $loader;
  34477. }
  34478. public function getDriver(): ?VcsDriverInterface
  34479. {
  34480. if ($this->driver) {
  34481. return $this->driver;
  34482. }
  34483. if (isset($this->drivers[$this->type])) {
  34484. $class = $this->drivers[$this->type];
  34485. $this->driver = new $class($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  34486. $this->driver->initialize();
  34487. return $this->driver;
  34488. }
  34489. foreach ($this->drivers as $driver) {
  34490. if ($driver::supports($this->io, $this->config, $this->url)) {
  34491. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  34492. $this->driver->initialize();
  34493. return $this->driver;
  34494. }
  34495. }
  34496. foreach ($this->drivers as $driver) {
  34497. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  34498. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  34499. $this->driver->initialize();
  34500. return $this->driver;
  34501. }
  34502. }
  34503. return null;
  34504. }
  34505. public function hadInvalidBranches(): bool
  34506. {
  34507. return $this->branchErrorOccurred;
  34508. }
  34509. public function getEmptyReferences(): array
  34510. {
  34511. return $this->emptyReferences;
  34512. }
  34513. public function getVersionTransportExceptions(): array
  34514. {
  34515. return $this->versionTransportExceptions;
  34516. }
  34517. protected function initialize()
  34518. {
  34519. parent::initialize();
  34520. $isVerbose = $this->isVerbose;
  34521. $isVeryVerbose = $this->isVeryVerbose;
  34522. $driver = $this->getDriver();
  34523. if (!$driver) {
  34524. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  34525. }
  34526. $this->versionParser = new VersionParser;
  34527. if (!$this->loader) {
  34528. $this->loader = new ArrayLoader($this->versionParser);
  34529. }
  34530. $hasRootIdentifierComposerJson = false;
  34531. try {
  34532. $hasRootIdentifierComposerJson = $driver->hasComposerFile($driver->getRootIdentifier());
  34533. if ($hasRootIdentifierComposerJson) {
  34534. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  34535. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  34536. }
  34537. } catch (\Exception $e) {
  34538. if ($e instanceof TransportException && $this->shouldRethrowTransportException($e)) {
  34539. throw $e;
  34540. }
  34541. if ($isVeryVerbose) {
  34542. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  34543. }
  34544. }
  34545. foreach ($driver->getTags() as $tag => $identifier) {
  34546. $tag = (string) $tag;
  34547. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  34548. $tag = str_replace('release-', '', $tag);
  34549. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
  34550. if ($cachedPackage) {
  34551. $this->addPackage($cachedPackage);
  34552. continue;
  34553. }
  34554. if ($cachedPackage === false) {
  34555. $this->emptyReferences[] = $identifier;
  34556. continue;
  34557. }
  34558. if (!$parsedTag = $this->validateTag($tag)) {
  34559. if ($isVeryVerbose) {
  34560. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  34561. }
  34562. continue;
  34563. }
  34564. if ($isVeryVerbose) {
  34565. $this->io->writeError($msg);
  34566. } elseif ($isVerbose) {
  34567. $this->io->overwriteError($msg, false);
  34568. }
  34569. try {
  34570. $data = $driver->getComposerInformation($identifier);
  34571. if (null === $data) {
  34572. if ($isVeryVerbose) {
  34573. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  34574. }
  34575. $this->emptyReferences[] = $identifier;
  34576. continue;
  34577. }
  34578. if (isset($data['version'])) {
  34579. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  34580. } else {
  34581. $data['version'] = $tag;
  34582. $data['version_normalized'] = $parsedTag;
  34583. }
  34584. $data['version'] = Preg::replace('{[.-]?dev$}i', '', $data['version']);
  34585. $data['version_normalized'] = Preg::replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  34586. unset($data['default-branch']);
  34587. if ($data['version_normalized'] !== $parsedTag) {
  34588. if ($isVeryVerbose) {
  34589. if (Preg::isMatch('{(^dev-|[.-]?dev$)}i', $parsedTag)) {
  34590. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name, tags can not use dev prefixes or suffixes</warning>');
  34591. } else {
  34592. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  34593. }
  34594. }
  34595. continue;
  34596. }
  34597. $tagPackageName = $this->packageName ?: ($data['name'] ?? '');
  34598. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  34599. if ($isVeryVerbose) {
  34600. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  34601. }
  34602. continue;
  34603. }
  34604. if ($isVeryVerbose) {
  34605. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  34606. }
  34607. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  34608. } catch (\Exception $e) {
  34609. if ($e instanceof TransportException) {
  34610. $this->versionTransportExceptions['tags'][$tag] = $e;
  34611. if ($e->getCode() === 404) {
  34612. $this->emptyReferences[] = $identifier;
  34613. }
  34614. if ($this->shouldRethrowTransportException($e)) {
  34615. throw $e;
  34616. }
  34617. }
  34618. if ($isVeryVerbose) {
  34619. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
  34620. }
  34621. continue;
  34622. }
  34623. }
  34624. if (!$isVeryVerbose) {
  34625. $this->io->overwriteError('', false);
  34626. }
  34627. $branches = $driver->getBranches();
  34628. if ($hasRootIdentifierComposerJson && isset($branches[$driver->getRootIdentifier()])) {
  34629. $branches = [$driver->getRootIdentifier() => $branches[$driver->getRootIdentifier()]] + $branches;
  34630. }
  34631. foreach ($branches as $branch => $identifier) {
  34632. $branch = (string) $branch;
  34633. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  34634. if ($isVeryVerbose) {
  34635. $this->io->writeError($msg);
  34636. } elseif ($isVerbose) {
  34637. $this->io->overwriteError($msg, false);
  34638. }
  34639. if (!$parsedBranch = $this->validateBranch($branch)) {
  34640. if ($isVeryVerbose) {
  34641. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  34642. }
  34643. continue;
  34644. }
  34645. if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
  34646. $version = 'dev-' . str_replace('#', '+', $branch);
  34647. $parsedBranch = str_replace('#', '+', $parsedBranch);
  34648. } else {
  34649. $prefix = strpos($branch, 'v') === 0 ? 'v' : '';
  34650. $version = $prefix . Preg::replace('{(\.9{7})+}', '.x', $parsedBranch);
  34651. }
  34652. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
  34653. if ($cachedPackage) {
  34654. $this->addPackage($cachedPackage);
  34655. continue;
  34656. }
  34657. if ($cachedPackage === false) {
  34658. $this->emptyReferences[] = $identifier;
  34659. continue;
  34660. }
  34661. try {
  34662. $data = $driver->getComposerInformation($identifier);
  34663. if (null === $data) {
  34664. if ($isVeryVerbose) {
  34665. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  34666. }
  34667. $this->emptyReferences[] = $identifier;
  34668. continue;
  34669. }
  34670. $data['version'] = $version;
  34671. $data['version_normalized'] = $parsedBranch;
  34672. unset($data['default-branch']);
  34673. if ($driver->getRootIdentifier() === $branch) {
  34674. $data['default-branch'] = true;
  34675. }
  34676. if ($isVeryVerbose) {
  34677. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  34678. }
  34679. $packageData = $this->preProcess($driver, $data, $identifier);
  34680. $package = $this->loader->load($packageData);
  34681. if ($this->loader instanceof ValidatingArrayLoader && \count($this->loader->getWarnings()) > 0) {
  34682. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  34683. }
  34684. $this->addPackage($package);
  34685. } catch (TransportException $e) {
  34686. $this->versionTransportExceptions['branches'][$branch] = $e;
  34687. if ($e->getCode() === 404) {
  34688. $this->emptyReferences[] = $identifier;
  34689. }
  34690. if ($this->shouldRethrowTransportException($e)) {
  34691. throw $e;
  34692. }
  34693. if ($isVeryVerbose) {
  34694. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
  34695. }
  34696. continue;
  34697. } catch (\Exception $e) {
  34698. if (!$isVeryVerbose) {
  34699. $this->io->writeError('');
  34700. }
  34701. $this->branchErrorOccurred = true;
  34702. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  34703. $this->io->writeError('');
  34704. continue;
  34705. }
  34706. }
  34707. $driver->cleanup();
  34708. if (!$isVeryVerbose) {
  34709. $this->io->overwriteError('', false);
  34710. }
  34711. if (!$this->getPackages()) {
  34712. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  34713. }
  34714. }
  34715. protected function preProcess(VcsDriverInterface $driver, array $data, string $identifier): array
  34716. {
  34717. $dataPackageName = $data['name'] ?? null;
  34718. $data['name'] = $this->packageName ?: $dataPackageName;
  34719. if (!isset($data['dist'])) {
  34720. $data['dist'] = $driver->getDist($identifier);
  34721. }
  34722. if (!isset($data['source'])) {
  34723. $data['source'] = $driver->getSource($identifier);
  34724. }
  34725. if (is_array($data['dist']) && !isset($data['dist']['reference']) && isset($data['source']['reference'])) {
  34726. $data['dist']['reference'] = $data['source']['reference'];
  34727. }
  34728. return $data;
  34729. }
  34730. private function validateBranch(string $branch)
  34731. {
  34732. try {
  34733. $normalizedBranch = $this->versionParser->normalizeBranch($branch);
  34734. $this->versionParser->parseConstraints($normalizedBranch);
  34735. return $normalizedBranch;
  34736. } catch (\Exception $e) {
  34737. }
  34738. return false;
  34739. }
  34740. private function validateTag(string $version)
  34741. {
  34742. try {
  34743. return $this->versionParser->normalize($version);
  34744. } catch (\Exception $e) {
  34745. }
  34746. return false;
  34747. }
  34748. private function getCachedPackageVersion(string $version, string $identifier, bool $isVerbose, bool $isVeryVerbose, bool $isDefaultBranch = false)
  34749. {
  34750. if (!$this->versionCache) {
  34751. return null;
  34752. }
  34753. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  34754. if ($cachedPackage === false) {
  34755. if ($isVeryVerbose) {
  34756. $this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
  34757. }
  34758. return false;
  34759. }
  34760. if ($cachedPackage) {
  34761. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  34762. if ($isVeryVerbose) {
  34763. $this->io->writeError($msg);
  34764. } elseif ($isVerbose) {
  34765. $this->io->overwriteError($msg, false);
  34766. }
  34767. unset($cachedPackage['default-branch']);
  34768. if ($isDefaultBranch) {
  34769. $cachedPackage['default-branch'] = true;
  34770. }
  34771. if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
  34772. if ($isVeryVerbose) {
  34773. $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>');
  34774. }
  34775. $cachedPackage = null;
  34776. }
  34777. }
  34778. if ($cachedPackage) {
  34779. return $this->loader->load($cachedPackage);
  34780. }
  34781. return null;
  34782. }
  34783. private function shouldRethrowTransportException(TransportException $e): bool
  34784. {
  34785. return in_array($e->getCode(), [401, 403, 429], true) || $e->getCode() >= 500;
  34786. }
  34787. }
  34788. <?php declare(strict_types=1);
  34789. namespace Composer\Repository;
  34790. interface VersionCacheInterface
  34791. {
  34792. public function getVersionPackage(string $version, string $identifier);
  34793. }
  34794. <?php declare(strict_types=1);
  34795. namespace Composer\Repository;
  34796. use Composer\Installer\InstallationManager;
  34797. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  34798. {
  34799. use CanonicalPackagesTrait;
  34800. protected $devPackageNames = [];
  34801. private $devMode = null;
  34802. public function getDevMode()
  34803. {
  34804. return $this->devMode;
  34805. }
  34806. public function setDevPackageNames(array $devPackageNames)
  34807. {
  34808. $this->devPackageNames = $devPackageNames;
  34809. }
  34810. public function getDevPackageNames()
  34811. {
  34812. return $this->devPackageNames;
  34813. }
  34814. public function write(bool $devMode, InstallationManager $installationManager)
  34815. {
  34816. $this->devMode = $devMode;
  34817. }
  34818. public function reload()
  34819. {
  34820. $this->devMode = null;
  34821. }
  34822. }
  34823. <?php declare(strict_types=1);
  34824. namespace Composer\Repository;
  34825. use Composer\Package\PackageInterface;
  34826. use Composer\Installer\InstallationManager;
  34827. interface WritableRepositoryInterface extends RepositoryInterface
  34828. {
  34829. public function write(bool $devMode, InstallationManager $installationManager);
  34830. public function addPackage(PackageInterface $package);
  34831. public function removePackage(PackageInterface $package);
  34832. public function getCanonicalPackages();
  34833. public function reload();
  34834. public function setDevPackageNames(array $devPackageNames);
  34835. public function getDevPackageNames();
  34836. }
  34837. <?php declare(strict_types=1);
  34838. namespace Composer\Script;
  34839. use Composer\Composer;
  34840. use Composer\IO\IOInterface;
  34841. use Composer\EventDispatcher\Event as BaseEvent;
  34842. class Event extends BaseEvent
  34843. {
  34844. private $composer;
  34845. private $io;
  34846. private $devMode;
  34847. private $originatingEvent;
  34848. public function __construct(string $name, Composer $composer, IOInterface $io, bool $devMode = false, array $args = [], array $flags = [])
  34849. {
  34850. parent::__construct($name, $args, $flags);
  34851. $this->composer = $composer;
  34852. $this->io = $io;
  34853. $this->devMode = $devMode;
  34854. }
  34855. public function getComposer(): Composer
  34856. {
  34857. return $this->composer;
  34858. }
  34859. public function getIO(): IOInterface
  34860. {
  34861. return $this->io;
  34862. }
  34863. public function isDevMode(): bool
  34864. {
  34865. return $this->devMode;
  34866. }
  34867. public function getOriginatingEvent(): ?BaseEvent
  34868. {
  34869. return $this->originatingEvent;
  34870. }
  34871. public function setOriginatingEvent(BaseEvent $event): self
  34872. {
  34873. $this->originatingEvent = $this->calculateOriginatingEvent($event);
  34874. return $this;
  34875. }
  34876. private function calculateOriginatingEvent(BaseEvent $event): BaseEvent
  34877. {
  34878. if ($event instanceof Event && $event->getOriginatingEvent()) {
  34879. return $this->calculateOriginatingEvent($event->getOriginatingEvent());
  34880. }
  34881. return $event;
  34882. }
  34883. }
  34884. <?php declare(strict_types=1);
  34885. namespace Composer\Script;
  34886. class ScriptEvents
  34887. {
  34888. public const PRE_INSTALL_CMD = 'pre-install-cmd';
  34889. public const POST_INSTALL_CMD = 'post-install-cmd';
  34890. public const PRE_UPDATE_CMD = 'pre-update-cmd';
  34891. public const POST_UPDATE_CMD = 'post-update-cmd';
  34892. public const PRE_STATUS_CMD = 'pre-status-cmd';
  34893. public const POST_STATUS_CMD = 'post-status-cmd';
  34894. public const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  34895. public const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  34896. public const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  34897. public const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  34898. public const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  34899. public const POST_ARCHIVE_CMD = 'post-archive-cmd';
  34900. }
  34901. <?php declare(strict_types=1);
  34902. namespace Composer\SelfUpdate;
  34903. use Composer\Pcre\Preg;
  34904. class Keys
  34905. {
  34906. public static function fingerprint(string $path): string
  34907. {
  34908. $hash = strtoupper(hash('sha256', Preg::replace('{\s}', '', file_get_contents($path))));
  34909. return implode(' ', [
  34910. substr($hash, 0, 8),
  34911. substr($hash, 8, 8),
  34912. substr($hash, 16, 8),
  34913. substr($hash, 24, 8),
  34914. '',
  34915. substr($hash, 32, 8),
  34916. substr($hash, 40, 8),
  34917. substr($hash, 48, 8),
  34918. substr($hash, 56, 8),
  34919. ]);
  34920. }
  34921. }
  34922. <?php declare(strict_types=1);
  34923. namespace Composer\SelfUpdate;
  34924. use Composer\IO\IOInterface;
  34925. use Composer\Pcre\Preg;
  34926. use Composer\Util\HttpDownloader;
  34927. use Composer\Config;
  34928. class Versions
  34929. {
  34930. public static $channels = self::CHANNELS;
  34931. public const CHANNELS = ['stable', 'preview', 'snapshot', '1', '2', '2.2'];
  34932. private $httpDownloader;
  34933. private $config;
  34934. private $channel;
  34935. private $versionsData = null;
  34936. public function __construct(Config $config, HttpDownloader $httpDownloader)
  34937. {
  34938. $this->httpDownloader = $httpDownloader;
  34939. $this->config = $config;
  34940. }
  34941. public function getChannel(): string
  34942. {
  34943. if ($this->channel) {
  34944. return $this->channel;
  34945. }
  34946. $channelFile = $this->config->get('home').'/update-channel';
  34947. if (file_exists($channelFile)) {
  34948. $channel = trim(file_get_contents($channelFile));
  34949. if (in_array($channel, ['stable', 'preview', 'snapshot', '2.2'], true)) {
  34950. return $this->channel = $channel;
  34951. }
  34952. }
  34953. return $this->channel = 'stable';
  34954. }
  34955. public function setChannel(string $channel, ?IOInterface $io = null): void
  34956. {
  34957. if (!in_array($channel, self::CHANNELS, true)) {
  34958. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::CHANNELS));
  34959. }
  34960. $channelFile = $this->config->get('home').'/update-channel';
  34961. $this->channel = $channel;
  34962. $storedChannel = Preg::isMatch('{^\d+$}D', $channel) ? 'stable' : $channel;
  34963. $previouslyStored = file_exists($channelFile) ? trim((string) file_get_contents($channelFile)) : null;
  34964. file_put_contents($channelFile, $storedChannel.PHP_EOL);
  34965. if ($io !== null && $previouslyStored !== $storedChannel) {
  34966. $io->writeError('Storing "<info>'.$storedChannel.'</info>" as default update channel for the next self-update run.');
  34967. }
  34968. }
  34969. public function getLatest(?string $channel = null): array
  34970. {
  34971. $versions = $this->getVersionsData();
  34972. foreach ($versions[$channel ?: $this->getChannel()] as $version) {
  34973. if ($version['min-php'] <= \PHP_VERSION_ID) {
  34974. return $version;
  34975. }
  34976. }
  34977. throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  34978. }
  34979. private function getVersionsData(): array
  34980. {
  34981. if (null === $this->versionsData) {
  34982. if ($this->config->get('disable-tls') === true) {
  34983. $protocol = 'http';
  34984. } else {
  34985. $protocol = 'https';
  34986. }
  34987. $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
  34988. }
  34989. return $this->versionsData;
  34990. }
  34991. }
  34992. <?php declare(strict_types=1);
  34993. namespace Composer\Util;
  34994. use Composer\Config;
  34995. use Composer\IO\IOInterface;
  34996. use Composer\Downloader\TransportException;
  34997. use Composer\Pcre\Preg;
  34998. class AuthHelper
  34999. {
  35000. protected $io;
  35001. protected $config;
  35002. private $displayedOriginAuthentications = [];
  35003. private $bitbucketRetry = [];
  35004. public function __construct(IOInterface $io, Config $config)
  35005. {
  35006. $this->io = $io;
  35007. $this->config = $config;
  35008. }
  35009. public function storeAuth(string $origin, $storeAuth): void
  35010. {
  35011. $store = false;
  35012. $configSource = $this->config->getAuthConfigSource();
  35013. if ($storeAuth === true) {
  35014. $store = $configSource;
  35015. } elseif ($storeAuth === 'prompt') {
  35016. $answer = $this->io->askAndValidate(
  35017. 'Do you want to store credentials for '.$origin.' in '.$configSource->getName().' ? [Yn] ',
  35018. static function ($value): string {
  35019. $input = strtolower(substr(trim($value), 0, 1));
  35020. if (in_array($input, ['y','n'])) {
  35021. return $input;
  35022. }
  35023. throw new \RuntimeException('Please answer (y)es or (n)o');
  35024. },
  35025. null,
  35026. 'y'
  35027. );
  35028. if ($answer === 'y') {
  35029. $store = $configSource;
  35030. }
  35031. }
  35032. if ($store) {
  35033. $store->addConfigSetting(
  35034. 'http-basic.'.$origin,
  35035. $this->io->getAuthentication($origin)
  35036. );
  35037. }
  35038. }
  35039. public function promptAuthIfNeeded(string $url, string $origin, int $statusCode, ?string $reason = null, array $headers = [], int $retryCount = 0): array
  35040. {
  35041. $storeAuth = false;
  35042. if (in_array($origin, $this->config->get('github-domains'), true)) {
  35043. $gitHubUtil = new GitHub($this->io, $this->config, null);
  35044. $message = "\n";
  35045. $rateLimited = $gitHubUtil->isRateLimited($headers);
  35046. $requiresSso = $gitHubUtil->requiresSso($headers);
  35047. if ($requiresSso) {
  35048. $ssoUrl = $gitHubUtil->getSsoUrl($headers);
  35049. $message = 'GitHub API token requires SSO authorization. Authorize this token at ' . $ssoUrl . "\n";
  35050. $this->io->writeError($message);
  35051. if (!$this->io->isInteractive()) {
  35052. throw new TransportException('Could not authenticate against ' . $origin, 403);
  35053. }
  35054. $this->io->ask('After authorizing your token, confirm that you would like to retry the request');
  35055. return ['retry' => true, 'storeAuth' => $storeAuth];
  35056. }
  35057. if ($rateLimited) {
  35058. $rateLimit = $gitHubUtil->getRateLimit($headers);
  35059. if ($this->io->hasAuthentication($origin)) {
  35060. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  35061. } else {
  35062. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  35063. }
  35064. $message = sprintf(
  35065. '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.',
  35066. $rateLimit['limit'],
  35067. $rateLimit['reset']
  35068. )."\n";
  35069. } else {
  35070. $message .= 'Could not fetch '.$url.', please ';
  35071. if ($this->io->hasAuthentication($origin)) {
  35072. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  35073. } else {
  35074. $message .= 'create a GitHub OAuth token to access private repos';
  35075. }
  35076. }
  35077. if (!$gitHubUtil->authorizeOAuth($origin)
  35078. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($origin, $message))
  35079. ) {
  35080. throw new TransportException('Could not authenticate against '.$origin, 401);
  35081. }
  35082. } elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
  35083. $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
  35084. $gitLabUtil = new GitLab($this->io, $this->config, null);
  35085. $auth = null;
  35086. if ($this->io->hasAuthentication($origin)) {
  35087. $auth = $this->io->getAuthentication($origin);
  35088. if (in_array($auth['password'], ['gitlab-ci-token', 'private-token', 'oauth2'], true)) {
  35089. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  35090. }
  35091. }
  35092. if (!$gitLabUtil->authorizeOAuth($origin)
  35093. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively(parse_url($url, PHP_URL_SCHEME), $origin, $message))
  35094. ) {
  35095. throw new TransportException('Could not authenticate against '.$origin, 401);
  35096. }
  35097. if ($auth !== null && $this->io->hasAuthentication($origin)) {
  35098. if ($auth === $this->io->getAuthentication($origin)) {
  35099. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  35100. }
  35101. }
  35102. } elseif ($origin === 'bitbucket.org' || $origin === 'api.bitbucket.org') {
  35103. $askForOAuthToken = true;
  35104. $origin = 'bitbucket.org';
  35105. if ($this->io->hasAuthentication($origin)) {
  35106. $auth = $this->io->getAuthentication($origin);
  35107. if ($auth['username'] !== 'x-token-auth') {
  35108. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  35109. $accessToken = $bitbucketUtil->requestToken($origin, $auth['username'], $auth['password']);
  35110. if (!empty($accessToken)) {
  35111. $this->io->setAuthentication($origin, 'x-token-auth', $accessToken);
  35112. $askForOAuthToken = false;
  35113. }
  35114. } elseif (!isset($this->bitbucketRetry[$url])) {
  35115. $askForOAuthToken = false;
  35116. $this->bitbucketRetry[$url] = true;
  35117. } else {
  35118. throw new TransportException('Could not authenticate against ' . $origin, 401);
  35119. }
  35120. }
  35121. if ($askForOAuthToken) {
  35122. $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');
  35123. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  35124. if (!$bitBucketUtil->authorizeOAuth($origin)
  35125. && (!$this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
  35126. ) {
  35127. throw new TransportException('Could not authenticate against ' . $origin, 401);
  35128. }
  35129. }
  35130. } else {
  35131. if ($statusCode === 404) {
  35132. return ['retry' => false, 'storeAuth' => false];
  35133. }
  35134. if (!$this->io->isInteractive()) {
  35135. if ($statusCode === 401) {
  35136. $message = "The '" . $url . "' URL required authentication (HTTP 401).\nYou must be using the interactive console to authenticate";
  35137. } elseif ($statusCode === 403) {
  35138. $message = "The '" . $url . "' URL could not be accessed (HTTP 403): " . $reason;
  35139. } else {
  35140. $message = "Unknown error code '" . $statusCode . "', reason: " . $reason;
  35141. }
  35142. throw new TransportException($message, $statusCode);
  35143. }
  35144. if ($this->io->hasAuthentication($origin)) {
  35145. if ($retryCount === 0) {
  35146. return ['retry' => true, 'storeAuth' => false];
  35147. }
  35148. throw new TransportException("Invalid credentials (HTTP $statusCode) for '$url', aborting.", $statusCode);
  35149. }
  35150. $this->io->writeError(' Authentication required (<info>'.$origin.'</info>):');
  35151. $username = $this->io->ask(' Username: ');
  35152. $password = $this->io->askAndHideAnswer(' Password: ');
  35153. $this->io->setAuthentication($origin, $username, $password);
  35154. $storeAuth = $this->config->get('store-auths');
  35155. }
  35156. return ['retry' => true, 'storeAuth' => $storeAuth];
  35157. }
  35158. public function addAuthenticationHeader(array $headers, string $origin, string $url): array
  35159. {
  35160. if ($this->io->hasAuthentication($origin)) {
  35161. $authenticationDisplayMessage = null;
  35162. $auth = $this->io->getAuthentication($origin);
  35163. if ($auth['password'] === 'bearer') {
  35164. $headers[] = 'Authorization: Bearer '.$auth['username'];
  35165. } elseif ('github.com' === $origin && 'x-oauth-basic' === $auth['password']) {
  35166. if (Preg::isMatch('{^https?://api\.github\.com/}', $url)) {
  35167. $headers[] = 'Authorization: token '.$auth['username'];
  35168. $authenticationDisplayMessage = 'Using GitHub token authentication';
  35169. }
  35170. } elseif (
  35171. in_array($origin, $this->config->get('gitlab-domains'), true)
  35172. && in_array($auth['password'], ['oauth2', 'private-token', 'gitlab-ci-token'], true)
  35173. ) {
  35174. if ($auth['password'] === 'oauth2') {
  35175. $headers[] = 'Authorization: Bearer '.$auth['username'];
  35176. $authenticationDisplayMessage = 'Using GitLab OAuth token authentication';
  35177. } else {
  35178. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  35179. $authenticationDisplayMessage = 'Using GitLab private token authentication';
  35180. }
  35181. } elseif (
  35182. 'bitbucket.org' === $origin
  35183. && $url !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL
  35184. && 'x-token-auth' === $auth['username']
  35185. ) {
  35186. if (!$this->isPublicBitBucketDownload($url)) {
  35187. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  35188. $authenticationDisplayMessage = 'Using Bitbucket OAuth token authentication';
  35189. }
  35190. } else {
  35191. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  35192. $headers[] = 'Authorization: Basic '.$authStr;
  35193. $authenticationDisplayMessage = 'Using HTTP basic authentication with username "' . $auth['username'] . '"';
  35194. }
  35195. if ($authenticationDisplayMessage && (!isset($this->displayedOriginAuthentications[$origin]) || $this->displayedOriginAuthentications[$origin] !== $authenticationDisplayMessage)) {
  35196. $this->io->writeError($authenticationDisplayMessage, true, IOInterface::DEBUG);
  35197. $this->displayedOriginAuthentications[$origin] = $authenticationDisplayMessage;
  35198. }
  35199. } elseif (in_array($origin, ['api.bitbucket.org', 'api.github.com'], true)) {
  35200. return $this->addAuthenticationHeader($headers, str_replace('api.', '', $origin), $url);
  35201. }
  35202. return $headers;
  35203. }
  35204. public function isPublicBitBucketDownload(string $urlToBitBucketFile): bool
  35205. {
  35206. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  35207. if (strpos($domain, 'bitbucket.org') === false) {
  35208. return true;
  35209. }
  35210. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  35211. $pathParts = explode('/', $path);
  35212. return count($pathParts) >= 4 && $pathParts[3] === 'downloads';
  35213. }
  35214. }
  35215. <?php declare(strict_types=1);
  35216. namespace Composer\Util;
  35217. use Composer\Factory;
  35218. use Composer\IO\IOInterface;
  35219. use Composer\Config;
  35220. use Composer\Downloader\TransportException;
  35221. class Bitbucket
  35222. {
  35223. private $io;
  35224. private $config;
  35225. private $process;
  35226. private $httpDownloader;
  35227. private $token = null;
  35228. private $time;
  35229. public const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  35230. public function __construct(IOInterface $io, Config $config, ?ProcessExecutor $process = null, ?HttpDownloader $httpDownloader = null, ?int $time = null)
  35231. {
  35232. $this->io = $io;
  35233. $this->config = $config;
  35234. $this->process = $process ?: new ProcessExecutor($io);
  35235. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  35236. $this->time = $time;
  35237. }
  35238. public function getToken(): string
  35239. {
  35240. if (!isset($this->token['access_token'])) {
  35241. return '';
  35242. }
  35243. return $this->token['access_token'];
  35244. }
  35245. public function authorizeOAuth(string $originUrl): bool
  35246. {
  35247. if ($originUrl !== 'bitbucket.org') {
  35248. return false;
  35249. }
  35250. if (0 === $this->process->execute(['git', 'config', 'bitbucket.accesstoken'], $output)) {
  35251. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  35252. return true;
  35253. }
  35254. return false;
  35255. }
  35256. private function requestAccessToken(): bool
  35257. {
  35258. try {
  35259. $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, [
  35260. 'retry-auth-failure' => false,
  35261. 'http' => [
  35262. 'method' => 'POST',
  35263. 'content' => 'grant_type=client_credentials',
  35264. ],
  35265. ]);
  35266. $token = $response->decodeJson();
  35267. if (!isset($token['expires_in']) || !isset($token['access_token'])) {
  35268. throw new \LogicException('Expected a token configured with expires_in and access_token present, got '.json_encode($token));
  35269. }
  35270. $this->token = $token;
  35271. } catch (TransportException $e) {
  35272. if ($e->getCode() === 400) {
  35273. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  35274. $this->io->writeError('This can have three reasons:');
  35275. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  35276. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  35277. $this->io->writeError('3. You are using an OAuth consumer, but didn\'t configure it as private consumer');
  35278. return false;
  35279. }
  35280. if (in_array($e->getCode(), [403, 401])) {
  35281. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  35282. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  35283. return false;
  35284. }
  35285. throw $e;
  35286. }
  35287. return true;
  35288. }
  35289. public function authorizeOAuthInteractively(string $originUrl, ?string $message = null): bool
  35290. {
  35291. if ($message) {
  35292. $this->io->writeError($message);
  35293. }
  35294. $localAuthConfig = $this->config->getLocalAuthConfigSource();
  35295. $url = 'https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/';
  35296. $this->io->writeError('Follow the instructions here:');
  35297. $this->io->writeError($url);
  35298. $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()));
  35299. $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)');
  35300. $storeInLocalAuthConfig = false;
  35301. if ($localAuthConfig !== null) {
  35302. $storeInLocalAuthConfig = $this->io->askConfirmation('A local auth config source was found, do you want to store the token there?', true);
  35303. }
  35304. $consumerKey = trim((string) $this->io->askAndHideAnswer('Consumer Key (hidden): '));
  35305. if (!$consumerKey) {
  35306. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  35307. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  35308. return false;
  35309. }
  35310. $consumerSecret = trim((string) $this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  35311. if (!$consumerSecret) {
  35312. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  35313. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  35314. return false;
  35315. }
  35316. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  35317. if (!$this->requestAccessToken()) {
  35318. return false;
  35319. }
  35320. $authConfigSource = $storeInLocalAuthConfig && $localAuthConfig !== null ? $localAuthConfig : $this->config->getAuthConfigSource();
  35321. $this->storeInAuthConfig($authConfigSource, $originUrl, $consumerKey, $consumerSecret);
  35322. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  35323. $this->io->writeError('<info>Consumer stored successfully.</info>');
  35324. return true;
  35325. }
  35326. public function requestToken(string $originUrl, string $consumerKey, string $consumerSecret): string
  35327. {
  35328. if ($this->token !== null || $this->getTokenFromConfig($originUrl)) {
  35329. return $this->token['access_token'];
  35330. }
  35331. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  35332. if (!$this->requestAccessToken()) {
  35333. return '';
  35334. }
  35335. $this->storeInAuthConfig($this->config->getLocalAuthConfigSource() ?? $this->config->getAuthConfigSource(), $originUrl, $consumerKey, $consumerSecret);
  35336. if (!isset($this->token['access_token'])) {
  35337. throw new \LogicException('Failed to initialize token above');
  35338. }
  35339. return $this->token['access_token'];
  35340. }
  35341. private function storeInAuthConfig(Config\ConfigSourceInterface $authConfigSource, string $originUrl, string $consumerKey, string $consumerSecret): void
  35342. {
  35343. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  35344. if (null === $this->token || !isset($this->token['expires_in'])) {
  35345. throw new \LogicException('Expected a token configured with expires_in present, got '.json_encode($this->token));
  35346. }
  35347. $time = null === $this->time ? time() : $this->time;
  35348. $consumer = [
  35349. "consumer-key" => $consumerKey,
  35350. "consumer-secret" => $consumerSecret,
  35351. "access-token" => $this->token['access_token'],
  35352. "access-token-expiration" => $time + $this->token['expires_in'],
  35353. ];
  35354. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  35355. }
  35356. private function getTokenFromConfig(string $originUrl): bool
  35357. {
  35358. $authConfig = $this->config->get('bitbucket-oauth');
  35359. if (
  35360. !isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
  35361. || time() > $authConfig[$originUrl]['access-token-expiration']
  35362. ) {
  35363. return false;
  35364. }
  35365. $this->token = [
  35366. 'access_token' => $authConfig[$originUrl]['access-token'],
  35367. ];
  35368. return true;
  35369. }
  35370. }
  35371. <?php declare(strict_types=1);
  35372. namespace Composer\Util;
  35373. use Composer\Pcre\Preg;
  35374. class ComposerMirror
  35375. {
  35376. public static function processUrl(string $mirrorUrl, string $packageName, string $version, ?string $reference, ?string $type, ?string $prettyVersion = null): string
  35377. {
  35378. if ($reference) {
  35379. $reference = Preg::isMatch('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : hash('md5', $reference);
  35380. }
  35381. $version = strpos($version, '/') === false ? $version : hash('md5', $version);
  35382. $from = ['%package%', '%version%', '%reference%', '%type%'];
  35383. $to = [$packageName, $version, $reference, $type];
  35384. if (null !== $prettyVersion) {
  35385. $from[] = '%prettyVersion%';
  35386. $to[] = $prettyVersion;
  35387. }
  35388. $url = str_replace($from, $to, $mirrorUrl);
  35389. assert($url !== '');
  35390. return $url;
  35391. }
  35392. public static function processGitUrl(string $mirrorUrl, string $packageName, string $url, ?string $type): string
  35393. {
  35394. if (Preg::isMatch('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  35395. $url = 'gh-'.$match[1].'/'.$match[2];
  35396. } elseif (Preg::isMatch('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  35397. $url = 'bb-'.$match[1].'/'.$match[2];
  35398. } else {
  35399. $url = Preg::replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  35400. }
  35401. return str_replace(
  35402. ['%package%', '%normalizedUrl%', '%type%'],
  35403. [$packageName, $url, $type],
  35404. $mirrorUrl
  35405. );
  35406. }
  35407. public static function processHgUrl(string $mirrorUrl, string $packageName, string $url, string $type): string
  35408. {
  35409. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  35410. }
  35411. }
  35412. <?php declare(strict_types=1);
  35413. namespace Composer\Util;
  35414. use Composer\Package\Loader\ArrayLoader;
  35415. use Composer\Package\Loader\ValidatingArrayLoader;
  35416. use Composer\Package\Loader\InvalidPackageException;
  35417. use Composer\Json\JsonValidationException;
  35418. use Composer\IO\IOInterface;
  35419. use Composer\Json\JsonFile;
  35420. use Composer\Pcre\Preg;
  35421. use Composer\Spdx\SpdxLicenses;
  35422. use Seld\JsonLint\DuplicateKeyException;
  35423. use Seld\JsonLint\JsonParser;
  35424. class ConfigValidator
  35425. {
  35426. public const CHECK_VERSION = 1;
  35427. private $io;
  35428. public function __construct(IOInterface $io)
  35429. {
  35430. $this->io = $io;
  35431. }
  35432. public function validate(string $file, int $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, int $flags = self::CHECK_VERSION): array
  35433. {
  35434. $errors = [];
  35435. $publishErrors = [];
  35436. $warnings = [];
  35437. $laxValid = false;
  35438. $manifest = null;
  35439. try {
  35440. $json = new JsonFile($file, null, $this->io);
  35441. $manifest = $json->read();
  35442. $json->validateSchema(JsonFile::LAX_SCHEMA);
  35443. $laxValid = true;
  35444. $json->validateSchema();
  35445. } catch (JsonValidationException $e) {
  35446. foreach ($e->getErrors() as $message) {
  35447. if ($laxValid) {
  35448. $publishErrors[] = $message;
  35449. } else {
  35450. $errors[] = $message;
  35451. }
  35452. }
  35453. } catch (\Exception $e) {
  35454. $errors[] = $e->getMessage();
  35455. return [$errors, $publishErrors, $warnings];
  35456. }
  35457. if (is_array($manifest)) {
  35458. $jsonParser = new JsonParser();
  35459. try {
  35460. $jsonParser->parse((string) file_get_contents($file), JsonParser::DETECT_KEY_CONFLICTS);
  35461. } catch (DuplicateKeyException $e) {
  35462. $details = $e->getDetails();
  35463. $warnings[] = 'Key '.$details['key'].' is a duplicate in '.$file.' at line '.$details['line'];
  35464. }
  35465. }
  35466. if (empty($manifest['license'])) {
  35467. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  35468. } else {
  35469. $licenses = (array) $manifest['license'];
  35470. foreach ($licenses as $key => $license) {
  35471. if ('proprietary' === $license) {
  35472. unset($licenses[$key]);
  35473. }
  35474. }
  35475. $licenseValidator = new SpdxLicenses();
  35476. foreach ($licenses as $license) {
  35477. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  35478. if ($spdxLicense && $spdxLicense[3]) {
  35479. if (Preg::isMatch('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  35480. $warnings[] = sprintf(
  35481. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  35482. $license
  35483. );
  35484. } elseif (Preg::isMatch('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  35485. $warnings[] = sprintf(
  35486. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  35487. $license
  35488. );
  35489. } else {
  35490. $warnings[] = sprintf(
  35491. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  35492. $license
  35493. );
  35494. }
  35495. }
  35496. }
  35497. }
  35498. if (($flags & self::CHECK_VERSION) && isset($manifest['version'])) {
  35499. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  35500. }
  35501. if (!empty($manifest['name']) && Preg::isMatch('{[A-Z]}', $manifest['name'])) {
  35502. $suggestName = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  35503. $suggestName = strtolower($suggestName);
  35504. $publishErrors[] = sprintf(
  35505. '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.',
  35506. $manifest['name'],
  35507. $suggestName
  35508. );
  35509. }
  35510. if (!empty($manifest['type']) && $manifest['type'] === 'composer-installer') {
  35511. $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.";
  35512. }
  35513. if (isset($manifest['require'], $manifest['require-dev'])) {
  35514. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  35515. if (!empty($requireOverrides)) {
  35516. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  35517. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  35518. }
  35519. }
  35520. foreach (['provide', 'replace'] as $linkType) {
  35521. if (isset($manifest[$linkType])) {
  35522. foreach (['require', 'require-dev'] as $requireType) {
  35523. if (isset($manifest[$requireType])) {
  35524. foreach ($manifest[$linkType] as $provide => $constraint) {
  35525. if (isset($manifest[$requireType][$provide])) {
  35526. $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.';
  35527. }
  35528. }
  35529. }
  35530. }
  35531. }
  35532. }
  35533. $require = $manifest['require'] ?? [];
  35534. $requireDev = $manifest['require-dev'] ?? [];
  35535. $packages = array_merge($require, $requireDev);
  35536. foreach ($packages as $package => $version) {
  35537. if (Preg::isMatch('/#/', $version)) {
  35538. $warnings[] = sprintf(
  35539. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  35540. $package
  35541. );
  35542. }
  35543. }
  35544. $scriptsDescriptions = $manifest['scripts-descriptions'] ?? [];
  35545. $scripts = $manifest['scripts'] ?? [];
  35546. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  35547. if (!array_key_exists($scriptName, $scripts)) {
  35548. $warnings[] = sprintf(
  35549. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  35550. $scriptName
  35551. );
  35552. }
  35553. }
  35554. $scriptAliases = $manifest['scripts-aliases'] ?? [];
  35555. foreach ($scriptAliases as $scriptName => $scriptAlias) {
  35556. if (!array_key_exists($scriptName, $scripts)) {
  35557. $warnings[] = sprintf(
  35558. 'Aliases for non-existent script "%s" found in "scripts-aliases"',
  35559. $scriptName
  35560. );
  35561. }
  35562. }
  35563. if (isset($manifest['autoload']['psr-0'][''])) {
  35564. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  35565. }
  35566. if (isset($manifest['autoload']['psr-4'][''])) {
  35567. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  35568. }
  35569. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  35570. try {
  35571. if (!isset($manifest['version'])) {
  35572. $manifest['version'] = '1.0.0';
  35573. }
  35574. if (!isset($manifest['name'])) {
  35575. $manifest['name'] = 'dummy/dummy';
  35576. }
  35577. $loader->load($manifest);
  35578. } catch (InvalidPackageException $e) {
  35579. $errors = array_merge($errors, $e->getErrors());
  35580. }
  35581. $warnings = array_merge($warnings, $loader->getWarnings());
  35582. return [$errors, $publishErrors, $warnings];
  35583. }
  35584. }
  35585. <?php declare(strict_types=1);
  35586. namespace Composer\Util;
  35587. use Composer\IO\IOInterface;
  35588. class ErrorHandler
  35589. {
  35590. private static $io;
  35591. private static $hasShownDeprecationNotice = 0;
  35592. public static function handle(int $level, string $message, string $file, int $line): bool
  35593. {
  35594. $isDeprecationNotice = $level === E_DEPRECATED || $level === E_USER_DEPRECATED;
  35595. if (!$isDeprecationNotice && 0 === (error_reporting() & $level)) {
  35596. return true;
  35597. }
  35598. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  35599. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  35600. "\na legitimately suppressed error that you were not supposed to see.";
  35601. }
  35602. if (!$isDeprecationNotice) {
  35603. if (in_array($level, [E_WARNING, E_USER_WARNING], true) && str_contains($message, 'should either be used or intentionally ignored by casting it as (void)')) {
  35604. self::outputWarning('Ignored new PHP warning but it should be reported and fixed: '.$message.' in '.$file.':'.$line, true);
  35605. return true;
  35606. }
  35607. throw new \ErrorException($message, 0, $level, $file, $line);
  35608. }
  35609. if (self::$io !== null) {
  35610. if (self::$hasShownDeprecationNotice > 0 && !self::$io->isVerbose()) {
  35611. if (self::$hasShownDeprecationNotice === 1) {
  35612. self::$io->writeError('<warning>More deprecation notices were hidden, run again with `-v` to show them.</warning>');
  35613. self::$hasShownDeprecationNotice = 2;
  35614. }
  35615. return true;
  35616. }
  35617. self::$hasShownDeprecationNotice = 1;
  35618. self::outputWarning('Deprecation Notice: '.$message.' in '.$file.':'.$line);
  35619. }
  35620. return true;
  35621. }
  35622. public static function register(?IOInterface $io = null): void
  35623. {
  35624. set_error_handler([__CLASS__, 'handle']);
  35625. error_reporting(E_ALL);
  35626. self::$io = $io;
  35627. }
  35628. private static function outputWarning(string $message, bool $outputEvenWithoutIO = false): void
  35629. {
  35630. if (self::$io !== null) {
  35631. self::$io->writeError('<warning>'.$message.'</warning>');
  35632. if (self::$io->isVerbose()) {
  35633. self::$io->writeError('<warning>Stack trace:</warning>');
  35634. self::$io->writeError(array_filter(array_map(static function ($a): ?string {
  35635. if (isset($a['line'], $a['file'])) {
  35636. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  35637. }
  35638. return null;
  35639. }, array_slice(debug_backtrace(), 2)), function (?string $line) {
  35640. return $line !== null;
  35641. }));
  35642. }
  35643. return;
  35644. }
  35645. if ($outputEvenWithoutIO) {
  35646. if (defined('STDERR') && is_resource(STDERR)) {
  35647. fwrite(STDERR, 'Warning: '.$message.PHP_EOL);
  35648. } else {
  35649. echo 'Warning: '.$message.PHP_EOL;
  35650. }
  35651. }
  35652. }
  35653. }
  35654. <?php declare(strict_types=1);
  35655. namespace Composer\Util;
  35656. use Composer\Pcre\Preg;
  35657. use ErrorException;
  35658. use React\Promise\PromiseInterface;
  35659. use RecursiveDirectoryIterator;
  35660. use RecursiveIteratorIterator;
  35661. use Symfony\Component\Filesystem\Exception\IOException;
  35662. use Symfony\Component\Finder\Finder;
  35663. class Filesystem
  35664. {
  35665. private $processExecutor;
  35666. public function __construct(?ProcessExecutor $executor = null)
  35667. {
  35668. $this->processExecutor = $executor;
  35669. }
  35670. public function remove(string $file)
  35671. {
  35672. if (is_dir($file)) {
  35673. return $this->removeDirectory($file);
  35674. }
  35675. if (file_exists($file)) {
  35676. return $this->unlink($file);
  35677. }
  35678. return false;
  35679. }
  35680. public function isDirEmpty(string $dir)
  35681. {
  35682. $finder = Finder::create()
  35683. ->ignoreVCS(false)
  35684. ->ignoreDotFiles(false)
  35685. ->depth(0)
  35686. ->in($dir);
  35687. return \count($finder) === 0;
  35688. }
  35689. public function emptyDirectory(string $dir, bool $ensureDirectoryExists = true)
  35690. {
  35691. if (is_link($dir) && file_exists($dir)) {
  35692. $this->unlink($dir);
  35693. }
  35694. if ($ensureDirectoryExists) {
  35695. $this->ensureDirectoryExists($dir);
  35696. }
  35697. if (is_dir($dir)) {
  35698. $finder = Finder::create()
  35699. ->ignoreVCS(false)
  35700. ->ignoreDotFiles(false)
  35701. ->depth(0)
  35702. ->in($dir);
  35703. foreach ($finder as $path) {
  35704. $this->remove((string) $path);
  35705. }
  35706. }
  35707. }
  35708. public function removeDirectory(string $directory)
  35709. {
  35710. $edgeCaseResult = $this->removeEdgeCases($directory);
  35711. if ($edgeCaseResult !== null) {
  35712. return $edgeCaseResult;
  35713. }
  35714. if (Platform::isWindows()) {
  35715. $cmd = ['rmdir', '/S', '/Q', Platform::realpath($directory)];
  35716. } else {
  35717. $cmd = ['rm', '-rf', $directory];
  35718. }
  35719. $result = $this->getProcess()->execute($cmd, $output) === 0;
  35720. clearstatcache();
  35721. if ($result && !is_dir($directory)) {
  35722. return true;
  35723. }
  35724. return $this->removeDirectoryPhp($directory);
  35725. }
  35726. public function removeDirectoryAsync(string $directory)
  35727. {
  35728. $edgeCaseResult = $this->removeEdgeCases($directory);
  35729. if ($edgeCaseResult !== null) {
  35730. return \React\Promise\resolve($edgeCaseResult);
  35731. }
  35732. if (Platform::isWindows()) {
  35733. $cmd = ['rmdir', '/S', '/Q', Platform::realpath($directory)];
  35734. } else {
  35735. $cmd = ['rm', '-rf', $directory];
  35736. }
  35737. $promise = $this->getProcess()->executeAsync($cmd);
  35738. return $promise->then(function ($process) use ($directory) {
  35739. clearstatcache();
  35740. if ($process->isSuccessful()) {
  35741. if (!is_dir($directory)) {
  35742. return \React\Promise\resolve(true);
  35743. }
  35744. }
  35745. return \React\Promise\resolve($this->removeDirectoryPhp($directory));
  35746. });
  35747. }
  35748. private function removeEdgeCases(string $directory, bool $fallbackToPhp = true): ?bool
  35749. {
  35750. if ($this->isSymlinkedDirectory($directory)) {
  35751. return $this->unlinkSymlinkedDirectory($directory);
  35752. }
  35753. if ($this->isJunction($directory)) {
  35754. return $this->removeJunction($directory);
  35755. }
  35756. if (is_link($directory)) {
  35757. return unlink($directory);
  35758. }
  35759. if (!is_dir($directory) || !file_exists($directory)) {
  35760. return true;
  35761. }
  35762. if (Preg::isMatch('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  35763. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  35764. }
  35765. if (!\function_exists('proc_open') && $fallbackToPhp) {
  35766. return $this->removeDirectoryPhp($directory);
  35767. }
  35768. return null;
  35769. }
  35770. public function removeDirectoryPhp(string $directory)
  35771. {
  35772. $edgeCaseResult = $this->removeEdgeCases($directory, false);
  35773. if ($edgeCaseResult !== null) {
  35774. return $edgeCaseResult;
  35775. }
  35776. try {
  35777. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  35778. } catch (\UnexpectedValueException $e) {
  35779. clearstatcache();
  35780. usleep(100000);
  35781. if (!is_dir($directory)) {
  35782. return true;
  35783. }
  35784. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  35785. }
  35786. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  35787. foreach ($ri as $file) {
  35788. if ($file->isDir()) {
  35789. $this->rmdir($file->getPathname());
  35790. } else {
  35791. $this->unlink($file->getPathname());
  35792. }
  35793. }
  35794. unset($ri, $it, $file);
  35795. return $this->rmdir($directory);
  35796. }
  35797. public function ensureDirectoryExists(string $directory)
  35798. {
  35799. if (!is_dir($directory)) {
  35800. if (file_exists($directory)) {
  35801. throw new \RuntimeException(
  35802. $directory.' exists and is not a directory.'
  35803. );
  35804. }
  35805. if (is_link($directory) && !@$this->unlinkImplementation($directory)) {
  35806. throw new \RuntimeException('Could not delete symbolic link '.$directory.': '.(error_get_last()['message'] ?? ''));
  35807. }
  35808. if (!@mkdir($directory, 0777, true)) {
  35809. $e = new \RuntimeException($directory.' does not exist and could not be created: '.(error_get_last()['message'] ?? ''));
  35810. $normalized = $this->normalizePath($directory);
  35811. if ($normalized !== $directory) {
  35812. try {
  35813. $this->ensureDirectoryExists($normalized);
  35814. return;
  35815. } catch (\Throwable $ignoredEx) {}
  35816. }
  35817. throw $e;
  35818. }
  35819. }
  35820. }
  35821. public function unlink(string $path)
  35822. {
  35823. $unlinked = @$this->unlinkImplementation($path);
  35824. if (!$unlinked) {
  35825. if (Platform::isWindows()) {
  35826. usleep(350000);
  35827. $unlinked = @$this->unlinkImplementation($path);
  35828. }
  35829. if (!$unlinked) {
  35830. $error = error_get_last();
  35831. $message = 'Could not delete '.$path.': ' . ($error['message'] ?? '');
  35832. if (Platform::isWindows()) {
  35833. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  35834. }
  35835. throw new \RuntimeException($message);
  35836. }
  35837. }
  35838. return true;
  35839. }
  35840. public function rmdir(string $path)
  35841. {
  35842. $deleted = @rmdir($path);
  35843. if (!$deleted) {
  35844. if (Platform::isWindows()) {
  35845. usleep(350000);
  35846. $deleted = @rmdir($path);
  35847. }
  35848. if (!$deleted) {
  35849. $error = error_get_last();
  35850. $message = 'Could not delete '.$path.': ' . ($error['message'] ?? '');
  35851. if (Platform::isWindows()) {
  35852. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  35853. }
  35854. throw new \RuntimeException($message);
  35855. }
  35856. }
  35857. return true;
  35858. }
  35859. public function copyThenRemove(string $source, string $target)
  35860. {
  35861. $this->copy($source, $target);
  35862. if (!is_dir($source)) {
  35863. $this->unlink($source);
  35864. return;
  35865. }
  35866. $this->removeDirectoryPhp($source);
  35867. }
  35868. public function copy(string $source, string $target)
  35869. {
  35870. $target = $this->normalizePath($target);
  35871. if (!is_dir($source)) {
  35872. try {
  35873. return copy($source, $target);
  35874. } catch (ErrorException $e) {
  35875. if (str_contains($e->getMessage(), 'Bad address')) {
  35876. $sourceHandle = fopen($source, 'r');
  35877. $targetHandle = fopen($target, 'w');
  35878. if (false === $sourceHandle || false === $targetHandle) {
  35879. throw $e;
  35880. }
  35881. while (!feof($sourceHandle)) {
  35882. if (false === fwrite($targetHandle, (string) fread($sourceHandle, 1024 * 1024))) {
  35883. throw $e;
  35884. }
  35885. }
  35886. fclose($sourceHandle);
  35887. fclose($targetHandle);
  35888. return true;
  35889. }
  35890. throw $e;
  35891. }
  35892. }
  35893. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  35894. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  35895. $this->ensureDirectoryExists($target);
  35896. $result = true;
  35897. foreach ($ri as $file) {
  35898. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathname();
  35899. if ($file->isDir()) {
  35900. $this->ensureDirectoryExists($targetPath);
  35901. } else {
  35902. $result = $result && copy($file->getPathname(), $targetPath);
  35903. }
  35904. }
  35905. return $result;
  35906. }
  35907. public function rename(string $source, string $target)
  35908. {
  35909. if (true === @rename($source, $target)) {
  35910. return;
  35911. }
  35912. if (!\function_exists('proc_open')) {
  35913. $this->copyThenRemove($source, $target);
  35914. return;
  35915. }
  35916. if (Platform::isWindows()) {
  35917. $result = $this->getProcess()->execute(['xcopy', $source, $target, '/E', '/I', '/Q', '/Y'], $output);
  35918. clearstatcache();
  35919. if (0 === $result) {
  35920. $this->remove($source);
  35921. return;
  35922. }
  35923. } else {
  35924. $result = $this->getProcess()->execute(['mv', $source, $target], $output);
  35925. clearstatcache();
  35926. if (0 === $result) {
  35927. return;
  35928. }
  35929. }
  35930. $this->copyThenRemove($source, $target);
  35931. }
  35932. public function findShortestPath(string $from, string $to, bool $directories = false, bool $preferRelative = false)
  35933. {
  35934. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  35935. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  35936. }
  35937. $from = $this->normalizePath($from);
  35938. $to = $this->normalizePath($to);
  35939. if ($directories) {
  35940. $from = rtrim($from, '/') . '/dummy_file';
  35941. }
  35942. if (\dirname($from) === \dirname($to)) {
  35943. return './'.basename($to);
  35944. }
  35945. $commonPath = $to;
  35946. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !Preg::isMatch('{^[A-Z]:/?$}i', $commonPath)) {
  35947. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  35948. }
  35949. if (0 !== strpos($from, $commonPath)) {
  35950. return $to;
  35951. }
  35952. $commonPath = rtrim($commonPath, '/') . '/';
  35953. $sourcePathDepth = substr_count((string) substr($from, \strlen($commonPath)), '/');
  35954. $commonPathCode = str_repeat('../', $sourcePathDepth);
  35955. if (!$preferRelative && '/' === $commonPath && $sourcePathDepth > 1) {
  35956. return $to;
  35957. }
  35958. $result = $commonPathCode . substr($to, \strlen($commonPath));
  35959. if (\strlen($result) === 0) {
  35960. return './';
  35961. }
  35962. return $result;
  35963. }
  35964. public function findShortestPathCode(string $from, string $to, bool $directories = false, bool $staticCode = false, bool $preferRelative = false)
  35965. {
  35966. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  35967. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  35968. }
  35969. $from = $this->normalizePath($from);
  35970. $to = $this->normalizePath($to);
  35971. if ($from === $to) {
  35972. return $directories ? '__DIR__' : '__FILE__';
  35973. }
  35974. $commonPath = $to;
  35975. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !Preg::isMatch('{^[A-Z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  35976. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  35977. }
  35978. if (0 !== strpos($from, $commonPath) || '.' === $commonPath) {
  35979. return var_export($to, true);
  35980. }
  35981. $commonPath = rtrim($commonPath, '/') . '/';
  35982. if (str_starts_with($to, $from.'/')) {
  35983. return '__DIR__ . '.var_export((string) substr($to, \strlen($from)), true);
  35984. }
  35985. $sourcePathDepth = substr_count((string) substr($from, \strlen($commonPath)), '/') + (int) $directories;
  35986. if (!$preferRelative && '/' === $commonPath && $sourcePathDepth > 1) {
  35987. return var_export($to, true);
  35988. }
  35989. if ($staticCode) {
  35990. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  35991. } else {
  35992. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  35993. }
  35994. $relTarget = (string) substr($to, \strlen($commonPath));
  35995. return $commonPathCode . (\strlen($relTarget) > 0 ? '.' . var_export('/' . $relTarget, true) : '');
  35996. }
  35997. public function isAbsolutePath(string $path)
  35998. {
  35999. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  36000. }
  36001. public function size(string $path)
  36002. {
  36003. if (!file_exists($path)) {
  36004. throw new \RuntimeException("$path does not exist.");
  36005. }
  36006. if (is_dir($path)) {
  36007. return $this->directorySize($path);
  36008. }
  36009. return (int) filesize($path);
  36010. }
  36011. public function normalizePath(string $path)
  36012. {
  36013. $parts = [];
  36014. $path = strtr($path, '\\', '/');
  36015. $prefix = '';
  36016. $absolute = '';
  36017. if (strpos($path, '//') === 0 && \strlen($path) > 2) {
  36018. $absolute = '//';
  36019. $path = substr($path, 2);
  36020. }
  36021. if (Preg::isMatchStrictGroups('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  36022. $prefix = $match[1];
  36023. $path = substr($path, \strlen($prefix));
  36024. }
  36025. if (strpos($path, '/') === 0) {
  36026. $absolute = '/';
  36027. $path = substr($path, 1);
  36028. }
  36029. $up = false;
  36030. foreach (explode('/', $path) as $chunk) {
  36031. if ('..' === $chunk && (\strlen($absolute) > 0 || $up)) {
  36032. array_pop($parts);
  36033. $up = !(\count($parts) === 0 || '..' === end($parts));
  36034. } elseif ('.' !== $chunk && '' !== $chunk) {
  36035. $parts[] = $chunk;
  36036. $up = '..' !== $chunk;
  36037. }
  36038. }
  36039. $prefix = Preg::replaceCallback('{(^|://)[a-z]:$}i', static function (array $m) {
  36040. return strtoupper($m[0]);
  36041. }, $prefix);
  36042. return $prefix.$absolute.implode('/', $parts);
  36043. }
  36044. public static function trimTrailingSlash(string $path)
  36045. {
  36046. if (!Preg::isMatch('{^[/\\\\]+$}', $path)) {
  36047. $path = rtrim($path, '/\\');
  36048. }
  36049. return $path;
  36050. }
  36051. public static function isLocalPath(string $path)
  36052. {
  36053. if (Platform::isWindows()) {
  36054. return Preg::isMatch('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  36055. }
  36056. return Preg::isMatch('{^(file://|/|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  36057. }
  36058. public static function getPlatformPath(string $path)
  36059. {
  36060. if (Platform::isWindows()) {
  36061. $path = Preg::replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  36062. }
  36063. return Preg::replace('{^file://}i', '', $path);
  36064. }
  36065. public static function isReadable(string $path)
  36066. {
  36067. if (is_readable($path)) {
  36068. return true;
  36069. }
  36070. if (is_file($path)) {
  36071. return false !== Silencer::call('file_get_contents', $path, false, null, 0, 1);
  36072. }
  36073. if (is_dir($path)) {
  36074. return false !== Silencer::call('opendir', $path);
  36075. }
  36076. return false;
  36077. }
  36078. protected function directorySize(string $directory)
  36079. {
  36080. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  36081. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  36082. $size = 0;
  36083. foreach ($ri as $file) {
  36084. if ($file->isFile()) {
  36085. $size += $file->getSize();
  36086. }
  36087. }
  36088. return $size;
  36089. }
  36090. protected function getProcess()
  36091. {
  36092. if (null === $this->processExecutor) {
  36093. $this->processExecutor = new ProcessExecutor();
  36094. }
  36095. return $this->processExecutor;
  36096. }
  36097. private function unlinkImplementation(string $path): bool
  36098. {
  36099. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  36100. return rmdir($path);
  36101. }
  36102. return unlink($path);
  36103. }
  36104. public function relativeSymlink(string $target, string $link)
  36105. {
  36106. if (!function_exists('symlink')) {
  36107. return false;
  36108. }
  36109. $cwd = Platform::getCwd();
  36110. $relativePath = $this->findShortestPath($link, $target);
  36111. chdir(\dirname($link));
  36112. $result = @symlink($relativePath, $link);
  36113. chdir($cwd);
  36114. return $result;
  36115. }
  36116. public function isSymlinkedDirectory(string $directory)
  36117. {
  36118. if (!is_dir($directory)) {
  36119. return false;
  36120. }
  36121. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  36122. return is_link($resolved);
  36123. }
  36124. private function unlinkSymlinkedDirectory(string $directory): bool
  36125. {
  36126. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  36127. return $this->unlink($resolved);
  36128. }
  36129. private function resolveSymlinkedDirectorySymlink(string $pathname): string
  36130. {
  36131. if (!is_dir($pathname)) {
  36132. return $pathname;
  36133. }
  36134. $resolved = rtrim($pathname, '/');
  36135. if (0 === \strlen($resolved)) {
  36136. return $pathname;
  36137. }
  36138. return $resolved;
  36139. }
  36140. public function junction(string $target, string $junction)
  36141. {
  36142. if (!Platform::isWindows()) {
  36143. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  36144. }
  36145. if (!is_dir($target)) {
  36146. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  36147. }
  36148. if (!is_dir($junction) || $this->isJunction($junction)) {
  36149. @rmdir($junction);
  36150. }
  36151. $cmd = ['mklink', '/J', str_replace('/', DIRECTORY_SEPARATOR, $junction), Platform::realpath($target)];
  36152. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  36153. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  36154. }
  36155. clearstatcache(true, $junction);
  36156. }
  36157. public function isJunction(string $junction)
  36158. {
  36159. if (!Platform::isWindows()) {
  36160. return false;
  36161. }
  36162. clearstatcache(true, $junction);
  36163. if (!is_dir($junction) || is_link($junction)) {
  36164. return false;
  36165. }
  36166. $stat = lstat($junction);
  36167. return is_array($stat) ? 0x4000 !== ($stat['mode'] & 0xF000) : false;
  36168. }
  36169. public function removeJunction(string $junction)
  36170. {
  36171. if (!Platform::isWindows()) {
  36172. return false;
  36173. }
  36174. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  36175. if (!$this->isJunction($junction)) {
  36176. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  36177. }
  36178. return $this->rmdir($junction);
  36179. }
  36180. public function filePutContentsIfModified(string $path, string $content)
  36181. {
  36182. $currentContent = Silencer::call('file_get_contents', $path);
  36183. if (false === $currentContent || $currentContent !== $content) {
  36184. return file_put_contents($path, $content);
  36185. }
  36186. return 0;
  36187. }
  36188. public function safeCopy(string $source, string $target): void
  36189. {
  36190. if (!file_exists($target) || !file_exists($source) || !$this->filesAreEqual($source, $target)) {
  36191. $sourceHandle = fopen($source, 'r');
  36192. assert($sourceHandle !== false, 'Could not open "'.$source.'" for reading.');
  36193. $targetHandle = fopen($target, 'w+');
  36194. assert($targetHandle !== false, 'Could not open "'.$target.'" for writing.');
  36195. stream_copy_to_stream($sourceHandle, $targetHandle);
  36196. fclose($sourceHandle);
  36197. fclose($targetHandle);
  36198. touch($target, (int) filemtime($source), (int) fileatime($source));
  36199. }
  36200. }
  36201. private function filesAreEqual(string $a, string $b): bool
  36202. {
  36203. if (filesize($a) !== filesize($b)) {
  36204. return false;
  36205. }
  36206. $aHandle = fopen($a, 'rb');
  36207. assert($aHandle !== false, 'Could not open "'.$a.'" for reading.');
  36208. $bHandle = fopen($b, 'rb');
  36209. assert($bHandle !== false, 'Could not open "'.$b.'" for reading.');
  36210. $result = true;
  36211. while (!feof($aHandle)) {
  36212. if (fread($aHandle, 8192) !== fread($bHandle, 8192)) {
  36213. $result = false;
  36214. break;
  36215. }
  36216. }
  36217. fclose($aHandle);
  36218. fclose($bHandle);
  36219. return $result;
  36220. }
  36221. }
  36222. <?php declare(strict_types=1);
  36223. namespace Composer\Util;
  36224. use Composer\Config;
  36225. use Composer\IO\IOInterface;
  36226. use Composer\Pcre\Preg;
  36227. class Git
  36228. {
  36229. private static $version = false;
  36230. protected $io;
  36231. protected $config;
  36232. protected $process;
  36233. protected $filesystem;
  36234. protected $httpDownloader;
  36235. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  36236. {
  36237. $this->io = $io;
  36238. $this->config = $config;
  36239. $this->process = $process;
  36240. $this->filesystem = $fs;
  36241. }
  36242. public static function checkForRepoOwnershipError(string $output, string $path, ?IOInterface $io = null): void
  36243. {
  36244. if (str_contains($output, 'fatal: detected dubious ownership')) {
  36245. $msg = 'The repository at "' . $path . '" does not have the correct ownership and git refuses to use it:' . PHP_EOL . PHP_EOL . $output;
  36246. if ($io === null) {
  36247. throw new \RuntimeException($msg);
  36248. }
  36249. $io->writeError('<warning>'.$msg.'</warning>');
  36250. }
  36251. }
  36252. public function setHttpDownloader(HttpDownloader $httpDownloader): void
  36253. {
  36254. $this->httpDownloader = $httpDownloader;
  36255. }
  36256. public function runCommands(array $commands, string $url, ?string $cwd, bool $initialClone = false, &$commandOutput = null): void
  36257. {
  36258. $callables = [];
  36259. foreach ($commands as $cmd) {
  36260. $callables[] = static function (string $url) use ($cmd): array {
  36261. $map = [
  36262. '%url%' => $url,
  36263. '%sanitizedUrl%' => Preg::replace('{://([^@]+?):(.+?)@}', '://', $url),
  36264. ];
  36265. return array_map(static function ($value) use ($map): string {
  36266. return $map[$value] ?? $value;
  36267. }, $cmd);
  36268. };
  36269. }
  36270. $this->runCommand($callables, $url, $cwd, $initialClone, $commandOutput);
  36271. }
  36272. public function runCommand($commandCallable, string $url, ?string $cwd, bool $initialClone = false, &$commandOutput = null): void
  36273. {
  36274. $commandCallables = is_callable($commandCallable) ? [$commandCallable] : $commandCallable;
  36275. $lastCommand = '';
  36276. $this->config->prohibitUrlByConfig($url, $this->io);
  36277. if ($initialClone) {
  36278. $origCwd = $cwd;
  36279. }
  36280. $runCommands = function ($url) use ($commandCallables, $cwd, &$commandOutput, &$lastCommand, $initialClone) {
  36281. $collectOutputs = !is_callable($commandOutput);
  36282. $outputs = [];
  36283. $status = 0;
  36284. $counter = 0;
  36285. foreach ($commandCallables as $callable) {
  36286. $lastCommand = $callable($url);
  36287. if ($collectOutputs) {
  36288. $outputs[] = '';
  36289. $output = &$outputs[count($outputs) - 1];
  36290. } else {
  36291. $output = &$commandOutput;
  36292. }
  36293. $status = $this->process->execute($lastCommand, $output, $initialClone && $counter === 0 ? null : $cwd);
  36294. if ($status !== 0) {
  36295. break;
  36296. }
  36297. $counter++;
  36298. }
  36299. if ($collectOutputs) {
  36300. $commandOutput = implode('', $outputs);
  36301. }
  36302. return $status;
  36303. };
  36304. if (Preg::isMatch('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  36305. 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.');
  36306. }
  36307. if (!$initialClone) {
  36308. $this->process->execute(['git', 'remote', '-v'], $output, $cwd);
  36309. if (Preg::isMatchStrictGroups('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
  36310. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  36311. }
  36312. }
  36313. $protocols = $this->config->get('github-protocols');
  36314. if (Preg::isMatchStrictGroups('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  36315. $messages = [];
  36316. foreach ($protocols as $protocol) {
  36317. if ('ssh' === $protocol) {
  36318. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  36319. } else {
  36320. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  36321. }
  36322. if (0 === $runCommands($protoUrl)) {
  36323. return;
  36324. }
  36325. $messages[] = '- ' . $protoUrl . "\n" . Preg::replace('#^#m', ' ', $this->process->getErrorOutput());
  36326. if ($initialClone && isset($origCwd)) {
  36327. $this->filesystem->removeDirectory($origCwd);
  36328. }
  36329. }
  36330. if (!$this->io->hasAuthentication($match[1]) && !$this->io->isInteractive()) {
  36331. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  36332. }
  36333. }
  36334. $bypassSshForGitHub = Preg::isMatch('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  36335. $auth = null;
  36336. $credentials = [];
  36337. if ($bypassSshForGitHub || 0 !== $runCommands($url)) {
  36338. $errorMsg = $this->process->getErrorOutput();
  36339. if (Preg::isMatchStrictGroups('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)
  36340. || Preg::isMatchStrictGroups('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*?)(?:\.git)?$}i', $url, $match)
  36341. ) {
  36342. if (!$this->io->hasAuthentication($match[1])) {
  36343. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  36344. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  36345. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  36346. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  36347. }
  36348. }
  36349. if ($this->io->hasAuthentication($match[1])) {
  36350. $auth = $this->io->getAuthentication($match[1]);
  36351. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  36352. if (0 === $runCommands($authUrl)) {
  36353. return;
  36354. }
  36355. $credentials = [rawurlencode($auth['username']), rawurlencode($auth['password'])];
  36356. $errorMsg = $this->process->getErrorOutput();
  36357. }
  36358. } elseif (
  36359. Preg::isMatchStrictGroups('{^(https?)://(bitbucket\.org)/(.*?)(?:\.git)?$}i', $url, $match)
  36360. || Preg::isMatchStrictGroups('{^(git)@(bitbucket\.org):(.+?\.git)$}i', $url, $match)
  36361. ) {
  36362. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  36363. $domain = $match[2];
  36364. $repo_with_git_part = $match[3];
  36365. if (!str_ends_with($repo_with_git_part, '.git')) {
  36366. $repo_with_git_part .= '.git';
  36367. }
  36368. if (!$this->io->hasAuthentication($domain)) {
  36369. $message = 'Enter your Bitbucket credentials to access private repos';
  36370. if (!$bitbucketUtil->authorizeOAuth($domain) && $this->io->isInteractive()) {
  36371. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  36372. $accessToken = $bitbucketUtil->getToken();
  36373. $this->io->setAuthentication($domain, 'x-token-auth', $accessToken);
  36374. }
  36375. }
  36376. if ($this->io->hasAuthentication($domain)) {
  36377. $auth = $this->io->getAuthentication($domain);
  36378. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $domain . '/' . $repo_with_git_part;
  36379. if (0 === $runCommands($authUrl)) {
  36380. return;
  36381. }
  36382. if ($auth['username'] !== 'x-token-auth') {
  36383. $accessToken = $bitbucketUtil->requestToken($domain, $auth['username'], $auth['password']);
  36384. if (!empty($accessToken)) {
  36385. $this->io->setAuthentication($domain, 'x-token-auth', $accessToken);
  36386. }
  36387. }
  36388. }
  36389. if ($this->io->hasAuthentication($domain)) {
  36390. $auth = $this->io->getAuthentication($domain);
  36391. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $domain . '/' . $repo_with_git_part;
  36392. if (0 === $runCommands($authUrl)) {
  36393. return;
  36394. }
  36395. $credentials = [rawurlencode($auth['username']), rawurlencode($auth['password'])];
  36396. }
  36397. $sshUrl = 'git@bitbucket.org:' . $repo_with_git_part;
  36398. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  36399. if (0 === $runCommands($sshUrl)) {
  36400. return;
  36401. }
  36402. $errorMsg = $this->process->getErrorOutput();
  36403. } elseif (
  36404. Preg::isMatchStrictGroups('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?\.git)$}i', $url, $match)
  36405. || Preg::isMatchStrictGroups('{^(https?)://' . self::getGitLabDomainsRegex($this->config) . '/(.*)}i', $url, $match)
  36406. ) {
  36407. if ($match[1] === 'git') {
  36408. $match[1] = 'https';
  36409. }
  36410. if (!$this->io->hasAuthentication($match[2])) {
  36411. $gitLabUtil = new GitLab($this->io, $this->config, $this->process);
  36412. $message = 'Cloning failed, enter your GitLab credentials to access private repos';
  36413. if (!$gitLabUtil->authorizeOAuth($match[2]) && $this->io->isInteractive()) {
  36414. $gitLabUtil->authorizeOAuthInteractively($match[1], $match[2], $message);
  36415. }
  36416. }
  36417. if ($this->io->hasAuthentication($match[2])) {
  36418. $auth = $this->io->getAuthentication($match[2]);
  36419. if ($auth['password'] === 'private-token' || $auth['password'] === 'oauth2' || $auth['password'] === 'gitlab-ci-token') {
  36420. $authUrl = $match[1] . '://' . rawurlencode($auth['password']) . ':' . rawurlencode((string) $auth['username']) . '@' . $match[2] . '/' . $match[3];
  36421. } else {
  36422. $authUrl = $match[1] . '://' . rawurlencode((string) $auth['username']) . ':' . rawurlencode((string) $auth['password']) . '@' . $match[2] . '/' . $match[3];
  36423. }
  36424. if (0 === $runCommands($authUrl)) {
  36425. return;
  36426. }
  36427. $credentials = [rawurlencode((string) $auth['username']), rawurlencode((string) $auth['password'])];
  36428. $errorMsg = $this->process->getErrorOutput();
  36429. }
  36430. } elseif (null !== ($match = $this->getAuthenticationFailure($url))) {
  36431. if (str_contains($match[2], '@')) {
  36432. [$authParts, $match[2]] = explode('@', $match[2], 2);
  36433. }
  36434. $storeAuth = false;
  36435. if ($this->io->hasAuthentication($match[2])) {
  36436. $auth = $this->io->getAuthentication($match[2]);
  36437. } elseif ($this->io->isInteractive()) {
  36438. $defaultUsername = null;
  36439. if (isset($authParts) && $authParts !== '') {
  36440. if (str_contains($authParts, ':')) {
  36441. [$defaultUsername, ] = explode(':', $authParts, 2);
  36442. } else {
  36443. $defaultUsername = $authParts;
  36444. }
  36445. }
  36446. $this->io->writeError(' Authentication required (<info>' . $match[2] . '</info>):');
  36447. $this->io->writeError('<warning>' . trim($errorMsg) . '</warning>', true, IOInterface::VERBOSE);
  36448. $auth = [
  36449. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  36450. 'password' => $this->io->askAndHideAnswer(' Password: '),
  36451. ];
  36452. $storeAuth = $this->config->get('store-auths');
  36453. }
  36454. if (null !== $auth) {
  36455. $authUrl = $match[1] . rawurlencode((string) $auth['username']) . ':' . rawurlencode((string) $auth['password']) . '@' . $match[2] . $match[3];
  36456. if (0 === $runCommands($authUrl)) {
  36457. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  36458. $authHelper = new AuthHelper($this->io, $this->config);
  36459. $authHelper->storeAuth($match[2], $storeAuth);
  36460. return;
  36461. }
  36462. $credentials = [rawurlencode((string) $auth['username']), rawurlencode((string) $auth['password'])];
  36463. $errorMsg = $this->process->getErrorOutput();
  36464. }
  36465. }
  36466. if ($initialClone && isset($origCwd)) {
  36467. $this->filesystem->removeDirectory($origCwd);
  36468. }
  36469. $lastCommand = implode(' ', $lastCommand);
  36470. if (count($credentials) > 0) {
  36471. $lastCommand = $this->maskCredentials($lastCommand, $credentials);
  36472. $errorMsg = $this->maskCredentials($errorMsg, $credentials);
  36473. }
  36474. $this->throwException('Failed to execute ' . $lastCommand . "\n\n" . $errorMsg, $url);
  36475. }
  36476. }
  36477. public function syncMirror(string $url, string $dir): bool
  36478. {
  36479. if ((bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK') && Platform::getEnv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
  36480. $this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
  36481. return false;
  36482. }
  36483. if (is_dir($dir) && 0 === $this->process->execute(['git', 'rev-parse', '--git-dir'], $output, $dir) && trim($output) === '.') {
  36484. try {
  36485. $commands = [
  36486. ['git', 'remote', 'set-url', 'origin', '--', '%url%'],
  36487. ['git', 'remote', 'update', '--prune', 'origin'],
  36488. ['git', 'remote', 'set-url', 'origin', '--', '%sanitizedUrl%'],
  36489. ['git', 'gc', '--auto'],
  36490. ];
  36491. $this->runCommands($commands, $url, $dir);
  36492. } catch (\Exception $e) {
  36493. $this->io->writeError('<error>Sync mirror failed: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  36494. return false;
  36495. }
  36496. return true;
  36497. }
  36498. self::checkForRepoOwnershipError($this->process->getErrorOutput(), $dir);
  36499. $this->filesystem->removeDirectory($dir);
  36500. $this->runCommands([['git', 'clone', '--mirror', '--', '%url%', $dir]], $url, $dir, true);
  36501. return true;
  36502. }
  36503. public function fetchRefOrSyncMirror(string $url, string $dir, string $ref, ?string $prettyVersion = null): bool
  36504. {
  36505. if ($this->checkRefIsInMirror($dir, $ref)) {
  36506. if (Preg::isMatch('{^[a-f0-9]{40}$}', $ref) && $prettyVersion !== null) {
  36507. $branch = Preg::replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $prettyVersion);
  36508. $branches = null;
  36509. $tags = null;
  36510. if (0 === $this->process->execute(['git', 'branch'], $output, $dir)) {
  36511. $branches = $output;
  36512. }
  36513. if (0 === $this->process->execute(['git', 'tag'], $output, $dir)) {
  36514. $tags = $output;
  36515. }
  36516. if (null !== $branches && !Preg::isMatch('{^[\s*]*v?'.preg_quote($branch).'$}m', $branches)
  36517. && null !== $tags && !Preg::isMatch('{^[\s*]*'.preg_quote($branch).'$}m', $tags)
  36518. ) {
  36519. $this->syncMirror($url, $dir);
  36520. }
  36521. }
  36522. return true;
  36523. }
  36524. if ($this->syncMirror($url, $dir)) {
  36525. return $this->checkRefIsInMirror($dir, $ref);
  36526. }
  36527. return false;
  36528. }
  36529. public static function getNoShowSignatureFlag(ProcessExecutor $process): string
  36530. {
  36531. $gitVersion = self::getVersion($process);
  36532. if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
  36533. return ' --no-show-signature';
  36534. }
  36535. return '';
  36536. }
  36537. public static function getNoShowSignatureFlags(ProcessExecutor $process): array
  36538. {
  36539. $flags = static::getNoShowSignatureFlag($process);
  36540. if ('' === $flags) {
  36541. return [];
  36542. }
  36543. return explode(' ', substr($flags, 1));
  36544. }
  36545. private function checkRefIsInMirror(string $dir, string $ref): bool
  36546. {
  36547. if (is_dir($dir) && 0 === $this->process->execute(['git', 'rev-parse', '--git-dir'], $output, $dir) && trim($output) === '.') {
  36548. $exitCode = $this->process->execute(['git', 'rev-parse', '--quiet', '--verify', $ref.'^{commit}'], $ignoredOutput, $dir);
  36549. if ($exitCode === 0) {
  36550. return true;
  36551. }
  36552. }
  36553. self::checkForRepoOwnershipError($this->process->getErrorOutput(), $dir);
  36554. return false;
  36555. }
  36556. private function getAuthenticationFailure(string $url): ?array
  36557. {
  36558. if (!Preg::isMatchStrictGroups('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  36559. return null;
  36560. }
  36561. $authFailures = [
  36562. 'fatal: Authentication failed',
  36563. 'remote error: Invalid username or password.',
  36564. 'error: 401 Unauthorized',
  36565. 'fatal: unable to access',
  36566. 'fatal: could not read Username',
  36567. ];
  36568. $errorOutput = $this->process->getErrorOutput();
  36569. foreach ($authFailures as $authFailure) {
  36570. if (strpos($errorOutput, $authFailure) !== false) {
  36571. return $match;
  36572. }
  36573. }
  36574. return null;
  36575. }
  36576. public function getMirrorDefaultBranch(string $url, string $dir, bool $isLocalPathRepository): ?string
  36577. {
  36578. if ((bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  36579. return null;
  36580. }
  36581. try {
  36582. if ($isLocalPathRepository) {
  36583. $this->process->execute(['git', 'remote', 'show', 'origin'], $output, $dir);
  36584. } else {
  36585. $commands = [
  36586. ['git', 'remote', 'set-url', 'origin', '--', '%url%'],
  36587. ['git', 'remote', 'show', 'origin'],
  36588. ['git', 'remote', 'set-url', 'origin', '--', '%sanitizedUrl%'],
  36589. ];
  36590. $this->runCommands($commands, $url, $dir, false, $output);
  36591. }
  36592. $lines = $this->process->splitLines($output);
  36593. foreach ($lines as $line) {
  36594. if (Preg::isMatch('{^\s*HEAD branch:\s(.+)\s*$}m', $line, $matches)) {
  36595. return $matches[1];
  36596. }
  36597. }
  36598. } catch (\Exception $e) {
  36599. $this->io->writeError('<error>Failed to fetch root identifier from remote: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  36600. }
  36601. return null;
  36602. }
  36603. public static function cleanEnv(): void
  36604. {
  36605. if (Platform::getEnv('GIT_ASKPASS') !== 'echo') {
  36606. Platform::putEnv('GIT_ASKPASS', 'echo');
  36607. }
  36608. if (Platform::getEnv('GIT_DIR')) {
  36609. Platform::clearEnv('GIT_DIR');
  36610. }
  36611. if (Platform::getEnv('GIT_WORK_TREE')) {
  36612. Platform::clearEnv('GIT_WORK_TREE');
  36613. }
  36614. if (Platform::getEnv('LANGUAGE') !== 'C') {
  36615. Platform::putEnv('LANGUAGE', 'C');
  36616. }
  36617. Platform::clearEnv('DYLD_LIBRARY_PATH');
  36618. }
  36619. public static function getGitHubDomainsRegex(Config $config): string
  36620. {
  36621. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  36622. }
  36623. public static function getGitLabDomainsRegex(Config $config): string
  36624. {
  36625. return '(' . implode('|', array_map('preg_quote', $config->get('gitlab-domains'))) . ')';
  36626. }
  36627. private function throwException($message, string $url): void
  36628. {
  36629. clearstatcache();
  36630. if (0 !== $this->process->execute(['git', '--version'], $ignoredOutput)) {
  36631. 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()));
  36632. }
  36633. throw new \RuntimeException(Url::sanitize($message));
  36634. }
  36635. public static function getVersion(ProcessExecutor $process): ?string
  36636. {
  36637. if (false === self::$version) {
  36638. self::$version = null;
  36639. if (0 === $process->execute(['git', '--version'], $output) && Preg::isMatch('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  36640. self::$version = $matches[1];
  36641. }
  36642. }
  36643. return self::$version;
  36644. }
  36645. private function maskCredentials(string $error, array $credentials): string
  36646. {
  36647. $maskedCredentials = [];
  36648. foreach ($credentials as $credential) {
  36649. if (in_array($credential, ['private-token', 'x-token-auth', 'oauth2', 'gitlab-ci-token', 'x-oauth-basic'])) {
  36650. $maskedCredentials[] = $credential;
  36651. } elseif (strlen($credential) > 6) {
  36652. $maskedCredentials[] = substr($credential, 0, 3) . '...' . substr($credential, -3);
  36653. } elseif (strlen($credential) > 3) {
  36654. $maskedCredentials[] = substr($credential, 0, 3) . '...';
  36655. } else {
  36656. $maskedCredentials[] = 'XXX';
  36657. }
  36658. }
  36659. return str_replace($credentials, $maskedCredentials, $error);
  36660. }
  36661. }
  36662. <?php declare(strict_types=1);
  36663. namespace Composer\Util;
  36664. use Composer\Factory;
  36665. use Composer\IO\IOInterface;
  36666. use Composer\Config;
  36667. use Composer\Downloader\TransportException;
  36668. use Composer\Pcre\Preg;
  36669. class GitHub
  36670. {
  36671. protected $io;
  36672. protected $config;
  36673. protected $process;
  36674. protected $httpDownloader;
  36675. public function __construct(IOInterface $io, Config $config, ?ProcessExecutor $process = null, ?HttpDownloader $httpDownloader = null)
  36676. {
  36677. $this->io = $io;
  36678. $this->config = $config;
  36679. $this->process = $process ?: new ProcessExecutor($io);
  36680. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  36681. }
  36682. public function authorizeOAuth(string $originUrl): bool
  36683. {
  36684. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  36685. return false;
  36686. }
  36687. if (0 === $this->process->execute(['git', 'config', 'github.accesstoken'], $output)) {
  36688. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  36689. return true;
  36690. }
  36691. return false;
  36692. }
  36693. public function authorizeOAuthInteractively(string $originUrl, ?string $message = null): bool
  36694. {
  36695. if ($message) {
  36696. $this->io->writeError($message);
  36697. }
  36698. $note = 'Composer';
  36699. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute(['hostname'], $output)) {
  36700. $note .= ' on ' . trim($output);
  36701. }
  36702. $note .= ' ' . date('Y-m-d Hi');
  36703. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=&description=' . str_replace('%20', '+', rawurlencode($note));
  36704. $this->io->writeError('When working with _public_ GitHub repositories only, head here to retrieve a token:');
  36705. $this->io->writeError($url);
  36706. $this->io->writeError('This token will have read-only permission for public information only.');
  36707. $localAuthConfig = $this->config->getLocalAuthConfigSource();
  36708. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  36709. $this->io->writeError('When you need to access _private_ GitHub repositories as well, go to:');
  36710. $this->io->writeError($url);
  36711. $this->io->writeError('Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.');
  36712. $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()));
  36713. $this->io->writeError('For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth');
  36714. $storeInLocalAuthConfig = false;
  36715. if ($localAuthConfig !== null) {
  36716. $storeInLocalAuthConfig = $this->io->askConfirmation('A local auth config source was found, do you want to store the token there?', true);
  36717. }
  36718. $token = trim((string) $this->io->askAndHideAnswer('Token (hidden): '));
  36719. if ($token === '') {
  36720. $this->io->writeError('<warning>No token given, aborting.</warning>');
  36721. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  36722. return false;
  36723. }
  36724. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  36725. try {
  36726. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  36727. $this->httpDownloader->get('https://'. $apiUrl, [
  36728. 'retry-auth-failure' => false,
  36729. ]);
  36730. } catch (TransportException $e) {
  36731. if (in_array($e->getCode(), [403, 401])) {
  36732. $this->io->writeError('<error>Invalid token provided.</error>');
  36733. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  36734. return false;
  36735. }
  36736. throw $e;
  36737. }
  36738. $authConfigSource = $storeInLocalAuthConfig && $localAuthConfig !== null ? $localAuthConfig : $this->config->getAuthConfigSource();
  36739. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  36740. $authConfigSource->addConfigSetting('github-oauth.'.$originUrl, $token);
  36741. $this->io->writeError('<info>Token stored successfully.</info>');
  36742. return true;
  36743. }
  36744. public function getRateLimit(array $headers): array
  36745. {
  36746. $rateLimit = [
  36747. 'limit' => '?',
  36748. 'reset' => '?',
  36749. ];
  36750. foreach ($headers as $header) {
  36751. $header = trim($header);
  36752. if (false === stripos($header, 'x-ratelimit-')) {
  36753. continue;
  36754. }
  36755. [$type, $value] = explode(':', $header, 2);
  36756. switch (strtolower($type)) {
  36757. case 'x-ratelimit-limit':
  36758. $rateLimit['limit'] = (int) trim($value);
  36759. break;
  36760. case 'x-ratelimit-reset':
  36761. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  36762. break;
  36763. }
  36764. }
  36765. return $rateLimit;
  36766. }
  36767. public function getSsoUrl(array $headers): ?string
  36768. {
  36769. foreach ($headers as $header) {
  36770. $header = trim($header);
  36771. if (false === stripos($header, 'x-github-sso: required')) {
  36772. continue;
  36773. }
  36774. if (Preg::isMatch('{\burl=(?P<url>[^\s;]+)}', $header, $match)) {
  36775. return $match['url'];
  36776. }
  36777. }
  36778. return null;
  36779. }
  36780. public function isRateLimited(array $headers): bool
  36781. {
  36782. foreach ($headers as $header) {
  36783. if (Preg::isMatch('{^x-ratelimit-remaining: *0$}i', trim($header))) {
  36784. return true;
  36785. }
  36786. }
  36787. return false;
  36788. }
  36789. public function requiresSso(array $headers): bool
  36790. {
  36791. foreach ($headers as $header) {
  36792. if (Preg::isMatch('{^x-github-sso: required}i', trim($header))) {
  36793. return true;
  36794. }
  36795. }
  36796. return false;
  36797. }
  36798. }
  36799. <?php declare(strict_types=1);
  36800. namespace Composer\Util;
  36801. use Composer\IO\IOInterface;
  36802. use Composer\Config;
  36803. use Composer\Factory;
  36804. use Composer\Downloader\TransportException;
  36805. use Composer\Pcre\Preg;
  36806. class GitLab
  36807. {
  36808. protected $io;
  36809. protected $config;
  36810. protected $process;
  36811. protected $httpDownloader;
  36812. public function __construct(IOInterface $io, Config $config, ?ProcessExecutor $process = null, ?HttpDownloader $httpDownloader = null)
  36813. {
  36814. $this->io = $io;
  36815. $this->config = $config;
  36816. $this->process = $process ?: new ProcessExecutor($io);
  36817. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  36818. }
  36819. public function authorizeOAuth(string $originUrl): bool
  36820. {
  36821. $bcOriginUrl = Preg::replace('{:\d+}', '', $originUrl);
  36822. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true) && !in_array($bcOriginUrl, $this->config->get('gitlab-domains'), true)) {
  36823. return false;
  36824. }
  36825. if (0 === $this->process->execute(['git', 'config', 'gitlab.accesstoken'], $output)) {
  36826. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  36827. return true;
  36828. }
  36829. if (0 === $this->process->execute(['git', 'config', 'gitlab.deploytoken.user'], $tokenUser) && 0 === $this->process->execute(['git', 'config', 'gitlab.deploytoken.token'], $tokenPassword)) {
  36830. $this->io->setAuthentication($originUrl, trim($tokenUser), trim($tokenPassword));
  36831. return true;
  36832. }
  36833. $authTokens = $this->config->get('gitlab-token');
  36834. if (isset($authTokens[$originUrl])) {
  36835. $token = $authTokens[$originUrl];
  36836. }
  36837. if (isset($authTokens[$bcOriginUrl])) {
  36838. $token = $authTokens[$bcOriginUrl];
  36839. }
  36840. if (isset($token)) {
  36841. $username = is_array($token) ? $token["username"] : $token;
  36842. $password = is_array($token) ? $token["token"] : 'private-token';
  36843. if (in_array($username, ['private-token', 'gitlab-ci-token', 'oauth2'], true)) {
  36844. $this->io->setAuthentication($originUrl, $password, $username);
  36845. } else {
  36846. $this->io->setAuthentication($originUrl, $username, $password);
  36847. }
  36848. return true;
  36849. }
  36850. return false;
  36851. }
  36852. public function authorizeOAuthInteractively(string $scheme, string $originUrl, ?string $message = null): bool
  36853. {
  36854. if ($message) {
  36855. $this->io->writeError($message);
  36856. }
  36857. $localAuthConfig = $this->config->getLocalAuthConfigSource();
  36858. $personalAccessTokenLink = $scheme.'://'.$originUrl.'/-/user_settings/personal_access_tokens';
  36859. $revokeLink = $scheme.'://'.$originUrl.'/-/user_settings/applications';
  36860. $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()));
  36861. $this->io->writeError('To revoke access to this token you can visit:');
  36862. $this->io->writeError($revokeLink);
  36863. $this->io->writeError('Alternatively you can setup an personal access token on:');
  36864. $this->io->writeError($personalAccessTokenLink);
  36865. $this->io->writeError('and store it under "gitlab-token" see https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token for more details.');
  36866. $this->io->writeError('https://getcomposer.org/doc/articles/authentication-for-private-packages.md#gitlab-token');
  36867. $this->io->writeError('for more details.');
  36868. $storeInLocalAuthConfig = false;
  36869. if ($localAuthConfig !== null) {
  36870. $storeInLocalAuthConfig = $this->io->askConfirmation('A local auth config source was found, do you want to store the token there?', true);
  36871. }
  36872. $attemptCounter = 0;
  36873. while ($attemptCounter++ < 5) {
  36874. try {
  36875. $response = $this->createToken($scheme, $originUrl);
  36876. } catch (TransportException $e) {
  36877. if (in_array($e->getCode(), [403, 401])) {
  36878. if (401 === $e->getCode()) {
  36879. $response = json_decode($e->getResponse(), true);
  36880. if (isset($response['error']) && $response['error'] === 'invalid_grant') {
  36881. $this->io->writeError('Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token');
  36882. } else {
  36883. $this->io->writeError('Bad credentials.');
  36884. }
  36885. } else {
  36886. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  36887. }
  36888. $this->io->writeError('You can also manually create a personal access token enabling the "read_api" scope at:');
  36889. $this->io->writeError($personalAccessTokenLink);
  36890. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  36891. continue;
  36892. }
  36893. throw $e;
  36894. }
  36895. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  36896. $authConfigSource = $storeInLocalAuthConfig && $localAuthConfig !== null ? $localAuthConfig : $this->config->getAuthConfigSource();
  36897. if (isset($response['expires_in'])) {
  36898. $authConfigSource->addConfigSetting(
  36899. 'gitlab-oauth.'.$originUrl,
  36900. [
  36901. 'expires-at' => intval($response['created_at']) + intval($response['expires_in']),
  36902. 'refresh-token' => $response['refresh_token'],
  36903. 'token' => $response['access_token'],
  36904. ]
  36905. );
  36906. } else {
  36907. $authConfigSource->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  36908. }
  36909. return true;
  36910. }
  36911. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  36912. }
  36913. public function authorizeOAuthRefresh(string $scheme, string $originUrl): bool
  36914. {
  36915. try {
  36916. $response = $this->refreshToken($scheme, $originUrl);
  36917. } catch (TransportException $e) {
  36918. $this->io->writeError("Couldn't refresh access token: ".$e->getMessage());
  36919. return false;
  36920. }
  36921. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  36922. $this->config->getAuthConfigSource()->addConfigSetting(
  36923. 'gitlab-oauth.'.$originUrl,
  36924. [
  36925. 'expires-at' => intval($response['created_at']) + intval($response['expires_in']),
  36926. 'refresh-token' => $response['refresh_token'],
  36927. 'token' => $response['access_token'],
  36928. ]
  36929. );
  36930. return true;
  36931. }
  36932. private function createToken(string $scheme, string $originUrl): array
  36933. {
  36934. $username = $this->io->ask('Username: ');
  36935. $password = $this->io->askAndHideAnswer('Password: ');
  36936. $headers = ['Content-Type: application/x-www-form-urlencoded'];
  36937. $apiUrl = $originUrl;
  36938. $data = http_build_query([
  36939. 'username' => $username,
  36940. 'password' => $password,
  36941. 'grant_type' => 'password',
  36942. ], '', '&');
  36943. $options = [
  36944. 'retry-auth-failure' => false,
  36945. 'http' => [
  36946. 'method' => 'POST',
  36947. 'header' => $headers,
  36948. 'content' => $data,
  36949. ],
  36950. ];
  36951. $token = $this->httpDownloader->get($scheme.'://'.$apiUrl.'/oauth/token', $options)->decodeJson();
  36952. $this->io->writeError('Token successfully created');
  36953. return $token;
  36954. }
  36955. public function isOAuthExpired(string $originUrl): bool
  36956. {
  36957. $authTokens = $this->config->get('gitlab-oauth');
  36958. if (isset($authTokens[$originUrl]['expires-at'])) {
  36959. if ($authTokens[$originUrl]['expires-at'] < time()) {
  36960. return true;
  36961. }
  36962. }
  36963. return false;
  36964. }
  36965. private function refreshToken(string $scheme, string $originUrl): array
  36966. {
  36967. $authTokens = $this->config->get('gitlab-oauth');
  36968. if (!isset($authTokens[$originUrl]['refresh-token'])) {
  36969. throw new \RuntimeException('No GitLab refresh token present for '.$originUrl.'.');
  36970. }
  36971. $refreshToken = $authTokens[$originUrl]['refresh-token'];
  36972. $headers = ['Content-Type: application/x-www-form-urlencoded'];
  36973. $data = http_build_query([
  36974. 'refresh_token' => $refreshToken,
  36975. 'grant_type' => 'refresh_token',
  36976. ], '', '&');
  36977. $options = [
  36978. 'retry-auth-failure' => false,
  36979. 'http' => [
  36980. 'method' => 'POST',
  36981. 'header' => $headers,
  36982. 'content' => $data,
  36983. ],
  36984. ];
  36985. $token = $this->httpDownloader->get($scheme.'://'.$originUrl.'/oauth/token', $options)->decodeJson();
  36986. $this->io->writeError('GitLab token successfully refreshed', true, IOInterface::VERY_VERBOSE);
  36987. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/-/user_settings/applications', true, IOInterface::VERY_VERBOSE);
  36988. return $token;
  36989. }
  36990. }
  36991. <?php declare(strict_types=1);
  36992. namespace Composer\Util;
  36993. use Composer\Config;
  36994. use Composer\IO\IOInterface;
  36995. use Composer\Pcre\Preg;
  36996. class Hg
  36997. {
  36998. private static $version = false;
  36999. private $io;
  37000. private $config;
  37001. private $process;
  37002. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  37003. {
  37004. $this->io = $io;
  37005. $this->config = $config;
  37006. $this->process = $process;
  37007. }
  37008. public function runCommand(callable $commandCallable, string $url, ?string $cwd): void
  37009. {
  37010. $this->config->prohibitUrlByConfig($url, $this->io);
  37011. $command = $commandCallable($url);
  37012. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  37013. return;
  37014. }
  37015. if (
  37016. Preg::isMatch('{^(?P<proto>ssh|https?)://(?:(?P<user>[^:@]+)(?::(?P<pass>[^:@]+))?@)?(?P<host>[^/]+)(?P<path>/.*)?}mi', $url, $matches)
  37017. && $this->io->hasAuthentication($matches['host'])
  37018. ) {
  37019. if ($matches['proto'] === 'ssh') {
  37020. $user = '';
  37021. if ($matches['user'] !== null) {
  37022. $user = rawurlencode($matches['user']) . '@';
  37023. }
  37024. $authenticatedUrl = $matches['proto'] . '://' . $user . $matches['host'] . $matches['path'];
  37025. } else {
  37026. $auth = $this->io->getAuthentication($matches['host']);
  37027. $authenticatedUrl = $matches['proto'] . '://' . rawurlencode((string) $auth['username']) . ':' . rawurlencode((string) $auth['password']) . '@' . $matches['host'] . $matches['path'];
  37028. }
  37029. $command = $commandCallable($authenticatedUrl);
  37030. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  37031. return;
  37032. }
  37033. $error = $this->process->getErrorOutput();
  37034. } else {
  37035. $error = 'The given URL (' .$url. ') does not match the required format (ssh|http(s)://(username:password@)example.com/path-to-repository)';
  37036. }
  37037. $this->throwException("Failed to clone $url, \n\n" . $error, $url);
  37038. }
  37039. private function throwException($message, string $url): void
  37040. {
  37041. if (null === self::getVersion($this->process)) {
  37042. throw new \RuntimeException(Url::sanitize(
  37043. 'Failed to clone ' . $url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()
  37044. ));
  37045. }
  37046. throw new \RuntimeException(Url::sanitize($message));
  37047. }
  37048. public static function getVersion(ProcessExecutor $process): ?string
  37049. {
  37050. if (false === self::$version) {
  37051. self::$version = null;
  37052. if (0 === $process->execute(['hg', '--version'], $output) && Preg::isMatch('/^.+? (\d+(?:\.\d+)+)(?:\+.*?)?\)?\r?\n/', $output, $matches)) {
  37053. self::$version = $matches[1];
  37054. }
  37055. }
  37056. return self::$version;
  37057. }
  37058. }
  37059. <?php declare(strict_types=1);
  37060. namespace Composer\Util\Http;
  37061. use Composer\Config;
  37062. use Composer\Downloader\MaxFileSizeExceededException;
  37063. use Composer\IO\IOInterface;
  37064. use Composer\Downloader\TransportException;
  37065. use Composer\Pcre\Preg;
  37066. use Composer\Util\Platform;
  37067. use Composer\Util\StreamContextFactory;
  37068. use Composer\Util\AuthHelper;
  37069. use Composer\Util\Url;
  37070. use Composer\Util\HttpDownloader;
  37071. use React\Promise\Promise;
  37072. use Symfony\Component\HttpFoundation\IpUtils;
  37073. class CurlDownloader
  37074. {
  37075. private const BAD_MULTIPLEXING_CURL_VERSIONS = ['7.87.0', '7.88.0', '7.88.1'];
  37076. private $multiHandle;
  37077. private $shareHandle;
  37078. private $jobs = [];
  37079. private $io;
  37080. private $config;
  37081. private $authHelper;
  37082. private $selectTimeout = 5.0;
  37083. private $maxRedirects = 20;
  37084. private $maxRetries = 3;
  37085. protected $multiErrors = [
  37086. CURLM_BAD_HANDLE => ['CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'],
  37087. 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."],
  37088. CURLM_OUT_OF_MEMORY => ['CURLM_OUT_OF_MEMORY', 'You are doomed.'],
  37089. CURLM_INTERNAL_ERROR => ['CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!'],
  37090. ];
  37091. private static $options = [
  37092. 'http' => [
  37093. 'method' => CURLOPT_CUSTOMREQUEST,
  37094. 'content' => CURLOPT_POSTFIELDS,
  37095. 'header' => CURLOPT_HTTPHEADER,
  37096. 'timeout' => CURLOPT_TIMEOUT,
  37097. ],
  37098. 'ssl' => [
  37099. 'cafile' => CURLOPT_CAINFO,
  37100. 'capath' => CURLOPT_CAPATH,
  37101. 'verify_peer' => CURLOPT_SSL_VERIFYPEER,
  37102. 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST,
  37103. 'local_cert' => CURLOPT_SSLCERT,
  37104. 'local_pk' => CURLOPT_SSLKEY,
  37105. 'passphrase' => CURLOPT_SSLKEYPASSWD,
  37106. ],
  37107. ];
  37108. private static $timeInfo = [
  37109. 'total_time' => true,
  37110. 'namelookup_time' => true,
  37111. 'connect_time' => true,
  37112. 'pretransfer_time' => true,
  37113. 'starttransfer_time' => true,
  37114. 'redirect_time' => true,
  37115. ];
  37116. public function __construct(IOInterface $io, Config $config, array $options = [], bool $disableTls = false)
  37117. {
  37118. $this->io = $io;
  37119. $this->config = $config;
  37120. $this->multiHandle = $mh = curl_multi_init();
  37121. if (function_exists('curl_multi_setopt')) {
  37122. if (ProxyManager::getInstance()->hasProxy() && ($version = curl_version()) !== false && in_array($version['version'], self::BAD_MULTIPLEXING_CURL_VERSIONS, true)) {
  37123. curl_multi_setopt($mh, CURLMOPT_PIPELINING, 0);
  37124. } else {
  37125. curl_multi_setopt($mh, CURLMOPT_PIPELINING, \PHP_VERSION_ID >= 70400 ? 2 : 3);
  37126. }
  37127. if (defined('CURLMOPT_MAX_HOST_CONNECTIONS') && !defined('HHVM_VERSION')) {
  37128. curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
  37129. }
  37130. }
  37131. if (function_exists('curl_share_init')) {
  37132. $this->shareHandle = $sh = curl_share_init();
  37133. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  37134. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
  37135. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
  37136. }
  37137. $this->authHelper = new AuthHelper($io, $config);
  37138. }
  37139. public function download(callable $resolve, callable $reject, string $origin, string $url, array $options, ?string $copyTo = null): int
  37140. {
  37141. $attributes = [];
  37142. if (isset($options['retry-auth-failure'])) {
  37143. $attributes['retryAuthFailure'] = $options['retry-auth-failure'];
  37144. unset($options['retry-auth-failure']);
  37145. }
  37146. return $this->initDownload($resolve, $reject, $origin, $url, $options, $copyTo, $attributes);
  37147. }
  37148. private function initDownload(callable $resolve, callable $reject, string $origin, string $url, array $options, ?string $copyTo = null, array $attributes = []): int
  37149. {
  37150. $attributes = array_merge([
  37151. 'retryAuthFailure' => true,
  37152. 'redirects' => 0,
  37153. 'retries' => 0,
  37154. 'storeAuth' => false,
  37155. 'ipResolve' => null,
  37156. ], $attributes);
  37157. if ($attributes['ipResolve'] === null && Platform::getEnv('COMPOSER_IPRESOLVE') === '4') {
  37158. $attributes['ipResolve'] = 4;
  37159. } elseif ($attributes['ipResolve'] === null && Platform::getEnv('COMPOSER_IPRESOLVE') === '6') {
  37160. $attributes['ipResolve'] = 6;
  37161. }
  37162. $originalOptions = $options;
  37163. if (!Preg::isMatch('{^http://(repo\.)?packagist\.org/p/}', $url) || (false === strpos($url, '$') && false === strpos($url, '%24'))) {
  37164. $this->config->prohibitUrlByConfig($url, $this->io, $options);
  37165. }
  37166. $curlHandle = curl_init();
  37167. $headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
  37168. if (false === $headerHandle) {
  37169. throw new \RuntimeException('Failed to open a temp stream to store curl headers');
  37170. }
  37171. if ($copyTo !== null) {
  37172. $bodyTarget = $copyTo.'~';
  37173. } else {
  37174. $bodyTarget = 'php://temp/maxmemory:524288';
  37175. }
  37176. $errorMessage = '';
  37177. set_error_handler(static function (int $code, string $msg) use (&$errorMessage): bool {
  37178. if ($errorMessage) {
  37179. $errorMessage .= "\n";
  37180. }
  37181. $errorMessage .= Preg::replace('{^fopen\(.*?\): }', '', $msg);
  37182. return true;
  37183. });
  37184. $bodyHandle = fopen($bodyTarget, 'w+b');
  37185. restore_error_handler();
  37186. if (false === $bodyHandle) {
  37187. throw new TransportException('The "'.$url.'" file could not be written to '.($copyTo ?? 'a temporary file').': '.$errorMessage);
  37188. }
  37189. curl_setopt($curlHandle, CURLOPT_URL, $url);
  37190. curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);
  37191. curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
  37192. curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));
  37193. curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
  37194. curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
  37195. curl_setopt($curlHandle, CURLOPT_ENCODING, "");
  37196. curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
  37197. if ($attributes['ipResolve'] === 4) {
  37198. curl_setopt($curlHandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
  37199. } elseif ($attributes['ipResolve'] === 6) {
  37200. curl_setopt($curlHandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
  37201. }
  37202. if (function_exists('curl_share_init')) {
  37203. curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
  37204. }
  37205. if (!isset($options['http']['header'])) {
  37206. $options['http']['header'] = [];
  37207. }
  37208. $options['http']['header'] = array_diff($options['http']['header'], ['Connection: close']);
  37209. $options['http']['header'][] = 'Connection: keep-alive';
  37210. $version = curl_version();
  37211. $features = $version['features'];
  37212. if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features) !== 0) {
  37213. curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  37214. }
  37215. if (isset($version['version']) && in_array($version['version'], ['8.7.0', '8.7.1'], true) && \defined('CURL_VERSION_LIBZ') && (CURL_VERSION_LIBZ & $features) !== 0) {
  37216. curl_setopt($curlHandle, CURLOPT_ENCODING, "gzip");
  37217. }
  37218. $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
  37219. $options = StreamContextFactory::initOptions($url, $options, true);
  37220. foreach (self::$options as $type => $curlOptions) {
  37221. foreach ($curlOptions as $name => $curlOption) {
  37222. if (isset($options[$type][$name])) {
  37223. if ($type === 'ssl' && $name === 'verify_peer_name') {
  37224. curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);
  37225. } else {
  37226. curl_setopt($curlHandle, $curlOption, $options[$type][$name]);
  37227. }
  37228. }
  37229. }
  37230. }
  37231. $proxy = ProxyManager::getInstance()->getProxyForRequest($url);
  37232. curl_setopt_array($curlHandle, $proxy->getCurlOptions($options['ssl'] ?? []));
  37233. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  37234. $this->jobs[(int) $curlHandle] = [
  37235. 'url' => $url,
  37236. 'origin' => $origin,
  37237. 'attributes' => $attributes,
  37238. 'options' => $originalOptions,
  37239. 'progress' => $progress,
  37240. 'curlHandle' => $curlHandle,
  37241. 'filename' => $copyTo,
  37242. 'headerHandle' => $headerHandle,
  37243. 'bodyHandle' => $bodyHandle,
  37244. 'resolve' => $resolve,
  37245. 'reject' => $reject,
  37246. 'primaryIp' => '',
  37247. ];
  37248. $usingProxy = $proxy->getStatus(' using proxy (%s)');
  37249. $ifModified = false !== stripos(implode(',', $options['http']['header']), 'if-modified-since:') ? ' if modified' : '';
  37250. if ($attributes['redirects'] === 0 && $attributes['retries'] === 0) {
  37251. $this->io->writeError('Downloading ' . Url::sanitize($url) . $usingProxy . $ifModified, true, IOInterface::DEBUG);
  37252. }
  37253. $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
  37254. return (int) $curlHandle;
  37255. }
  37256. public function abortRequest(int $id): void
  37257. {
  37258. if (isset($this->jobs[$id], $this->jobs[$id]['curlHandle'])) {
  37259. $job = $this->jobs[$id];
  37260. curl_multi_remove_handle($this->multiHandle, $job['curlHandle']);
  37261. curl_close($job['curlHandle']);
  37262. if (is_resource($job['headerHandle'])) {
  37263. fclose($job['headerHandle']);
  37264. }
  37265. if (is_resource($job['bodyHandle'])) {
  37266. fclose($job['bodyHandle']);
  37267. }
  37268. if (null !== $job['filename']) {
  37269. @unlink($job['filename'].'~');
  37270. }
  37271. unset($this->jobs[$id]);
  37272. }
  37273. }
  37274. public function tick(): void
  37275. {
  37276. static $timeoutWarning = false;
  37277. if (count($this->jobs) === 0) {
  37278. return;
  37279. }
  37280. $active = true;
  37281. $this->checkCurlResult(curl_multi_exec($this->multiHandle, $active));
  37282. if (-1 === curl_multi_select($this->multiHandle, $this->selectTimeout)) {
  37283. usleep(150);
  37284. }
  37285. while ($progress = curl_multi_info_read($this->multiHandle)) {
  37286. $curlHandle = $progress['handle'];
  37287. $result = $progress['result'];
  37288. $i = (int) $curlHandle;
  37289. if (!isset($this->jobs[$i])) {
  37290. continue;
  37291. }
  37292. $progress = curl_getinfo($curlHandle);
  37293. if (false === $progress) {
  37294. throw new \RuntimeException('Failed getting info from curl handle '.$i.' ('.$this->jobs[$i]['url'].')');
  37295. }
  37296. $job = $this->jobs[$i];
  37297. unset($this->jobs[$i]);
  37298. $error = curl_error($curlHandle);
  37299. $errno = curl_errno($curlHandle);
  37300. curl_multi_remove_handle($this->multiHandle, $curlHandle);
  37301. curl_close($curlHandle);
  37302. $headers = null;
  37303. $statusCode = null;
  37304. $response = null;
  37305. try {
  37306. if (CURLE_OK !== $errno || $error || $result !== CURLE_OK) {
  37307. $errno = $errno ?: $result;
  37308. if (!$error && function_exists('curl_strerror')) {
  37309. $error = curl_strerror($errno);
  37310. }
  37311. $progress['error_code'] = $errno;
  37312. if (
  37313. (!isset($job['options']['http']['method']) || $job['options']['http']['method'] === 'GET')
  37314. && (
  37315. in_array($errno, [7 , 16 , 92 , 6 ], true)
  37316. || (in_array($errno, [56 , 35 ], true) && str_contains((string) $error, 'Connection reset by peer'))
  37317. ) && $job['attributes']['retries'] < $this->maxRetries
  37318. ) {
  37319. $attributes = ['retries' => $job['attributes']['retries'] + 1];
  37320. if ($errno === 7 && !isset($job['attributes']['ipResolve'])) {
  37321. $attributes['ipResolve'] = 4;
  37322. }
  37323. $this->io->writeError('Retrying ('.($job['attributes']['retries'] + 1).') ' . Url::sanitize($job['url']) . ' due to curl error '. $errno, true, IOInterface::DEBUG);
  37324. $this->restartJobWithDelay($job, $job['url'], $attributes);
  37325. continue;
  37326. }
  37327. if ($errno === 55 ) {
  37328. $this->io->writeError('Retrying ('.($job['attributes']['retries'] + 1).') ' . Url::sanitize($job['url']) . ' due to curl error '. $errno, true, IOInterface::DEBUG);
  37329. $this->restartJobWithDelay($job, $job['url'], ['retries' => $job['attributes']['retries'] + 1]);
  37330. continue;
  37331. }
  37332. if ($errno === 28 && \PHP_VERSION_ID >= 70300 && $progress['namelookup_time'] === 0.0 && !$timeoutWarning) {
  37333. $timeoutWarning = true;
  37334. $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>');
  37335. }
  37336. throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);
  37337. }
  37338. $statusCode = $progress['http_code'];
  37339. rewind($job['headerHandle']);
  37340. $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));
  37341. fclose($job['headerHandle']);
  37342. if ($statusCode === 0) {
  37343. 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));
  37344. }
  37345. if (null !== $job['filename']) {
  37346. $contents = $job['filename'].'~';
  37347. if ($statusCode >= 300) {
  37348. rewind($job['bodyHandle']);
  37349. $contents = stream_get_contents($job['bodyHandle']);
  37350. }
  37351. $response = new CurlResponse(['url' => $job['url']], $statusCode, $headers, $contents, $progress);
  37352. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($job['url']), true, IOInterface::DEBUG);
  37353. } else {
  37354. $maxFileSize = $job['options']['max_file_size'] ?? null;
  37355. rewind($job['bodyHandle']);
  37356. if ($maxFileSize !== null) {
  37357. $contents = stream_get_contents($job['bodyHandle'], $maxFileSize);
  37358. if ($contents !== false && Platform::strlen($contents) >= $maxFileSize) {
  37359. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($contents) . ' of allowed ' . $maxFileSize . ' bytes');
  37360. }
  37361. } else {
  37362. $contents = stream_get_contents($job['bodyHandle']);
  37363. }
  37364. $response = new CurlResponse(['url' => $job['url']], $statusCode, $headers, $contents, $progress);
  37365. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($job['url']), true, IOInterface::DEBUG);
  37366. }
  37367. fclose($job['bodyHandle']);
  37368. if ($response->getStatusCode() >= 300 && $response->getHeader('content-type') === 'application/json') {
  37369. HttpDownloader::outputWarnings($this->io, $job['origin'], json_decode($response->getBody(), true));
  37370. }
  37371. $result = $this->isAuthenticatedRetryNeeded($job, $response);
  37372. if ($result['retry']) {
  37373. $this->restartJob($job, $job['url'], ['storeAuth' => $result['storeAuth'], 'retries' => $job['attributes']['retries'] + 1]);
  37374. continue;
  37375. }
  37376. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $job['attributes']['redirects'] < $this->maxRedirects) {
  37377. $location = $this->handleRedirect($job, $response);
  37378. if ($location) {
  37379. $this->restartJob($job, $location, ['redirects' => $job['attributes']['redirects'] + 1]);
  37380. continue;
  37381. }
  37382. }
  37383. if ($statusCode >= 400 && $statusCode <= 599) {
  37384. if (
  37385. (!isset($job['options']['http']['method']) || $job['options']['http']['method'] === 'GET')
  37386. && in_array($statusCode, [423, 425, 500, 502, 503, 504, 507, 510], true)
  37387. && $job['attributes']['retries'] < $this->maxRetries
  37388. ) {
  37389. $this->io->writeError('Retrying ('.($job['attributes']['retries'] + 1).') ' . Url::sanitize($job['url']) . ' due to status code '. $statusCode, true, IOInterface::DEBUG);
  37390. $this->restartJobWithDelay($job, $job['url'], ['retries' => $job['attributes']['retries'] + 1]);
  37391. continue;
  37392. }
  37393. throw $this->failResponse($job, $response, $response->getStatusMessage());
  37394. }
  37395. if ($job['attributes']['storeAuth'] !== false) {
  37396. $this->authHelper->storeAuth($job['origin'], $job['attributes']['storeAuth']);
  37397. }
  37398. if (null !== $job['filename']) {
  37399. rename($job['filename'].'~', $job['filename']);
  37400. $job['resolve']($response);
  37401. } else {
  37402. $job['resolve']($response);
  37403. }
  37404. } catch (\Exception $e) {
  37405. if ($e instanceof TransportException) {
  37406. if (null !== $headers) {
  37407. $e->setHeaders($headers);
  37408. $e->setStatusCode($statusCode);
  37409. }
  37410. if (null !== $response) {
  37411. $e->setResponse($response->getBody());
  37412. }
  37413. $e->setResponseInfo($progress);
  37414. }
  37415. $this->rejectJob($job, $e);
  37416. }
  37417. }
  37418. foreach ($this->jobs as $i => $curlHandle) {
  37419. $curlHandle = $this->jobs[$i]['curlHandle'];
  37420. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  37421. if ($this->jobs[$i]['progress'] !== $progress) {
  37422. $this->jobs[$i]['progress'] = $progress;
  37423. if (isset($this->jobs[$i]['options']['max_file_size'])) {
  37424. if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
  37425. $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'));
  37426. }
  37427. if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
  37428. $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'));
  37429. }
  37430. }
  37431. if (isset($progress['primary_ip']) && $progress['primary_ip'] !== $this->jobs[$i]['primaryIp']) {
  37432. if (
  37433. isset($this->jobs[$i]['options']['prevent_ip_access_callable']) &&
  37434. is_callable($this->jobs[$i]['options']['prevent_ip_access_callable']) &&
  37435. $this->jobs[$i]['options']['prevent_ip_access_callable']($progress['primary_ip'])
  37436. ) {
  37437. $this->rejectJob($this->jobs[$i], new TransportException(sprintf('IP "%s" is blocked for "%s".', $progress['primary_ip'], $progress['url'])));
  37438. }
  37439. $this->jobs[$i]['primaryIp'] = (string) $progress['primary_ip'];
  37440. }
  37441. }
  37442. }
  37443. }
  37444. private function handleRedirect(array $job, Response $response): string
  37445. {
  37446. if ($locationHeader = $response->getHeader('location')) {
  37447. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  37448. $targetUrl = $locationHeader;
  37449. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  37450. $targetUrl = parse_url($job['url'], PHP_URL_SCHEME).':'.$locationHeader;
  37451. } elseif ('/' === $locationHeader[0]) {
  37452. $urlHost = parse_url($job['url'], PHP_URL_HOST);
  37453. $targetUrl = Preg::replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $job['url']);
  37454. } else {
  37455. $targetUrl = Preg::replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $job['url']);
  37456. }
  37457. }
  37458. if (!empty($targetUrl)) {
  37459. $this->io->writeError(sprintf('Following redirect (%u) %s', $job['attributes']['redirects'] + 1, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  37460. return $targetUrl;
  37461. }
  37462. throw new TransportException('The "'.$job['url'].'" file could not be downloaded, got redirect without Location ('.$response->getStatusMessage().')');
  37463. }
  37464. private function isAuthenticatedRetryNeeded(array $job, Response $response): array
  37465. {
  37466. if (in_array($response->getStatusCode(), [401, 403]) && $job['attributes']['retryAuthFailure']) {
  37467. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders(), $job['attributes']['retries']);
  37468. if ($result['retry']) {
  37469. return $result;
  37470. }
  37471. }
  37472. $locationHeader = $response->getHeader('location');
  37473. $needsAuthRetry = false;
  37474. if (
  37475. $job['origin'] === 'bitbucket.org'
  37476. && !$this->authHelper->isPublicBitBucketDownload($job['url'])
  37477. && substr($job['url'], -4) === '.zip'
  37478. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  37479. && Preg::isMatch('{^text/html\b}i', $response->getHeader('content-type'))
  37480. ) {
  37481. $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
  37482. }
  37483. if (
  37484. $response->getStatusCode() === 404
  37485. && in_array($job['origin'], $this->config->get('gitlab-domains'), true)
  37486. && false !== strpos($job['url'], 'archive.zip')
  37487. ) {
  37488. $needsAuthRetry = 'GitLab requires authentication and it was not provided';
  37489. }
  37490. if ($needsAuthRetry) {
  37491. if ($job['attributes']['retryAuthFailure']) {
  37492. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], 401, null, [], $job['attributes']['retries']);
  37493. if ($result['retry']) {
  37494. return $result;
  37495. }
  37496. }
  37497. throw $this->failResponse($job, $response, $needsAuthRetry);
  37498. }
  37499. return ['retry' => false, 'storeAuth' => false];
  37500. }
  37501. private function restartJob(array $job, string $url, array $attributes = []): void
  37502. {
  37503. if (null !== $job['filename']) {
  37504. @unlink($job['filename'].'~');
  37505. }
  37506. $attributes = array_merge($job['attributes'], $attributes);
  37507. $origin = Url::getOrigin($this->config, $url);
  37508. $this->initDownload($job['resolve'], $job['reject'], $origin, $url, $job['options'], $job['filename'], $attributes);
  37509. }
  37510. private function restartJobWithDelay(array $job, string $url, array $attributes): void
  37511. {
  37512. if ($attributes['retries'] >= 3) {
  37513. usleep(500000);
  37514. } elseif ($attributes['retries'] >= 2) {
  37515. usleep(100000);
  37516. }
  37517. $this->restartJob($job, $url, $attributes);
  37518. }
  37519. private function failResponse(array $job, Response $response, string $errorMessage): TransportException
  37520. {
  37521. if (null !== $job['filename']) {
  37522. @unlink($job['filename'].'~');
  37523. }
  37524. $details = '';
  37525. if (in_array(strtolower((string) $response->getHeader('content-type')), ['application/json', 'application/json; charset=utf-8'], true)) {
  37526. $details = ':'.PHP_EOL.substr($response->getBody(), 0, 200).(strlen($response->getBody()) > 200 ? '...' : '');
  37527. }
  37528. return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')' . $details, $response->getStatusCode());
  37529. }
  37530. private function rejectJob(array $job, \Exception $e): void
  37531. {
  37532. if (is_resource($job['headerHandle'])) {
  37533. fclose($job['headerHandle']);
  37534. }
  37535. if (is_resource($job['bodyHandle'])) {
  37536. fclose($job['bodyHandle']);
  37537. }
  37538. if (null !== $job['filename']) {
  37539. @unlink($job['filename'].'~');
  37540. }
  37541. $job['reject']($e);
  37542. }
  37543. private function checkCurlResult(int $code): void
  37544. {
  37545. if ($code !== CURLM_OK && $code !== CURLM_CALL_MULTI_PERFORM) {
  37546. throw new \RuntimeException(
  37547. isset($this->multiErrors[$code])
  37548. ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
  37549. : 'Unexpected cURL error: ' . $code
  37550. );
  37551. }
  37552. }
  37553. }
  37554. <?php declare(strict_types=1);
  37555. namespace Composer\Util\Http;
  37556. class CurlResponse extends Response
  37557. {
  37558. private $curlInfo;
  37559. public function __construct(array $request, ?int $code, array $headers, ?string $body, array $curlInfo)
  37560. {
  37561. parent::__construct($request, $code, $headers, $body);
  37562. $this->curlInfo = $curlInfo;
  37563. }
  37564. public function getCurlInfo(): array
  37565. {
  37566. return $this->curlInfo;
  37567. }
  37568. }
  37569. <?php declare(strict_types=1);
  37570. namespace Composer\Util\Http;
  37571. class ProxyItem
  37572. {
  37573. private $url;
  37574. private $safeUrl;
  37575. private $curlAuth;
  37576. private $optionsProxy;
  37577. private $optionsAuth;
  37578. public function __construct(string $proxyUrl, string $envName)
  37579. {
  37580. $syntaxError = sprintf('unsupported `%s` syntax', $envName);
  37581. if (strpbrk($proxyUrl, "\r\n\t") !== false) {
  37582. throw new \RuntimeException($syntaxError);
  37583. }
  37584. if (false === ($proxy = parse_url($proxyUrl))) {
  37585. throw new \RuntimeException($syntaxError);
  37586. }
  37587. if (!isset($proxy['host'])) {
  37588. throw new \RuntimeException('unable to find proxy host in ' . $envName);
  37589. }
  37590. $scheme = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : 'http://';
  37591. $safe = '';
  37592. if (isset($proxy['user'])) {
  37593. $safe = '***';
  37594. $user = $proxy['user'];
  37595. $auth = rawurldecode($proxy['user']);
  37596. if (isset($proxy['pass'])) {
  37597. $safe .= ':***';
  37598. $user .= ':' . $proxy['pass'];
  37599. $auth .= ':' . rawurldecode($proxy['pass']);
  37600. }
  37601. $safe .= '@';
  37602. if (strlen($user) > 0) {
  37603. $this->curlAuth = $user;
  37604. $this->optionsAuth = 'Proxy-Authorization: Basic ' . base64_encode($auth);
  37605. }
  37606. }
  37607. $host = $proxy['host'];
  37608. $port = null;
  37609. if (isset($proxy['port'])) {
  37610. $port = $proxy['port'];
  37611. } elseif ($scheme === 'http://') {
  37612. $port = 80;
  37613. } elseif ($scheme === 'https://') {
  37614. $port = 443;
  37615. }
  37616. if ($port === null) {
  37617. throw new \RuntimeException('unable to find proxy port in ' . $envName);
  37618. }
  37619. if ($port === 0) {
  37620. throw new \RuntimeException('port 0 is reserved in ' . $envName);
  37621. }
  37622. $this->url = sprintf('%s%s:%d', $scheme, $host, $port);
  37623. $this->safeUrl = sprintf('%s%s%s:%d', $scheme, $safe, $host, $port);
  37624. $scheme = str_replace(['http://', 'https://'], ['tcp://', 'ssl://'], $scheme);
  37625. $this->optionsProxy = sprintf('%s%s:%d', $scheme, $host, $port);
  37626. }
  37627. public function toRequestProxy(string $scheme): RequestProxy
  37628. {
  37629. $options = ['http' => ['proxy' => $this->optionsProxy]];
  37630. if ($this->optionsAuth !== null) {
  37631. $options['http']['header'] = $this->optionsAuth;
  37632. }
  37633. if ($scheme === 'http') {
  37634. $options['http']['request_fulluri'] = true;
  37635. }
  37636. return new RequestProxy($this->url, $this->curlAuth, $options, $this->safeUrl);
  37637. }
  37638. }
  37639. <?php declare(strict_types=1);
  37640. namespace Composer\Util\Http;
  37641. use Composer\Downloader\TransportException;
  37642. use Composer\Util\NoProxyPattern;
  37643. class ProxyManager
  37644. {
  37645. private $error = null;
  37646. private $httpProxy = null;
  37647. private $httpsProxy = null;
  37648. private $noProxyHandler = null;
  37649. private static $instance = null;
  37650. private function __construct()
  37651. {
  37652. try {
  37653. $this->getProxyData();
  37654. } catch (\RuntimeException $e) {
  37655. $this->error = $e->getMessage();
  37656. }
  37657. }
  37658. public static function getInstance(): ProxyManager
  37659. {
  37660. if (self::$instance === null) {
  37661. self::$instance = new self();
  37662. }
  37663. return self::$instance;
  37664. }
  37665. public static function reset(): void
  37666. {
  37667. self::$instance = null;
  37668. }
  37669. public function hasProxy(): bool
  37670. {
  37671. return $this->httpProxy !== null || $this->httpsProxy !== null;
  37672. }
  37673. public function getProxyForRequest(string $requestUrl): RequestProxy
  37674. {
  37675. if ($this->error !== null) {
  37676. throw new TransportException('Unable to use a proxy: '.$this->error);
  37677. }
  37678. $scheme = (string) parse_url($requestUrl, PHP_URL_SCHEME);
  37679. $proxy = $this->getProxyForScheme($scheme);
  37680. if ($proxy === null) {
  37681. return RequestProxy::none();
  37682. }
  37683. if ($this->noProxy($requestUrl)) {
  37684. return RequestProxy::noProxy();
  37685. }
  37686. return $proxy->toRequestProxy($scheme);
  37687. }
  37688. private function getProxyForScheme(string $scheme): ?ProxyItem
  37689. {
  37690. if ($scheme === 'http') {
  37691. return $this->httpProxy;
  37692. }
  37693. if ($scheme === 'https') {
  37694. return $this->httpsProxy;
  37695. }
  37696. return null;
  37697. }
  37698. private function getProxyData(): void
  37699. {
  37700. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  37701. [$env, $name] = $this->getProxyEnv('http_proxy');
  37702. if ($env !== null) {
  37703. $this->httpProxy = new ProxyItem($env, $name);
  37704. }
  37705. }
  37706. if ($this->httpProxy === null) {
  37707. [$env, $name] = $this->getProxyEnv('cgi_http_proxy');
  37708. if ($env !== null) {
  37709. $this->httpProxy = new ProxyItem($env, $name);
  37710. }
  37711. }
  37712. [$env, $name] = $this->getProxyEnv('https_proxy');
  37713. if ($env !== null) {
  37714. $this->httpsProxy = new ProxyItem($env, $name);
  37715. }
  37716. [$env, $name] = $this->getProxyEnv('no_proxy');
  37717. if ($env !== null) {
  37718. $this->noProxyHandler = new NoProxyPattern($env);
  37719. }
  37720. }
  37721. private function getProxyEnv(string $envName): array
  37722. {
  37723. $names = [strtolower($envName), strtoupper($envName)];
  37724. foreach ($names as $name) {
  37725. if (is_string($_SERVER[$name] ?? null)) {
  37726. if ($_SERVER[$name] !== '') {
  37727. return [$_SERVER[$name], $name];
  37728. }
  37729. }
  37730. }
  37731. return [null, ''];
  37732. }
  37733. private function noProxy(string $requestUrl): bool
  37734. {
  37735. if ($this->noProxyHandler === null) {
  37736. return false;
  37737. }
  37738. return $this->noProxyHandler->test($requestUrl);
  37739. }
  37740. }
  37741. <?php declare(strict_types=1);
  37742. namespace Composer\Util\Http;
  37743. use Composer\Downloader\TransportException;
  37744. class RequestProxy
  37745. {
  37746. private $contextOptions;
  37747. private $status;
  37748. private $url;
  37749. private $auth;
  37750. public function __construct(?string $url, ?string $auth, ?array $contextOptions, ?string $status)
  37751. {
  37752. $this->url = $url;
  37753. $this->auth = $auth;
  37754. $this->contextOptions = $contextOptions;
  37755. $this->status = $status;
  37756. }
  37757. public static function none(): RequestProxy
  37758. {
  37759. return new self(null, null, null, null);
  37760. }
  37761. public static function noProxy(): RequestProxy
  37762. {
  37763. return new self(null, null, null, 'excluded by no_proxy');
  37764. }
  37765. public function getContextOptions(): ?array
  37766. {
  37767. return $this->contextOptions;
  37768. }
  37769. public function getCurlOptions(array $sslOptions): array
  37770. {
  37771. if ($this->isSecure() && !$this->supportsSecureProxy()) {
  37772. throw new TransportException('Cannot use an HTTPS proxy. PHP >= 7.3 and cUrl >= 7.52.0 are required.');
  37773. }
  37774. $options = [CURLOPT_PROXY => (string) $this->url];
  37775. if ($this->url !== null) {
  37776. $options[CURLOPT_NOPROXY] = '';
  37777. }
  37778. if ($this->auth !== null) {
  37779. $options[CURLOPT_PROXYAUTH] = CURLAUTH_BASIC;
  37780. $options[CURLOPT_PROXYUSERPWD] = $this->auth;
  37781. }
  37782. if ($this->isSecure()) {
  37783. if (isset($sslOptions['cafile'])) {
  37784. $options[CURLOPT_PROXY_CAINFO] = $sslOptions['cafile'];
  37785. }
  37786. if (isset($sslOptions['capath'])) {
  37787. $options[CURLOPT_PROXY_CAPATH] = $sslOptions['capath'];
  37788. }
  37789. }
  37790. return $options;
  37791. }
  37792. public function getStatus(?string $format = null): string
  37793. {
  37794. if ($this->status === null) {
  37795. return '';
  37796. }
  37797. $format = $format ?? '%s';
  37798. if (strpos($format, '%s') !== false) {
  37799. return sprintf($format, $this->status);
  37800. }
  37801. throw new \InvalidArgumentException('String format specifier is missing');
  37802. }
  37803. public function isExcludedByNoProxy(): bool
  37804. {
  37805. return $this->status !== null && $this->url === null;
  37806. }
  37807. public function isSecure(): bool
  37808. {
  37809. return 0 === strpos((string) $this->url, 'https://');
  37810. }
  37811. public function supportsSecureProxy(): bool
  37812. {
  37813. if (false === ($version = curl_version()) || !defined('CURL_VERSION_HTTPS_PROXY')) {
  37814. return false;
  37815. }
  37816. $features = $version['features'];
  37817. return (bool) ($features & CURL_VERSION_HTTPS_PROXY);
  37818. }
  37819. }
  37820. <?php declare(strict_types=1);
  37821. namespace Composer\Util\Http;
  37822. use Composer\Json\JsonFile;
  37823. use Composer\Pcre\Preg;
  37824. use Composer\Util\HttpDownloader;
  37825. class Response
  37826. {
  37827. private $request;
  37828. private $code;
  37829. private $headers;
  37830. private $body;
  37831. public function __construct(array $request, ?int $code, array $headers, ?string $body)
  37832. {
  37833. if (!isset($request['url'])) {
  37834. throw new \LogicException('url key missing from request array');
  37835. }
  37836. $this->request = $request;
  37837. $this->code = (int) $code;
  37838. $this->headers = $headers;
  37839. $this->body = $body;
  37840. }
  37841. public function getStatusCode(): int
  37842. {
  37843. return $this->code;
  37844. }
  37845. public function getStatusMessage(): ?string
  37846. {
  37847. $value = null;
  37848. foreach ($this->headers as $header) {
  37849. if (Preg::isMatch('{^HTTP/\S+ \d+}i', $header)) {
  37850. $value = $header;
  37851. }
  37852. }
  37853. return $value;
  37854. }
  37855. public function getHeaders(): array
  37856. {
  37857. return $this->headers;
  37858. }
  37859. public function getHeader(string $name): ?string
  37860. {
  37861. return self::findHeaderValue($this->headers, $name);
  37862. }
  37863. public function getBody(): ?string
  37864. {
  37865. return $this->body;
  37866. }
  37867. public function decodeJson()
  37868. {
  37869. return JsonFile::parseJson($this->body, $this->request['url']);
  37870. }
  37871. public function collect(): void
  37872. {
  37873. unset($this->request, $this->code, $this->headers, $this->body);
  37874. }
  37875. public static function findHeaderValue(array $headers, string $name): ?string
  37876. {
  37877. $value = null;
  37878. foreach ($headers as $header) {
  37879. if (Preg::isMatch('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) {
  37880. $value = $match[1];
  37881. }
  37882. }
  37883. return $value;
  37884. }
  37885. }
  37886. <?php declare(strict_types=1);
  37887. namespace Composer\Util;
  37888. use Composer\Config;
  37889. use Composer\IO\IOInterface;
  37890. use Composer\Downloader\TransportException;
  37891. use Composer\Pcre\Preg;
  37892. use Composer\Util\Http\Response;
  37893. use Composer\Util\Http\CurlDownloader;
  37894. use Composer\Composer;
  37895. use Composer\Package\Version\VersionParser;
  37896. use Composer\Semver\Constraint\Constraint;
  37897. use Composer\Exception\IrrecoverableDownloadException;
  37898. use React\Promise\Promise;
  37899. use React\Promise\PromiseInterface;
  37900. class HttpDownloader
  37901. {
  37902. private const STATUS_QUEUED = 1;
  37903. private const STATUS_STARTED = 2;
  37904. private const STATUS_COMPLETED = 3;
  37905. private const STATUS_FAILED = 4;
  37906. private const STATUS_ABORTED = 5;
  37907. private $io;
  37908. private $config;
  37909. private $jobs = [];
  37910. private $options = [];
  37911. private $runningJobs = 0;
  37912. private $maxJobs = 12;
  37913. private $curl;
  37914. private $rfs;
  37915. private $idGen = 0;
  37916. private $disabled;
  37917. private $allowAsync = false;
  37918. public function __construct(IOInterface $io, Config $config, array $options = [], bool $disableTls = false)
  37919. {
  37920. $this->io = $io;
  37921. $this->disabled = (bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK');
  37922. if ($disableTls === false) {
  37923. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  37924. }
  37925. $this->options = array_replace_recursive($this->options, $options);
  37926. $this->config = $config;
  37927. if (self::isCurlEnabled()) {
  37928. $this->curl = new CurlDownloader($io, $config, $options, $disableTls);
  37929. }
  37930. $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls);
  37931. if (is_numeric($maxJobs = Platform::getEnv('COMPOSER_MAX_PARALLEL_HTTP'))) {
  37932. $this->maxJobs = max(1, min(50, (int) $maxJobs));
  37933. }
  37934. }
  37935. public function get(string $url, array $options = [])
  37936. {
  37937. if ('' === $url) {
  37938. throw new \InvalidArgumentException('$url must not be an empty string');
  37939. }
  37940. [$job, $promise] = $this->addJob(['url' => $url, 'options' => $options, 'copyTo' => null], true);
  37941. $promise->then(null, function (\Throwable $e) {
  37942. });
  37943. $this->wait($job['id']);
  37944. $response = $this->getResponse($job['id']);
  37945. return $response;
  37946. }
  37947. public function add(string $url, array $options = [])
  37948. {
  37949. if ('' === $url) {
  37950. throw new \InvalidArgumentException('$url must not be an empty string');
  37951. }
  37952. [, $promise] = $this->addJob(['url' => $url, 'options' => $options, 'copyTo' => null]);
  37953. return $promise;
  37954. }
  37955. public function copy(string $url, string $to, array $options = [])
  37956. {
  37957. if ('' === $url) {
  37958. throw new \InvalidArgumentException('$url must not be an empty string');
  37959. }
  37960. [$job] = $this->addJob(['url' => $url, 'options' => $options, 'copyTo' => $to], true);
  37961. $this->wait($job['id']);
  37962. return $this->getResponse($job['id']);
  37963. }
  37964. public function addCopy(string $url, string $to, array $options = [])
  37965. {
  37966. if ('' === $url) {
  37967. throw new \InvalidArgumentException('$url must not be an empty string');
  37968. }
  37969. [, $promise] = $this->addJob(['url' => $url, 'options' => $options, 'copyTo' => $to]);
  37970. return $promise;
  37971. }
  37972. public function getOptions()
  37973. {
  37974. return $this->options;
  37975. }
  37976. public function setOptions(array $options)
  37977. {
  37978. $this->options = array_replace_recursive($this->options, $options);
  37979. }
  37980. private function addJob(array $request, bool $sync = false): array
  37981. {
  37982. $request['options'] = array_replace_recursive($this->options, $request['options']);
  37983. $job = [
  37984. 'id' => $this->idGen++,
  37985. 'status' => self::STATUS_QUEUED,
  37986. 'request' => $request,
  37987. 'sync' => $sync,
  37988. 'origin' => Url::getOrigin($this->config, $request['url']),
  37989. ];
  37990. if (!$sync && !$this->allowAsync) {
  37991. 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');
  37992. }
  37993. if (Preg::isMatchStrictGroups('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $request['url'], $match)) {
  37994. $this->io->setAuthentication($job['origin'], rawurldecode($match[1]), rawurldecode($match[2]));
  37995. }
  37996. $rfs = $this->rfs;
  37997. if ($this->canUseCurl($job)) {
  37998. $resolver = static function ($resolve, $reject) use (&$job): void {
  37999. $job['status'] = HttpDownloader::STATUS_QUEUED;
  38000. $job['resolve'] = $resolve;
  38001. $job['reject'] = $reject;
  38002. };
  38003. } else {
  38004. $resolver = static function ($resolve, $reject) use (&$job, $rfs): void {
  38005. $url = $job['request']['url'];
  38006. $options = $job['request']['options'];
  38007. $job['status'] = HttpDownloader::STATUS_STARTED;
  38008. if ($job['request']['copyTo']) {
  38009. $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false , $options);
  38010. $headers = $rfs->getLastHeaders();
  38011. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
  38012. $resolve($response);
  38013. } else {
  38014. $body = $rfs->getContents($job['origin'], $url, false , $options);
  38015. $headers = $rfs->getLastHeaders();
  38016. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $body);
  38017. $resolve($response);
  38018. }
  38019. };
  38020. }
  38021. $curl = $this->curl;
  38022. $canceler = static function () use (&$job, $curl): void {
  38023. if ($job['status'] === HttpDownloader::STATUS_QUEUED) {
  38024. $job['status'] = HttpDownloader::STATUS_ABORTED;
  38025. }
  38026. if ($job['status'] !== HttpDownloader::STATUS_STARTED) {
  38027. return;
  38028. }
  38029. $job['status'] = HttpDownloader::STATUS_ABORTED;
  38030. if (isset($job['curl_id'])) {
  38031. $curl->abortRequest($job['curl_id']);
  38032. }
  38033. throw new IrrecoverableDownloadException('Download of ' . Url::sanitize($job['request']['url']) . ' canceled');
  38034. };
  38035. $promise = new Promise($resolver, $canceler);
  38036. $promise = $promise->then(function ($response) use (&$job) {
  38037. $job['status'] = HttpDownloader::STATUS_COMPLETED;
  38038. $job['response'] = $response;
  38039. $this->markJobDone();
  38040. return $response;
  38041. }, function ($e) use (&$job): void {
  38042. $job['status'] = HttpDownloader::STATUS_FAILED;
  38043. $job['exception'] = $e;
  38044. $this->markJobDone();
  38045. throw $e;
  38046. });
  38047. $this->jobs[$job['id']] = &$job;
  38048. if ($this->runningJobs < $this->maxJobs) {
  38049. $this->startJob($job['id']);
  38050. }
  38051. return [$job, $promise];
  38052. }
  38053. private function startJob(int $id): void
  38054. {
  38055. $job = &$this->jobs[$id];
  38056. if ($job['status'] !== self::STATUS_QUEUED) {
  38057. return;
  38058. }
  38059. $job['status'] = self::STATUS_STARTED;
  38060. $this->runningJobs++;
  38061. assert(isset($job['resolve']));
  38062. assert(isset($job['reject']));
  38063. $resolve = $job['resolve'];
  38064. $reject = $job['reject'];
  38065. $url = $job['request']['url'];
  38066. $options = $job['request']['options'];
  38067. $origin = $job['origin'];
  38068. if ($this->disabled) {
  38069. if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
  38070. $resolve(new Response(['url' => $url], 304, [], ''));
  38071. } else {
  38072. $e = new TransportException('Network disabled, request canceled: '.Url::sanitize($url), 499);
  38073. $e->setStatusCode(499);
  38074. $reject($e);
  38075. }
  38076. return;
  38077. }
  38078. try {
  38079. if ($job['request']['copyTo']) {
  38080. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
  38081. } else {
  38082. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options);
  38083. }
  38084. } catch (\Exception $exception) {
  38085. $reject($exception);
  38086. }
  38087. }
  38088. private function markJobDone(): void
  38089. {
  38090. $this->runningJobs--;
  38091. }
  38092. public function wait(?int $index = null)
  38093. {
  38094. do {
  38095. $jobCount = $this->countActiveJobs($index);
  38096. } while ($jobCount);
  38097. }
  38098. public function enableAsync(): void
  38099. {
  38100. $this->allowAsync = true;
  38101. }
  38102. public function countActiveJobs(?int $index = null): int
  38103. {
  38104. if ($this->runningJobs < $this->maxJobs) {
  38105. foreach ($this->jobs as $job) {
  38106. if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
  38107. $this->startJob($job['id']);
  38108. }
  38109. }
  38110. }
  38111. if ($this->curl) {
  38112. $this->curl->tick();
  38113. }
  38114. if (null !== $index) {
  38115. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  38116. }
  38117. $active = 0;
  38118. foreach ($this->jobs as $job) {
  38119. if ($job['status'] < self::STATUS_COMPLETED) {
  38120. $active++;
  38121. } elseif (!$job['sync']) {
  38122. unset($this->jobs[$job['id']]);
  38123. }
  38124. }
  38125. return $active;
  38126. }
  38127. private function getResponse(int $index): Response
  38128. {
  38129. if (!isset($this->jobs[$index])) {
  38130. throw new \LogicException('Invalid request id');
  38131. }
  38132. if ($this->jobs[$index]['status'] === self::STATUS_FAILED) {
  38133. assert(isset($this->jobs[$index]['exception']));
  38134. throw $this->jobs[$index]['exception'];
  38135. }
  38136. if (!isset($this->jobs[$index]['response'])) {
  38137. throw new \LogicException('Response not available yet, call wait() first');
  38138. }
  38139. $resp = $this->jobs[$index]['response'];
  38140. unset($this->jobs[$index]);
  38141. return $resp;
  38142. }
  38143. public static function outputWarnings(IOInterface $io, string $url, $data): void
  38144. {
  38145. $cleanMessage = static function ($msg) use ($io) {
  38146. if (!$io->isDecorated()) {
  38147. $msg = Preg::replace('{'.chr(27).'\\[[;\d]*m}u', '', $msg);
  38148. }
  38149. return $msg;
  38150. };
  38151. foreach (['warning', 'info'] as $type) {
  38152. if (empty($data[$type])) {
  38153. continue;
  38154. }
  38155. if (!empty($data[$type . '-versions'])) {
  38156. $versionParser = new VersionParser();
  38157. $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
  38158. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  38159. if (!$constraint->matches($composer)) {
  38160. continue;
  38161. }
  38162. }
  38163. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$cleanMessage($data[$type]).'</'.$type.'>');
  38164. }
  38165. foreach (['warnings', 'infos'] as $key) {
  38166. if (empty($data[$key])) {
  38167. continue;
  38168. }
  38169. $versionParser = new VersionParser();
  38170. foreach ($data[$key] as $spec) {
  38171. $type = substr($key, 0, -1);
  38172. $constraint = $versionParser->parseConstraints($spec['versions']);
  38173. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  38174. if (!$constraint->matches($composer)) {
  38175. continue;
  38176. }
  38177. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$cleanMessage($spec['message']).'</'.$type.'>');
  38178. }
  38179. }
  38180. }
  38181. public static function getExceptionHints(\Throwable $e): ?array
  38182. {
  38183. if (!$e instanceof TransportException) {
  38184. return null;
  38185. }
  38186. if (
  38187. false !== strpos($e->getMessage(), 'Resolving timed out')
  38188. || false !== strpos($e->getMessage(), 'Could not resolve host')
  38189. ) {
  38190. Silencer::suppress();
  38191. $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create([
  38192. 'ssl' => ['verify_peer' => false],
  38193. 'http' => ['follow_location' => false, 'ignore_errors' => true],
  38194. ]));
  38195. Silencer::restore();
  38196. if (false !== $testConnectivity) {
  38197. return [
  38198. '<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>',
  38199. ];
  38200. }
  38201. return [
  38202. '<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>',
  38203. ];
  38204. }
  38205. return null;
  38206. }
  38207. private function canUseCurl(array $job): bool
  38208. {
  38209. if (!$this->curl) {
  38210. return false;
  38211. }
  38212. if (!Preg::isMatch('{^https?://}i', $job['request']['url'])) {
  38213. return false;
  38214. }
  38215. if (!empty($job['request']['options']['ssl']['allow_self_signed'])) {
  38216. return false;
  38217. }
  38218. return true;
  38219. }
  38220. public static function isCurlEnabled(): bool
  38221. {
  38222. return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
  38223. }
  38224. }
  38225. <?php declare(strict_types=1);
  38226. namespace Composer\Util;
  38227. use Composer\XdebugHandler\XdebugHandler;
  38228. class IniHelper
  38229. {
  38230. public static function getAll(): array
  38231. {
  38232. return XdebugHandler::getAllIniFiles();
  38233. }
  38234. public static function getMessage(): string
  38235. {
  38236. $paths = self::getAll();
  38237. if (empty($paths[0])) {
  38238. array_shift($paths);
  38239. }
  38240. $ini = array_shift($paths);
  38241. if (empty($ini)) {
  38242. return 'A php.ini file does not exist. You will have to create one.';
  38243. }
  38244. if (!empty($paths)) {
  38245. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  38246. }
  38247. return 'The php.ini used by your command-line PHP is: '.$ini;
  38248. }
  38249. }
  38250. <?php declare(strict_types=1);
  38251. namespace Composer\Util;
  38252. use React\Promise\CancellablePromiseInterface;
  38253. use Symfony\Component\Console\Helper\ProgressBar;
  38254. use React\Promise\PromiseInterface;
  38255. class Loop
  38256. {
  38257. private $httpDownloader;
  38258. private $processExecutor;
  38259. private $currentPromises = [];
  38260. private $waitIndex = 0;
  38261. public function __construct(HttpDownloader $httpDownloader, ?ProcessExecutor $processExecutor = null)
  38262. {
  38263. $this->httpDownloader = $httpDownloader;
  38264. $this->httpDownloader->enableAsync();
  38265. $this->processExecutor = $processExecutor;
  38266. if ($this->processExecutor) {
  38267. $this->processExecutor->enableAsync();
  38268. }
  38269. }
  38270. public function getHttpDownloader(): HttpDownloader
  38271. {
  38272. return $this->httpDownloader;
  38273. }
  38274. public function getProcessExecutor(): ?ProcessExecutor
  38275. {
  38276. return $this->processExecutor;
  38277. }
  38278. public function wait(array $promises, ?ProgressBar $progress = null): void
  38279. {
  38280. $uncaught = null;
  38281. \React\Promise\all($promises)->then(
  38282. static function (): void {
  38283. },
  38284. static function (\Throwable $e) use (&$uncaught): void {
  38285. $uncaught = $e;
  38286. }
  38287. );
  38288. $waitIndex = $this->waitIndex++;
  38289. $this->currentPromises[$waitIndex] = $promises;
  38290. if ($progress) {
  38291. $totalJobs = 0;
  38292. $totalJobs += $this->httpDownloader->countActiveJobs();
  38293. if ($this->processExecutor) {
  38294. $totalJobs += $this->processExecutor->countActiveJobs();
  38295. }
  38296. $progress->start($totalJobs);
  38297. }
  38298. $lastUpdate = 0;
  38299. while (true) {
  38300. $activeJobs = 0;
  38301. $activeJobs += $this->httpDownloader->countActiveJobs();
  38302. if ($this->processExecutor) {
  38303. $activeJobs += $this->processExecutor->countActiveJobs();
  38304. }
  38305. if ($progress && microtime(true) - $lastUpdate > 0.1) {
  38306. $lastUpdate = microtime(true);
  38307. $progress->setProgress($progress->getMaxSteps() - $activeJobs);
  38308. }
  38309. if (!$activeJobs) {
  38310. break;
  38311. }
  38312. }
  38313. if ($progress) {
  38314. $progress->finish();
  38315. }
  38316. unset($this->currentPromises[$waitIndex]);
  38317. if (null !== $uncaught) {
  38318. throw $uncaught;
  38319. }
  38320. }
  38321. public function abortJobs(): void
  38322. {
  38323. foreach ($this->currentPromises as $promiseGroup) {
  38324. foreach ($promiseGroup as $promise) {
  38325. \React\Promise\resolve($promise)->cancel();
  38326. }
  38327. }
  38328. }
  38329. }
  38330. <?php declare(strict_types=1);
  38331. namespace Composer\Util;
  38332. @trigger_error('Composer\Util\MetadataMinifier is deprecated, use Composer\MetadataMinifier\MetadataMinifier from composer/metadata-minifier instead.', E_USER_DEPRECATED);
  38333. class MetadataMinifier extends \Composer\MetadataMinifier\MetadataMinifier
  38334. {
  38335. }
  38336. <?php declare(strict_types=1);
  38337. namespace Composer\Util;
  38338. use Composer\Pcre\Preg;
  38339. use stdClass;
  38340. class NoProxyPattern
  38341. {
  38342. protected $hostNames = [];
  38343. protected $rules = [];
  38344. protected $noproxy;
  38345. public function __construct(string $pattern)
  38346. {
  38347. $this->hostNames = Preg::split('{[\s,]+}', $pattern, -1, PREG_SPLIT_NO_EMPTY);
  38348. $this->noproxy = empty($this->hostNames) || '*' === $this->hostNames[0];
  38349. }
  38350. public function test(string $url): bool
  38351. {
  38352. if ($this->noproxy) {
  38353. return true;
  38354. }
  38355. if (!$urlData = $this->getUrlData($url)) {
  38356. return false;
  38357. }
  38358. foreach ($this->hostNames as $index => $hostName) {
  38359. if ($this->match($index, $hostName, $urlData)) {
  38360. return true;
  38361. }
  38362. }
  38363. return false;
  38364. }
  38365. protected function getUrlData(string $url)
  38366. {
  38367. if (!$host = parse_url($url, PHP_URL_HOST)) {
  38368. return false;
  38369. }
  38370. $port = parse_url($url, PHP_URL_PORT);
  38371. if (empty($port)) {
  38372. switch (parse_url($url, PHP_URL_SCHEME)) {
  38373. case 'http':
  38374. $port = 80;
  38375. break;
  38376. case 'https':
  38377. $port = 443;
  38378. break;
  38379. }
  38380. }
  38381. $hostName = $host . ($port ? ':' . $port : '');
  38382. [$host, $port, $err] = $this->splitHostPort($hostName);
  38383. if ($err || !$this->ipCheckData($host, $ipdata)) {
  38384. return false;
  38385. }
  38386. return $this->makeData($host, $port, $ipdata);
  38387. }
  38388. protected function match(int $index, string $hostName, stdClass $url): bool
  38389. {
  38390. if (!$rule = $this->getRule($index, $hostName)) {
  38391. return false;
  38392. }
  38393. if ($rule->ipdata) {
  38394. if (!$url->ipdata) {
  38395. return false;
  38396. }
  38397. if ($rule->ipdata->netmask) {
  38398. return $this->matchRange($rule->ipdata, $url->ipdata);
  38399. }
  38400. $match = $rule->ipdata->ip === $url->ipdata->ip;
  38401. } else {
  38402. $haystack = substr($url->name, -strlen($rule->name));
  38403. $match = stripos($haystack, $rule->name) === 0;
  38404. }
  38405. if ($match && $rule->port) {
  38406. $match = $rule->port === $url->port;
  38407. }
  38408. return $match;
  38409. }
  38410. protected function matchRange(stdClass $network, stdClass $target): bool
  38411. {
  38412. $net = unpack('C*', $network->ip);
  38413. $mask = unpack('C*', $network->netmask);
  38414. $ip = unpack('C*', $target->ip);
  38415. if (false === $net) {
  38416. throw new \RuntimeException('Could not parse network IP '.$network->ip);
  38417. }
  38418. if (false === $mask) {
  38419. throw new \RuntimeException('Could not parse netmask '.$network->netmask);
  38420. }
  38421. if (false === $ip) {
  38422. throw new \RuntimeException('Could not parse target IP '.$target->ip);
  38423. }
  38424. for ($i = 1; $i < 17; ++$i) {
  38425. if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
  38426. return false;
  38427. }
  38428. }
  38429. return true;
  38430. }
  38431. private function getRule(int $index, string $hostName): ?stdClass
  38432. {
  38433. if (array_key_exists($index, $this->rules)) {
  38434. return $this->rules[$index];
  38435. }
  38436. $this->rules[$index] = null;
  38437. [$host, $port, $err] = $this->splitHostPort($hostName);
  38438. if ($err || !$this->ipCheckData($host, $ipdata, true)) {
  38439. return null;
  38440. }
  38441. $this->rules[$index] = $this->makeData($host, $port, $ipdata);
  38442. return $this->rules[$index];
  38443. }
  38444. private function ipCheckData(string $host, ?stdClass &$ipdata, bool $allowPrefix = false): bool
  38445. {
  38446. $ipdata = null;
  38447. $netmask = null;
  38448. $prefix = null;
  38449. $modified = false;
  38450. if (strpos($host, '/') !== false) {
  38451. [$host, $prefix] = explode('/', $host);
  38452. if (!$allowPrefix || !$this->validateInt($prefix, 0, 128)) {
  38453. return false;
  38454. }
  38455. $prefix = (int) $prefix;
  38456. $modified = true;
  38457. }
  38458. if (!filter_var($host, FILTER_VALIDATE_IP)) {
  38459. return !$modified;
  38460. }
  38461. [$ip, $size] = $this->ipGetAddr($host);
  38462. if ($prefix !== null) {
  38463. if ($prefix > $size * 8) {
  38464. return false;
  38465. }
  38466. [$ip, $netmask] = $this->ipGetNetwork($ip, $size, $prefix);
  38467. }
  38468. $ipdata = $this->makeIpData($ip, $size, $netmask);
  38469. return true;
  38470. }
  38471. private function ipGetAddr(string $host): array
  38472. {
  38473. $ip = inet_pton($host);
  38474. $size = strlen($ip);
  38475. $mapped = $this->ipMapTo6($ip, $size);
  38476. return [$mapped, $size];
  38477. }
  38478. private function ipGetMask(int $prefix, int $size): string
  38479. {
  38480. $mask = '';
  38481. if ($ones = floor($prefix / 8)) {
  38482. $mask = str_repeat(chr(255), (int) $ones);
  38483. }
  38484. if ($remainder = $prefix % 8) {
  38485. $mask .= chr(0xff ^ (0xff >> $remainder));
  38486. }
  38487. $mask = str_pad($mask, $size, chr(0));
  38488. return $this->ipMapTo6($mask, $size);
  38489. }
  38490. private function ipGetNetwork(string $rangeIp, int $size, int $prefix): array
  38491. {
  38492. $netmask = $this->ipGetMask($prefix, $size);
  38493. $mask = unpack('C*', $netmask);
  38494. $ip = unpack('C*', $rangeIp);
  38495. $net = '';
  38496. if (false === $mask) {
  38497. throw new \RuntimeException('Could not parse netmask '.$netmask);
  38498. }
  38499. if (false === $ip) {
  38500. throw new \RuntimeException('Could not parse range IP '.$rangeIp);
  38501. }
  38502. for ($i = 1; $i < 17; ++$i) {
  38503. $net .= chr($ip[$i] & $mask[$i]);
  38504. }
  38505. return [$net, $netmask];
  38506. }
  38507. private function ipMapTo6(string $binary, int $size): string
  38508. {
  38509. if ($size === 4) {
  38510. $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
  38511. $binary = $prefix . $binary;
  38512. }
  38513. return $binary;
  38514. }
  38515. private function makeData(string $host, int $port, ?stdClass $ipdata): stdClass
  38516. {
  38517. return (object) [
  38518. 'host' => $host,
  38519. 'name' => '.' . ltrim($host, '.'),
  38520. 'port' => $port,
  38521. 'ipdata' => $ipdata,
  38522. ];
  38523. }
  38524. private function makeIpData(string $ip, int $size, ?string $netmask): stdClass
  38525. {
  38526. return (object) [
  38527. 'ip' => $ip,
  38528. 'size' => $size,
  38529. 'netmask' => $netmask,
  38530. ];
  38531. }
  38532. private function splitHostPort(string $hostName): array
  38533. {
  38534. $error = ['', '', true];
  38535. $port = 0;
  38536. $ip6 = '';
  38537. if ($hostName[0] === '[') {
  38538. $index = strpos($hostName, ']');
  38539. if (false === $index || $index < 3) {
  38540. return $error;
  38541. }
  38542. $ip6 = substr($hostName, 1, $index - 1);
  38543. $hostName = substr($hostName, $index + 1);
  38544. if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) {
  38545. return $error;
  38546. }
  38547. }
  38548. if (substr_count($hostName, ':') === 1) {
  38549. $index = strpos($hostName, ':');
  38550. $port = substr($hostName, $index + 1);
  38551. $hostName = substr($hostName, 0, $index);
  38552. if (!$this->validateInt($port, 1, 65535)) {
  38553. return $error;
  38554. }
  38555. $port = (int) $port;
  38556. }
  38557. $host = $ip6 . $hostName;
  38558. return [$host, $port, false];
  38559. }
  38560. private function validateInt(string $int, int $min, int $max): bool
  38561. {
  38562. $options = [
  38563. 'options' => [
  38564. 'min_range' => $min,
  38565. 'max_range' => $max,
  38566. ],
  38567. ];
  38568. return false !== filter_var($int, FILTER_VALIDATE_INT, $options);
  38569. }
  38570. }
  38571. <?php declare(strict_types=1);
  38572. namespace Composer\Util;
  38573. use Composer\Package\CompletePackageInterface;
  38574. use Composer\Package\PackageInterface;
  38575. class PackageInfo
  38576. {
  38577. public static function getViewSourceUrl(PackageInterface $package): ?string
  38578. {
  38579. if ($package instanceof CompletePackageInterface && isset($package->getSupport()['source']) && '' !== $package->getSupport()['source']) {
  38580. return $package->getSupport()['source'];
  38581. }
  38582. return $package->getSourceUrl();
  38583. }
  38584. public static function getViewSourceOrHomepageUrl(PackageInterface $package): ?string
  38585. {
  38586. $url = self::getViewSourceUrl($package) ?? ($package instanceof CompletePackageInterface ? $package->getHomepage() : null);
  38587. if ($url === '') {
  38588. return null;
  38589. }
  38590. return $url;
  38591. }
  38592. }
  38593. <?php declare(strict_types=1);
  38594. namespace Composer\Util;
  38595. use Composer\Package\PackageInterface;
  38596. use Composer\Package\RootPackageInterface;
  38597. class PackageSorter
  38598. {
  38599. public static function getMostCurrentVersion(array $packages): ?PackageInterface
  38600. {
  38601. if (count($packages) === 0) {
  38602. return null;
  38603. }
  38604. $highest = reset($packages);
  38605. foreach ($packages as $candidate) {
  38606. if ($candidate->isDefaultBranch()) {
  38607. return $candidate;
  38608. }
  38609. if (version_compare($highest->getVersion(), $candidate->getVersion(), '<')) {
  38610. $highest = $candidate;
  38611. }
  38612. }
  38613. return $highest;
  38614. }
  38615. public static function sortPackagesAlphabetically(array $packages): array
  38616. {
  38617. usort($packages, static function (PackageInterface $a, PackageInterface $b) {
  38618. return $a->getName() <=> $b->getName();
  38619. });
  38620. return $packages;
  38621. }
  38622. public static function sortPackages(array $packages, array $weights = []): array
  38623. {
  38624. $usageList = [];
  38625. foreach ($packages as $package) {
  38626. $links = $package->getRequires();
  38627. if ($package instanceof RootPackageInterface) {
  38628. $links = array_merge($links, $package->getDevRequires());
  38629. }
  38630. foreach ($links as $link) {
  38631. $target = $link->getTarget();
  38632. $usageList[$target][] = $package->getName();
  38633. }
  38634. }
  38635. $computing = [];
  38636. $computed = [];
  38637. $computeImportance = static function ($name) use (&$computeImportance, &$computing, &$computed, $usageList, $weights) {
  38638. if (isset($computed[$name])) {
  38639. return $computed[$name];
  38640. }
  38641. if (isset($computing[$name])) {
  38642. return 0;
  38643. }
  38644. $computing[$name] = true;
  38645. $weight = $weights[$name] ?? 0;
  38646. if (isset($usageList[$name])) {
  38647. foreach ($usageList[$name] as $user) {
  38648. $weight -= 1 - $computeImportance($user);
  38649. }
  38650. }
  38651. unset($computing[$name]);
  38652. $computed[$name] = $weight;
  38653. return $weight;
  38654. };
  38655. $weightedPackages = [];
  38656. foreach ($packages as $index => $package) {
  38657. $name = $package->getName();
  38658. $weight = $computeImportance($name);
  38659. $weightedPackages[] = ['name' => $name, 'weight' => $weight, 'index' => $index];
  38660. }
  38661. usort($weightedPackages, static function (array $a, array $b): int {
  38662. if ($a['weight'] !== $b['weight']) {
  38663. return $a['weight'] - $b['weight'];
  38664. }
  38665. return strnatcasecmp($a['name'], $b['name']);
  38666. });
  38667. $sortedPackages = [];
  38668. foreach ($weightedPackages as $pkg) {
  38669. $sortedPackages[] = $packages[$pkg['index']];
  38670. }
  38671. return $sortedPackages;
  38672. }
  38673. }
  38674. <?php declare(strict_types=1);
  38675. namespace Composer\Util;
  38676. use Composer\IO\IOInterface;
  38677. use Composer\Pcre\Preg;
  38678. use Symfony\Component\Process\ExecutableFinder;
  38679. use Symfony\Component\Process\Process;
  38680. class Perforce
  38681. {
  38682. protected $path;
  38683. protected $p4Depot;
  38684. protected $p4Client;
  38685. protected $p4User;
  38686. protected $p4Password;
  38687. protected $p4Port;
  38688. protected $p4Stream;
  38689. protected $p4ClientSpec;
  38690. protected $p4DepotType;
  38691. protected $p4Branch;
  38692. protected $process;
  38693. protected $uniquePerforceClientName;
  38694. protected $windowsFlag;
  38695. protected $commandResult;
  38696. protected $io;
  38697. protected $filesystem;
  38698. public function __construct($repoConfig, string $port, string $path, ProcessExecutor $process, bool $isWindows, IOInterface $io)
  38699. {
  38700. $this->windowsFlag = $isWindows;
  38701. $this->p4Port = $port;
  38702. $this->initializePath($path);
  38703. $this->process = $process;
  38704. $this->initialize($repoConfig);
  38705. $this->io = $io;
  38706. }
  38707. public static function create($repoConfig, string $port, string $path, ProcessExecutor $process, IOInterface $io): self
  38708. {
  38709. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  38710. }
  38711. public static function checkServerExists(string $url, ProcessExecutor $processExecutor): bool
  38712. {
  38713. return 0 === $processExecutor->execute(['p4', '-p', $url, 'info', '-s'], $ignoredOutput);
  38714. }
  38715. public function initialize($repoConfig): void
  38716. {
  38717. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  38718. if (!$repoConfig) {
  38719. return;
  38720. }
  38721. if (isset($repoConfig['unique_perforce_client_name'])) {
  38722. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  38723. }
  38724. if (isset($repoConfig['depot'])) {
  38725. $this->p4Depot = $repoConfig['depot'];
  38726. }
  38727. if (isset($repoConfig['branch'])) {
  38728. $this->p4Branch = $repoConfig['branch'];
  38729. }
  38730. if (isset($repoConfig['p4user'])) {
  38731. $this->p4User = $repoConfig['p4user'];
  38732. } else {
  38733. $this->p4User = $this->getP4variable('P4USER');
  38734. }
  38735. if (isset($repoConfig['p4password'])) {
  38736. $this->p4Password = $repoConfig['p4password'];
  38737. }
  38738. }
  38739. public function initializeDepotAndBranch(?string $depot, ?string $branch): void
  38740. {
  38741. if (isset($depot)) {
  38742. $this->p4Depot = $depot;
  38743. }
  38744. if (isset($branch)) {
  38745. $this->p4Branch = $branch;
  38746. }
  38747. }
  38748. public function generateUniquePerforceClientName(): string
  38749. {
  38750. return gethostname() . "_" . time();
  38751. }
  38752. public function cleanupClientSpec(): void
  38753. {
  38754. $client = $this->getClient();
  38755. $task = 'client -d ' . ProcessExecutor::escape($client);
  38756. $useP4Client = false;
  38757. $command = $this->generateP4Command($task, $useP4Client);
  38758. $this->executeCommand($command);
  38759. $clientSpec = $this->getP4ClientSpec();
  38760. $fileSystem = $this->getFilesystem();
  38761. $fileSystem->remove($clientSpec);
  38762. }
  38763. protected function executeCommand($command): int
  38764. {
  38765. $this->commandResult = '';
  38766. return $this->process->execute($command, $this->commandResult);
  38767. }
  38768. public function getClient(): string
  38769. {
  38770. if (!isset($this->p4Client)) {
  38771. $cleanStreamName = str_replace(['//', '/', '@'], ['', '_', ''], $this->getStream());
  38772. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  38773. }
  38774. return $this->p4Client;
  38775. }
  38776. protected function getPath(): string
  38777. {
  38778. return $this->path;
  38779. }
  38780. public function initializePath(string $path): void
  38781. {
  38782. $this->path = $path;
  38783. $fs = $this->getFilesystem();
  38784. $fs->ensureDirectoryExists($path);
  38785. }
  38786. protected function getPort(): string
  38787. {
  38788. return $this->p4Port;
  38789. }
  38790. public function setStream(string $stream): void
  38791. {
  38792. $this->p4Stream = $stream;
  38793. $index = strrpos($stream, '/');
  38794. if ($index > 2) {
  38795. $this->p4DepotType = 'stream';
  38796. }
  38797. }
  38798. public function isStream(): bool
  38799. {
  38800. return is_string($this->p4DepotType) && (strcmp($this->p4DepotType, 'stream') === 0);
  38801. }
  38802. public function getStream(): string
  38803. {
  38804. if (!isset($this->p4Stream)) {
  38805. if ($this->isStream()) {
  38806. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  38807. } else {
  38808. $this->p4Stream = '//' . $this->p4Depot;
  38809. }
  38810. }
  38811. return $this->p4Stream;
  38812. }
  38813. public function getStreamWithoutLabel(string $stream): string
  38814. {
  38815. $index = strpos($stream, '@');
  38816. if ($index === false) {
  38817. return $stream;
  38818. }
  38819. return substr($stream, 0, $index);
  38820. }
  38821. public function getP4ClientSpec(): string
  38822. {
  38823. return $this->path . '/' . $this->getClient() . '.p4.spec';
  38824. }
  38825. public function getUser(): ?string
  38826. {
  38827. return $this->p4User;
  38828. }
  38829. public function setUser(?string $user): void
  38830. {
  38831. $this->p4User = $user;
  38832. }
  38833. public function queryP4User(): void
  38834. {
  38835. $this->getUser();
  38836. if (strlen((string) $this->p4User) > 0) {
  38837. return;
  38838. }
  38839. $this->p4User = $this->getP4variable('P4USER');
  38840. if (strlen((string) $this->p4User) > 0) {
  38841. return;
  38842. }
  38843. $this->p4User = $this->io->ask('Enter P4 User:');
  38844. if ($this->windowsFlag) {
  38845. $command = $this->getP4Executable().' set P4USER=' . $this->p4User;
  38846. } else {
  38847. $command = 'export P4USER=' . $this->p4User;
  38848. }
  38849. $this->executeCommand($command);
  38850. }
  38851. protected function getP4variable(string $name): ?string
  38852. {
  38853. if ($this->windowsFlag) {
  38854. $command = $this->getP4Executable().' set';
  38855. $this->executeCommand($command);
  38856. $result = trim($this->commandResult);
  38857. $resArray = explode(PHP_EOL, $result);
  38858. foreach ($resArray as $line) {
  38859. $fields = explode('=', $line);
  38860. if (strcmp($name, $fields[0]) === 0) {
  38861. $index = strpos($fields[1], ' ');
  38862. if ($index === false) {
  38863. $value = $fields[1];
  38864. } else {
  38865. $value = substr($fields[1], 0, $index);
  38866. }
  38867. $value = trim($value);
  38868. return $value;
  38869. }
  38870. }
  38871. return null;
  38872. }
  38873. $command = 'echo $' . $name;
  38874. $this->executeCommand($command);
  38875. $result = trim($this->commandResult);
  38876. return $result;
  38877. }
  38878. public function queryP4Password(): ?string
  38879. {
  38880. if (isset($this->p4Password)) {
  38881. return $this->p4Password;
  38882. }
  38883. $password = $this->getP4variable('P4PASSWD');
  38884. if (strlen((string) $password) <= 0) {
  38885. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  38886. }
  38887. $this->p4Password = $password;
  38888. return $password;
  38889. }
  38890. public function generateP4Command(string $command, bool $useClient = true): string
  38891. {
  38892. $p4Command = $this->getP4Executable().' ';
  38893. $p4Command .= '-u ' . $this->getUser() . ' ';
  38894. if ($useClient) {
  38895. $p4Command .= '-c ' . $this->getClient() . ' ';
  38896. }
  38897. $p4Command .= '-p ' . $this->getPort() . ' ' . $command;
  38898. return $p4Command;
  38899. }
  38900. public function isLoggedIn(): bool
  38901. {
  38902. $command = $this->generateP4Command('login -s', false);
  38903. $exitCode = $this->executeCommand($command);
  38904. if ($exitCode) {
  38905. $errorOutput = $this->process->getErrorOutput();
  38906. $index = strpos($errorOutput, $this->getUser());
  38907. if ($index === false) {
  38908. $index = strpos($errorOutput, 'p4');
  38909. if ($index === false) {
  38910. return false;
  38911. }
  38912. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  38913. }
  38914. throw new \Exception('Invalid user name: ' . $this->getUser());
  38915. }
  38916. return true;
  38917. }
  38918. public function connectClient(): void
  38919. {
  38920. $p4CreateClientCommand = $this->generateP4Command(
  38921. 'client -i < ' . ProcessExecutor::escape($this->getP4ClientSpec())
  38922. );
  38923. $this->executeCommand($p4CreateClientCommand);
  38924. }
  38925. public function syncCodeBase(?string $sourceReference): void
  38926. {
  38927. $prevDir = Platform::getCwd();
  38928. chdir($this->path);
  38929. $p4SyncCommand = $this->generateP4Command('sync -f ');
  38930. if (null !== $sourceReference) {
  38931. $p4SyncCommand .= '@' . $sourceReference;
  38932. }
  38933. $this->executeCommand($p4SyncCommand);
  38934. chdir($prevDir);
  38935. }
  38936. public function writeClientSpecToFile($spec): void
  38937. {
  38938. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  38939. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  38940. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  38941. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  38942. fwrite($spec, 'Description:' . PHP_EOL);
  38943. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  38944. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  38945. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  38946. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  38947. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  38948. if ($this->isStream()) {
  38949. fwrite($spec, 'Stream:' . PHP_EOL);
  38950. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  38951. } else {
  38952. fwrite(
  38953. $spec,
  38954. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  38955. );
  38956. }
  38957. }
  38958. public function writeP4ClientSpec(): void
  38959. {
  38960. $clientSpec = $this->getP4ClientSpec();
  38961. $spec = fopen($clientSpec, 'w');
  38962. try {
  38963. $this->writeClientSpecToFile($spec);
  38964. } catch (\Exception $e) {
  38965. fclose($spec);
  38966. throw $e;
  38967. }
  38968. fclose($spec);
  38969. }
  38970. protected function read($pipe, $name): void
  38971. {
  38972. if (feof($pipe)) {
  38973. return;
  38974. }
  38975. $line = fgets($pipe);
  38976. while ($line !== false) {
  38977. $line = fgets($pipe);
  38978. }
  38979. }
  38980. public function windowsLogin(?string $password): int
  38981. {
  38982. $command = $this->generateP4Command(' login -a');
  38983. $process = Process::fromShellCommandline($command, null, null, $password);
  38984. return $process->run();
  38985. }
  38986. public function p4Login(): void
  38987. {
  38988. $this->queryP4User();
  38989. if (!$this->isLoggedIn()) {
  38990. $password = $this->queryP4Password();
  38991. if ($this->windowsFlag) {
  38992. $this->windowsLogin($password);
  38993. } else {
  38994. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  38995. $exitCode = $this->executeCommand($command);
  38996. if ($exitCode) {
  38997. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  38998. }
  38999. }
  39000. }
  39001. }
  39002. public function getComposerInformation(string $identifier): ?array
  39003. {
  39004. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  39005. if (!$composerFileContent) {
  39006. return null;
  39007. }
  39008. return json_decode($composerFileContent, true);
  39009. }
  39010. public function getFileContent(string $file, string $identifier): ?string
  39011. {
  39012. $path = $this->getFilePath($file, $identifier);
  39013. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  39014. $this->executeCommand($command);
  39015. $result = $this->commandResult;
  39016. if (!trim($result)) {
  39017. return null;
  39018. }
  39019. return $result;
  39020. }
  39021. public function getFilePath(string $file, string $identifier): ?string
  39022. {
  39023. $index = strpos($identifier, '@');
  39024. if ($index === false) {
  39025. return $identifier. '/' . $file;
  39026. }
  39027. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  39028. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  39029. $this->executeCommand($command);
  39030. $result = $this->commandResult;
  39031. $index2 = strpos($result, 'no such file(s).');
  39032. if ($index2 === false) {
  39033. $index3 = strpos($result, 'change');
  39034. if ($index3 !== false) {
  39035. $phrase = trim(substr($result, $index3));
  39036. $fields = explode(' ', $phrase);
  39037. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  39038. }
  39039. }
  39040. return null;
  39041. }
  39042. public function getBranches(): array
  39043. {
  39044. $possibleBranches = [];
  39045. if (!$this->isStream()) {
  39046. $possibleBranches[$this->p4Branch] = $this->getStream();
  39047. } else {
  39048. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  39049. $this->executeCommand($command);
  39050. $result = $this->commandResult;
  39051. $resArray = explode(PHP_EOL, $result);
  39052. foreach ($resArray as $line) {
  39053. $resBits = explode(' ', $line);
  39054. if (count($resBits) > 4) {
  39055. $branch = Preg::replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  39056. $possibleBranches[$branch] = $resBits[1];
  39057. }
  39058. }
  39059. }
  39060. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  39061. $this->executeCommand($command);
  39062. $result = $this->commandResult;
  39063. $resArray = explode(PHP_EOL, $result);
  39064. $lastCommit = $resArray[0];
  39065. $lastCommitArr = explode(' ', $lastCommit);
  39066. $lastCommitNum = $lastCommitArr[1];
  39067. return ['master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum];
  39068. }
  39069. public function getTags(): array
  39070. {
  39071. $command = $this->generateP4Command('labels');
  39072. $this->executeCommand($command);
  39073. $result = $this->commandResult;
  39074. $resArray = explode(PHP_EOL, $result);
  39075. $tags = [];
  39076. foreach ($resArray as $line) {
  39077. if (strpos($line, 'Label') !== false) {
  39078. $fields = explode(' ', $line);
  39079. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  39080. }
  39081. }
  39082. return $tags;
  39083. }
  39084. public function checkStream(): bool
  39085. {
  39086. $command = $this->generateP4Command('depots', false);
  39087. $this->executeCommand($command);
  39088. $result = $this->commandResult;
  39089. $resArray = explode(PHP_EOL, $result);
  39090. foreach ($resArray as $line) {
  39091. if (strpos($line, 'Depot') !== false) {
  39092. $fields = explode(' ', $line);
  39093. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  39094. $this->p4DepotType = $fields[3];
  39095. return $this->isStream();
  39096. }
  39097. }
  39098. }
  39099. return false;
  39100. }
  39101. protected function getChangeList(string $reference): mixed
  39102. {
  39103. $index = strpos($reference, '@');
  39104. if ($index === false) {
  39105. return null;
  39106. }
  39107. $label = substr($reference, $index);
  39108. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  39109. $this->executeCommand($command);
  39110. $changes = $this->commandResult;
  39111. if (strpos($changes, 'Change') !== 0) {
  39112. return null;
  39113. }
  39114. $fields = explode(' ', $changes);
  39115. return $fields[1];
  39116. }
  39117. public function getCommitLogs(string $fromReference, string $toReference): mixed
  39118. {
  39119. $fromChangeList = $this->getChangeList($fromReference);
  39120. if ($fromChangeList === null) {
  39121. return null;
  39122. }
  39123. $toChangeList = $this->getChangeList($toReference);
  39124. if ($toChangeList === null) {
  39125. return null;
  39126. }
  39127. $index = strpos($fromReference, '@');
  39128. $main = substr($fromReference, 0, $index) . '/...';
  39129. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  39130. $this->executeCommand($command);
  39131. return $this->commandResult;
  39132. }
  39133. public function getFilesystem(): Filesystem
  39134. {
  39135. if (null === $this->filesystem) {
  39136. $this->filesystem = new Filesystem($this->process);
  39137. }
  39138. return $this->filesystem;
  39139. }
  39140. public function setFilesystem(Filesystem $fs): void
  39141. {
  39142. $this->filesystem = $fs;
  39143. }
  39144. private function getP4Executable(): string
  39145. {
  39146. static $p4Executable;
  39147. if ($p4Executable) {
  39148. return $p4Executable;
  39149. }
  39150. $finder = new ExecutableFinder();
  39151. return $p4Executable = $finder->find('p4') ?? 'p4';
  39152. }
  39153. }
  39154. <?php declare(strict_types=1);
  39155. namespace Composer\Util;
  39156. use Composer\Pcre\Preg;
  39157. class Platform
  39158. {
  39159. private static $isVirtualBoxGuest = null;
  39160. private static $isWindowsSubsystemForLinux = null;
  39161. private static $isDocker = null;
  39162. public static function getCwd(bool $allowEmpty = false): string
  39163. {
  39164. $cwd = getcwd();
  39165. if (false === $cwd) {
  39166. $cwd = realpath('');
  39167. }
  39168. if (false === $cwd) {
  39169. if ($allowEmpty) {
  39170. return '';
  39171. }
  39172. throw new \RuntimeException('Could not determine the current working directory');
  39173. }
  39174. return $cwd;
  39175. }
  39176. public static function realpath(string $path): string
  39177. {
  39178. $realPath = realpath($path);
  39179. if ($realPath === false) {
  39180. return $path;
  39181. }
  39182. return $realPath;
  39183. }
  39184. public static function getEnv(string $name)
  39185. {
  39186. if (array_key_exists($name, $_SERVER)) {
  39187. return (string) $_SERVER[$name];
  39188. }
  39189. if (array_key_exists($name, $_ENV)) {
  39190. return (string) $_ENV[$name];
  39191. }
  39192. return getenv($name);
  39193. }
  39194. public static function putEnv(string $name, string $value): void
  39195. {
  39196. putenv($name . '=' . $value);
  39197. $_SERVER[$name] = $_ENV[$name] = $value;
  39198. }
  39199. public static function clearEnv(string $name): void
  39200. {
  39201. putenv($name);
  39202. unset($_SERVER[$name], $_ENV[$name]);
  39203. }
  39204. public static function expandPath(string $path): string
  39205. {
  39206. if (Preg::isMatch('#^~[\\/]#', $path)) {
  39207. return self::getUserDirectory() . substr($path, 1);
  39208. }
  39209. return Preg::replaceCallback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', static function ($matches): string {
  39210. if (Platform::isWindows() && $matches['var'] === 'HOME') {
  39211. if ((bool) Platform::getEnv('HOME')) {
  39212. return Platform::getEnv('HOME') . $matches['path'];
  39213. }
  39214. return Platform::getEnv('USERPROFILE') . $matches['path'];
  39215. }
  39216. return Platform::getEnv($matches['var']) . $matches['path'];
  39217. }, $path);
  39218. }
  39219. public static function getUserDirectory(): string
  39220. {
  39221. if (false !== ($home = self::getEnv('HOME'))) {
  39222. return $home;
  39223. }
  39224. if (self::isWindows() && false !== ($home = self::getEnv('USERPROFILE'))) {
  39225. return $home;
  39226. }
  39227. if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
  39228. $info = posix_getpwuid(posix_getuid());
  39229. if (is_array($info)) {
  39230. return $info['dir'];
  39231. }
  39232. }
  39233. throw new \RuntimeException('Could not determine user directory');
  39234. }
  39235. public static function isWindowsSubsystemForLinux(): bool
  39236. {
  39237. if (null === self::$isWindowsSubsystemForLinux) {
  39238. self::$isWindowsSubsystemForLinux = false;
  39239. if (self::isWindows()) {
  39240. return self::$isWindowsSubsystemForLinux = false;
  39241. }
  39242. if (
  39243. !(bool) ini_get('open_basedir')
  39244. && is_readable('/proc/version')
  39245. && false !== stripos((string)Silencer::call('file_get_contents', '/proc/version'), 'microsoft')
  39246. && !self::isDocker()
  39247. ) {
  39248. return self::$isWindowsSubsystemForLinux = true;
  39249. }
  39250. }
  39251. return self::$isWindowsSubsystemForLinux;
  39252. }
  39253. public static function isWindows(): bool
  39254. {
  39255. return \defined('PHP_WINDOWS_VERSION_BUILD');
  39256. }
  39257. public static function isDocker(): bool
  39258. {
  39259. if (null !== self::$isDocker) {
  39260. return self::$isDocker;
  39261. }
  39262. if ((bool) ini_get('open_basedir')) {
  39263. return self::$isDocker = false;
  39264. }
  39265. if (file_exists('/.dockerenv') || file_exists('/run/.containerenv') || file_exists('/var/run/.containerenv')) {
  39266. return self::$isDocker = true;
  39267. }
  39268. $cgroups = [
  39269. '/proc/self/mountinfo',
  39270. '/proc/1/cgroup',
  39271. ];
  39272. foreach ($cgroups as $cgroup) {
  39273. if (!is_readable($cgroup)) {
  39274. continue;
  39275. }
  39276. try {
  39277. $data = @file_get_contents($cgroup);
  39278. } catch (\Throwable $e) {
  39279. break;
  39280. }
  39281. if (!is_string($data)) {
  39282. continue;
  39283. }
  39284. if (str_contains($data, '/var/lib/docker/') || str_contains($data, '/io.containerd.snapshotter')) {
  39285. return self::$isDocker = true;
  39286. }
  39287. }
  39288. return self::$isDocker = false;
  39289. }
  39290. public static function strlen(string $str): int
  39291. {
  39292. static $useMbString = null;
  39293. if (null === $useMbString) {
  39294. $useMbString = \function_exists('mb_strlen') && (bool) ini_get('mbstring.func_overload');
  39295. }
  39296. if ($useMbString) {
  39297. return mb_strlen($str, '8bit');
  39298. }
  39299. return \strlen($str);
  39300. }
  39301. public static function isTty($fd = null): bool
  39302. {
  39303. if ($fd === null) {
  39304. $fd = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
  39305. if ($fd === false) {
  39306. return false;
  39307. }
  39308. }
  39309. if (in_array(strtoupper((string) self::getEnv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
  39310. return true;
  39311. }
  39312. if (function_exists('stream_isatty')) {
  39313. return stream_isatty($fd);
  39314. }
  39315. if (function_exists('posix_isatty') && posix_isatty($fd)) {
  39316. return true;
  39317. }
  39318. $stat = @fstat($fd);
  39319. if ($stat === false) {
  39320. return false;
  39321. }
  39322. return 0020000 === ($stat['mode'] & 0170000);
  39323. }
  39324. public static function isInputCompletionProcess(): bool
  39325. {
  39326. return '_complete' === ($_SERVER['argv'][1] ?? null);
  39327. }
  39328. public static function workaroundFilesystemIssues(): void
  39329. {
  39330. if (self::isVirtualBoxGuest()) {
  39331. usleep(200000);
  39332. }
  39333. }
  39334. private static function isVirtualBoxGuest(): bool
  39335. {
  39336. if (null === self::$isVirtualBoxGuest) {
  39337. self::$isVirtualBoxGuest = false;
  39338. if (self::isWindows()) {
  39339. return self::$isVirtualBoxGuest;
  39340. }
  39341. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  39342. $processUser = posix_getpwuid(posix_geteuid());
  39343. if (is_array($processUser) && $processUser['name'] === 'vagrant') {
  39344. return self::$isVirtualBoxGuest = true;
  39345. }
  39346. }
  39347. if (self::getEnv('COMPOSER_RUNTIME_ENV') === 'virtualbox') {
  39348. return self::$isVirtualBoxGuest = true;
  39349. }
  39350. if (defined('PHP_OS_FAMILY') && PHP_OS_FAMILY === 'Linux') {
  39351. $process = new ProcessExecutor();
  39352. try {
  39353. if (0 === $process->execute(['lsmod'], $output) && str_contains($output, 'vboxguest')) {
  39354. return self::$isVirtualBoxGuest = true;
  39355. }
  39356. } catch (\Exception $e) {
  39357. }
  39358. }
  39359. }
  39360. return self::$isVirtualBoxGuest;
  39361. }
  39362. public static function getDevNull(): string
  39363. {
  39364. if (self::isWindows()) {
  39365. return 'NUL';
  39366. }
  39367. return '/dev/null';
  39368. }
  39369. }
  39370. <?php declare(strict_types=1);
  39371. namespace Composer\Util;
  39372. use Composer\IO\IOInterface;
  39373. use Composer\Pcre\Preg;
  39374. use Seld\Signal\SignalHandler;
  39375. use Symfony\Component\Process\Exception\ProcessSignaledException;
  39376. use Symfony\Component\Process\Process;
  39377. use Symfony\Component\Process\Exception\RuntimeException;
  39378. use React\Promise\Promise;
  39379. use React\Promise\PromiseInterface;
  39380. use Symfony\Component\Process\ExecutableFinder;
  39381. class ProcessExecutor
  39382. {
  39383. private const STATUS_QUEUED = 1;
  39384. private const STATUS_STARTED = 2;
  39385. private const STATUS_COMPLETED = 3;
  39386. private const STATUS_FAILED = 4;
  39387. private const STATUS_ABORTED = 5;
  39388. private const BUILTIN_CMD_COMMANDS = [
  39389. 'assoc', 'break', 'call', 'cd', 'chdir', 'cls', 'color', 'copy', 'date',
  39390. 'del', 'dir', 'echo', 'endlocal', 'erase', 'exit', 'for', 'ftype', 'goto',
  39391. 'help', 'if', 'label', 'md', 'mkdir', 'mklink', 'move', 'path', 'pause',
  39392. 'popd', 'prompt', 'pushd', 'rd', 'rem', 'ren', 'rename', 'rmdir', 'set',
  39393. 'setlocal', 'shift', 'start', 'time', 'title', 'type', 'ver', 'vol',
  39394. ];
  39395. private const GIT_CMDS_NEED_GIT_DIR = [
  39396. ['show'],
  39397. ['log'],
  39398. ['branch'],
  39399. ['remote', 'set-url']
  39400. ];
  39401. protected static $timeout = 300;
  39402. protected $captureOutput = false;
  39403. protected $errorOutput = '';
  39404. protected $io;
  39405. private $jobs = [];
  39406. private $runningJobs = 0;
  39407. private $maxJobs = 10;
  39408. private $idGen = 0;
  39409. private $allowAsync = false;
  39410. private static $executables = [];
  39411. public function __construct(?IOInterface $io = null)
  39412. {
  39413. $this->io = $io;
  39414. $this->resetMaxJobs();
  39415. }
  39416. public function execute($command, &$output = null, ?string $cwd = null): int
  39417. {
  39418. if (func_num_args() > 1) {
  39419. return $this->doExecute($command, $cwd, false, $output);
  39420. }
  39421. return $this->doExecute($command, $cwd, false);
  39422. }
  39423. public function executeTty($command, ?string $cwd = null): int
  39424. {
  39425. if (Platform::isTty()) {
  39426. return $this->doExecute($command, $cwd, true);
  39427. }
  39428. return $this->doExecute($command, $cwd, false);
  39429. }
  39430. private function runProcess($command, ?string $cwd, ?array $env, bool $tty, &$output = null): ?int
  39431. {
  39432. if (is_string($command)) {
  39433. if (Platform::isWindows() && Preg::isMatch('{^([^:/\\\\]++) }', $command, $match)) {
  39434. $command = substr_replace($command, self::escape(self::getExecutable($match[1])), 0, strlen($match[1]));
  39435. }
  39436. $process = Process::fromShellCommandline($command, $cwd, $env, null, static::getTimeout());
  39437. } else {
  39438. if (Platform::isWindows() && \strlen($command[0]) === strcspn($command[0], ':/\\')) {
  39439. $command[0] = self::getExecutable($command[0]);
  39440. }
  39441. $process = new Process($command, $cwd, $env, null, static::getTimeout());
  39442. }
  39443. if (! Platform::isWindows() && $tty) {
  39444. try {
  39445. $process->setTty(true);
  39446. } catch (RuntimeException $e) {
  39447. }
  39448. }
  39449. $callback = is_callable($output) ? $output : function (string $type, string $buffer): void {
  39450. $this->outputHandler($type, $buffer);
  39451. };
  39452. $signalHandler = SignalHandler::create(
  39453. [SignalHandler::SIGINT, SignalHandler::SIGTERM, SignalHandler::SIGHUP],
  39454. function (string $signal) {
  39455. if ($this->io !== null) {
  39456. $this->io->writeError(
  39457. 'Received '.$signal.', aborting when child process is done',
  39458. true,
  39459. IOInterface::DEBUG
  39460. );
  39461. }
  39462. }
  39463. );
  39464. try {
  39465. $process->run($callback);
  39466. if ($this->captureOutput && !is_callable($output)) {
  39467. $output = $process->getOutput();
  39468. }
  39469. $this->errorOutput = $process->getErrorOutput();
  39470. } catch (ProcessSignaledException $e) {
  39471. if ($signalHandler->isTriggered()) {
  39472. $signalHandler->exitWithLastSignal();
  39473. }
  39474. } finally {
  39475. $signalHandler->unregister();
  39476. }
  39477. return $process->getExitCode();
  39478. }
  39479. private function doExecute($command, ?string $cwd, bool $tty, &$output = null): int
  39480. {
  39481. $this->outputCommandRun($command, $cwd, false);
  39482. $this->captureOutput = func_num_args() > 3;
  39483. $this->errorOutput = '';
  39484. $env = null;
  39485. $requiresGitDirEnv = $this->requiresGitDirEnv($command);
  39486. if ($cwd !== null && $requiresGitDirEnv) {
  39487. $isBareRepository = !is_dir(sprintf('%s/.git', rtrim($cwd, '/')));
  39488. if ($isBareRepository) {
  39489. $configValue = '';
  39490. $this->runProcess(['git', 'config', 'safe.bareRepository'], $cwd, ['GIT_DIR' => $cwd], $tty, $configValue);
  39491. $configValue = trim($configValue);
  39492. if ($configValue === 'explicit') {
  39493. $env = ['GIT_DIR' => $cwd];
  39494. }
  39495. }
  39496. }
  39497. return $this->runProcess($command, $cwd, $env, $tty, $output);
  39498. }
  39499. public function executeAsync($command, ?string $cwd = null): PromiseInterface
  39500. {
  39501. if (!$this->allowAsync) {
  39502. throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
  39503. }
  39504. $job = [
  39505. 'id' => $this->idGen++,
  39506. 'status' => self::STATUS_QUEUED,
  39507. 'command' => $command,
  39508. 'cwd' => $cwd,
  39509. ];
  39510. $resolver = static function ($resolve, $reject) use (&$job): void {
  39511. $job['status'] = ProcessExecutor::STATUS_QUEUED;
  39512. $job['resolve'] = $resolve;
  39513. $job['reject'] = $reject;
  39514. };
  39515. $canceler = static function () use (&$job): void {
  39516. if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {
  39517. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  39518. }
  39519. if ($job['status'] !== ProcessExecutor::STATUS_STARTED) {
  39520. return;
  39521. }
  39522. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  39523. try {
  39524. if (defined('SIGINT')) {
  39525. $job['process']->signal(SIGINT);
  39526. }
  39527. } catch (\Exception $e) {
  39528. }
  39529. $job['process']->stop(1);
  39530. throw new \RuntimeException('Aborted process');
  39531. };
  39532. $promise = new Promise($resolver, $canceler);
  39533. $promise = $promise->then(function () use (&$job) {
  39534. if ($job['process']->isSuccessful()) {
  39535. $job['status'] = ProcessExecutor::STATUS_COMPLETED;
  39536. } else {
  39537. $job['status'] = ProcessExecutor::STATUS_FAILED;
  39538. }
  39539. $this->markJobDone();
  39540. return $job['process'];
  39541. }, function ($e) use (&$job): void {
  39542. $job['status'] = ProcessExecutor::STATUS_FAILED;
  39543. $this->markJobDone();
  39544. throw $e;
  39545. });
  39546. $this->jobs[$job['id']] = &$job;
  39547. if ($this->runningJobs < $this->maxJobs) {
  39548. $this->startJob($job['id']);
  39549. }
  39550. return $promise;
  39551. }
  39552. protected function outputHandler(string $type, string $buffer): void
  39553. {
  39554. if ($this->captureOutput) {
  39555. return;
  39556. }
  39557. if (null === $this->io) {
  39558. echo $buffer;
  39559. return;
  39560. }
  39561. if (Process::ERR === $type) {
  39562. $this->io->writeErrorRaw($buffer, false);
  39563. } else {
  39564. $this->io->writeRaw($buffer, false);
  39565. }
  39566. }
  39567. private function startJob(int $id): void
  39568. {
  39569. $job = &$this->jobs[$id];
  39570. if ($job['status'] !== self::STATUS_QUEUED) {
  39571. return;
  39572. }
  39573. $job['status'] = self::STATUS_STARTED;
  39574. $this->runningJobs++;
  39575. $command = $job['command'];
  39576. $cwd = $job['cwd'];
  39577. $this->outputCommandRun($command, $cwd, true);
  39578. try {
  39579. if (is_string($command)) {
  39580. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  39581. } else {
  39582. $process = new Process($command, $cwd, null, null, static::getTimeout());
  39583. }
  39584. } catch (\Throwable $e) {
  39585. $job['reject']($e);
  39586. return;
  39587. }
  39588. $job['process'] = $process;
  39589. try {
  39590. $process->start();
  39591. } catch (\Throwable $e) {
  39592. $job['reject']($e);
  39593. return;
  39594. }
  39595. }
  39596. public function setMaxJobs(int $maxJobs): void
  39597. {
  39598. $this->maxJobs = $maxJobs;
  39599. }
  39600. public function resetMaxJobs(): void
  39601. {
  39602. if (is_numeric($maxJobs = Platform::getEnv('COMPOSER_MAX_PARALLEL_PROCESSES'))) {
  39603. $this->maxJobs = max(1, min(50, (int) $maxJobs));
  39604. } else {
  39605. $this->maxJobs = 10;
  39606. }
  39607. }
  39608. public function wait($index = null): void
  39609. {
  39610. while (true) {
  39611. if (0 === $this->countActiveJobs($index)) {
  39612. return;
  39613. }
  39614. usleep(1000);
  39615. }
  39616. }
  39617. public function enableAsync(): void
  39618. {
  39619. $this->allowAsync = true;
  39620. }
  39621. public function countActiveJobs($index = null): int
  39622. {
  39623. foreach ($this->jobs as $job) {
  39624. if ($job['status'] === self::STATUS_STARTED) {
  39625. if (!$job['process']->isRunning()) {
  39626. call_user_func($job['resolve'], $job['process']);
  39627. }
  39628. $job['process']->checkTimeout();
  39629. }
  39630. if ($this->runningJobs < $this->maxJobs) {
  39631. if ($job['status'] === self::STATUS_QUEUED) {
  39632. $this->startJob($job['id']);
  39633. }
  39634. }
  39635. }
  39636. if (null !== $index) {
  39637. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  39638. }
  39639. $active = 0;
  39640. foreach ($this->jobs as $job) {
  39641. if ($job['status'] < self::STATUS_COMPLETED) {
  39642. $active++;
  39643. } else {
  39644. unset($this->jobs[$job['id']]);
  39645. }
  39646. }
  39647. return $active;
  39648. }
  39649. private function markJobDone(): void
  39650. {
  39651. $this->runningJobs--;
  39652. }
  39653. public function splitLines(?string $output): array
  39654. {
  39655. $output = trim((string) $output);
  39656. return $output === '' ? [] : Preg::split('{\r?\n}', $output);
  39657. }
  39658. public function getErrorOutput(): string
  39659. {
  39660. return $this->errorOutput;
  39661. }
  39662. public static function getTimeout(): int
  39663. {
  39664. return static::$timeout;
  39665. }
  39666. public static function setTimeout(int $timeout): void
  39667. {
  39668. static::$timeout = $timeout;
  39669. }
  39670. public static function escape($argument): string
  39671. {
  39672. return self::escapeArgument($argument);
  39673. }
  39674. private function outputCommandRun($command, ?string $cwd, bool $async): void
  39675. {
  39676. if (null === $this->io || !$this->io->isDebug()) {
  39677. return;
  39678. }
  39679. $commandString = is_string($command) ? $command : implode(' ', array_map(self::class.'::escape', $command));
  39680. $safeCommand = Preg::replaceCallback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', static function ($m): string {
  39681. if (Preg::isMatch('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
  39682. return '://***:***@';
  39683. }
  39684. if (Preg::isMatch('{^[a-f0-9]{12,}$}', $m['user'])) {
  39685. return '://***:***@';
  39686. }
  39687. return '://'.$m['user'].':***@';
  39688. }, $commandString);
  39689. $safeCommand = Preg::replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  39690. $this->io->writeError('Executing'.($async ? ' async' : '').' command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  39691. }
  39692. private static function escapeArgument($argument): string
  39693. {
  39694. if ('' === ($argument = (string) $argument)) {
  39695. return escapeshellarg($argument);
  39696. }
  39697. if (!Platform::isWindows()) {
  39698. return "'".str_replace("'", "'\\''", $argument)."'";
  39699. }
  39700. $argument = strtr($argument, [
  39701. "\n" => ' ',
  39702. "\u{ff02}" => '"',
  39703. "\u{02ba}" => '"',
  39704. "\u{301d}" => '"',
  39705. "\u{301e}" => '"',
  39706. "\u{030e}" => '"',
  39707. "\u{ff1a}" => ':',
  39708. "\u{0589}" => ':',
  39709. "\u{2236}" => ':',
  39710. "\u{ff0f}" => '/',
  39711. "\u{2044}" => '/',
  39712. "\u{2215}" => '/',
  39713. "\u{00b4}" => '/',
  39714. ]);
  39715. $quote = strpbrk($argument, " \t,") !== false;
  39716. $argument = Preg::replace('/(\\\\*)"/', '$1$1\\"', $argument, -1, $dquotes);
  39717. $meta = $dquotes > 0 || Preg::isMatch('/%[^%]+%|![^!]+!/', $argument);
  39718. if (!$meta && !$quote) {
  39719. $quote = strpbrk($argument, '^&|<>()') !== false;
  39720. }
  39721. if ($quote) {
  39722. $argument = '"'.Preg::replace('/(\\\\*)$/', '$1$1', $argument).'"';
  39723. }
  39724. if ($meta) {
  39725. $argument = Preg::replace('/(["^&|<>()%])/', '^$1', $argument);
  39726. $argument = Preg::replace('/(!)/', '^^$1', $argument);
  39727. }
  39728. return $argument;
  39729. }
  39730. public function requiresGitDirEnv($command): bool
  39731. {
  39732. $cmd = !is_array($command) ? explode(' ', $command) : $command;
  39733. if ($cmd[0] !== 'git') {
  39734. return false;
  39735. }
  39736. foreach (self::GIT_CMDS_NEED_GIT_DIR as $gitCmd) {
  39737. if (array_intersect($cmd, $gitCmd) === $gitCmd) {
  39738. return true;
  39739. }
  39740. }
  39741. return false;
  39742. }
  39743. private static function getExecutable(string $name): string
  39744. {
  39745. if (\in_array(strtolower($name), self::BUILTIN_CMD_COMMANDS, true)) {
  39746. return $name;
  39747. }
  39748. if (!isset(self::$executables[$name])) {
  39749. $path = (new ExecutableFinder())->find($name, $name);
  39750. if ($path !== null) {
  39751. self::$executables[$name] = $path;
  39752. }
  39753. }
  39754. return self::$executables[$name] ?? $name;
  39755. }
  39756. }
  39757. <?php declare(strict_types=1);
  39758. namespace Composer\Util;
  39759. use Composer\Config;
  39760. use Composer\Downloader\MaxFileSizeExceededException;
  39761. use Composer\IO\IOInterface;
  39762. use Composer\Downloader\TransportException;
  39763. use Composer\Pcre\Preg;
  39764. use Composer\Util\Http\Response;
  39765. use Composer\Util\Http\ProxyManager;
  39766. class RemoteFilesystem
  39767. {
  39768. private $io;
  39769. private $config;
  39770. private $scheme;
  39771. private $bytesMax;
  39772. private $originUrl;
  39773. private $fileUrl;
  39774. private $fileName;
  39775. private $retry = false;
  39776. private $progress;
  39777. private $lastProgress;
  39778. private $options = [];
  39779. private $disableTls = false;
  39780. private $lastHeaders;
  39781. private $storeAuth = false;
  39782. private $authHelper;
  39783. private $degradedMode = false;
  39784. private $redirects;
  39785. private $maxRedirects = 20;
  39786. public function __construct(IOInterface $io, Config $config, array $options = [], bool $disableTls = false, ?AuthHelper $authHelper = null)
  39787. {
  39788. $this->io = $io;
  39789. if ($disableTls === false) {
  39790. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  39791. } else {
  39792. $this->disableTls = true;
  39793. }
  39794. $this->options = array_replace_recursive($this->options, $options);
  39795. $this->config = $config;
  39796. $this->authHelper = $authHelper ?? new AuthHelper($io, $config);
  39797. }
  39798. public function copy(string $originUrl, string $fileUrl, string $fileName, bool $progress = true, array $options = [])
  39799. {
  39800. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  39801. }
  39802. public function getContents(string $originUrl, string $fileUrl, bool $progress = true, array $options = [])
  39803. {
  39804. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  39805. }
  39806. public function getOptions()
  39807. {
  39808. return $this->options;
  39809. }
  39810. public function setOptions(array $options)
  39811. {
  39812. $this->options = array_replace_recursive($this->options, $options);
  39813. }
  39814. public function isTlsDisabled()
  39815. {
  39816. return $this->disableTls === true;
  39817. }
  39818. public function getLastHeaders()
  39819. {
  39820. return $this->lastHeaders;
  39821. }
  39822. public static function findStatusCode(array $headers)
  39823. {
  39824. $value = null;
  39825. foreach ($headers as $header) {
  39826. if (Preg::isMatch('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  39827. $value = (int) $match[1];
  39828. }
  39829. }
  39830. return $value;
  39831. }
  39832. public function findStatusMessage(array $headers)
  39833. {
  39834. $value = null;
  39835. foreach ($headers as $header) {
  39836. if (Preg::isMatch('{^HTTP/\S+ \d+}i', $header)) {
  39837. $value = $header;
  39838. }
  39839. }
  39840. return $value;
  39841. }
  39842. protected function get(string $originUrl, string $fileUrl, array $additionalOptions = [], ?string $fileName = null, bool $progress = true)
  39843. {
  39844. $this->scheme = parse_url(strtr($fileUrl, '\\', '/'), PHP_URL_SCHEME);
  39845. $this->bytesMax = 0;
  39846. $this->originUrl = $originUrl;
  39847. $this->fileUrl = $fileUrl;
  39848. $this->fileName = $fileName;
  39849. $this->progress = $progress;
  39850. $this->lastProgress = null;
  39851. $retryAuthFailure = true;
  39852. $this->lastHeaders = [];
  39853. $this->redirects = 1;
  39854. $tempAdditionalOptions = $additionalOptions;
  39855. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  39856. $retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  39857. unset($tempAdditionalOptions['retry-auth-failure']);
  39858. }
  39859. $isRedirect = false;
  39860. if (isset($tempAdditionalOptions['redirects'])) {
  39861. $this->redirects = $tempAdditionalOptions['redirects'];
  39862. $isRedirect = true;
  39863. unset($tempAdditionalOptions['redirects']);
  39864. }
  39865. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  39866. unset($tempAdditionalOptions);
  39867. $origFileUrl = $fileUrl;
  39868. if (isset($options['prevent_ip_access_callable'])) {
  39869. throw new \RuntimeException("RemoteFilesystem doesn't support the 'prevent_ip_access_callable' config.");
  39870. }
  39871. if (isset($options['gitlab-token'])) {
  39872. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  39873. unset($options['gitlab-token']);
  39874. }
  39875. if (isset($options['http'])) {
  39876. $options['http']['ignore_errors'] = true;
  39877. }
  39878. if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
  39879. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  39880. $degradedPackagist = true;
  39881. }
  39882. $maxFileSize = null;
  39883. if (isset($options['max_file_size'])) {
  39884. $maxFileSize = $options['max_file_size'];
  39885. unset($options['max_file_size']);
  39886. }
  39887. $ctx = StreamContextFactory::getContext($fileUrl, $options, ['notification' => [$this, 'callbackGet']]);
  39888. $proxy = ProxyManager::getInstance()->getProxyForRequest($fileUrl);
  39889. $usingProxy = $proxy->getStatus(' using proxy (%s)');
  39890. $this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
  39891. unset($origFileUrl, $proxy, $usingProxy);
  39892. if ((!Preg::isMatch('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist)) {
  39893. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  39894. }
  39895. if ($this->progress && !$isRedirect) {
  39896. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  39897. }
  39898. $errorMessage = '';
  39899. $errorCode = 0;
  39900. $result = false;
  39901. set_error_handler(static function ($code, $msg) use (&$errorMessage): bool {
  39902. if ($errorMessage) {
  39903. $errorMessage .= "\n";
  39904. }
  39905. $errorMessage .= Preg::replace('{^file_get_contents\(.*?\): }', '', $msg);
  39906. return true;
  39907. });
  39908. $http_response_header = [];
  39909. try {
  39910. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
  39911. if (!empty($http_response_header[0])) {
  39912. $statusCode = self::findStatusCode($http_response_header);
  39913. if ($statusCode >= 300 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  39914. HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
  39915. }
  39916. if (in_array($statusCode, [401, 403]) && $retryAuthFailure) {
  39917. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
  39918. }
  39919. }
  39920. $contentLength = !empty($http_response_header[0]) ? Response::findHeaderValue($http_response_header, 'content-length') : null;
  39921. if ($contentLength && Platform::strlen($result) < $contentLength) {
  39922. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  39923. $e->setHeaders($http_response_header);
  39924. $e->setStatusCode(self::findStatusCode($http_response_header));
  39925. try {
  39926. $e->setResponse($this->decodeResult($result, $http_response_header));
  39927. } catch (\Exception $discarded) {
  39928. $e->setResponse($this->normalizeResult($result));
  39929. }
  39930. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  39931. throw $e;
  39932. }
  39933. } catch (\Exception $e) {
  39934. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  39935. $e->setHeaders($http_response_header);
  39936. $e->setStatusCode(self::findStatusCode($http_response_header));
  39937. }
  39938. if ($e instanceof TransportException && $result !== false) {
  39939. $e->setResponse($this->decodeResult($result, $http_response_header));
  39940. }
  39941. $result = false;
  39942. }
  39943. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  39944. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  39945. }
  39946. restore_error_handler();
  39947. if (isset($e) && !$this->retry) {
  39948. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  39949. $this->degradedMode = true;
  39950. $this->io->writeError('');
  39951. $this->io->writeError([
  39952. '<error>'.$e->getMessage().'</error>',
  39953. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  39954. ]);
  39955. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  39956. }
  39957. throw $e;
  39958. }
  39959. $statusCode = null;
  39960. $contentType = null;
  39961. $locationHeader = null;
  39962. if (!empty($http_response_header[0])) {
  39963. $statusCode = self::findStatusCode($http_response_header);
  39964. $contentType = Response::findHeaderValue($http_response_header, 'content-type');
  39965. $locationHeader = Response::findHeaderValue($http_response_header, 'location');
  39966. }
  39967. if ($originUrl === 'bitbucket.org'
  39968. && !$this->authHelper->isPublicBitBucketDownload($fileUrl)
  39969. && substr($fileUrl, -4) === '.zip'
  39970. && (!$locationHeader || substr(parse_url($locationHeader, PHP_URL_PATH), -4) !== '.zip')
  39971. && $contentType && Preg::isMatch('{^text/html\b}i', $contentType)
  39972. ) {
  39973. $result = false;
  39974. if ($retryAuthFailure) {
  39975. $this->promptAuthAndRetry(401);
  39976. }
  39977. }
  39978. if ($statusCode === 404
  39979. && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  39980. && false !== strpos($fileUrl, 'archive.zip')
  39981. ) {
  39982. $result = false;
  39983. if ($retryAuthFailure) {
  39984. $this->promptAuthAndRetry(401);
  39985. }
  39986. }
  39987. $hasFollowedRedirect = false;
  39988. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  39989. $hasFollowedRedirect = true;
  39990. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  39991. }
  39992. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  39993. if (!$this->retry) {
  39994. if ($this->progress && !$isRedirect) {
  39995. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  39996. }
  39997. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  39998. $e->setHeaders($http_response_header);
  39999. $e->setResponse($this->decodeResult($result, $http_response_header));
  40000. $e->setStatusCode($statusCode);
  40001. throw $e;
  40002. }
  40003. $result = false;
  40004. }
  40005. if ($this->progress && !$this->retry && !$isRedirect) {
  40006. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  40007. }
  40008. if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
  40009. try {
  40010. $result = $this->decodeResult($result, $http_response_header);
  40011. } catch (\Exception $e) {
  40012. if ($this->degradedMode) {
  40013. throw $e;
  40014. }
  40015. $this->degradedMode = true;
  40016. $this->io->writeError([
  40017. '',
  40018. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  40019. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  40020. ]);
  40021. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  40022. }
  40023. }
  40024. if (false !== $result && null !== $fileName && !$isRedirect) {
  40025. if ('' === $result) {
  40026. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  40027. }
  40028. $errorMessage = '';
  40029. set_error_handler(static function ($code, $msg) use (&$errorMessage): bool {
  40030. if ($errorMessage) {
  40031. $errorMessage .= "\n";
  40032. }
  40033. $errorMessage .= Preg::replace('{^file_put_contents\(.*?\): }', '', $msg);
  40034. return true;
  40035. });
  40036. $result = (bool) file_put_contents($fileName, $result);
  40037. restore_error_handler();
  40038. if (false === $result) {
  40039. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  40040. }
  40041. }
  40042. if ($this->retry) {
  40043. $this->retry = false;
  40044. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  40045. if ($this->storeAuth) {
  40046. $this->authHelper->storeAuth($this->originUrl, $this->storeAuth);
  40047. $this->storeAuth = false;
  40048. }
  40049. return $result;
  40050. }
  40051. if (false === $result) {
  40052. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  40053. if (!empty($http_response_header[0])) {
  40054. $e->setHeaders($http_response_header);
  40055. }
  40056. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  40057. $this->degradedMode = true;
  40058. $this->io->writeError('');
  40059. $this->io->writeError([
  40060. '<error>'.$e->getMessage().'</error>',
  40061. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  40062. ]);
  40063. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  40064. }
  40065. throw $e;
  40066. }
  40067. if (!empty($http_response_header[0])) {
  40068. $this->lastHeaders = $http_response_header;
  40069. }
  40070. return $result;
  40071. }
  40072. protected function getRemoteContents(string $originUrl, string $fileUrl, $context, ?array &$responseHeaders = null, ?int $maxFileSize = null)
  40073. {
  40074. $result = false;
  40075. try {
  40076. $e = null;
  40077. if ($maxFileSize !== null) {
  40078. $result = file_get_contents($fileUrl, false, $context, 0, $maxFileSize);
  40079. } else {
  40080. $result = file_get_contents($fileUrl, false, $context);
  40081. }
  40082. } catch (\Throwable $e) {
  40083. }
  40084. if ($result !== false && $maxFileSize !== null && Platform::strlen($result) >= $maxFileSize) {
  40085. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
  40086. }
  40087. if (\PHP_VERSION_ID >= 80400) {
  40088. $responseHeaders = http_get_last_response_headers();
  40089. http_clear_last_response_headers();
  40090. } else {
  40091. $responseHeaders = $http_response_header ?? [];
  40092. }
  40093. if (null !== $e) {
  40094. throw $e;
  40095. }
  40096. return $result;
  40097. }
  40098. protected function callbackGet(int $notificationCode, int $severity, ?string $message, int $messageCode, int $bytesTransferred, int $bytesMax)
  40099. {
  40100. switch ($notificationCode) {
  40101. case STREAM_NOTIFY_FAILURE:
  40102. if (400 === $messageCode) {
  40103. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  40104. }
  40105. break;
  40106. case STREAM_NOTIFY_FILE_SIZE_IS:
  40107. $this->bytesMax = $bytesMax;
  40108. break;
  40109. case STREAM_NOTIFY_PROGRESS:
  40110. if ($this->bytesMax > 0 && $this->progress) {
  40111. $progression = min(100, (int) round($bytesTransferred / $this->bytesMax * 100));
  40112. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  40113. $this->lastProgress = $progression;
  40114. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  40115. }
  40116. }
  40117. break;
  40118. default:
  40119. break;
  40120. }
  40121. }
  40122. protected function promptAuthAndRetry($httpStatus, ?string $reason = null, array $headers = [])
  40123. {
  40124. $result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers, 1 );
  40125. $this->storeAuth = $result['storeAuth'];
  40126. $this->retry = $result['retry'];
  40127. if ($this->retry) {
  40128. throw new TransportException('RETRY');
  40129. }
  40130. }
  40131. protected function getOptionsForUrl(string $originUrl, array $additionalOptions)
  40132. {
  40133. $tlsOptions = [];
  40134. $headers = [];
  40135. if (extension_loaded('zlib')) {
  40136. $headers[] = 'Accept-Encoding: gzip';
  40137. }
  40138. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  40139. if (!$this->degradedMode) {
  40140. $options['http']['protocol_version'] = 1.1;
  40141. $headers[] = 'Connection: close';
  40142. }
  40143. $headers = $this->authHelper->addAuthenticationHeader($headers, $originUrl, $this->fileUrl);
  40144. $options['http']['follow_location'] = 0;
  40145. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  40146. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  40147. }
  40148. foreach ($headers as $header) {
  40149. $options['http']['header'][] = $header;
  40150. }
  40151. return $options;
  40152. }
  40153. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  40154. {
  40155. if ($locationHeader = Response::findHeaderValue($http_response_header, 'location')) {
  40156. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  40157. $targetUrl = $locationHeader;
  40158. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  40159. $targetUrl = $this->scheme.':'.$locationHeader;
  40160. } elseif ('/' === $locationHeader[0]) {
  40161. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  40162. $targetUrl = Preg::replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  40163. } else {
  40164. $targetUrl = Preg::replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  40165. }
  40166. }
  40167. if (!empty($targetUrl)) {
  40168. $this->redirects++;
  40169. $this->io->writeError('', true, IOInterface::DEBUG);
  40170. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  40171. $additionalOptions['redirects'] = $this->redirects;
  40172. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  40173. }
  40174. if (!$this->retry) {
  40175. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  40176. $e->setHeaders($http_response_header);
  40177. $e->setResponse($this->decodeResult($result, $http_response_header));
  40178. throw $e;
  40179. }
  40180. return false;
  40181. }
  40182. private function decodeResult($result, array $http_response_header): ?string
  40183. {
  40184. if ($result && extension_loaded('zlib')) {
  40185. $contentEncoding = Response::findHeaderValue($http_response_header, 'content-encoding');
  40186. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  40187. if ($decode) {
  40188. $result = zlib_decode($result);
  40189. if ($result === false) {
  40190. throw new TransportException('Failed to decode zlib stream');
  40191. }
  40192. }
  40193. }
  40194. return $this->normalizeResult($result);
  40195. }
  40196. private function normalizeResult($result): ?string
  40197. {
  40198. if ($result === false) {
  40199. return null;
  40200. }
  40201. return $result;
  40202. }
  40203. }
  40204. <?php declare(strict_types=1);
  40205. namespace Composer\Util;
  40206. class Silencer
  40207. {
  40208. private static $stack = [];
  40209. public static function suppress(?int $mask = null): int
  40210. {
  40211. if (!isset($mask)) {
  40212. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED;
  40213. }
  40214. $old = error_reporting();
  40215. self::$stack[] = $old;
  40216. error_reporting($old & ~$mask);
  40217. return $old;
  40218. }
  40219. public static function restore(): void
  40220. {
  40221. if (!empty(self::$stack)) {
  40222. error_reporting(array_pop(self::$stack));
  40223. }
  40224. }
  40225. public static function call(callable $callable, ...$parameters)
  40226. {
  40227. try {
  40228. self::suppress();
  40229. $result = $callable(...$parameters);
  40230. self::restore();
  40231. return $result;
  40232. } catch (\Exception $e) {
  40233. self::restore();
  40234. throw $e;
  40235. }
  40236. }
  40237. }
  40238. <?php declare(strict_types=1);
  40239. namespace Composer\Util;
  40240. use Composer\Composer;
  40241. use Composer\CaBundle\CaBundle;
  40242. use Composer\Downloader\TransportException;
  40243. use Composer\Repository\PlatformRepository;
  40244. use Composer\Util\Http\ProxyManager;
  40245. use Psr\Log\LoggerInterface;
  40246. final class StreamContextFactory
  40247. {
  40248. public static function getContext(string $url, array $defaultOptions = [], array $defaultParams = [])
  40249. {
  40250. $options = ['http' => [
  40251. 'follow_location' => 1,
  40252. 'max_redirects' => 20,
  40253. ]];
  40254. $options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
  40255. unset($defaultOptions['http']['header']);
  40256. $options = array_replace_recursive($options, $defaultOptions);
  40257. if (isset($options['http']['header'])) {
  40258. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  40259. }
  40260. return stream_context_create($options, $defaultParams);
  40261. }
  40262. public static function initOptions(string $url, array $options, bool $forCurl = false): array
  40263. {
  40264. if (!isset($options['http']['header'])) {
  40265. $options['http']['header'] = [];
  40266. }
  40267. if (is_string($options['http']['header'])) {
  40268. $options['http']['header'] = explode("\r\n", $options['http']['header']);
  40269. }
  40270. if (!$forCurl) {
  40271. $proxy = ProxyManager::getInstance()->getProxyForRequest($url);
  40272. $proxyOptions = $proxy->getContextOptions();
  40273. if ($proxyOptions !== null) {
  40274. $isHttpsRequest = 0 === strpos($url, 'https://');
  40275. if ($proxy->isSecure()) {
  40276. if (!extension_loaded('openssl')) {
  40277. throw new TransportException('You must enable the openssl extension to use a secure proxy.');
  40278. }
  40279. if ($isHttpsRequest) {
  40280. throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
  40281. }
  40282. } elseif ($isHttpsRequest && !extension_loaded('openssl')) {
  40283. throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
  40284. }
  40285. if (isset($proxyOptions['http']['header'])) {
  40286. $options['http']['header'][] = $proxyOptions['http']['header'];
  40287. unset($proxyOptions['http']['header']);
  40288. }
  40289. $options = array_replace_recursive($options, $proxyOptions);
  40290. }
  40291. }
  40292. if (defined('HHVM_VERSION')) {
  40293. $phpVersion = 'HHVM ' . HHVM_VERSION;
  40294. } else {
  40295. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  40296. }
  40297. if ($forCurl) {
  40298. $curl = curl_version();
  40299. $httpVersion = 'cURL '.$curl['version'];
  40300. } else {
  40301. $httpVersion = 'streams';
  40302. }
  40303. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  40304. $platformPhpVersion = PlatformRepository::getPlatformPhpVersion();
  40305. $options['http']['header'][] = sprintf(
  40306. 'User-Agent: Composer/%s (%s; %s; %s; %s%s%s)',
  40307. Composer::getVersion(),
  40308. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  40309. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  40310. $phpVersion,
  40311. $httpVersion,
  40312. $platformPhpVersion ? '; Platform-PHP '.$platformPhpVersion : '',
  40313. Platform::getEnv('CI') ? '; CI' : ''
  40314. );
  40315. }
  40316. return $options;
  40317. }
  40318. public static function getTlsDefaults(array $options, ?LoggerInterface $logger = null): array
  40319. {
  40320. $ciphers = implode(':', [
  40321. 'ECDHE-RSA-AES128-GCM-SHA256',
  40322. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  40323. 'ECDHE-RSA-AES256-GCM-SHA384',
  40324. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  40325. 'DHE-RSA-AES128-GCM-SHA256',
  40326. 'DHE-DSS-AES128-GCM-SHA256',
  40327. 'kEDH+AESGCM',
  40328. 'ECDHE-RSA-AES128-SHA256',
  40329. 'ECDHE-ECDSA-AES128-SHA256',
  40330. 'ECDHE-RSA-AES128-SHA',
  40331. 'ECDHE-ECDSA-AES128-SHA',
  40332. 'ECDHE-RSA-AES256-SHA384',
  40333. 'ECDHE-ECDSA-AES256-SHA384',
  40334. 'ECDHE-RSA-AES256-SHA',
  40335. 'ECDHE-ECDSA-AES256-SHA',
  40336. 'DHE-RSA-AES128-SHA256',
  40337. 'DHE-RSA-AES128-SHA',
  40338. 'DHE-DSS-AES128-SHA256',
  40339. 'DHE-RSA-AES256-SHA256',
  40340. 'DHE-DSS-AES256-SHA',
  40341. 'DHE-RSA-AES256-SHA',
  40342. 'AES128-GCM-SHA256',
  40343. 'AES256-GCM-SHA384',
  40344. 'AES128-SHA256',
  40345. 'AES256-SHA256',
  40346. 'AES128-SHA',
  40347. 'AES256-SHA',
  40348. 'AES',
  40349. 'CAMELLIA',
  40350. 'DES-CBC3-SHA',
  40351. '!aNULL',
  40352. '!eNULL',
  40353. '!EXPORT',
  40354. '!DES',
  40355. '!RC4',
  40356. '!MD5',
  40357. '!PSK',
  40358. '!aECDH',
  40359. '!EDH-DSS-DES-CBC3-SHA',
  40360. '!EDH-RSA-DES-CBC3-SHA',
  40361. '!KRB5-DES-CBC3-SHA',
  40362. ]);
  40363. $defaults = [
  40364. 'ssl' => [
  40365. 'ciphers' => $ciphers,
  40366. 'verify_peer' => true,
  40367. 'verify_depth' => 7,
  40368. 'SNI_enabled' => true,
  40369. 'capture_peer_cert' => true,
  40370. ],
  40371. ];
  40372. if (isset($options['ssl'])) {
  40373. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  40374. }
  40375. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  40376. $result = CaBundle::getSystemCaRootBundlePath($logger);
  40377. if (is_dir($result)) {
  40378. $defaults['ssl']['capath'] = $result;
  40379. } else {
  40380. $defaults['ssl']['cafile'] = $result;
  40381. }
  40382. }
  40383. if (isset($defaults['ssl']['cafile']) && (!Filesystem::isReadable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $logger))) {
  40384. throw new TransportException('The configured cafile was not valid or could not be read.');
  40385. }
  40386. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !Filesystem::isReadable($defaults['ssl']['capath']))) {
  40387. throw new TransportException('The configured capath was not valid or could not be read.');
  40388. }
  40389. $defaults['ssl']['disable_compression'] = true;
  40390. return $defaults;
  40391. }
  40392. private static function fixHttpHeaderField($header): array
  40393. {
  40394. if (!is_array($header)) {
  40395. $header = explode("\r\n", $header);
  40396. }
  40397. uasort($header, static function ($el): int {
  40398. return stripos($el, 'content-type') === 0 ? 1 : -1;
  40399. });
  40400. return $header;
  40401. }
  40402. }
  40403. <?php declare(strict_types=1);
  40404. namespace Composer\Util;
  40405. use Composer\Config;
  40406. use Composer\IO\IOInterface;
  40407. use Composer\Pcre\Preg;
  40408. class Svn
  40409. {
  40410. private const MAX_QTY_AUTH_TRIES = 5;
  40411. protected $credentials;
  40412. protected $hasAuth;
  40413. protected $io;
  40414. protected $url;
  40415. protected $cacheCredentials = true;
  40416. protected $process;
  40417. protected $qtyAuthTries = 0;
  40418. protected $config;
  40419. private static $version;
  40420. public function __construct(string $url, IOInterface $io, Config $config, ?ProcessExecutor $process = null)
  40421. {
  40422. $this->url = $url;
  40423. $this->io = $io;
  40424. $this->config = $config;
  40425. $this->process = $process ?: new ProcessExecutor($io);
  40426. }
  40427. public static function cleanEnv(): void
  40428. {
  40429. Platform::clearEnv('DYLD_LIBRARY_PATH');
  40430. }
  40431. public function execute(array $command, string $url, ?string $cwd = null, ?string $path = null, bool $verbose = false): string
  40432. {
  40433. $this->config->prohibitUrlByConfig($url, $this->io);
  40434. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  40435. }
  40436. public function executeLocal(array $command, string $path, ?string $cwd = null, bool $verbose = false): string
  40437. {
  40438. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  40439. }
  40440. private function executeWithAuthRetry(array $svnCommand, ?string $cwd, string $url, ?string $path, bool $verbose): ?string
  40441. {
  40442. $command = $this->getCommand($svnCommand, $url, $path);
  40443. $output = null;
  40444. $io = $this->io;
  40445. $handler = static function ($type, $buffer) use (&$output, $io, $verbose) {
  40446. if ($type !== 'out') {
  40447. return null;
  40448. }
  40449. if (strpos($buffer, 'Redirecting to URL ') === 0) {
  40450. return null;
  40451. }
  40452. $output .= $buffer;
  40453. if ($verbose) {
  40454. $io->writeError($buffer, false);
  40455. }
  40456. };
  40457. $status = $this->process->execute($command, $handler, $cwd);
  40458. if (0 === $status) {
  40459. return $output;
  40460. }
  40461. $errorOutput = $this->process->getErrorOutput();
  40462. $fullOutput = trim(implode("\n", [$output, $errorOutput]));
  40463. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  40464. && false === stripos($fullOutput, 'authorization failed')
  40465. && false === stripos($fullOutput, 'svn: E170001:')
  40466. && false === stripos($fullOutput, 'svn: E215004:')) {
  40467. throw new \RuntimeException($fullOutput);
  40468. }
  40469. if (!$this->hasAuth()) {
  40470. $this->doAuthDance();
  40471. }
  40472. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  40473. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  40474. }
  40475. throw new \RuntimeException(
  40476. 'wrong credentials provided ('.$fullOutput.')'
  40477. );
  40478. }
  40479. public function setCacheCredentials(bool $cacheCredentials): void
  40480. {
  40481. $this->cacheCredentials = $cacheCredentials;
  40482. }
  40483. protected function doAuthDance(): Svn
  40484. {
  40485. if (!$this->io->isInteractive()) {
  40486. throw new \RuntimeException(
  40487. 'can not ask for authentication in non interactive mode'
  40488. );
  40489. }
  40490. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  40491. $this->hasAuth = true;
  40492. $this->credentials = [
  40493. 'username' => (string) $this->io->ask("Username: ", ''),
  40494. 'password' => (string) $this->io->askAndHideAnswer("Password: "),
  40495. ];
  40496. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
  40497. return $this;
  40498. }
  40499. protected function getCommand(array $cmd, string $url, ?string $path = null): array
  40500. {
  40501. $cmd = array_merge(
  40502. $cmd,
  40503. ['--non-interactive'],
  40504. $this->getCredentialArgs(),
  40505. ['--', $url]
  40506. );
  40507. if ($path !== null) {
  40508. $cmd[] = $path;
  40509. }
  40510. return $cmd;
  40511. }
  40512. protected function getCredentialArgs(): array
  40513. {
  40514. if (!$this->hasAuth()) {
  40515. return [];
  40516. }
  40517. return array_merge(
  40518. $this->getAuthCacheArgs(),
  40519. ['--username', $this->getUsername(), '--password', $this->getPassword()]
  40520. );
  40521. }
  40522. protected function getPassword(): string
  40523. {
  40524. if ($this->credentials === null) {
  40525. throw new \LogicException("No svn auth detected.");
  40526. }
  40527. return $this->credentials['password'];
  40528. }
  40529. protected function getUsername(): string
  40530. {
  40531. if ($this->credentials === null) {
  40532. throw new \LogicException("No svn auth detected.");
  40533. }
  40534. return $this->credentials['username'];
  40535. }
  40536. protected function hasAuth(): bool
  40537. {
  40538. if (null !== $this->hasAuth) {
  40539. return $this->hasAuth;
  40540. }
  40541. if (false === $this->createAuthFromConfig()) {
  40542. $this->createAuthFromUrl();
  40543. }
  40544. return (bool) $this->hasAuth;
  40545. }
  40546. protected function getAuthCacheArgs(): array
  40547. {
  40548. return $this->cacheCredentials ? [] : ['--no-auth-cache'];
  40549. }
  40550. private function createAuthFromConfig(): bool
  40551. {
  40552. if (!$this->config->has('http-basic')) {
  40553. return $this->hasAuth = false;
  40554. }
  40555. $authConfig = $this->config->get('http-basic');
  40556. $host = parse_url($this->url, PHP_URL_HOST);
  40557. if (isset($authConfig[$host])) {
  40558. $this->credentials = [
  40559. 'username' => $authConfig[$host]['username'],
  40560. 'password' => $authConfig[$host]['password'],
  40561. ];
  40562. return $this->hasAuth = true;
  40563. }
  40564. return $this->hasAuth = false;
  40565. }
  40566. private function createAuthFromUrl(): bool
  40567. {
  40568. $uri = parse_url($this->url);
  40569. if (empty($uri['user'])) {
  40570. return $this->hasAuth = false;
  40571. }
  40572. $this->credentials = [
  40573. 'username' => $uri['user'],
  40574. 'password' => !empty($uri['pass']) ? $uri['pass'] : '',
  40575. ];
  40576. return $this->hasAuth = true;
  40577. }
  40578. public function binaryVersion(): ?string
  40579. {
  40580. if (!self::$version) {
  40581. if (0 === $this->process->execute(['svn', '--version'], $output)) {
  40582. if (Preg::isMatch('{(\d+(?:\.\d+)+)}', $output, $match)) {
  40583. self::$version = $match[1];
  40584. }
  40585. }
  40586. }
  40587. return self::$version;
  40588. }
  40589. }
  40590. <?php declare(strict_types=1);
  40591. namespace Composer\Util;
  40592. use Composer\Downloader\DownloaderInterface;
  40593. use Composer\Downloader\DownloadManager;
  40594. use Composer\Package\PackageInterface;
  40595. use React\Promise\PromiseInterface;
  40596. class SyncHelper
  40597. {
  40598. public static function downloadAndInstallPackageSync(Loop $loop, $downloader, string $path, PackageInterface $package, ?PackageInterface $prevPackage = null): void
  40599. {
  40600. assert($downloader instanceof DownloaderInterface || $downloader instanceof DownloadManager);
  40601. $type = $prevPackage !== null ? 'update' : 'install';
  40602. try {
  40603. self::await($loop, $downloader->download($package, $path, $prevPackage));
  40604. self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
  40605. if ($type === 'update' && $prevPackage !== null) {
  40606. self::await($loop, $downloader->update($package, $prevPackage, $path));
  40607. } else {
  40608. self::await($loop, $downloader->install($package, $path));
  40609. }
  40610. } catch (\Exception $e) {
  40611. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  40612. throw $e;
  40613. }
  40614. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  40615. }
  40616. public static function await(Loop $loop, ?PromiseInterface $promise = null): void
  40617. {
  40618. if ($promise !== null) {
  40619. $loop->wait([$promise]);
  40620. }
  40621. }
  40622. }
  40623. <?php declare(strict_types=1);
  40624. namespace Composer\Util;
  40625. class Tar
  40626. {
  40627. public static function getComposerJson(string $pathToArchive): ?string
  40628. {
  40629. $phar = new \PharData($pathToArchive);
  40630. if (!$phar->valid()) {
  40631. return null;
  40632. }
  40633. return self::extractComposerJsonFromFolder($phar);
  40634. }
  40635. private static function extractComposerJsonFromFolder(\PharData $phar): string
  40636. {
  40637. if (isset($phar['composer.json'])) {
  40638. return $phar['composer.json']->getContent();
  40639. }
  40640. $topLevelPaths = [];
  40641. foreach ($phar as $folderFile) {
  40642. $name = $folderFile->getBasename();
  40643. if ($folderFile->isDir()) {
  40644. $topLevelPaths[$name] = true;
  40645. if (\count($topLevelPaths) > 1) {
  40646. 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)));
  40647. }
  40648. }
  40649. }
  40650. $composerJsonPath = key($topLevelPaths).'/composer.json';
  40651. if (\count($topLevelPaths) > 0 && isset($phar[$composerJsonPath])) {
  40652. return $phar[$composerJsonPath]->getContent();
  40653. }
  40654. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  40655. }
  40656. }
  40657. <?php declare(strict_types=1);
  40658. namespace Composer\Util;
  40659. use Composer\CaBundle\CaBundle;
  40660. use Composer\Pcre\Preg;
  40661. final class TlsHelper
  40662. {
  40663. public static function checkCertificateHost($certificate, string $hostname, ?string &$cn = null): bool
  40664. {
  40665. $names = self::getCertificateNames($certificate);
  40666. if (empty($names)) {
  40667. return false;
  40668. }
  40669. $combinedNames = array_merge($names['san'], [$names['cn']]);
  40670. $hostname = strtolower($hostname);
  40671. foreach ($combinedNames as $certName) {
  40672. $matcher = self::certNameMatcher($certName);
  40673. if ($matcher && $matcher($hostname)) {
  40674. $cn = $names['cn'];
  40675. return true;
  40676. }
  40677. }
  40678. return false;
  40679. }
  40680. public static function getCertificateNames($certificate): ?array
  40681. {
  40682. if (is_array($certificate)) {
  40683. $info = $certificate;
  40684. } elseif (CaBundle::isOpensslParseSafe()) {
  40685. $info = openssl_x509_parse($certificate, false);
  40686. }
  40687. if (!isset($info['subject']['commonName'])) {
  40688. return null;
  40689. }
  40690. $commonName = strtolower($info['subject']['commonName']);
  40691. $subjectAltNames = [];
  40692. if (isset($info['extensions']['subjectAltName'])) {
  40693. $subjectAltNames = Preg::split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  40694. $subjectAltNames = array_filter(
  40695. array_map(static function ($name): ?string {
  40696. if (0 === strpos($name, 'DNS:')) {
  40697. return strtolower(ltrim(substr($name, 4)));
  40698. }
  40699. return null;
  40700. }, $subjectAltNames),
  40701. function (?string $san) {
  40702. return $san !== null;
  40703. }
  40704. );
  40705. $subjectAltNames = array_values($subjectAltNames);
  40706. }
  40707. return [
  40708. 'cn' => $commonName,
  40709. 'san' => $subjectAltNames,
  40710. ];
  40711. }
  40712. public static function getCertificateFingerprint(string $certificate): string
  40713. {
  40714. $pubkey = openssl_get_publickey($certificate);
  40715. if ($pubkey === false) {
  40716. throw new \RuntimeException('Failed to retrieve the public key from certificate');
  40717. }
  40718. $pubkeydetails = openssl_pkey_get_details($pubkey);
  40719. $pubkeypem = $pubkeydetails['key'];
  40720. $start = '-----BEGIN PUBLIC KEY-----';
  40721. $end = '-----END PUBLIC KEY-----';
  40722. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  40723. $der = base64_decode($pemtrim);
  40724. return hash('sha1', $der);
  40725. }
  40726. public static function isOpensslParseSafe(): bool
  40727. {
  40728. return CaBundle::isOpensslParseSafe();
  40729. }
  40730. private static function certNameMatcher(string $certName): ?callable
  40731. {
  40732. $wildcards = substr_count($certName, '*');
  40733. if (0 === $wildcards) {
  40734. return static function ($hostname) use ($certName): bool {
  40735. return $hostname === $certName;
  40736. };
  40737. }
  40738. if (1 === $wildcards) {
  40739. $components = explode('.', $certName);
  40740. if (3 > count($components)) {
  40741. return null;
  40742. }
  40743. $firstComponent = $components[0];
  40744. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  40745. return null;
  40746. }
  40747. $wildcardRegex = preg_quote($certName);
  40748. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  40749. $wildcardRegex = "{^{$wildcardRegex}$}";
  40750. return static function ($hostname) use ($wildcardRegex): bool {
  40751. return Preg::isMatch($wildcardRegex, $hostname);
  40752. };
  40753. }
  40754. return null;
  40755. }
  40756. }
  40757. <?php declare(strict_types=1);
  40758. namespace Composer\Util;
  40759. use Composer\Config;
  40760. use Composer\Pcre\Preg;
  40761. class Url
  40762. {
  40763. public static function updateDistReference(Config $config, string $url, string $ref): string
  40764. {
  40765. $host = parse_url($url, PHP_URL_HOST);
  40766. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  40767. if (Preg::isMatch('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  40768. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  40769. } elseif (Preg::isMatch('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  40770. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  40771. } elseif (Preg::isMatch('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  40772. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  40773. }
  40774. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  40775. if (Preg::isMatch('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  40776. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  40777. }
  40778. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  40779. if (Preg::isMatch('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  40780. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  40781. }
  40782. } elseif (in_array($host, $config->get('github-domains'), true)) {
  40783. $url = Preg::replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  40784. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  40785. $url = Preg::replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  40786. }
  40787. assert($url !== '');
  40788. return $url;
  40789. }
  40790. public static function getOrigin(Config $config, string $url): string
  40791. {
  40792. if (0 === strpos($url, 'file://')) {
  40793. return $url;
  40794. }
  40795. $origin = (string) parse_url($url, PHP_URL_HOST);
  40796. if ($port = parse_url($url, PHP_URL_PORT)) {
  40797. $origin .= ':'.$port;
  40798. }
  40799. if (str_ends_with($origin, '.github.com') && $origin !== 'codeload.github.com') {
  40800. return 'github.com';
  40801. }
  40802. if ($origin === 'repo.packagist.org') {
  40803. return 'packagist.org';
  40804. }
  40805. if ($origin === '') {
  40806. $origin = $url;
  40807. }
  40808. if (
  40809. false === strpos($origin, '/')
  40810. && !in_array($origin, $config->get('gitlab-domains'), true)
  40811. ) {
  40812. foreach ($config->get('gitlab-domains') as $gitlabDomain) {
  40813. if ($gitlabDomain !== '' && str_starts_with($gitlabDomain, $origin)) {
  40814. return $gitlabDomain;
  40815. }
  40816. }
  40817. }
  40818. return $origin;
  40819. }
  40820. public static function sanitize(string $url): string
  40821. {
  40822. $url = Preg::replace('{([&?]access_token=)[^&]+}', '$1***', $url);
  40823. $url = Preg::replaceCallback('{^(?P<prefix>[a-z0-9]+://)?(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', static function ($m): string {
  40824. if (Preg::isMatch('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+|github_pat_[a-zA-Z0-9_]+)$}', $m['user'])) {
  40825. return $m['prefix'].'***:***@';
  40826. }
  40827. return $m['prefix'].$m['user'].':***@';
  40828. }, $url);
  40829. return $url;
  40830. }
  40831. }
  40832. <?php declare(strict_types=1);
  40833. namespace Composer\Util;
  40834. class Zip
  40835. {
  40836. public static function getComposerJson(string $pathToZip): ?string
  40837. {
  40838. if (!extension_loaded('zip')) {
  40839. throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
  40840. }
  40841. $zip = new \ZipArchive();
  40842. if ($zip->open($pathToZip) !== true) {
  40843. return null;
  40844. }
  40845. if (0 === $zip->numFiles) {
  40846. $zip->close();
  40847. return null;
  40848. }
  40849. $foundFileIndex = self::locateFile($zip, 'composer.json');
  40850. $content = null;
  40851. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  40852. $stream = $zip->getStream($configurationFileName);
  40853. if (false !== $stream) {
  40854. $content = stream_get_contents($stream);
  40855. }
  40856. $zip->close();
  40857. return $content;
  40858. }
  40859. private static function locateFile(\ZipArchive $zip, string $filename): int
  40860. {
  40861. if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {
  40862. return $index;
  40863. }
  40864. $topLevelPaths = [];
  40865. for ($i = 0; $i < $zip->numFiles; $i++) {
  40866. $name = $zip->getNameIndex($i);
  40867. $dirname = dirname($name);
  40868. if (strpos($name, '__MACOSX') !== false) {
  40869. continue;
  40870. }
  40871. if ($dirname === '.') {
  40872. $topLevelPaths[$name] = true;
  40873. if (\count($topLevelPaths) > 1) {
  40874. 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)));
  40875. }
  40876. continue;
  40877. }
  40878. if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) {
  40879. $topLevelPaths[$dirname.'/'] = true;
  40880. if (\count($topLevelPaths) > 1) {
  40881. 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)));
  40882. }
  40883. }
  40884. }
  40885. if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) {
  40886. return $index;
  40887. }
  40888. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  40889. }
  40890. }
  40891. <?php declare(strict_types=1);
  40892. use Composer\Autoload\ClassLoader;
  40893. function includeIfExists(string $file): ?ClassLoader
  40894. {
  40895. return file_exists($file) ? include $file : null;
  40896. }
  40897. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  40898. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  40899. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  40900. exit(1);
  40901. }
  40902. return $loader;
  40903. <?php
  40904. /*
  40905. * This file is part of Composer.
  40906. *
  40907. * (c) Nils Adermann <naderman@naderman.de>
  40908. * Jordi Boggiano <j.boggiano@seld.be>
  40909. *
  40910. * For the full copyright and license information, please view the LICENSE
  40911. * file that was distributed with this source code.
  40912. */
  40913. namespace Composer\Autoload;
  40914. /**
  40915. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  40916. *
  40917. * $loader = new \Composer\Autoload\ClassLoader();
  40918. *
  40919. * // register classes with namespaces
  40920. * $loader->add('Symfony\Component', __DIR__.'/component');
  40921. * $loader->add('Symfony', __DIR__.'/framework');
  40922. *
  40923. * // activate the autoloader
  40924. * $loader->register();
  40925. *
  40926. * // to enable searching the include path (eg. for PEAR packages)
  40927. * $loader->setUseIncludePath(true);
  40928. *
  40929. * In this example, if you try to use a class in the Symfony\Component
  40930. * namespace or one of its children (Symfony\Component\Console for instance),
  40931. * the autoloader will first look for the class under the component/
  40932. * directory, and it will then fallback to the framework/ directory if not
  40933. * found before giving up.
  40934. *
  40935. * This class is loosely based on the Symfony UniversalClassLoader.
  40936. *
  40937. * @author Fabien Potencier <fabien@symfony.com>
  40938. * @author Jordi Boggiano <j.boggiano@seld.be>
  40939. * @see https://www.php-fig.org/psr/psr-0/
  40940. * @see https://www.php-fig.org/psr/psr-4/
  40941. */
  40942. class ClassLoader
  40943. {
  40944. /** @var \Closure(string):void */
  40945. private static $includeFile;
  40946. /** @var string|null */
  40947. private $vendorDir;
  40948. // PSR-4
  40949. /**
  40950. * @var array<string, array<string, int>>
  40951. */
  40952. private $prefixLengthsPsr4 = array();
  40953. /**
  40954. * @var array<string, list<string>>
  40955. */
  40956. private $prefixDirsPsr4 = array();
  40957. /**
  40958. * @var list<string>
  40959. */
  40960. private $fallbackDirsPsr4 = array();
  40961. // PSR-0
  40962. /**
  40963. * List of PSR-0 prefixes
  40964. *
  40965. * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
  40966. *
  40967. * @var array<string, array<string, list<string>>>
  40968. */
  40969. private $prefixesPsr0 = array();
  40970. /**
  40971. * @var list<string>
  40972. */
  40973. private $fallbackDirsPsr0 = array();
  40974. /** @var bool */
  40975. private $useIncludePath = false;
  40976. /**
  40977. * @var array<string, string>
  40978. */
  40979. private $classMap = array();
  40980. /** @var bool */
  40981. private $classMapAuthoritative = false;
  40982. /**
  40983. * @var array<string, bool>
  40984. */
  40985. private $missingClasses = array();
  40986. /** @var string|null */
  40987. private $apcuPrefix;
  40988. /**
  40989. * @var array<string, self>
  40990. */
  40991. private static $registeredLoaders = array();
  40992. /**
  40993. * @param string|null $vendorDir
  40994. */
  40995. public function __construct($vendorDir = null)
  40996. {
  40997. $this->vendorDir = $vendorDir;
  40998. self::initializeIncludeClosure();
  40999. }
  41000. /**
  41001. * @return array<string, list<string>>
  41002. */
  41003. public function getPrefixes()
  41004. {
  41005. if (!empty($this->prefixesPsr0)) {
  41006. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  41007. }
  41008. return array();
  41009. }
  41010. /**
  41011. * @return array<string, list<string>>
  41012. */
  41013. public function getPrefixesPsr4()
  41014. {
  41015. return $this->prefixDirsPsr4;
  41016. }
  41017. /**
  41018. * @return list<string>
  41019. */
  41020. public function getFallbackDirs()
  41021. {
  41022. return $this->fallbackDirsPsr0;
  41023. }
  41024. /**
  41025. * @return list<string>
  41026. */
  41027. public function getFallbackDirsPsr4()
  41028. {
  41029. return $this->fallbackDirsPsr4;
  41030. }
  41031. /**
  41032. * @return array<string, string> Array of classname => path
  41033. */
  41034. public function getClassMap()
  41035. {
  41036. return $this->classMap;
  41037. }
  41038. /**
  41039. * @param array<string, string> $classMap Class to filename map
  41040. *
  41041. * @return void
  41042. */
  41043. public function addClassMap(array $classMap)
  41044. {
  41045. if ($this->classMap) {
  41046. $this->classMap = array_merge($this->classMap, $classMap);
  41047. } else {
  41048. $this->classMap = $classMap;
  41049. }
  41050. }
  41051. /**
  41052. * Registers a set of PSR-0 directories for a given prefix, either
  41053. * appending or prepending to the ones previously set for this prefix.
  41054. *
  41055. * @param string $prefix The prefix
  41056. * @param list<string>|string $paths The PSR-0 root directories
  41057. * @param bool $prepend Whether to prepend the directories
  41058. *
  41059. * @return void
  41060. */
  41061. public function add($prefix, $paths, $prepend = false)
  41062. {
  41063. $paths = (array) $paths;
  41064. if (!$prefix) {
  41065. if ($prepend) {
  41066. $this->fallbackDirsPsr0 = array_merge(
  41067. $paths,
  41068. $this->fallbackDirsPsr0
  41069. );
  41070. } else {
  41071. $this->fallbackDirsPsr0 = array_merge(
  41072. $this->fallbackDirsPsr0,
  41073. $paths
  41074. );
  41075. }
  41076. return;
  41077. }
  41078. $first = $prefix[0];
  41079. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  41080. $this->prefixesPsr0[$first][$prefix] = $paths;
  41081. return;
  41082. }
  41083. if ($prepend) {
  41084. $this->prefixesPsr0[$first][$prefix] = array_merge(
  41085. $paths,
  41086. $this->prefixesPsr0[$first][$prefix]
  41087. );
  41088. } else {
  41089. $this->prefixesPsr0[$first][$prefix] = array_merge(
  41090. $this->prefixesPsr0[$first][$prefix],
  41091. $paths
  41092. );
  41093. }
  41094. }
  41095. /**
  41096. * Registers a set of PSR-4 directories for a given namespace, either
  41097. * appending or prepending to the ones previously set for this namespace.
  41098. *
  41099. * @param string $prefix The prefix/namespace, with trailing '\\'
  41100. * @param list<string>|string $paths The PSR-4 base directories
  41101. * @param bool $prepend Whether to prepend the directories
  41102. *
  41103. * @throws \InvalidArgumentException
  41104. *
  41105. * @return void
  41106. */
  41107. public function addPsr4($prefix, $paths, $prepend = false)
  41108. {
  41109. $paths = (array) $paths;
  41110. if (!$prefix) {
  41111. // Register directories for the root namespace.
  41112. if ($prepend) {
  41113. $this->fallbackDirsPsr4 = array_merge(
  41114. $paths,
  41115. $this->fallbackDirsPsr4
  41116. );
  41117. } else {
  41118. $this->fallbackDirsPsr4 = array_merge(
  41119. $this->fallbackDirsPsr4,
  41120. $paths
  41121. );
  41122. }
  41123. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  41124. // Register directories for a new namespace.
  41125. $length = strlen($prefix);
  41126. if ('\\' !== $prefix[$length - 1]) {
  41127. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  41128. }
  41129. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  41130. $this->prefixDirsPsr4[$prefix] = $paths;
  41131. } elseif ($prepend) {
  41132. // Prepend directories for an already registered namespace.
  41133. $this->prefixDirsPsr4[$prefix] = array_merge(
  41134. $paths,
  41135. $this->prefixDirsPsr4[$prefix]
  41136. );
  41137. } else {
  41138. // Append directories for an already registered namespace.
  41139. $this->prefixDirsPsr4[$prefix] = array_merge(
  41140. $this->prefixDirsPsr4[$prefix],
  41141. $paths
  41142. );
  41143. }
  41144. }
  41145. /**
  41146. * Registers a set of PSR-0 directories for a given prefix,
  41147. * replacing any others previously set for this prefix.
  41148. *
  41149. * @param string $prefix The prefix
  41150. * @param list<string>|string $paths The PSR-0 base directories
  41151. *
  41152. * @return void
  41153. */
  41154. public function set($prefix, $paths)
  41155. {
  41156. if (!$prefix) {
  41157. $this->fallbackDirsPsr0 = (array) $paths;
  41158. } else {
  41159. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  41160. }
  41161. }
  41162. /**
  41163. * Registers a set of PSR-4 directories for a given namespace,
  41164. * replacing any others previously set for this namespace.
  41165. *
  41166. * @param string $prefix The prefix/namespace, with trailing '\\'
  41167. * @param list<string>|string $paths The PSR-4 base directories
  41168. *
  41169. * @throws \InvalidArgumentException
  41170. *
  41171. * @return void
  41172. */
  41173. public function setPsr4($prefix, $paths)
  41174. {
  41175. if (!$prefix) {
  41176. $this->fallbackDirsPsr4 = (array) $paths;
  41177. } else {
  41178. $length = strlen($prefix);
  41179. if ('\\' !== $prefix[$length - 1]) {
  41180. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  41181. }
  41182. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  41183. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  41184. }
  41185. }
  41186. /**
  41187. * Turns on searching the include path for class files.
  41188. *
  41189. * @param bool $useIncludePath
  41190. *
  41191. * @return void
  41192. */
  41193. public function setUseIncludePath($useIncludePath)
  41194. {
  41195. $this->useIncludePath = $useIncludePath;
  41196. }
  41197. /**
  41198. * Can be used to check if the autoloader uses the include path to check
  41199. * for classes.
  41200. *
  41201. * @return bool
  41202. */
  41203. public function getUseIncludePath()
  41204. {
  41205. return $this->useIncludePath;
  41206. }
  41207. /**
  41208. * Turns off searching the prefix and fallback directories for classes
  41209. * that have not been registered with the class map.
  41210. *
  41211. * @param bool $classMapAuthoritative
  41212. *
  41213. * @return void
  41214. */
  41215. public function setClassMapAuthoritative($classMapAuthoritative)
  41216. {
  41217. $this->classMapAuthoritative = $classMapAuthoritative;
  41218. }
  41219. /**
  41220. * Should class lookup fail if not found in the current class map?
  41221. *
  41222. * @return bool
  41223. */
  41224. public function isClassMapAuthoritative()
  41225. {
  41226. return $this->classMapAuthoritative;
  41227. }
  41228. /**
  41229. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  41230. *
  41231. * @param string|null $apcuPrefix
  41232. *
  41233. * @return void
  41234. */
  41235. public function setApcuPrefix($apcuPrefix)
  41236. {
  41237. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  41238. }
  41239. /**
  41240. * The APCu prefix in use, or null if APCu caching is not enabled.
  41241. *
  41242. * @return string|null
  41243. */
  41244. public function getApcuPrefix()
  41245. {
  41246. return $this->apcuPrefix;
  41247. }
  41248. /**
  41249. * Registers this instance as an autoloader.
  41250. *
  41251. * @param bool $prepend Whether to prepend the autoloader or not
  41252. *
  41253. * @return void
  41254. */
  41255. public function register($prepend = false)
  41256. {
  41257. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  41258. if (null === $this->vendorDir) {
  41259. return;
  41260. }
  41261. if ($prepend) {
  41262. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  41263. } else {
  41264. unset(self::$registeredLoaders[$this->vendorDir]);
  41265. self::$registeredLoaders[$this->vendorDir] = $this;
  41266. }
  41267. }
  41268. /**
  41269. * Unregisters this instance as an autoloader.
  41270. *
  41271. * @return void
  41272. */
  41273. public function unregister()
  41274. {
  41275. spl_autoload_unregister(array($this, 'loadClass'));
  41276. if (null !== $this->vendorDir) {
  41277. unset(self::$registeredLoaders[$this->vendorDir]);
  41278. }
  41279. }
  41280. /**
  41281. * Loads the given class or interface.
  41282. *
  41283. * @param string $class The name of the class
  41284. * @return true|null True if loaded, null otherwise
  41285. */
  41286. public function loadClass($class)
  41287. {
  41288. if ($file = $this->findFile($class)) {
  41289. $includeFile = self::$includeFile;
  41290. $includeFile($file);
  41291. return true;
  41292. }
  41293. return null;
  41294. }
  41295. /**
  41296. * Finds the path to the file where the class is defined.
  41297. *
  41298. * @param string $class The name of the class
  41299. *
  41300. * @return string|false The path if found, false otherwise
  41301. */
  41302. public function findFile($class)
  41303. {
  41304. // class map lookup
  41305. if (isset($this->classMap[$class])) {
  41306. return $this->classMap[$class];
  41307. }
  41308. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  41309. return false;
  41310. }
  41311. if (null !== $this->apcuPrefix) {
  41312. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  41313. if ($hit) {
  41314. return $file;
  41315. }
  41316. }
  41317. $file = $this->findFileWithExtension($class, '.php');
  41318. // Search for Hack files if we are running on HHVM
  41319. if (false === $file && defined('HHVM_VERSION')) {
  41320. $file = $this->findFileWithExtension($class, '.hh');
  41321. }
  41322. if (null !== $this->apcuPrefix) {
  41323. apcu_add($this->apcuPrefix.$class, $file);
  41324. }
  41325. if (false === $file) {
  41326. // Remember that this class does not exist.
  41327. $this->missingClasses[$class] = true;
  41328. }
  41329. return $file;
  41330. }
  41331. /**
  41332. * Returns the currently registered loaders keyed by their corresponding vendor directories.
  41333. *
  41334. * @return array<string, self>
  41335. */
  41336. public static function getRegisteredLoaders()
  41337. {
  41338. return self::$registeredLoaders;
  41339. }
  41340. /**
  41341. * @param string $class
  41342. * @param string $ext
  41343. * @return string|false
  41344. */
  41345. private function findFileWithExtension($class, $ext)
  41346. {
  41347. // PSR-4 lookup
  41348. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  41349. $first = $class[0];
  41350. if (isset($this->prefixLengthsPsr4[$first])) {
  41351. $subPath = $class;
  41352. while (false !== $lastPos = strrpos($subPath, '\\')) {
  41353. $subPath = substr($subPath, 0, $lastPos);
  41354. $search = $subPath . '\\';
  41355. if (isset($this->prefixDirsPsr4[$search])) {
  41356. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  41357. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  41358. if (file_exists($file = $dir . $pathEnd)) {
  41359. return $file;
  41360. }
  41361. }
  41362. }
  41363. }
  41364. }
  41365. // PSR-4 fallback dirs
  41366. foreach ($this->fallbackDirsPsr4 as $dir) {
  41367. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  41368. return $file;
  41369. }
  41370. }
  41371. // PSR-0 lookup
  41372. if (false !== $pos = strrpos($class, '\\')) {
  41373. // namespaced class name
  41374. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  41375. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  41376. } else {
  41377. // PEAR-like class name
  41378. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  41379. }
  41380. if (isset($this->prefixesPsr0[$first])) {
  41381. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  41382. if (0 === strpos($class, $prefix)) {
  41383. foreach ($dirs as $dir) {
  41384. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  41385. return $file;
  41386. }
  41387. }
  41388. }
  41389. }
  41390. }
  41391. // PSR-0 fallback dirs
  41392. foreach ($this->fallbackDirsPsr0 as $dir) {
  41393. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  41394. return $file;
  41395. }
  41396. }
  41397. // PSR-0 include paths.
  41398. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  41399. return $file;
  41400. }
  41401. return false;
  41402. }
  41403. /**
  41404. * @return void
  41405. */
  41406. private static function initializeIncludeClosure()
  41407. {
  41408. if (self::$includeFile !== null) {
  41409. return;
  41410. }
  41411. /**
  41412. * Scope isolated include.
  41413. *
  41414. * Prevents access to $this/self from included files.
  41415. *
  41416. * @param string $file
  41417. * @return void
  41418. */
  41419. self::$includeFile = \Closure::bind(static function($file) {
  41420. include $file;
  41421. }, null, null);
  41422. }
  41423. }
  41424. <?php
  41425. /*
  41426. * This file is part of Composer.
  41427. *
  41428. * (c) Nils Adermann <naderman@naderman.de>
  41429. * Jordi Boggiano <j.boggiano@seld.be>
  41430. *
  41431. * For the full copyright and license information, please view the LICENSE
  41432. * file that was distributed with this source code.
  41433. */
  41434. namespace Composer;
  41435. use Composer\Autoload\ClassLoader;
  41436. use Composer\Semver\VersionParser;
  41437. /**
  41438. * This class is copied in every Composer installed project and available to all
  41439. *
  41440. * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
  41441. *
  41442. * To require its presence, you can require `composer-runtime-api ^2.0`
  41443. *
  41444. * @final
  41445. */
  41446. class InstalledVersions
  41447. {
  41448. /**
  41449. * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
  41450. * @internal
  41451. */
  41452. private static $selfDir = null;
  41453. /**
  41454. * @var mixed[]|null
  41455. * @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
  41456. */
  41457. private static $installed;
  41458. /**
  41459. * @var bool
  41460. */
  41461. private static $installedIsLocalDir;
  41462. /**
  41463. * @var bool|null
  41464. */
  41465. private static $canGetVendors;
  41466. /**
  41467. * @var array[]
  41468. * @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[]}>}>
  41469. */
  41470. private static $installedByVendor = array();
  41471. /**
  41472. * Returns a list of all package names which are present, either by being installed, replaced or provided
  41473. *
  41474. * @return string[]
  41475. * @psalm-return list<string>
  41476. */
  41477. public static function getInstalledPackages()
  41478. {
  41479. $packages = array();
  41480. foreach (self::getInstalled() as $installed) {
  41481. $packages[] = array_keys($installed['versions']);
  41482. }
  41483. if (1 === \count($packages)) {
  41484. return $packages[0];
  41485. }
  41486. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  41487. }
  41488. /**
  41489. * Returns a list of all package names with a specific type e.g. 'library'
  41490. *
  41491. * @param string $type
  41492. * @return string[]
  41493. * @psalm-return list<string>
  41494. */
  41495. public static function getInstalledPackagesByType($type)
  41496. {
  41497. $packagesByType = array();
  41498. foreach (self::getInstalled() as $installed) {
  41499. foreach ($installed['versions'] as $name => $package) {
  41500. if (isset($package['type']) && $package['type'] === $type) {
  41501. $packagesByType[] = $name;
  41502. }
  41503. }
  41504. }
  41505. return $packagesByType;
  41506. }
  41507. /**
  41508. * Checks whether the given package is installed
  41509. *
  41510. * This also returns true if the package name is provided or replaced by another package
  41511. *
  41512. * @param string $packageName
  41513. * @param bool $includeDevRequirements
  41514. * @return bool
  41515. */
  41516. public static function isInstalled($packageName, $includeDevRequirements = true)
  41517. {
  41518. foreach (self::getInstalled() as $installed) {
  41519. if (isset($installed['versions'][$packageName])) {
  41520. return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
  41521. }
  41522. }
  41523. return false;
  41524. }
  41525. /**
  41526. * Checks whether the given package satisfies a version constraint
  41527. *
  41528. * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
  41529. *
  41530. * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
  41531. *
  41532. * @param VersionParser $parser Install composer/semver to have access to this class and functionality
  41533. * @param string $packageName
  41534. * @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
  41535. * @return bool
  41536. */
  41537. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  41538. {
  41539. $constraint = $parser->parseConstraints((string) $constraint);
  41540. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  41541. return $provided->matches($constraint);
  41542. }
  41543. /**
  41544. * Returns a version constraint representing all the range(s) which are installed for a given package
  41545. *
  41546. * It is easier to use this via isInstalled() with the $constraint argument if you need to check
  41547. * whether a given version of a package is installed, and not just whether it exists
  41548. *
  41549. * @param string $packageName
  41550. * @return string Version constraint usable with composer/semver
  41551. */
  41552. public static function getVersionRanges($packageName)
  41553. {
  41554. foreach (self::getInstalled() as $installed) {
  41555. if (!isset($installed['versions'][$packageName])) {
  41556. continue;
  41557. }
  41558. $ranges = array();
  41559. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  41560. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  41561. }
  41562. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  41563. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  41564. }
  41565. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  41566. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  41567. }
  41568. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  41569. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  41570. }
  41571. return implode(' || ', $ranges);
  41572. }
  41573. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  41574. }
  41575. /**
  41576. * @param string $packageName
  41577. * @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
  41578. */
  41579. public static function getVersion($packageName)
  41580. {
  41581. foreach (self::getInstalled() as $installed) {
  41582. if (!isset($installed['versions'][$packageName])) {
  41583. continue;
  41584. }
  41585. if (!isset($installed['versions'][$packageName]['version'])) {
  41586. return null;
  41587. }
  41588. return $installed['versions'][$packageName]['version'];
  41589. }
  41590. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  41591. }
  41592. /**
  41593. * @param string $packageName
  41594. * @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
  41595. */
  41596. public static function getPrettyVersion($packageName)
  41597. {
  41598. foreach (self::getInstalled() as $installed) {
  41599. if (!isset($installed['versions'][$packageName])) {
  41600. continue;
  41601. }
  41602. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  41603. return null;
  41604. }
  41605. return $installed['versions'][$packageName]['pretty_version'];
  41606. }
  41607. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  41608. }
  41609. /**
  41610. * @param string $packageName
  41611. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
  41612. */
  41613. public static function getReference($packageName)
  41614. {
  41615. foreach (self::getInstalled() as $installed) {
  41616. if (!isset($installed['versions'][$packageName])) {
  41617. continue;
  41618. }
  41619. if (!isset($installed['versions'][$packageName]['reference'])) {
  41620. return null;
  41621. }
  41622. return $installed['versions'][$packageName]['reference'];
  41623. }
  41624. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  41625. }
  41626. /**
  41627. * @param string $packageName
  41628. * @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.
  41629. */
  41630. public static function getInstallPath($packageName)
  41631. {
  41632. foreach (self::getInstalled() as $installed) {
  41633. if (!isset($installed['versions'][$packageName])) {
  41634. continue;
  41635. }
  41636. return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
  41637. }
  41638. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  41639. }
  41640. /**
  41641. * @return array
  41642. * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
  41643. */
  41644. public static function getRootPackage()
  41645. {
  41646. $installed = self::getInstalled();
  41647. return $installed[0]['root'];
  41648. }
  41649. /**
  41650. * Returns the raw installed.php data for custom implementations
  41651. *
  41652. * @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.
  41653. * @return array[]
  41654. * @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[]}>}
  41655. */
  41656. public static function getRawData()
  41657. {
  41658. @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);
  41659. if (null === self::$installed) {
  41660. // only require the installed.php file if this file is loaded from its dumped location,
  41661. // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
  41662. if (substr(__DIR__, -8, 1) !== 'C') {
  41663. self::$installed = include __DIR__ . '/installed.php';
  41664. } else {
  41665. self::$installed = array();
  41666. }
  41667. }
  41668. return self::$installed;
  41669. }
  41670. /**
  41671. * Returns the raw data of all installed.php which are currently loaded for custom implementations
  41672. *
  41673. * @return array[]
  41674. * @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[]}>}>
  41675. */
  41676. public static function getAllRawData()
  41677. {
  41678. return self::getInstalled();
  41679. }
  41680. /**
  41681. * Lets you reload the static array from another file
  41682. *
  41683. * This is only useful for complex integrations in which a project needs to use
  41684. * this class but then also needs to execute another project's autoloader in process,
  41685. * and wants to ensure both projects have access to their version of installed.php.
  41686. *
  41687. * A typical case would be PHPUnit, where it would need to make sure it reads all
  41688. * the data it needs from this class, then call reload() with
  41689. * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
  41690. * the project in which it runs can then also use this class safely, without
  41691. * interference between PHPUnit's dependencies and the project's dependencies.
  41692. *
  41693. * @param array[] $data A vendor/composer/installed.php data set
  41694. * @return void
  41695. *
  41696. * @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
  41697. */
  41698. public static function reload($data)
  41699. {
  41700. self::$installed = $data;
  41701. self::$installedByVendor = array();
  41702. // when using reload, we disable the duplicate protection to ensure that self::$installed data is
  41703. // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
  41704. // so we have to assume it does not, and that may result in duplicate data being returned when listing
  41705. // all installed packages for example
  41706. self::$installedIsLocalDir = false;
  41707. }
  41708. /**
  41709. * @return string
  41710. */
  41711. private static function getSelfDir()
  41712. {
  41713. if (self::$selfDir === null) {
  41714. self::$selfDir = strtr(__DIR__, '\\', '/');
  41715. }
  41716. return self::$selfDir;
  41717. }
  41718. /**
  41719. * @return array[]
  41720. * @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[]}>}>
  41721. */
  41722. private static function getInstalled()
  41723. {
  41724. if (null === self::$canGetVendors) {
  41725. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  41726. }
  41727. $installed = array();
  41728. $copiedLocalDir = false;
  41729. if (self::$canGetVendors) {
  41730. $selfDir = self::getSelfDir();
  41731. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  41732. $vendorDir = strtr($vendorDir, '\\', '/');
  41733. if (isset(self::$installedByVendor[$vendorDir])) {
  41734. $installed[] = self::$installedByVendor[$vendorDir];
  41735. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  41736. /** @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 */
  41737. $required = require $vendorDir.'/composer/installed.php';
  41738. self::$installedByVendor[$vendorDir] = $required;
  41739. $installed[] = $required;
  41740. if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
  41741. self::$installed = $required;
  41742. self::$installedIsLocalDir = true;
  41743. }
  41744. }
  41745. if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
  41746. $copiedLocalDir = true;
  41747. }
  41748. }
  41749. }
  41750. if (null === self::$installed) {
  41751. // only require the installed.php file if this file is loaded from its dumped location,
  41752. // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
  41753. if (substr(__DIR__, -8, 1) !== 'C') {
  41754. /** @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 */
  41755. $required = require __DIR__ . '/installed.php';
  41756. self::$installed = $required;
  41757. } else {
  41758. self::$installed = array();
  41759. }
  41760. }
  41761. if (self::$installed !== array() && !$copiedLocalDir) {
  41762. $installed[] = self::$installed;
  41763. }
  41764. return $installed;
  41765. }
  41766. }
  41767. {
  41768. "$schema": "https://json-schema.org/draft-04/schema#",
  41769. "title": "Composer Lock File",
  41770. "type": "object",
  41771. "required": [ "content-hash", "packages", "packages-dev" ],
  41772. "additionalProperties": true,
  41773. "properties": {
  41774. "_readme": {
  41775. "type": "array",
  41776. "items": {
  41777. "type": "string"
  41778. },
  41779. "description": "Informational text for humans reading the file"
  41780. },
  41781. "content-hash": {
  41782. "type": "string",
  41783. "description": "Hash of all relevant properties of the composer.json that was used to create this lock file."
  41784. },
  41785. "packages": {
  41786. "type": "array",
  41787. "description": "An array of packages that are required.",
  41788. "items": {
  41789. "$ref": "./composer-schema.json",
  41790. "required": ["name", "version"]
  41791. }
  41792. },
  41793. "packages-dev": {
  41794. "type": "array",
  41795. "description": "An array of packages that are required in require-dev.",
  41796. "items": {
  41797. "$ref": "./composer-schema.json"
  41798. }
  41799. },
  41800. "aliases": {
  41801. "type": "array",
  41802. "description": "Inline aliases defined in the root package.",
  41803. "items": {
  41804. "type": "object",
  41805. "required": [ "package", "version", "alias", "alias_normalized" ],
  41806. "properties": {
  41807. "package": {
  41808. "type": "string"
  41809. },
  41810. "version": {
  41811. "type": "string"
  41812. },
  41813. "alias": {
  41814. "type": "string"
  41815. },
  41816. "alias_normalized": {
  41817. "type": "string"
  41818. }
  41819. }
  41820. }
  41821. },
  41822. "minimum-stability": {
  41823. "type": "string",
  41824. "description": "The minimum-stability used to generate this lock file."
  41825. },
  41826. "stability-flags": {
  41827. "type": "object",
  41828. "description": "Root package stability flags changing the minimum-stability for specific packages.",
  41829. "additionalProperties": {
  41830. "type": "integer"
  41831. }
  41832. },
  41833. "prefer-stable": {
  41834. "type": "boolean",
  41835. "description": "Whether the --prefer-stable flag was used when building this lock file."
  41836. },
  41837. "prefer-lowest": {
  41838. "type": "boolean",
  41839. "description": "Whether the --prefer-lowest flag was used when building this lock file."
  41840. },
  41841. "platform": {
  41842. "type": "object",
  41843. "description": "Platform requirements of the root package.",
  41844. "additionalProperties": {
  41845. "type": "string"
  41846. }
  41847. },
  41848. "platform-dev": {
  41849. "type": "object",
  41850. "description": "Platform dev-requirements of the root package.",
  41851. "additionalProperties": {
  41852. "type": "string"
  41853. }
  41854. },
  41855. "platform-overrides": {
  41856. "type": "object",
  41857. "description": "Platform config overrides of the root package.",
  41858. "additionalProperties": {
  41859. "type": "string"
  41860. }
  41861. },
  41862. "plugin-api-version": {
  41863. "type": "string",
  41864. "description": "The composer-plugin-api version that was used to generate this lock file."
  41865. }
  41866. }
  41867. }
  41868. {
  41869. "$schema": "https://json-schema.org/draft-04/schema#",
  41870. "title": "Composer Package Repository",
  41871. "type": "object",
  41872. "oneOf": [
  41873. { "required": [ "packages" ] },
  41874. { "required": [ "providers" ] },
  41875. { "required": [ "provider-includes", "providers-url" ] },
  41876. { "required": [ "metadata-url" ] }
  41877. ],
  41878. "properties": {
  41879. "packages": {
  41880. "type": ["object", "array"],
  41881. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  41882. "additionalProperties": { "$ref": "#/definitions/versions" }
  41883. },
  41884. "metadata-url": {
  41885. "type": "string",
  41886. "description": "Endpoint to retrieve package metadata data from, in Composer v2 format, e.g. '/p2/%package%.json'."
  41887. },
  41888. "available-packages": {
  41889. "type": "array",
  41890. "items": {
  41891. "type": "string"
  41892. },
  41893. "description": "If your repository only has a small number of packages, and you want to avoid serving many 404s, specify all the package names that your repository contains here."
  41894. },
  41895. "available-package-patterns": {
  41896. "type": "array",
  41897. "items": {
  41898. "type": "string"
  41899. },
  41900. "description": "If your repository only has a small number of packages, and you want to avoid serving many 404s, specify package name patterns containing wildcards (*) that your repository contains here."
  41901. },
  41902. "security-advisories": {
  41903. "type": "array",
  41904. "items": {
  41905. "type": "object",
  41906. "required": ["metadata", "api-url"],
  41907. "properties": {
  41908. "metadata": {
  41909. "type": "boolean",
  41910. "description": "Whether metadata files contain security advisory data or whether it should always be queried using the API URL."
  41911. },
  41912. "api-url": {
  41913. "type": "string",
  41914. "description": "Endpoint to call to retrieve security advisories data."
  41915. }
  41916. }
  41917. }
  41918. },
  41919. "metadata-changes-url": {
  41920. "type": "string",
  41921. "description": "Endpoint to retrieve package metadata updates from. This should receive a timestamp since last call to be able to return new changes. e.g. '/metadata/changes.json'."
  41922. },
  41923. "providers-api": {
  41924. "type": "string",
  41925. "description": "Endpoint to retrieve package names providing a given name from, e.g. '/providers/%package%.json'."
  41926. },
  41927. "notify-batch": {
  41928. "type": "string",
  41929. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  41930. },
  41931. "search": {
  41932. "type": "string",
  41933. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  41934. },
  41935. "list": {
  41936. "type": "string",
  41937. "description": "Endpoint that provides a full list of packages present in the repository. It should accept an optional `?filter=xx` query param, which can contain `*` as wildcards matching any substring. e.g. '/list.json'."
  41938. },
  41939. "warnings": {
  41940. "type": "array",
  41941. "items": {
  41942. "type": "object",
  41943. "required": ["message", "versions"],
  41944. "properties": {
  41945. "message": {
  41946. "type": "string",
  41947. "description": "A message that will be output by Composer as a warning when this source is consulted."
  41948. },
  41949. "versions": {
  41950. "type": "string",
  41951. "description": "A version constraint to limit to which Composer versions the warning should be shown."
  41952. }
  41953. }
  41954. }
  41955. },
  41956. "infos": {
  41957. "type": "array",
  41958. "items": {
  41959. "type": "object",
  41960. "required": ["message", "versions"],
  41961. "properties": {
  41962. "message": {
  41963. "type": "string",
  41964. "description": "A message that will be output by Composer as info when this source is consulted."
  41965. },
  41966. "versions": {
  41967. "type": "string",
  41968. "description": "A version constraint to limit to which Composer versions the info should be shown."
  41969. }
  41970. }
  41971. }
  41972. },
  41973. "providers-url": {
  41974. "type": "string",
  41975. "description": "DEPRECATED: Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  41976. },
  41977. "provider-includes": {
  41978. "type": "object",
  41979. "description": "DEPRECATED: A hashmap of provider listings.",
  41980. "additionalProperties": { "$ref": "#/definitions/provider" }
  41981. },
  41982. "providers": {
  41983. "type": "object",
  41984. "description": "DEPRECATED: A hashmap of package names in the form of <vendor>/<name>.",
  41985. "additionalProperties": { "$ref": "#/definitions/provider" }
  41986. },
  41987. "warning": {
  41988. "type": "string",
  41989. "description": "DEPRECATED: A message that will be output by Composer as a warning when this source is consulted."
  41990. },
  41991. "warning-versions": {
  41992. "type": "string",
  41993. "description": "DEPRECATED: A version constraint to limit to which Composer versions the warning should be shown."
  41994. },
  41995. "info": {
  41996. "type": "string",
  41997. "description": "DEPRECATED: A message that will be output by Composer as a info when this source is consulted."
  41998. },
  41999. "info-versions": {
  42000. "type": "string",
  42001. "description": "DEPRECATED: A version constraint to limit to which Composer versions the info should be shown."
  42002. }
  42003. },
  42004. "definitions": {
  42005. "versions": {
  42006. "type": "object",
  42007. "description": "A hashmap of versions and their metadata.",
  42008. "additionalProperties": { "$ref": "#/definitions/version" }
  42009. },
  42010. "version": {
  42011. "type": "object",
  42012. "oneOf": [
  42013. { "$ref": "#/definitions/package" },
  42014. { "$ref": "#/definitions/metapackage" }
  42015. ]
  42016. },
  42017. "package-base": {
  42018. "properties": {
  42019. "name": { "type": "string" },
  42020. "type": { "type": "string" },
  42021. "version": { "type": "string" },
  42022. "version_normalized": {
  42023. "type": "string",
  42024. "description": "Normalized version, optional but can save computational time on client side."
  42025. },
  42026. "autoload": { "type": "object" },
  42027. "require": { "type": "object" },
  42028. "replace": { "type": "object" },
  42029. "conflict": { "type": "object" },
  42030. "provide": { "type": "object" },
  42031. "time": { "type": "string" }
  42032. },
  42033. "additionalProperties": true
  42034. },
  42035. "package": {
  42036. "allOf": [
  42037. { "$ref": "#/definitions/package-base" },
  42038. {
  42039. "properties": {
  42040. "dist": { "type": "object" },
  42041. "source": { "type": "object" }
  42042. }
  42043. },
  42044. { "oneOf": [
  42045. { "required": [ "name", "version", "source" ] },
  42046. { "required": [ "name", "version", "dist" ] }
  42047. ] }
  42048. ]
  42049. },
  42050. "metapackage": {
  42051. "allOf": [
  42052. { "$ref": "#/definitions/package-base" },
  42053. {
  42054. "properties": {
  42055. "type": { "type": "string", "enum": [ "metapackage" ] }
  42056. },
  42057. "required": [ "name", "version", "type" ]
  42058. }
  42059. ]
  42060. },
  42061. "provider": {
  42062. "type": "object",
  42063. "properties": {
  42064. "sha256": {
  42065. "type": "string",
  42066. "description": "Hash value that can be used to validate the resource."
  42067. }
  42068. }
  42069. }
  42070. }
  42071. }
  42072. {
  42073. "$schema": "https://json-schema.org/draft-04/schema#",
  42074. "title": "Composer Package",
  42075. "type": "object",
  42076. "properties": {
  42077. "name": {
  42078. "type": "string",
  42079. "description": "Package name, including 'vendor-name/' prefix.",
  42080. "pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*\/[a-z0-9](([_.]|-{1,2})?[a-z0-9]+)*$"
  42081. },
  42082. "description": {
  42083. "type": "string",
  42084. "description": "Short package description."
  42085. },
  42086. "license": {
  42087. "type": ["string", "array"],
  42088. "description": "License name. Or an array of license names."
  42089. },
  42090. "type": {
  42091. "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.",
  42092. "type": "string",
  42093. "pattern": "^[a-z0-9-]+$"
  42094. },
  42095. "abandoned": {
  42096. "type": ["boolean", "string"],
  42097. "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."
  42098. },
  42099. "version": {
  42100. "type": "string",
  42101. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
  42102. "pattern": "^v?\\d+(?:[.-]\\d+){0,3}[._-]?(?:(?:stable|beta|b|RC|rc|alpha|a|patch|pl|p)(?:(?:[.-]?\\d+)*+)?)?(?:[.-]?dev|\\.x-dev)?(?:\\+.*)?$|^dev-.*$"
  42103. },
  42104. "default-branch": {
  42105. "type": ["boolean"],
  42106. "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."
  42107. },
  42108. "non-feature-branches": {
  42109. "type": ["array"],
  42110. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  42111. "items": {
  42112. "type": "string"
  42113. }
  42114. },
  42115. "keywords": {
  42116. "type": "array",
  42117. "items": {
  42118. "type": "string",
  42119. "description": "A tag/keyword that this package relates to."
  42120. }
  42121. },
  42122. "readme": {
  42123. "type": "string",
  42124. "description": "Relative path to the readme document."
  42125. },
  42126. "time": {
  42127. "type": "string",
  42128. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  42129. },
  42130. "authors": {
  42131. "$ref": "#/definitions/authors"
  42132. },
  42133. "homepage": {
  42134. "type": "string",
  42135. "description": "Homepage URL for the project.",
  42136. "format": "uri"
  42137. },
  42138. "support": {
  42139. "type": "object",
  42140. "properties": {
  42141. "email": {
  42142. "type": "string",
  42143. "description": "Email address for support.",
  42144. "format": "email"
  42145. },
  42146. "issues": {
  42147. "type": "string",
  42148. "description": "URL to the issue tracker.",
  42149. "format": "uri"
  42150. },
  42151. "forum": {
  42152. "type": "string",
  42153. "description": "URL to the forum.",
  42154. "format": "uri"
  42155. },
  42156. "wiki": {
  42157. "type": "string",
  42158. "description": "URL to the wiki.",
  42159. "format": "uri"
  42160. },
  42161. "irc": {
  42162. "type": "string",
  42163. "description": "IRC channel for support, as irc://server/channel.",
  42164. "format": "uri"
  42165. },
  42166. "chat": {
  42167. "type": "string",
  42168. "description": "URL to the support chat.",
  42169. "format": "uri"
  42170. },
  42171. "source": {
  42172. "type": "string",
  42173. "description": "URL to browse or download the sources.",
  42174. "format": "uri"
  42175. },
  42176. "docs": {
  42177. "type": "string",
  42178. "description": "URL to the documentation.",
  42179. "format": "uri"
  42180. },
  42181. "rss": {
  42182. "type": "string",
  42183. "description": "URL to the RSS feed.",
  42184. "format": "uri"
  42185. },
  42186. "security": {
  42187. "type": "string",
  42188. "description": "URL to the vulnerability disclosure policy (VDP).",
  42189. "format": "uri"
  42190. }
  42191. }
  42192. },
  42193. "funding": {
  42194. "type": "array",
  42195. "description": "A list of options to fund the development and maintenance of the package.",
  42196. "items": {
  42197. "type": "object",
  42198. "properties": {
  42199. "type": {
  42200. "type": "string",
  42201. "description": "Type of funding or platform through which funding is possible."
  42202. },
  42203. "url": {
  42204. "type": "string",
  42205. "description": "URL to a website with details on funding and a way to fund the package.",
  42206. "format": "uri"
  42207. }
  42208. }
  42209. }
  42210. },
  42211. "source": {
  42212. "$ref": "#/definitions/source"
  42213. },
  42214. "dist": {
  42215. "$ref": "#/definitions/dist"
  42216. },
  42217. "_comment": {
  42218. "type": ["array", "string"],
  42219. "description": "A key to store comments in"
  42220. },
  42221. "require": {
  42222. "type": "object",
  42223. "description": "This is an object of package name (keys) and version constraints (values) that are required to run this package.",
  42224. "additionalProperties": {
  42225. "type": "string"
  42226. }
  42227. },
  42228. "require-dev": {
  42229. "type": "object",
  42230. "description": "This is an object of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  42231. "additionalProperties": {
  42232. "type": "string"
  42233. }
  42234. },
  42235. "replace": {
  42236. "type": "object",
  42237. "description": "This is an object of package name (keys) and version constraints (values) that can be replaced by this package.",
  42238. "additionalProperties": {
  42239. "type": "string"
  42240. }
  42241. },
  42242. "conflict": {
  42243. "type": "object",
  42244. "description": "This is an object of package name (keys) and version constraints (values) that conflict with this package.",
  42245. "additionalProperties": {
  42246. "type": "string"
  42247. }
  42248. },
  42249. "provide": {
  42250. "type": "object",
  42251. "description": "This is an object of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  42252. "additionalProperties": {
  42253. "type": "string"
  42254. }
  42255. },
  42256. "suggest": {
  42257. "type": "object",
  42258. "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).",
  42259. "additionalProperties": {
  42260. "type": "string"
  42261. }
  42262. },
  42263. "repositories": {
  42264. "type": ["object", "array"],
  42265. "description": "A set of additional repositories where packages can be found.",
  42266. "additionalProperties": {
  42267. "anyOf": [
  42268. { "$ref": "#/definitions/repository" },
  42269. { "type": "boolean", "enum": [false] }
  42270. ]
  42271. },
  42272. "items": {
  42273. "anyOf": [
  42274. { "$ref": "#/definitions/repository" },
  42275. {
  42276. "type": "object",
  42277. "additionalProperties": { "type": "boolean", "enum": [false] },
  42278. "minProperties": 1,
  42279. "maxProperties": 1
  42280. }
  42281. ]
  42282. }
  42283. },
  42284. "minimum-stability": {
  42285. "type": ["string"],
  42286. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  42287. "enum": ["dev", "alpha", "beta", "rc", "RC", "stable"]
  42288. },
  42289. "prefer-stable": {
  42290. "type": ["boolean"],
  42291. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  42292. },
  42293. "autoload": {
  42294. "$ref": "#/definitions/autoload"
  42295. },
  42296. "autoload-dev": {
  42297. "type": "object",
  42298. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  42299. "properties": {
  42300. "psr-0": {
  42301. "type": "object",
  42302. "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.",
  42303. "additionalProperties": {
  42304. "type": ["string", "array"],
  42305. "items": {
  42306. "type": "string"
  42307. }
  42308. }
  42309. },
  42310. "psr-4": {
  42311. "type": "object",
  42312. "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.",
  42313. "additionalProperties": {
  42314. "type": ["string", "array"],
  42315. "items": {
  42316. "type": "string"
  42317. }
  42318. }
  42319. },
  42320. "classmap": {
  42321. "type": "array",
  42322. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  42323. },
  42324. "files": {
  42325. "type": "array",
  42326. "description": "This is an array of files that are always required on every request."
  42327. }
  42328. }
  42329. },
  42330. "target-dir": {
  42331. "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.",
  42332. "type": "string"
  42333. },
  42334. "include-path": {
  42335. "type": ["array"],
  42336. "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.",
  42337. "items": {
  42338. "type": "string"
  42339. }
  42340. },
  42341. "bin": {
  42342. "type": ["string", "array"],
  42343. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  42344. "items": {
  42345. "type": "string"
  42346. }
  42347. },
  42348. "archive": {
  42349. "type": ["object"],
  42350. "description": "Options for creating package archives for distribution.",
  42351. "properties": {
  42352. "name": {
  42353. "type": "string",
  42354. "description": "A base name for archive."
  42355. },
  42356. "exclude": {
  42357. "type": "array",
  42358. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  42359. }
  42360. }
  42361. },
  42362. "php-ext": {
  42363. "type": "object",
  42364. "description": "Settings for PHP extension packages.",
  42365. "properties": {
  42366. "extension-name": {
  42367. "type": "string",
  42368. "description": "If specified, this will be used as the name of the extension, where needed by tooling. If this is not specified, the extension name will be derived from the Composer package name (e.g. `vendor/name` would become `ext-name`). The extension name may be specified with or without the `ext-` prefix, and tools that use this must normalise this appropriately.",
  42369. "example": "ext-xdebug"
  42370. },
  42371. "priority": {
  42372. "type": "integer",
  42373. "description": "This is used to add a prefix to the INI file, e.g. `90-xdebug.ini` which affects the loading order. The priority is a number in the range 10-99 inclusive, with 10 being the highest priority (i.e. will be processed first), and 99 being the lowest priority (i.e. will be processed last). There are two digits so that the files sort correctly on any platform, whether the sorting is natural or not.",
  42374. "minimum": 10,
  42375. "maximum": 99,
  42376. "example": 80,
  42377. "default": 80
  42378. },
  42379. "support-zts": {
  42380. "type": "boolean",
  42381. "description": "Does this package support Zend Thread Safety",
  42382. "example": false,
  42383. "default": true
  42384. },
  42385. "support-nts": {
  42386. "type": "boolean",
  42387. "description": "Does this package support non-Thread Safe mode",
  42388. "example": false,
  42389. "default": true
  42390. },
  42391. "build-path": {
  42392. "type": ["string", "null"],
  42393. "description": "If specified, this is the subdirectory that will be used to build the extension instead of the root of the project.",
  42394. "example": "my-extension-source",
  42395. "default": null
  42396. },
  42397. "download-url-method": {
  42398. "type": "string",
  42399. "description": "If specified, this technique will be used to override the URL that PIE uses to download the asset. The default, if not specified, is composer-default.",
  42400. "enum": ["composer-default", "pre-packaged-source"],
  42401. "example": "composer-default"
  42402. },
  42403. "os-families": {
  42404. "type": "array",
  42405. "minItems": 1,
  42406. "description": "An array of OS families to mark as compatible with the extension. Specifying this property will mean this package is not installable with PIE on any OS family not listed here. Must not be specified alongside os-families-exclude.",
  42407. "items": {
  42408. "type": "string",
  42409. "enum": ["windows", "bsd", "darwin", "solaris", "linux", "unknown"],
  42410. "description": "The name of the OS family to mark as compatible."
  42411. }
  42412. },
  42413. "os-families-exclude": {
  42414. "type": "array",
  42415. "minItems": 1,
  42416. "description": "An array of OS families to mark as incompatible with the extension. Specifying this property will mean this package is installable on any OS family except those listed here. Must not be specified alongside os-families.",
  42417. "items": {
  42418. "type": "string",
  42419. "enum": ["windows", "bsd", "darwin", "solaris", "linux", "unknown"],
  42420. "description": "The name of the OS family to exclude."
  42421. }
  42422. },
  42423. "configure-options": {
  42424. "type": "array",
  42425. "description": "These configure options make up the flags that can be passed to ./configure when installing the extension.",
  42426. "items": {
  42427. "type": "object",
  42428. "required": ["name"],
  42429. "properties": {
  42430. "name": {
  42431. "type": "string",
  42432. "description": "The name of the flag, this would typically be prefixed with `--`, for example, the value 'the-flag' would be passed as `./configure --the-flag`.",
  42433. "example": "without-xdebug-compression",
  42434. "pattern": "^[a-zA-Z0-9][a-zA-Z0-9-_]*$"
  42435. },
  42436. "needs-value": {
  42437. "type": "boolean",
  42438. "description": "If this is set to true, the flag needs a value (e.g. --with-somelib=<path>), otherwise it is a flag without a value (e.g. --enable-some-feature).",
  42439. "example": false,
  42440. "default": false
  42441. },
  42442. "description": {
  42443. "type": "string",
  42444. "description": "The description of what the flag does or means.",
  42445. "example": "Disable compression through zlib"
  42446. }
  42447. }
  42448. }
  42449. }
  42450. },
  42451. "allOf": [
  42452. {
  42453. "not": {
  42454. "required": ["os-families", "os-families-exclude"]
  42455. }
  42456. }
  42457. ]
  42458. },
  42459. "config": {
  42460. "type": "object",
  42461. "description": "Composer options.",
  42462. "properties": {
  42463. "platform": {
  42464. "type": "object",
  42465. "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.",
  42466. "additionalProperties": {
  42467. "type": ["string", "boolean"]
  42468. }
  42469. },
  42470. "allow-plugins": {
  42471. "type": ["object", "boolean"],
  42472. "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.",
  42473. "additionalProperties": {
  42474. "type": ["boolean"]
  42475. }
  42476. },
  42477. "process-timeout": {
  42478. "type": "integer",
  42479. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  42480. },
  42481. "use-include-path": {
  42482. "type": "boolean",
  42483. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  42484. },
  42485. "use-parent-dir": {
  42486. "type": ["string", "boolean"],
  42487. "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."
  42488. },
  42489. "preferred-install": {
  42490. "type": ["string", "object"],
  42491. "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\"}.",
  42492. "additionalProperties": {
  42493. "type": ["string"]
  42494. }
  42495. },
  42496. "audit": {
  42497. "type": "object",
  42498. "description": "Security audit configuration options",
  42499. "properties": {
  42500. "ignore": {
  42501. "anyOf": [
  42502. {
  42503. "type": "object",
  42504. "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.",
  42505. "additionalProperties": {
  42506. "type": ["string", "string"]
  42507. }
  42508. },
  42509. {
  42510. "type": "array",
  42511. "description": "A set of advisory ids, remote ids or CVE ids that are reported but let the audit command pass.",
  42512. "items": {
  42513. "type": "string"
  42514. }
  42515. }
  42516. ]
  42517. },
  42518. "abandoned": {
  42519. "enum": ["ignore", "report", "fail"],
  42520. "description": "Whether abandoned packages should be ignored, reported as problems or cause an audit failure."
  42521. }
  42522. }
  42523. },
  42524. "notify-on-install": {
  42525. "type": "boolean",
  42526. "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."
  42527. },
  42528. "github-protocols": {
  42529. "type": "array",
  42530. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"https\", \"ssh\", \"git\"].",
  42531. "items": {
  42532. "type": "string"
  42533. }
  42534. },
  42535. "github-oauth": {
  42536. "type": "object",
  42537. "description": "An object of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  42538. "additionalProperties": {
  42539. "type": "string"
  42540. }
  42541. },
  42542. "gitlab-oauth": {
  42543. "type": "object",
  42544. "description": "An object of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":{\"expires-at\":\"<expiration date>\", \"refresh-token\":\"<refresh token>\", \"token\":\"<token>\"}}.",
  42545. "additionalProperties": {
  42546. "type": ["string", "object"],
  42547. "required": [ "token"],
  42548. "properties": {
  42549. "expires-at": {
  42550. "type": "integer",
  42551. "description": "The expiration date for this GitLab token"
  42552. },
  42553. "refresh-token": {
  42554. "type": "string",
  42555. "description": "The refresh token used for GitLab authentication"
  42556. },
  42557. "token": {
  42558. "type": "string",
  42559. "description": "The token used for GitLab authentication"
  42560. }
  42561. }
  42562. }
  42563. },
  42564. "gitlab-token": {
  42565. "type": "object",
  42566. "description": "An object of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}, or an object with username and token keys.",
  42567. "additionalProperties": {
  42568. "type": ["string", "object"],
  42569. "required": ["username", "token"],
  42570. "properties": {
  42571. "username": {
  42572. "type": "string",
  42573. "description": "The username used for GitLab authentication"
  42574. },
  42575. "token": {
  42576. "type": "string",
  42577. "description": "The token used for GitLab authentication"
  42578. }
  42579. }
  42580. }
  42581. },
  42582. "gitlab-protocol": {
  42583. "enum": ["git", "http", "https"],
  42584. "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."
  42585. },
  42586. "bearer": {
  42587. "type": "object",
  42588. "description": "An object of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
  42589. "additionalProperties": {
  42590. "type": "string"
  42591. }
  42592. },
  42593. "disable-tls": {
  42594. "type": "boolean",
  42595. "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."
  42596. },
  42597. "secure-http": {
  42598. "type": "boolean",
  42599. "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."
  42600. },
  42601. "secure-svn-domains": {
  42602. "type": "array",
  42603. "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.",
  42604. "items": {
  42605. "type": "string"
  42606. }
  42607. },
  42608. "cafile": {
  42609. "type": "string",
  42610. "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."
  42611. },
  42612. "capath": {
  42613. "type": "string",
  42614. "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."
  42615. },
  42616. "http-basic": {
  42617. "type": "object",
  42618. "description": "An object of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  42619. "additionalProperties": {
  42620. "type": "object",
  42621. "required": ["username", "password"],
  42622. "properties": {
  42623. "username": {
  42624. "type": "string",
  42625. "description": "The username used for HTTP Basic authentication"
  42626. },
  42627. "password": {
  42628. "type": "string",
  42629. "description": "The password used for HTTP Basic authentication"
  42630. }
  42631. }
  42632. }
  42633. },
  42634. "store-auths": {
  42635. "type": ["string", "boolean"],
  42636. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  42637. },
  42638. "vendor-dir": {
  42639. "type": "string",
  42640. "description": "The location where all packages are installed, defaults to \"vendor\"."
  42641. },
  42642. "bin-dir": {
  42643. "type": "string",
  42644. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  42645. },
  42646. "data-dir": {
  42647. "type": "string",
  42648. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  42649. },
  42650. "cache-dir": {
  42651. "type": "string",
  42652. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  42653. },
  42654. "cache-files-dir": {
  42655. "type": "string",
  42656. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  42657. },
  42658. "cache-repo-dir": {
  42659. "type": "string",
  42660. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  42661. },
  42662. "cache-vcs-dir": {
  42663. "type": "string",
  42664. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  42665. },
  42666. "cache-ttl": {
  42667. "type": "integer",
  42668. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  42669. },
  42670. "cache-files-ttl": {
  42671. "type": "integer",
  42672. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  42673. },
  42674. "cache-files-maxsize": {
  42675. "type": ["string", "integer"],
  42676. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  42677. },
  42678. "cache-read-only": {
  42679. "type": ["boolean"],
  42680. "description": "Whether to use the Composer cache in read-only mode."
  42681. },
  42682. "bin-compat": {
  42683. "enum": ["auto", "full", "proxy", "symlink"],
  42684. "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)."
  42685. },
  42686. "discard-changes": {
  42687. "type": ["string", "boolean"],
  42688. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  42689. },
  42690. "autoloader-suffix": {
  42691. "type": "string",
  42692. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  42693. },
  42694. "optimize-autoloader": {
  42695. "type": "boolean",
  42696. "description": "Always optimize when dumping the autoloader."
  42697. },
  42698. "prepend-autoloader": {
  42699. "type": "boolean",
  42700. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  42701. },
  42702. "classmap-authoritative": {
  42703. "type": "boolean",
  42704. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  42705. },
  42706. "apcu-autoloader": {
  42707. "type": "boolean",
  42708. "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."
  42709. },
  42710. "github-domains": {
  42711. "type": "array",
  42712. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  42713. "items": {
  42714. "type": "string"
  42715. }
  42716. },
  42717. "github-expose-hostname": {
  42718. "type": "boolean",
  42719. "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."
  42720. },
  42721. "gitlab-domains": {
  42722. "type": "array",
  42723. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  42724. "items": {
  42725. "type": "string"
  42726. }
  42727. },
  42728. "bitbucket-oauth": {
  42729. "type": "object",
  42730. "description": "An object of domain name => {\"consumer-key\": \"...\", \"consumer-secret\": \"...\"}.",
  42731. "additionalProperties": {
  42732. "type": "object",
  42733. "required": ["consumer-key", "consumer-secret"],
  42734. "properties": {
  42735. "consumer-key": {
  42736. "type": "string",
  42737. "description": "The consumer-key used for OAuth authentication"
  42738. },
  42739. "consumer-secret": {
  42740. "type": "string",
  42741. "description": "The consumer-secret used for OAuth authentication"
  42742. },
  42743. "access-token": {
  42744. "type": "string",
  42745. "description": "The OAuth token retrieved from Bitbucket's API, this is written by Composer and you should not set it nor modify it."
  42746. },
  42747. "access-token-expiration": {
  42748. "type": "integer",
  42749. "description": "The generated token's expiration timestamp, this is written by Composer and you should not set it nor modify it."
  42750. }
  42751. }
  42752. }
  42753. },
  42754. "use-github-api": {
  42755. "type": "boolean",
  42756. "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."
  42757. },
  42758. "archive-format": {
  42759. "type": "string",
  42760. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  42761. },
  42762. "archive-dir": {
  42763. "type": "string",
  42764. "description": "The default archive path when not provided on cli, defaults to \".\"."
  42765. },
  42766. "htaccess-protect": {
  42767. "type": "boolean",
  42768. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  42769. },
  42770. "sort-packages": {
  42771. "type": "boolean",
  42772. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  42773. },
  42774. "lock": {
  42775. "type": "boolean",
  42776. "description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
  42777. },
  42778. "platform-check": {
  42779. "type": ["boolean", "string"],
  42780. "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."
  42781. },
  42782. "bump-after-update": {
  42783. "type": ["string", "boolean"],
  42784. "description": "Defaults to false and can be any of true, false, \"dev\"` or \"no-dev\"`. If set to true, Composer will run the bump command after running the update command. If set to \"dev\" or \"no-dev\" then only the corresponding dependencies will be bumped."
  42785. },
  42786. "allow-missing-requirements": {
  42787. "type": ["boolean"],
  42788. "description": "Defaults to false. If set to true, Composer will allow install when lock file is not up to date with the latest changes in composer.json."
  42789. }
  42790. }
  42791. },
  42792. "extra": {
  42793. "type": ["object", "array"],
  42794. "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.",
  42795. "additionalProperties": true
  42796. },
  42797. "scripts": {
  42798. "type": ["object"],
  42799. "description": "Script listeners that will be executed before/after some events.",
  42800. "properties": {
  42801. "pre-install-cmd": {
  42802. "type": ["array", "string"],
  42803. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  42804. },
  42805. "post-install-cmd": {
  42806. "type": ["array", "string"],
  42807. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  42808. },
  42809. "pre-update-cmd": {
  42810. "type": ["array", "string"],
  42811. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  42812. },
  42813. "post-update-cmd": {
  42814. "type": ["array", "string"],
  42815. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  42816. },
  42817. "pre-status-cmd": {
  42818. "type": ["array", "string"],
  42819. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  42820. },
  42821. "post-status-cmd": {
  42822. "type": ["array", "string"],
  42823. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  42824. },
  42825. "pre-package-install": {
  42826. "type": ["array", "string"],
  42827. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  42828. },
  42829. "post-package-install": {
  42830. "type": ["array", "string"],
  42831. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  42832. },
  42833. "pre-package-update": {
  42834. "type": ["array", "string"],
  42835. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  42836. },
  42837. "post-package-update": {
  42838. "type": ["array", "string"],
  42839. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  42840. },
  42841. "pre-package-uninstall": {
  42842. "type": ["array", "string"],
  42843. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  42844. },
  42845. "post-package-uninstall": {
  42846. "type": ["array", "string"],
  42847. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  42848. },
  42849. "pre-autoload-dump": {
  42850. "type": ["array", "string"],
  42851. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  42852. },
  42853. "post-autoload-dump": {
  42854. "type": ["array", "string"],
  42855. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  42856. },
  42857. "post-root-package-install": {
  42858. "type": ["array", "string"],
  42859. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  42860. },
  42861. "post-create-project-cmd": {
  42862. "type": ["array", "string"],
  42863. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  42864. }
  42865. }
  42866. },
  42867. "scripts-descriptions": {
  42868. "type": ["object"],
  42869. "description": "Descriptions for custom commands, shown in console help.",
  42870. "additionalProperties": {
  42871. "type": "string"
  42872. }
  42873. },
  42874. "scripts-aliases": {
  42875. "type": ["object"],
  42876. "description": "Aliases for custom commands.",
  42877. "additionalProperties": {
  42878. "type": "array"
  42879. }
  42880. }
  42881. },
  42882. "definitions": {
  42883. "authors": {
  42884. "type": "array",
  42885. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  42886. "items": {
  42887. "type": "object",
  42888. "additionalProperties": false,
  42889. "required": [ "name"],
  42890. "properties": {
  42891. "name": {
  42892. "type": "string",
  42893. "description": "Full name of the author."
  42894. },
  42895. "email": {
  42896. "type": "string",
  42897. "description": "Email address of the author.",
  42898. "format": "email"
  42899. },
  42900. "homepage": {
  42901. "type": "string",
  42902. "description": "Homepage URL for the author.",
  42903. "format": "uri"
  42904. },
  42905. "role": {
  42906. "type": "string",
  42907. "description": "Author's role in the project."
  42908. }
  42909. }
  42910. }
  42911. },
  42912. "autoload": {
  42913. "type": "object",
  42914. "description": "Description of how the package can be autoloaded.",
  42915. "properties": {
  42916. "psr-0": {
  42917. "type": "object",
  42918. "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.",
  42919. "additionalProperties": {
  42920. "type": ["string", "array"],
  42921. "items": {
  42922. "type": "string"
  42923. }
  42924. }
  42925. },
  42926. "psr-4": {
  42927. "type": "object",
  42928. "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.",
  42929. "additionalProperties": {
  42930. "type": ["string", "array"],
  42931. "items": {
  42932. "type": "string"
  42933. }
  42934. }
  42935. },
  42936. "classmap": {
  42937. "type": "array",
  42938. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  42939. },
  42940. "files": {
  42941. "type": "array",
  42942. "description": "This is an array of files that are always required on every request."
  42943. },
  42944. "exclude-from-classmap": {
  42945. "type": "array",
  42946. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  42947. }
  42948. }
  42949. },
  42950. "repository": {
  42951. "type": "object",
  42952. "anyOf": [
  42953. { "$ref": "#/definitions/composer-repository" },
  42954. { "$ref": "#/definitions/vcs-repository" },
  42955. { "$ref": "#/definitions/path-repository" },
  42956. { "$ref": "#/definitions/artifact-repository" },
  42957. { "$ref": "#/definitions/pear-repository" },
  42958. { "$ref": "#/definitions/package-repository" }
  42959. ]
  42960. },
  42961. "composer-repository": {
  42962. "type": "object",
  42963. "required": ["type", "url"],
  42964. "properties": {
  42965. "type": { "type": "string", "enum": ["composer"] },
  42966. "url": { "type": "string" },
  42967. "canonical": { "type": "boolean" },
  42968. "only": {
  42969. "type": "array",
  42970. "items": {
  42971. "type": "string"
  42972. }
  42973. },
  42974. "exclude": {
  42975. "type": "array",
  42976. "items": {
  42977. "type": "string"
  42978. }
  42979. },
  42980. "options": {
  42981. "type": "object",
  42982. "additionalProperties": true
  42983. },
  42984. "allow_ssl_downgrade": { "type": "boolean" },
  42985. "force-lazy-providers": { "type": "boolean" }
  42986. }
  42987. },
  42988. "vcs-repository": {
  42989. "type": "object",
  42990. "required": ["type", "url"],
  42991. "properties": {
  42992. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "bitbucket", "git-bitbucket", "hg", "fossil", "perforce", "svn"] },
  42993. "url": { "type": "string" },
  42994. "canonical": { "type": "boolean" },
  42995. "only": {
  42996. "type": "array",
  42997. "items": {
  42998. "type": "string"
  42999. }
  43000. },
  43001. "exclude": {
  43002. "type": "array",
  43003. "items": {
  43004. "type": "string"
  43005. }
  43006. },
  43007. "no-api": { "type": "boolean" },
  43008. "secure-http": { "type": "boolean" },
  43009. "svn-cache-credentials": { "type": "boolean" },
  43010. "trunk-path": { "type": ["string", "boolean"] },
  43011. "branches-path": { "type": ["string", "boolean"] },
  43012. "tags-path": { "type": ["string", "boolean"] },
  43013. "package-path": { "type": "string" },
  43014. "depot": { "type": "string" },
  43015. "branch": { "type": "string" },
  43016. "unique_perforce_client_name": { "type": "string" },
  43017. "p4user": { "type": "string" },
  43018. "p4password": { "type": "string" }
  43019. }
  43020. },
  43021. "path-repository": {
  43022. "type": "object",
  43023. "required": ["type", "url"],
  43024. "properties": {
  43025. "type": { "type": "string", "enum": ["path"] },
  43026. "url": { "type": "string" },
  43027. "canonical": { "type": "boolean" },
  43028. "only": {
  43029. "type": "array",
  43030. "items": {
  43031. "type": "string"
  43032. }
  43033. },
  43034. "exclude": {
  43035. "type": "array",
  43036. "items": {
  43037. "type": "string"
  43038. }
  43039. },
  43040. "options": {
  43041. "type": "object",
  43042. "properties": {
  43043. "reference": { "type": ["string"], "enum": ["none", "config", "auto"] },
  43044. "symlink": { "type": ["boolean", "null"] },
  43045. "relative": { "type": ["boolean"] },
  43046. "versions": { "type": "object", "additionalProperties": { "type": "string" } }
  43047. },
  43048. "additionalProperties": true
  43049. }
  43050. }
  43051. },
  43052. "artifact-repository": {
  43053. "type": "object",
  43054. "required": ["type", "url"],
  43055. "properties": {
  43056. "type": { "type": "string", "enum": ["artifact"] },
  43057. "url": { "type": "string" },
  43058. "canonical": { "type": "boolean" },
  43059. "only": {
  43060. "type": "array",
  43061. "items": {
  43062. "type": "string"
  43063. }
  43064. },
  43065. "exclude": {
  43066. "type": "array",
  43067. "items": {
  43068. "type": "string"
  43069. }
  43070. }
  43071. }
  43072. },
  43073. "pear-repository": {
  43074. "type": "object",
  43075. "required": ["type", "url"],
  43076. "properties": {
  43077. "type": { "type": "string", "enum": ["pear"] },
  43078. "url": { "type": "string" },
  43079. "canonical": { "type": "boolean" },
  43080. "only": {
  43081. "type": "array",
  43082. "items": {
  43083. "type": "string"
  43084. }
  43085. },
  43086. "exclude": {
  43087. "type": "array",
  43088. "items": {
  43089. "type": "string"
  43090. }
  43091. },
  43092. "vendor-alias": { "type": "string" }
  43093. }
  43094. },
  43095. "package-repository": {
  43096. "type": "object",
  43097. "required": ["type", "package"],
  43098. "properties": {
  43099. "type": { "type": "string", "enum": ["package"] },
  43100. "canonical": { "type": "boolean" },
  43101. "only": {
  43102. "type": "array",
  43103. "items": {
  43104. "type": "string"
  43105. }
  43106. },
  43107. "exclude": {
  43108. "type": "array",
  43109. "items": {
  43110. "type": "string"
  43111. }
  43112. },
  43113. "package": {
  43114. "oneOf": [
  43115. { "$ref": "#/definitions/inline-package" },
  43116. {
  43117. "type": "array",
  43118. "items": { "$ref": "#/definitions/inline-package" }
  43119. }
  43120. ]
  43121. }
  43122. }
  43123. },
  43124. "inline-package": {
  43125. "type": "object",
  43126. "required": ["name", "version"],
  43127. "properties": {
  43128. "name": {
  43129. "type": "string",
  43130. "description": "Package name, including 'vendor-name/' prefix."
  43131. },
  43132. "type": {
  43133. "type": "string"
  43134. },
  43135. "target-dir": {
  43136. "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.",
  43137. "type": "string"
  43138. },
  43139. "description": {
  43140. "type": "string"
  43141. },
  43142. "keywords": {
  43143. "type": "array",
  43144. "items": {
  43145. "type": "string"
  43146. }
  43147. },
  43148. "homepage": {
  43149. "type": "string",
  43150. "format": "uri"
  43151. },
  43152. "version": {
  43153. "type": "string"
  43154. },
  43155. "time": {
  43156. "type": "string"
  43157. },
  43158. "license": {
  43159. "type": [
  43160. "string",
  43161. "array"
  43162. ]
  43163. },
  43164. "authors": {
  43165. "$ref": "#/definitions/authors"
  43166. },
  43167. "require": {
  43168. "type": "object",
  43169. "additionalProperties": {
  43170. "type": "string"
  43171. }
  43172. },
  43173. "replace": {
  43174. "type": "object",
  43175. "additionalProperties": {
  43176. "type": "string"
  43177. }
  43178. },
  43179. "conflict": {
  43180. "type": "object",
  43181. "additionalProperties": {
  43182. "type": "string"
  43183. }
  43184. },
  43185. "provide": {
  43186. "type": "object",
  43187. "additionalProperties": {
  43188. "type": "string"
  43189. }
  43190. },
  43191. "require-dev": {
  43192. "type": "object",
  43193. "additionalProperties": {
  43194. "type": "string"
  43195. }
  43196. },
  43197. "suggest": {
  43198. "type": "object",
  43199. "additionalProperties": {
  43200. "type": "string"
  43201. }
  43202. },
  43203. "extra": {
  43204. "type": ["object", "array"],
  43205. "additionalProperties": true
  43206. },
  43207. "autoload": {
  43208. "$ref": "#/definitions/autoload"
  43209. },
  43210. "archive": {
  43211. "type": ["object"],
  43212. "properties": {
  43213. "exclude": {
  43214. "type": "array"
  43215. }
  43216. }
  43217. },
  43218. "bin": {
  43219. "type": ["string", "array"],
  43220. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  43221. "items": {
  43222. "type": "string"
  43223. }
  43224. },
  43225. "include-path": {
  43226. "type": ["array"],
  43227. "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.",
  43228. "items": {
  43229. "type": "string"
  43230. }
  43231. },
  43232. "source": {
  43233. "$ref": "#/definitions/source"
  43234. },
  43235. "dist": {
  43236. "$ref": "#/definitions/dist"
  43237. }
  43238. },
  43239. "additionalProperties": true
  43240. },
  43241. "source": {
  43242. "type": "object",
  43243. "required": ["type", "url", "reference"],
  43244. "properties": {
  43245. "type": {
  43246. "type": "string"
  43247. },
  43248. "url": {
  43249. "type": "string"
  43250. },
  43251. "reference": {
  43252. "type": "string"
  43253. },
  43254. "mirrors": {
  43255. "type": "array"
  43256. }
  43257. }
  43258. },
  43259. "dist": {
  43260. "type": "object",
  43261. "required": ["type", "url"],
  43262. "properties": {
  43263. "type": {
  43264. "type": "string"
  43265. },
  43266. "url": {
  43267. "type": "string"
  43268. },
  43269. "reference": {
  43270. "type": "string"
  43271. },
  43272. "shasum": {
  43273. "type": "string"
  43274. },
  43275. "mirrors": {
  43276. "type": "array"
  43277. }
  43278. }
  43279. }
  43280. }
  43281. }
  43282. <?php
  43283. if (PHP_VERSION_ID < 50600) {
  43284. if (!headers_sent()) {
  43285. header('HTTP/1.1 500 Internal Server Error');
  43286. }
  43287. $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;
  43288. if (!ini_get('display_errors')) {
  43289. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  43290. fwrite(STDERR, $err);
  43291. } elseif (!headers_sent()) {
  43292. echo $err;
  43293. }
  43294. }
  43295. throw new RuntimeException($err);
  43296. }
  43297. require_once __DIR__ . '/composer/autoload_real.php';
  43298. return ComposerAutoloaderInitComposerPhar1743778606::getLoader();
  43299. <?php
  43300. namespace Composer\Autoload;
  43301. class ClassLoader
  43302. {
  43303. private static $includeFile;
  43304. private $vendorDir;
  43305. private $prefixLengthsPsr4 = array();
  43306. private $prefixDirsPsr4 = array();
  43307. private $fallbackDirsPsr4 = array();
  43308. private $prefixesPsr0 = array();
  43309. private $fallbackDirsPsr0 = array();
  43310. private $useIncludePath = false;
  43311. private $classMap = array();
  43312. private $classMapAuthoritative = false;
  43313. private $missingClasses = array();
  43314. private $apcuPrefix;
  43315. private static $registeredLoaders = array();
  43316. public function __construct($vendorDir = null)
  43317. {
  43318. $this->vendorDir = $vendorDir;
  43319. self::initializeIncludeClosure();
  43320. }
  43321. public function getPrefixes()
  43322. {
  43323. if (!empty($this->prefixesPsr0)) {
  43324. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  43325. }
  43326. return array();
  43327. }
  43328. public function getPrefixesPsr4()
  43329. {
  43330. return $this->prefixDirsPsr4;
  43331. }
  43332. public function getFallbackDirs()
  43333. {
  43334. return $this->fallbackDirsPsr0;
  43335. }
  43336. public function getFallbackDirsPsr4()
  43337. {
  43338. return $this->fallbackDirsPsr4;
  43339. }
  43340. public function getClassMap()
  43341. {
  43342. return $this->classMap;
  43343. }
  43344. public function addClassMap(array $classMap)
  43345. {
  43346. if ($this->classMap) {
  43347. $this->classMap = array_merge($this->classMap, $classMap);
  43348. } else {
  43349. $this->classMap = $classMap;
  43350. }
  43351. }
  43352. public function add($prefix, $paths, $prepend = false)
  43353. {
  43354. $paths = (array) $paths;
  43355. if (!$prefix) {
  43356. if ($prepend) {
  43357. $this->fallbackDirsPsr0 = array_merge(
  43358. $paths,
  43359. $this->fallbackDirsPsr0
  43360. );
  43361. } else {
  43362. $this->fallbackDirsPsr0 = array_merge(
  43363. $this->fallbackDirsPsr0,
  43364. $paths
  43365. );
  43366. }
  43367. return;
  43368. }
  43369. $first = $prefix[0];
  43370. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  43371. $this->prefixesPsr0[$first][$prefix] = $paths;
  43372. return;
  43373. }
  43374. if ($prepend) {
  43375. $this->prefixesPsr0[$first][$prefix] = array_merge(
  43376. $paths,
  43377. $this->prefixesPsr0[$first][$prefix]
  43378. );
  43379. } else {
  43380. $this->prefixesPsr0[$first][$prefix] = array_merge(
  43381. $this->prefixesPsr0[$first][$prefix],
  43382. $paths
  43383. );
  43384. }
  43385. }
  43386. public function addPsr4($prefix, $paths, $prepend = false)
  43387. {
  43388. $paths = (array) $paths;
  43389. if (!$prefix) {
  43390. if ($prepend) {
  43391. $this->fallbackDirsPsr4 = array_merge(
  43392. $paths,
  43393. $this->fallbackDirsPsr4
  43394. );
  43395. } else {
  43396. $this->fallbackDirsPsr4 = array_merge(
  43397. $this->fallbackDirsPsr4,
  43398. $paths
  43399. );
  43400. }
  43401. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  43402. $length = strlen($prefix);
  43403. if ('\\' !== $prefix[$length - 1]) {
  43404. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  43405. }
  43406. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  43407. $this->prefixDirsPsr4[$prefix] = $paths;
  43408. } elseif ($prepend) {
  43409. $this->prefixDirsPsr4[$prefix] = array_merge(
  43410. $paths,
  43411. $this->prefixDirsPsr4[$prefix]
  43412. );
  43413. } else {
  43414. $this->prefixDirsPsr4[$prefix] = array_merge(
  43415. $this->prefixDirsPsr4[$prefix],
  43416. $paths
  43417. );
  43418. }
  43419. }
  43420. public function set($prefix, $paths)
  43421. {
  43422. if (!$prefix) {
  43423. $this->fallbackDirsPsr0 = (array) $paths;
  43424. } else {
  43425. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  43426. }
  43427. }
  43428. public function setPsr4($prefix, $paths)
  43429. {
  43430. if (!$prefix) {
  43431. $this->fallbackDirsPsr4 = (array) $paths;
  43432. } else {
  43433. $length = strlen($prefix);
  43434. if ('\\' !== $prefix[$length - 1]) {
  43435. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  43436. }
  43437. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  43438. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  43439. }
  43440. }
  43441. public function setUseIncludePath($useIncludePath)
  43442. {
  43443. $this->useIncludePath = $useIncludePath;
  43444. }
  43445. public function getUseIncludePath()
  43446. {
  43447. return $this->useIncludePath;
  43448. }
  43449. public function setClassMapAuthoritative($classMapAuthoritative)
  43450. {
  43451. $this->classMapAuthoritative = $classMapAuthoritative;
  43452. }
  43453. public function isClassMapAuthoritative()
  43454. {
  43455. return $this->classMapAuthoritative;
  43456. }
  43457. public function setApcuPrefix($apcuPrefix)
  43458. {
  43459. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  43460. }
  43461. public function getApcuPrefix()
  43462. {
  43463. return $this->apcuPrefix;
  43464. }
  43465. public function register($prepend = false)
  43466. {
  43467. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  43468. if (null === $this->vendorDir) {
  43469. return;
  43470. }
  43471. if ($prepend) {
  43472. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  43473. } else {
  43474. unset(self::$registeredLoaders[$this->vendorDir]);
  43475. self::$registeredLoaders[$this->vendorDir] = $this;
  43476. }
  43477. }
  43478. public function unregister()
  43479. {
  43480. spl_autoload_unregister(array($this, 'loadClass'));
  43481. if (null !== $this->vendorDir) {
  43482. unset(self::$registeredLoaders[$this->vendorDir]);
  43483. }
  43484. }
  43485. public function loadClass($class)
  43486. {
  43487. if ($file = $this->findFile($class)) {
  43488. $includeFile = self::$includeFile;
  43489. $includeFile($file);
  43490. return true;
  43491. }
  43492. return null;
  43493. }
  43494. public function findFile($class)
  43495. {
  43496. if (isset($this->classMap[$class])) {
  43497. return $this->classMap[$class];
  43498. }
  43499. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  43500. return false;
  43501. }
  43502. if (null !== $this->apcuPrefix) {
  43503. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  43504. if ($hit) {
  43505. return $file;
  43506. }
  43507. }
  43508. $file = $this->findFileWithExtension($class, '.php');
  43509. if (false === $file && defined('HHVM_VERSION')) {
  43510. $file = $this->findFileWithExtension($class, '.hh');
  43511. }
  43512. if (null !== $this->apcuPrefix) {
  43513. apcu_add($this->apcuPrefix.$class, $file);
  43514. }
  43515. if (false === $file) {
  43516. $this->missingClasses[$class] = true;
  43517. }
  43518. return $file;
  43519. }
  43520. public static function getRegisteredLoaders()
  43521. {
  43522. return self::$registeredLoaders;
  43523. }
  43524. private function findFileWithExtension($class, $ext)
  43525. {
  43526. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  43527. $first = $class[0];
  43528. if (isset($this->prefixLengthsPsr4[$first])) {
  43529. $subPath = $class;
  43530. while (false !== $lastPos = strrpos($subPath, '\\')) {
  43531. $subPath = substr($subPath, 0, $lastPos);
  43532. $search = $subPath . '\\';
  43533. if (isset($this->prefixDirsPsr4[$search])) {
  43534. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  43535. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  43536. if (file_exists($file = $dir . $pathEnd)) {
  43537. return $file;
  43538. }
  43539. }
  43540. }
  43541. }
  43542. }
  43543. foreach ($this->fallbackDirsPsr4 as $dir) {
  43544. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  43545. return $file;
  43546. }
  43547. }
  43548. if (false !== $pos = strrpos($class, '\\')) {
  43549. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  43550. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  43551. } else {
  43552. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  43553. }
  43554. if (isset($this->prefixesPsr0[$first])) {
  43555. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  43556. if (0 === strpos($class, $prefix)) {
  43557. foreach ($dirs as $dir) {
  43558. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  43559. return $file;
  43560. }
  43561. }
  43562. }
  43563. }
  43564. }
  43565. foreach ($this->fallbackDirsPsr0 as $dir) {
  43566. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  43567. return $file;
  43568. }
  43569. }
  43570. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  43571. return $file;
  43572. }
  43573. return false;
  43574. }
  43575. private static function initializeIncludeClosure()
  43576. {
  43577. if (self::$includeFile !== null) {
  43578. return;
  43579. }
  43580. self::$includeFile = \Closure::bind(static function($file) {
  43581. include $file;
  43582. }, null, null);
  43583. }
  43584. }
  43585. <?php
  43586. namespace Composer;
  43587. use Composer\Autoload\ClassLoader;
  43588. use Composer\Semver\VersionParser;
  43589. class InstalledVersions
  43590. {
  43591. private static $selfDir = null;
  43592. private static $installed;
  43593. private static $installedIsLocalDir;
  43594. private static $canGetVendors;
  43595. private static $installedByVendor = array();
  43596. public static function getInstalledPackages()
  43597. {
  43598. $packages = array();
  43599. foreach (self::getInstalled() as $installed) {
  43600. $packages[] = array_keys($installed['versions']);
  43601. }
  43602. if (1 === \count($packages)) {
  43603. return $packages[0];
  43604. }
  43605. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  43606. }
  43607. public static function getInstalledPackagesByType($type)
  43608. {
  43609. $packagesByType = array();
  43610. foreach (self::getInstalled() as $installed) {
  43611. foreach ($installed['versions'] as $name => $package) {
  43612. if (isset($package['type']) && $package['type'] === $type) {
  43613. $packagesByType[] = $name;
  43614. }
  43615. }
  43616. }
  43617. return $packagesByType;
  43618. }
  43619. public static function isInstalled($packageName, $includeDevRequirements = true)
  43620. {
  43621. foreach (self::getInstalled() as $installed) {
  43622. if (isset($installed['versions'][$packageName])) {
  43623. return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
  43624. }
  43625. }
  43626. return false;
  43627. }
  43628. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  43629. {
  43630. $constraint = $parser->parseConstraints((string) $constraint);
  43631. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  43632. return $provided->matches($constraint);
  43633. }
  43634. public static function getVersionRanges($packageName)
  43635. {
  43636. foreach (self::getInstalled() as $installed) {
  43637. if (!isset($installed['versions'][$packageName])) {
  43638. continue;
  43639. }
  43640. $ranges = array();
  43641. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  43642. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  43643. }
  43644. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  43645. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  43646. }
  43647. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  43648. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  43649. }
  43650. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  43651. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  43652. }
  43653. return implode(' || ', $ranges);
  43654. }
  43655. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  43656. }
  43657. public static function getVersion($packageName)
  43658. {
  43659. foreach (self::getInstalled() as $installed) {
  43660. if (!isset($installed['versions'][$packageName])) {
  43661. continue;
  43662. }
  43663. if (!isset($installed['versions'][$packageName]['version'])) {
  43664. return null;
  43665. }
  43666. return $installed['versions'][$packageName]['version'];
  43667. }
  43668. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  43669. }
  43670. public static function getPrettyVersion($packageName)
  43671. {
  43672. foreach (self::getInstalled() as $installed) {
  43673. if (!isset($installed['versions'][$packageName])) {
  43674. continue;
  43675. }
  43676. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  43677. return null;
  43678. }
  43679. return $installed['versions'][$packageName]['pretty_version'];
  43680. }
  43681. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  43682. }
  43683. public static function getReference($packageName)
  43684. {
  43685. foreach (self::getInstalled() as $installed) {
  43686. if (!isset($installed['versions'][$packageName])) {
  43687. continue;
  43688. }
  43689. if (!isset($installed['versions'][$packageName]['reference'])) {
  43690. return null;
  43691. }
  43692. return $installed['versions'][$packageName]['reference'];
  43693. }
  43694. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  43695. }
  43696. public static function getInstallPath($packageName)
  43697. {
  43698. foreach (self::getInstalled() as $installed) {
  43699. if (!isset($installed['versions'][$packageName])) {
  43700. continue;
  43701. }
  43702. return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
  43703. }
  43704. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  43705. }
  43706. public static function getRootPackage()
  43707. {
  43708. $installed = self::getInstalled();
  43709. return $installed[0]['root'];
  43710. }
  43711. public static function getRawData()
  43712. {
  43713. @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);
  43714. if (null === self::$installed) {
  43715. if (substr(__DIR__, -8, 1) !== 'C') {
  43716. self::$installed = include __DIR__ . '/installed.php';
  43717. } else {
  43718. self::$installed = array();
  43719. }
  43720. }
  43721. return self::$installed;
  43722. }
  43723. public static function getAllRawData()
  43724. {
  43725. return self::getInstalled();
  43726. }
  43727. public static function reload($data)
  43728. {
  43729. self::$installed = $data;
  43730. self::$installedByVendor = array();
  43731. self::$installedIsLocalDir = false;
  43732. }
  43733. private static function getSelfDir()
  43734. {
  43735. if (self::$selfDir === null) {
  43736. self::$selfDir = strtr(__DIR__, '\\', '/');
  43737. }
  43738. return self::$selfDir;
  43739. }
  43740. private static function getInstalled()
  43741. {
  43742. if (null === self::$canGetVendors) {
  43743. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  43744. }
  43745. $installed = array();
  43746. $copiedLocalDir = false;
  43747. if (self::$canGetVendors) {
  43748. $selfDir = self::getSelfDir();
  43749. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  43750. $vendorDir = strtr($vendorDir, '\\', '/');
  43751. if (isset(self::$installedByVendor[$vendorDir])) {
  43752. $installed[] = self::$installedByVendor[$vendorDir];
  43753. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  43754. $required = require $vendorDir.'/composer/installed.php';
  43755. self::$installedByVendor[$vendorDir] = $required;
  43756. $installed[] = $required;
  43757. if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
  43758. self::$installed = $required;
  43759. self::$installedIsLocalDir = true;
  43760. }
  43761. }
  43762. if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
  43763. $copiedLocalDir = true;
  43764. }
  43765. }
  43766. }
  43767. if (null === self::$installed) {
  43768. if (substr(__DIR__, -8, 1) !== 'C') {
  43769. $required = require __DIR__ . '/installed.php';
  43770. self::$installed = $required;
  43771. } else {
  43772. self::$installed = array();
  43773. }
  43774. }
  43775. if (self::$installed !== array() && !$copiedLocalDir) {
  43776. $installed[] = self::$installed;
  43777. }
  43778. return $installed;
  43779. }
  43780. }
  43781. <?php
  43782. $vendorDir = dirname(__DIR__);
  43783. $baseDir = dirname($vendorDir);
  43784. return array(
  43785. 'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
  43786. 'CURLStringFile' => $vendorDir . '/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php',
  43787. 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
  43788. 'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
  43789. 'Normalizer' => $vendorDir . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
  43790. 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
  43791. 'ReturnTypeWillChange' => $vendorDir . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php',
  43792. 'Stringable' => $vendorDir . '/marc-mabe/php-enum/stubs/Stringable.php',
  43793. 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
  43794. 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
  43795. );
  43796. <?php
  43797. $vendorDir = dirname(__DIR__);
  43798. $baseDir = dirname($vendorDir);
  43799. return array(
  43800. 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
  43801. '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
  43802. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  43803. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  43804. '8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
  43805. 'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
  43806. '0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
  43807. 'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
  43808. 'ad155f8f1cf0d418fe49e248db8c661b' => $vendorDir . '/react/promise/src/functions_include.php',
  43809. '23c18046f52bef3eea034657bafda50f' => $vendorDir . '/symfony/polyfill-php81/bootstrap.php',
  43810. );
  43811. <?php
  43812. $vendorDir = dirname(__DIR__);
  43813. $baseDir = dirname($vendorDir);
  43814. return array(
  43815. );
  43816. <?php
  43817. $vendorDir = dirname(__DIR__);
  43818. $baseDir = dirname($vendorDir);
  43819. return array(
  43820. 'Symfony\\Polyfill\\Php81\\' => array($vendorDir . '/symfony/polyfill-php81'),
  43821. 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'),
  43822. 'Symfony\\Polyfill\\Php73\\' => array($vendorDir . '/symfony/polyfill-php73'),
  43823. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  43824. 'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'),
  43825. 'Symfony\\Polyfill\\Intl\\Grapheme\\' => array($vendorDir . '/symfony/polyfill-intl-grapheme'),
  43826. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  43827. 'Symfony\\Contracts\\Service\\' => array($vendorDir . '/symfony/service-contracts'),
  43828. 'Symfony\\Component\\String\\' => array($vendorDir . '/symfony/string'),
  43829. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  43830. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  43831. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  43832. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  43833. 'Seld\\Signal\\' => array($vendorDir . '/seld/signal-handler/src'),
  43834. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  43835. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  43836. 'React\\Promise\\' => array($vendorDir . '/react/promise/src'),
  43837. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  43838. 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
  43839. 'MabeEnum\\' => array($vendorDir . '/marc-mabe/php-enum/src'),
  43840. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  43841. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  43842. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  43843. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  43844. 'Composer\\Pcre\\' => array($vendorDir . '/composer/pcre/src'),
  43845. 'Composer\\MetadataMinifier\\' => array($vendorDir . '/composer/metadata-minifier/src'),
  43846. 'Composer\\ClassMapGenerator\\' => array($vendorDir . '/composer/class-map-generator/src'),
  43847. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  43848. 'Composer\\' => array($baseDir . '/src/Composer'),
  43849. );
  43850. <?php
  43851. class ComposerAutoloaderInitComposerPhar1743778606
  43852. {
  43853. private static $loader;
  43854. public static function loadClassLoader($class)
  43855. {
  43856. if ('Composer\Autoload\ClassLoader' === $class) {
  43857. require __DIR__ . '/ClassLoader.php';
  43858. }
  43859. }
  43860. public static function getLoader()
  43861. {
  43862. if (null !== self::$loader) {
  43863. return self::$loader;
  43864. }
  43865. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1743778606', 'loadClassLoader'), true, true);
  43866. self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
  43867. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1743778606', 'loadClassLoader'));
  43868. require __DIR__ . '/autoload_static.php';
  43869. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1743778606::getInitializer($loader));
  43870. $loader->register(true);
  43871. $filesToLoad = \Composer\Autoload\ComposerStaticInitComposerPhar1743778606::$files;
  43872. $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
  43873. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  43874. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  43875. require $file;
  43876. }
  43877. }, null, null);
  43878. foreach ($filesToLoad as $fileIdentifier => $file) {
  43879. $requireFile($fileIdentifier, $file);
  43880. }
  43881. return $loader;
  43882. }
  43883. }
  43884. <?php
  43885. namespace Composer\Autoload;
  43886. class ComposerStaticInitComposerPhar1743778606
  43887. {
  43888. public static $files = array (
  43889. 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
  43890. '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
  43891. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  43892. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  43893. '8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
  43894. 'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
  43895. '0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
  43896. 'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
  43897. 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
  43898. '23c18046f52bef3eea034657bafda50f' => __DIR__ . '/..' . '/symfony/polyfill-php81/bootstrap.php',
  43899. );
  43900. public static $prefixLengthsPsr4 = array (
  43901. 'S' =>
  43902. array (
  43903. 'Symfony\\Polyfill\\Php81\\' => 23,
  43904. 'Symfony\\Polyfill\\Php80\\' => 23,
  43905. 'Symfony\\Polyfill\\Php73\\' => 23,
  43906. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  43907. 'Symfony\\Polyfill\\Intl\\Normalizer\\' => 33,
  43908. 'Symfony\\Polyfill\\Intl\\Grapheme\\' => 31,
  43909. 'Symfony\\Polyfill\\Ctype\\' => 23,
  43910. 'Symfony\\Contracts\\Service\\' => 26,
  43911. 'Symfony\\Component\\String\\' => 25,
  43912. 'Symfony\\Component\\Process\\' => 26,
  43913. 'Symfony\\Component\\Finder\\' => 25,
  43914. 'Symfony\\Component\\Filesystem\\' => 29,
  43915. 'Symfony\\Component\\Console\\' => 26,
  43916. 'Seld\\Signal\\' => 12,
  43917. 'Seld\\PharUtils\\' => 15,
  43918. 'Seld\\JsonLint\\' => 14,
  43919. ),
  43920. 'R' =>
  43921. array (
  43922. 'React\\Promise\\' => 14,
  43923. ),
  43924. 'P' =>
  43925. array (
  43926. 'Psr\\Log\\' => 8,
  43927. 'Psr\\Container\\' => 14,
  43928. ),
  43929. 'M' =>
  43930. array (
  43931. 'MabeEnum\\' => 9,
  43932. ),
  43933. 'J' =>
  43934. array (
  43935. 'JsonSchema\\' => 11,
  43936. ),
  43937. 'C' =>
  43938. array (
  43939. 'Composer\\XdebugHandler\\' => 23,
  43940. 'Composer\\Spdx\\' => 14,
  43941. 'Composer\\Semver\\' => 16,
  43942. 'Composer\\Pcre\\' => 14,
  43943. 'Composer\\MetadataMinifier\\' => 26,
  43944. 'Composer\\ClassMapGenerator\\' => 27,
  43945. 'Composer\\CaBundle\\' => 18,
  43946. 'Composer\\' => 9,
  43947. ),
  43948. );
  43949. public static $prefixDirsPsr4 = array (
  43950. 'Symfony\\Polyfill\\Php81\\' =>
  43951. array (
  43952. 0 => __DIR__ . '/..' . '/symfony/polyfill-php81',
  43953. ),
  43954. 'Symfony\\Polyfill\\Php80\\' =>
  43955. array (
  43956. 0 => __DIR__ . '/..' . '/symfony/polyfill-php80',
  43957. ),
  43958. 'Symfony\\Polyfill\\Php73\\' =>
  43959. array (
  43960. 0 => __DIR__ . '/..' . '/symfony/polyfill-php73',
  43961. ),
  43962. 'Symfony\\Polyfill\\Mbstring\\' =>
  43963. array (
  43964. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  43965. ),
  43966. 'Symfony\\Polyfill\\Intl\\Normalizer\\' =>
  43967. array (
  43968. 0 => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer',
  43969. ),
  43970. 'Symfony\\Polyfill\\Intl\\Grapheme\\' =>
  43971. array (
  43972. 0 => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme',
  43973. ),
  43974. 'Symfony\\Polyfill\\Ctype\\' =>
  43975. array (
  43976. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  43977. ),
  43978. 'Symfony\\Contracts\\Service\\' =>
  43979. array (
  43980. 0 => __DIR__ . '/..' . '/symfony/service-contracts',
  43981. ),
  43982. 'Symfony\\Component\\String\\' =>
  43983. array (
  43984. 0 => __DIR__ . '/..' . '/symfony/string',
  43985. ),
  43986. 'Symfony\\Component\\Process\\' =>
  43987. array (
  43988. 0 => __DIR__ . '/..' . '/symfony/process',
  43989. ),
  43990. 'Symfony\\Component\\Finder\\' =>
  43991. array (
  43992. 0 => __DIR__ . '/..' . '/symfony/finder',
  43993. ),
  43994. 'Symfony\\Component\\Filesystem\\' =>
  43995. array (
  43996. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  43997. ),
  43998. 'Symfony\\Component\\Console\\' =>
  43999. array (
  44000. 0 => __DIR__ . '/..' . '/symfony/console',
  44001. ),
  44002. 'Seld\\Signal\\' =>
  44003. array (
  44004. 0 => __DIR__ . '/..' . '/seld/signal-handler/src',
  44005. ),
  44006. 'Seld\\PharUtils\\' =>
  44007. array (
  44008. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  44009. ),
  44010. 'Seld\\JsonLint\\' =>
  44011. array (
  44012. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  44013. ),
  44014. 'React\\Promise\\' =>
  44015. array (
  44016. 0 => __DIR__ . '/..' . '/react/promise/src',
  44017. ),
  44018. 'Psr\\Log\\' =>
  44019. array (
  44020. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  44021. ),
  44022. 'Psr\\Container\\' =>
  44023. array (
  44024. 0 => __DIR__ . '/..' . '/psr/container/src',
  44025. ),
  44026. 'MabeEnum\\' =>
  44027. array (
  44028. 0 => __DIR__ . '/..' . '/marc-mabe/php-enum/src',
  44029. ),
  44030. 'JsonSchema\\' =>
  44031. array (
  44032. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  44033. ),
  44034. 'Composer\\XdebugHandler\\' =>
  44035. array (
  44036. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  44037. ),
  44038. 'Composer\\Spdx\\' =>
  44039. array (
  44040. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  44041. ),
  44042. 'Composer\\Semver\\' =>
  44043. array (
  44044. 0 => __DIR__ . '/..' . '/composer/semver/src',
  44045. ),
  44046. 'Composer\\Pcre\\' =>
  44047. array (
  44048. 0 => __DIR__ . '/..' . '/composer/pcre/src',
  44049. ),
  44050. 'Composer\\MetadataMinifier\\' =>
  44051. array (
  44052. 0 => __DIR__ . '/..' . '/composer/metadata-minifier/src',
  44053. ),
  44054. 'Composer\\ClassMapGenerator\\' =>
  44055. array (
  44056. 0 => __DIR__ . '/..' . '/composer/class-map-generator/src',
  44057. ),
  44058. 'Composer\\CaBundle\\' =>
  44059. array (
  44060. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  44061. ),
  44062. 'Composer\\' =>
  44063. array (
  44064. 0 => __DIR__ . '/../..' . '/src/Composer',
  44065. ),
  44066. );
  44067. public static $classMap = array (
  44068. 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
  44069. 'CURLStringFile' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php',
  44070. 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
  44071. 'JsonException' => __DIR__ . '/..' . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
  44072. 'Normalizer' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php',
  44073. 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php',
  44074. 'ReturnTypeWillChange' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php',
  44075. 'Stringable' => __DIR__ . '/..' . '/marc-mabe/php-enum/stubs/Stringable.php',
  44076. 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php',
  44077. 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php',
  44078. );
  44079. public static function getInitializer(ClassLoader $loader)
  44080. {
  44081. return \Closure::bind(function () use ($loader) {
  44082. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1743778606::$prefixLengthsPsr4;
  44083. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1743778606::$prefixDirsPsr4;
  44084. $loader->classMap = ComposerStaticInitComposerPhar1743778606::$classMap;
  44085. }, null, ClassLoader::class);
  44086. }
  44087. }
  44088. Copyright (C) 2016 Composer
  44089. Permission is hereby granted, free of charge, to any person obtaining a copy of
  44090. this software and associated documentation files (the "Software"), to deal in
  44091. the Software without restriction, including without limitation the rights to
  44092. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  44093. of the Software, and to permit persons to whom the Software is furnished to do
  44094. so, subject to the following conditions:
  44095. The above copyright notice and this permission notice shall be included in all
  44096. copies or substantial portions of the Software.
  44097. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  44098. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  44099. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  44100. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  44101. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  44102. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  44103. SOFTWARE.
  44104. ##
  44105. ## Bundle of CA Root Certificates
  44106. ##
  44107. ## Certificate data from Mozilla as of: Tue Feb 25 04:12:03 2025 GMT
  44108. ##
  44109. ## Find updated versions here: https://curl.se/docs/caextract.html
  44110. ##
  44111. ## This is a bundle of X.509 certificates of public Certificate Authorities
  44112. ## (CA). These were automatically extracted from Mozilla's root certificates
  44113. ## file (certdata.txt). This file can be found in the mozilla source tree:
  44114. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  44115. ##
  44116. ## It contains the certificates in PEM format and therefore
  44117. ## can be directly used with curl / libcurl / php_curl, or with
  44118. ## an Apache+mod_ssl webserver for SSL client authentication.
  44119. ## Just configure this file as the SSLCACertificateFile.
  44120. ##
  44121. ## Conversion done with mk-ca-bundle.pl version 1.29.
  44122. ## SHA256: 620fd89c02acb0019f1899dab7907db5d20735904f5a9a0d3a8771a5857ac482
  44123. ##
  44124. GlobalSign Root CA
  44125. ==================
  44126. -----BEGIN CERTIFICATE-----
  44127. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  44128. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  44129. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  44130. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  44131. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  44132. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  44133. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  44134. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  44135. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  44136. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  44137. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  44138. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  44139. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  44140. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  44141. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  44142. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  44143. -----END CERTIFICATE-----
  44144. Entrust.net Premium 2048 Secure Server CA
  44145. =========================================
  44146. -----BEGIN CERTIFICATE-----
  44147. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  44148. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  44149. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  44150. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  44151. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  44152. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  44153. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  44154. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  44155. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  44156. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  44157. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  44158. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  44159. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  44160. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  44161. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  44162. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  44163. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  44164. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  44165. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  44166. -----END CERTIFICATE-----
  44167. Baltimore CyberTrust Root
  44168. =========================
  44169. -----BEGIN CERTIFICATE-----
  44170. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  44171. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  44172. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  44173. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  44174. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  44175. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  44176. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  44177. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  44178. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  44179. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  44180. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  44181. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  44182. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  44183. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  44184. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  44185. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  44186. -----END CERTIFICATE-----
  44187. Entrust Root Certification Authority
  44188. ====================================
  44189. -----BEGIN CERTIFICATE-----
  44190. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  44191. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  44192. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  44193. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  44194. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  44195. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  44196. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  44197. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  44198. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  44199. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  44200. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  44201. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  44202. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  44203. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  44204. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  44205. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  44206. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  44207. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  44208. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  44209. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  44210. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  44211. -----END CERTIFICATE-----
  44212. Comodo AAA Services root
  44213. ========================
  44214. -----BEGIN CERTIFICATE-----
  44215. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  44216. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  44217. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  44218. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  44219. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  44220. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  44221. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  44222. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  44223. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  44224. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  44225. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  44226. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  44227. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  44228. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  44229. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  44230. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  44231. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  44232. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  44233. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  44234. -----END CERTIFICATE-----
  44235. QuoVadis Root CA 2
  44236. ==================
  44237. -----BEGIN CERTIFICATE-----
  44238. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  44239. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  44240. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  44241. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  44242. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  44243. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  44244. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  44245. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  44246. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  44247. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  44248. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  44249. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  44250. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  44251. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  44252. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  44253. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  44254. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  44255. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  44256. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  44257. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  44258. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  44259. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  44260. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  44261. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  44262. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  44263. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  44264. -----END CERTIFICATE-----
  44265. QuoVadis Root CA 3
  44266. ==================
  44267. -----BEGIN CERTIFICATE-----
  44268. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  44269. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  44270. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  44271. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  44272. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  44273. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  44274. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  44275. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  44276. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  44277. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  44278. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  44279. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  44280. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  44281. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  44282. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  44283. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  44284. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  44285. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  44286. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  44287. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  44288. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  44289. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  44290. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  44291. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  44292. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  44293. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  44294. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  44295. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  44296. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  44297. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  44298. -----END CERTIFICATE-----
  44299. XRamp Global CA Root
  44300. ====================
  44301. -----BEGIN CERTIFICATE-----
  44302. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  44303. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  44304. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  44305. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  44306. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  44307. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  44308. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  44309. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  44310. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  44311. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  44312. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  44313. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  44314. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  44315. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  44316. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  44317. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  44318. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  44319. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  44320. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  44321. -----END CERTIFICATE-----
  44322. Go Daddy Class 2 CA
  44323. ===================
  44324. -----BEGIN CERTIFICATE-----
  44325. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  44326. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  44327. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  44328. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  44329. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  44330. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  44331. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  44332. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  44333. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  44334. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  44335. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  44336. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  44337. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  44338. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  44339. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  44340. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  44341. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  44342. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  44343. vZ8=
  44344. -----END CERTIFICATE-----
  44345. Starfield Class 2 CA
  44346. ====================
  44347. -----BEGIN CERTIFICATE-----
  44348. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  44349. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  44350. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  44351. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  44352. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  44353. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  44354. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  44355. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  44356. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  44357. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  44358. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  44359. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  44360. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  44361. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  44362. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  44363. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  44364. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  44365. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  44366. QBFGmh95DmK/D5fs4C8fF5Q=
  44367. -----END CERTIFICATE-----
  44368. DigiCert Assured ID Root CA
  44369. ===========================
  44370. -----BEGIN CERTIFICATE-----
  44371. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  44372. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  44373. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  44374. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  44375. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  44376. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  44377. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  44378. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  44379. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  44380. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  44381. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  44382. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  44383. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  44384. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  44385. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  44386. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  44387. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  44388. -----END CERTIFICATE-----
  44389. DigiCert Global Root CA
  44390. =======================
  44391. -----BEGIN CERTIFICATE-----
  44392. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  44393. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  44394. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  44395. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  44396. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  44397. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  44398. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  44399. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  44400. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  44401. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  44402. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  44403. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  44404. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  44405. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  44406. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  44407. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  44408. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  44409. -----END CERTIFICATE-----
  44410. DigiCert High Assurance EV Root CA
  44411. ==================================
  44412. -----BEGIN CERTIFICATE-----
  44413. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  44414. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  44415. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  44416. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  44417. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  44418. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  44419. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  44420. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  44421. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  44422. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  44423. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  44424. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  44425. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  44426. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  44427. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  44428. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  44429. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  44430. -----END CERTIFICATE-----
  44431. SwissSign Gold CA - G2
  44432. ======================
  44433. -----BEGIN CERTIFICATE-----
  44434. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  44435. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  44436. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  44437. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  44438. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  44439. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  44440. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  44441. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  44442. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  44443. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  44444. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  44445. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  44446. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  44447. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  44448. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  44449. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  44450. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  44451. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  44452. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  44453. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  44454. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  44455. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  44456. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  44457. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  44458. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  44459. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  44460. -----END CERTIFICATE-----
  44461. SecureTrust CA
  44462. ==============
  44463. -----BEGIN CERTIFICATE-----
  44464. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  44465. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  44466. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  44467. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  44468. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  44469. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  44470. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  44471. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  44472. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  44473. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  44474. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  44475. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  44476. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  44477. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  44478. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  44479. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  44480. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  44481. -----END CERTIFICATE-----
  44482. Secure Global CA
  44483. ================
  44484. -----BEGIN CERTIFICATE-----
  44485. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  44486. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  44487. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  44488. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  44489. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  44490. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  44491. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  44492. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  44493. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  44494. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  44495. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  44496. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  44497. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  44498. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  44499. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  44500. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  44501. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  44502. -----END CERTIFICATE-----
  44503. COMODO Certification Authority
  44504. ==============================
  44505. -----BEGIN CERTIFICATE-----
  44506. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  44507. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  44508. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  44509. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  44510. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  44511. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  44512. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  44513. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  44514. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  44515. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  44516. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  44517. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  44518. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  44519. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  44520. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  44521. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  44522. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  44523. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  44524. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  44525. -----END CERTIFICATE-----
  44526. COMODO ECC Certification Authority
  44527. ==================================
  44528. -----BEGIN CERTIFICATE-----
  44529. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  44530. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  44531. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  44532. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  44533. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  44534. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  44535. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  44536. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  44537. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  44538. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  44539. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  44540. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  44541. -----END CERTIFICATE-----
  44542. Certigna
  44543. ========
  44544. -----BEGIN CERTIFICATE-----
  44545. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  44546. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  44547. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  44548. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  44549. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  44550. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  44551. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  44552. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  44553. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  44554. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  44555. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  44556. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  44557. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  44558. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  44559. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  44560. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  44561. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  44562. -----END CERTIFICATE-----
  44563. ePKI Root Certification Authority
  44564. =================================
  44565. -----BEGIN CERTIFICATE-----
  44566. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  44567. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  44568. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  44569. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  44570. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  44571. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  44572. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  44573. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  44574. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  44575. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  44576. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  44577. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  44578. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  44579. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  44580. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  44581. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  44582. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  44583. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  44584. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  44585. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  44586. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  44587. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  44588. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  44589. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  44590. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  44591. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  44592. -----END CERTIFICATE-----
  44593. certSIGN ROOT CA
  44594. ================
  44595. -----BEGIN CERTIFICATE-----
  44596. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  44597. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  44598. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  44599. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  44600. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  44601. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  44602. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  44603. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  44604. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  44605. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  44606. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  44607. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  44608. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  44609. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  44610. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  44611. -----END CERTIFICATE-----
  44612. NetLock Arany (Class Gold) Főtanúsítvány
  44613. ========================================
  44614. -----BEGIN CERTIFICATE-----
  44615. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  44616. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  44617. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  44618. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  44619. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  44620. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  44621. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  44622. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  44623. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  44624. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  44625. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  44626. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  44627. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  44628. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  44629. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  44630. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  44631. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  44632. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  44633. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  44634. -----END CERTIFICATE-----
  44635. Microsec e-Szigno Root CA 2009
  44636. ==============================
  44637. -----BEGIN CERTIFICATE-----
  44638. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  44639. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  44640. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  44641. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  44642. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  44643. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  44644. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  44645. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  44646. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  44647. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  44648. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  44649. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  44650. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  44651. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  44652. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  44653. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  44654. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  44655. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  44656. LXpUq3DDfSJlgnCW
  44657. -----END CERTIFICATE-----
  44658. GlobalSign Root CA - R3
  44659. =======================
  44660. -----BEGIN CERTIFICATE-----
  44661. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  44662. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  44663. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  44664. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  44665. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  44666. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  44667. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  44668. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  44669. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  44670. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  44671. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  44672. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  44673. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  44674. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  44675. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  44676. kpeDMdmztcpHWD9f
  44677. -----END CERTIFICATE-----
  44678. Izenpe.com
  44679. ==========
  44680. -----BEGIN CERTIFICATE-----
  44681. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  44682. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  44683. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  44684. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  44685. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  44686. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  44687. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  44688. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  44689. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  44690. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  44691. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  44692. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  44693. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  44694. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  44695. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  44696. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  44697. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  44698. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  44699. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  44700. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  44701. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  44702. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  44703. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  44704. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  44705. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  44706. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  44707. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  44708. -----END CERTIFICATE-----
  44709. Go Daddy Root Certificate Authority - G2
  44710. ========================================
  44711. -----BEGIN CERTIFICATE-----
  44712. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  44713. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  44714. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  44715. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  44716. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  44717. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  44718. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  44719. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  44720. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  44721. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  44722. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  44723. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  44724. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  44725. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  44726. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  44727. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  44728. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  44729. -----END CERTIFICATE-----
  44730. Starfield Root Certificate Authority - G2
  44731. =========================================
  44732. -----BEGIN CERTIFICATE-----
  44733. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  44734. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  44735. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  44736. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  44737. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  44738. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  44739. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  44740. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  44741. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  44742. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  44743. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  44744. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  44745. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  44746. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  44747. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  44748. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  44749. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  44750. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  44751. -----END CERTIFICATE-----
  44752. Starfield Services Root Certificate Authority - G2
  44753. ==================================================
  44754. -----BEGIN CERTIFICATE-----
  44755. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  44756. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  44757. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  44758. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  44759. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  44760. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  44761. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  44762. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  44763. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  44764. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  44765. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  44766. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  44767. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  44768. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  44769. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  44770. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  44771. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  44772. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  44773. -----END CERTIFICATE-----
  44774. AffirmTrust Commercial
  44775. ======================
  44776. -----BEGIN CERTIFICATE-----
  44777. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  44778. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  44779. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  44780. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  44781. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  44782. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  44783. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  44784. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  44785. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  44786. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  44787. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  44788. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  44789. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  44790. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  44791. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  44792. -----END CERTIFICATE-----
  44793. AffirmTrust Networking
  44794. ======================
  44795. -----BEGIN CERTIFICATE-----
  44796. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  44797. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  44798. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  44799. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  44800. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  44801. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  44802. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  44803. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  44804. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  44805. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  44806. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  44807. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  44808. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  44809. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  44810. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  44811. -----END CERTIFICATE-----
  44812. AffirmTrust Premium
  44813. ===================
  44814. -----BEGIN CERTIFICATE-----
  44815. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  44816. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  44817. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  44818. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  44819. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  44820. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  44821. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  44822. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  44823. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  44824. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  44825. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  44826. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  44827. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  44828. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  44829. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  44830. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  44831. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  44832. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  44833. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  44834. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  44835. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  44836. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  44837. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  44838. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  44839. -----END CERTIFICATE-----
  44840. AffirmTrust Premium ECC
  44841. =======================
  44842. -----BEGIN CERTIFICATE-----
  44843. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  44844. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  44845. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  44846. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  44847. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  44848. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  44849. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  44850. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  44851. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  44852. eQ==
  44853. -----END CERTIFICATE-----
  44854. Certum Trusted Network CA
  44855. =========================
  44856. -----BEGIN CERTIFICATE-----
  44857. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  44858. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  44859. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  44860. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  44861. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  44862. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  44863. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  44864. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  44865. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  44866. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  44867. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  44868. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  44869. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  44870. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  44871. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  44872. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  44873. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  44874. -----END CERTIFICATE-----
  44875. TWCA Root Certification Authority
  44876. =================================
  44877. -----BEGIN CERTIFICATE-----
  44878. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  44879. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  44880. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  44881. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  44882. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  44883. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  44884. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  44885. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  44886. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  44887. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  44888. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  44889. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  44890. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  44891. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  44892. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  44893. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  44894. -----END CERTIFICATE-----
  44895. Security Communication RootCA2
  44896. ==============================
  44897. -----BEGIN CERTIFICATE-----
  44898. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  44899. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  44900. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  44901. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  44902. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  44903. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  44904. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  44905. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  44906. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  44907. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  44908. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  44909. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  44910. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  44911. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  44912. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  44913. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  44914. -----END CERTIFICATE-----
  44915. Actalis Authentication Root CA
  44916. ==============================
  44917. -----BEGIN CERTIFICATE-----
  44918. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  44919. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  44920. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  44921. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  44922. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  44923. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  44924. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  44925. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  44926. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  44927. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  44928. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  44929. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  44930. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  44931. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  44932. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  44933. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  44934. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  44935. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  44936. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  44937. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  44938. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  44939. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  44940. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  44941. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  44942. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  44943. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  44944. -----END CERTIFICATE-----
  44945. Buypass Class 2 Root CA
  44946. =======================
  44947. -----BEGIN CERTIFICATE-----
  44948. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  44949. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  44950. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  44951. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  44952. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  44953. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  44954. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  44955. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  44956. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  44957. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  44958. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  44959. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  44960. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  44961. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  44962. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  44963. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  44964. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  44965. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  44966. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  44967. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  44968. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  44969. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  44970. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  44971. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  44972. rJgWVqA=
  44973. -----END CERTIFICATE-----
  44974. Buypass Class 3 Root CA
  44975. =======================
  44976. -----BEGIN CERTIFICATE-----
  44977. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  44978. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  44979. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  44980. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  44981. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  44982. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  44983. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  44984. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  44985. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  44986. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  44987. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  44988. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  44989. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  44990. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  44991. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  44992. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  44993. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  44994. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  44995. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  44996. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  44997. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  44998. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  44999. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  45000. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  45001. Cp/HuZc=
  45002. -----END CERTIFICATE-----
  45003. T-TeleSec GlobalRoot Class 3
  45004. ============================
  45005. -----BEGIN CERTIFICATE-----
  45006. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  45007. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  45008. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  45009. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  45010. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  45011. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  45012. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  45013. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  45014. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  45015. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  45016. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  45017. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  45018. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  45019. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  45020. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  45021. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  45022. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  45023. -----END CERTIFICATE-----
  45024. D-TRUST Root Class 3 CA 2 2009
  45025. ==============================
  45026. -----BEGIN CERTIFICATE-----
  45027. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  45028. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  45029. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  45030. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  45031. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  45032. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  45033. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  45034. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  45035. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  45036. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  45037. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  45038. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  45039. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  45040. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  45041. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  45042. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  45043. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  45044. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  45045. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  45046. -----END CERTIFICATE-----
  45047. D-TRUST Root Class 3 CA 2 EV 2009
  45048. =================================
  45049. -----BEGIN CERTIFICATE-----
  45050. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  45051. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  45052. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  45053. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  45054. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  45055. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  45056. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  45057. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  45058. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  45059. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  45060. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  45061. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  45062. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  45063. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  45064. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  45065. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  45066. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  45067. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  45068. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  45069. w9y4AyHqnxbxLFS1
  45070. -----END CERTIFICATE-----
  45071. CA Disig Root R2
  45072. ================
  45073. -----BEGIN CERTIFICATE-----
  45074. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  45075. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  45076. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  45077. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  45078. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  45079. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  45080. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  45081. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  45082. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  45083. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  45084. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  45085. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  45086. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  45087. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  45088. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  45089. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  45090. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  45091. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  45092. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  45093. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  45094. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  45095. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  45096. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  45097. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  45098. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  45099. -----END CERTIFICATE-----
  45100. ACCVRAIZ1
  45101. =========
  45102. -----BEGIN CERTIFICATE-----
  45103. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  45104. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  45105. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  45106. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  45107. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  45108. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  45109. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  45110. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  45111. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  45112. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  45113. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  45114. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  45115. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  45116. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  45117. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  45118. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  45119. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  45120. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  45121. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  45122. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  45123. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  45124. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  45125. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  45126. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  45127. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  45128. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  45129. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  45130. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  45131. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  45132. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  45133. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  45134. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  45135. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  45136. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  45137. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  45138. EfbRD0tVNEYqi4Y7
  45139. -----END CERTIFICATE-----
  45140. TWCA Global Root CA
  45141. ===================
  45142. -----BEGIN CERTIFICATE-----
  45143. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  45144. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  45145. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  45146. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  45147. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  45148. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  45149. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  45150. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  45151. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  45152. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  45153. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  45154. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  45155. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  45156. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  45157. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  45158. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  45159. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  45160. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  45161. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  45162. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  45163. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  45164. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  45165. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  45166. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  45167. -----END CERTIFICATE-----
  45168. TeliaSonera Root CA v1
  45169. ======================
  45170. -----BEGIN CERTIFICATE-----
  45171. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  45172. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  45173. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  45174. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  45175. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  45176. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  45177. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  45178. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  45179. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  45180. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  45181. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  45182. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  45183. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  45184. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  45185. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  45186. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  45187. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  45188. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  45189. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  45190. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  45191. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  45192. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  45193. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  45194. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  45195. -----END CERTIFICATE-----
  45196. T-TeleSec GlobalRoot Class 2
  45197. ============================
  45198. -----BEGIN CERTIFICATE-----
  45199. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  45200. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  45201. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  45202. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  45203. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  45204. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  45205. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  45206. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  45207. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  45208. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  45209. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  45210. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  45211. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  45212. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  45213. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  45214. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  45215. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  45216. -----END CERTIFICATE-----
  45217. Atos TrustedRoot 2011
  45218. =====================
  45219. -----BEGIN CERTIFICATE-----
  45220. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  45221. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  45222. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  45223. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  45224. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  45225. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  45226. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  45227. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  45228. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  45229. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  45230. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  45231. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  45232. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  45233. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  45234. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  45235. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  45236. -----END CERTIFICATE-----
  45237. QuoVadis Root CA 1 G3
  45238. =====================
  45239. -----BEGIN CERTIFICATE-----
  45240. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  45241. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  45242. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  45243. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  45244. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  45245. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  45246. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  45247. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  45248. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  45249. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  45250. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  45251. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  45252. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  45253. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  45254. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  45255. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  45256. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  45257. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  45258. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  45259. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  45260. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  45261. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  45262. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  45263. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  45264. hMJKzRwuJIczYOXD
  45265. -----END CERTIFICATE-----
  45266. QuoVadis Root CA 2 G3
  45267. =====================
  45268. -----BEGIN CERTIFICATE-----
  45269. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  45270. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  45271. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  45272. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  45273. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  45274. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  45275. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  45276. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  45277. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  45278. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  45279. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  45280. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  45281. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  45282. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  45283. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  45284. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  45285. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  45286. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  45287. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  45288. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  45289. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  45290. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  45291. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  45292. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  45293. O3jtZsSOeWmD3n+M
  45294. -----END CERTIFICATE-----
  45295. QuoVadis Root CA 3 G3
  45296. =====================
  45297. -----BEGIN CERTIFICATE-----
  45298. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  45299. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  45300. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  45301. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  45302. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  45303. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  45304. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  45305. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  45306. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  45307. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  45308. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  45309. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  45310. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  45311. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  45312. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  45313. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  45314. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  45315. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  45316. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  45317. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  45318. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  45319. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  45320. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  45321. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  45322. PpxxVJkES/1Y+Zj0
  45323. -----END CERTIFICATE-----
  45324. DigiCert Assured ID Root G2
  45325. ===========================
  45326. -----BEGIN CERTIFICATE-----
  45327. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  45328. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  45329. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  45330. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  45331. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  45332. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  45333. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  45334. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  45335. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  45336. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  45337. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  45338. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  45339. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  45340. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  45341. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  45342. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  45343. IhNzbM8m9Yop5w==
  45344. -----END CERTIFICATE-----
  45345. DigiCert Assured ID Root G3
  45346. ===========================
  45347. -----BEGIN CERTIFICATE-----
  45348. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  45349. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  45350. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  45351. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  45352. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  45353. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  45354. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  45355. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  45356. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  45357. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  45358. 1vUhZscv6pZjamVFkpUBtA==
  45359. -----END CERTIFICATE-----
  45360. DigiCert Global Root G2
  45361. =======================
  45362. -----BEGIN CERTIFICATE-----
  45363. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  45364. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  45365. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  45366. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  45367. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  45368. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  45369. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  45370. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  45371. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  45372. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  45373. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  45374. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  45375. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  45376. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  45377. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  45378. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  45379. MrY=
  45380. -----END CERTIFICATE-----
  45381. DigiCert Global Root G3
  45382. =======================
  45383. -----BEGIN CERTIFICATE-----
  45384. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  45385. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  45386. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  45387. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  45388. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  45389. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  45390. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  45391. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  45392. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  45393. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  45394. VOKa5Vt8sycX
  45395. -----END CERTIFICATE-----
  45396. DigiCert Trusted Root G4
  45397. ========================
  45398. -----BEGIN CERTIFICATE-----
  45399. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  45400. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  45401. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  45402. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  45403. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  45404. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  45405. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  45406. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  45407. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  45408. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  45409. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  45410. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  45411. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  45412. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  45413. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  45414. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  45415. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  45416. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  45417. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  45418. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  45419. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  45420. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  45421. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  45422. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  45423. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  45424. 82Z+
  45425. -----END CERTIFICATE-----
  45426. COMODO RSA Certification Authority
  45427. ==================================
  45428. -----BEGIN CERTIFICATE-----
  45429. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  45430. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  45431. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  45432. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  45433. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  45434. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  45435. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  45436. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  45437. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  45438. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  45439. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  45440. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  45441. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  45442. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  45443. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  45444. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  45445. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  45446. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  45447. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  45448. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  45449. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  45450. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  45451. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  45452. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  45453. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  45454. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  45455. LaZRfyHBNVOFBkpdn627G190
  45456. -----END CERTIFICATE-----
  45457. USERTrust RSA Certification Authority
  45458. =====================================
  45459. -----BEGIN CERTIFICATE-----
  45460. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  45461. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  45462. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  45463. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  45464. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  45465. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  45466. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  45467. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  45468. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  45469. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  45470. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  45471. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  45472. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  45473. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  45474. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  45475. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  45476. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  45477. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  45478. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  45479. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  45480. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  45481. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  45482. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  45483. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  45484. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  45485. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  45486. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  45487. -----END CERTIFICATE-----
  45488. USERTrust ECC Certification Authority
  45489. =====================================
  45490. -----BEGIN CERTIFICATE-----
  45491. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  45492. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  45493. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  45494. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  45495. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  45496. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  45497. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  45498. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  45499. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  45500. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  45501. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  45502. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  45503. -----END CERTIFICATE-----
  45504. GlobalSign ECC Root CA - R5
  45505. ===========================
  45506. -----BEGIN CERTIFICATE-----
  45507. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  45508. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  45509. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  45510. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  45511. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  45512. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  45513. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  45514. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  45515. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  45516. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  45517. -----END CERTIFICATE-----
  45518. IdenTrust Commercial Root CA 1
  45519. ==============================
  45520. -----BEGIN CERTIFICATE-----
  45521. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  45522. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  45523. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  45524. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  45525. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  45526. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  45527. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  45528. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  45529. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  45530. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  45531. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  45532. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  45533. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  45534. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  45535. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  45536. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  45537. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  45538. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  45539. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  45540. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  45541. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  45542. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  45543. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  45544. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  45545. cGzM7vRX+Bi6hG6H
  45546. -----END CERTIFICATE-----
  45547. IdenTrust Public Sector Root CA 1
  45548. =================================
  45549. -----BEGIN CERTIFICATE-----
  45550. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  45551. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  45552. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  45553. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  45554. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  45555. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  45556. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  45557. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  45558. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  45559. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  45560. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  45561. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  45562. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  45563. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  45564. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  45565. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  45566. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  45567. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  45568. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  45569. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  45570. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  45571. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  45572. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  45573. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  45574. 3Wl9af0AVqW3rLatt8o+Ae+c
  45575. -----END CERTIFICATE-----
  45576. Entrust Root Certification Authority - G2
  45577. =========================================
  45578. -----BEGIN CERTIFICATE-----
  45579. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  45580. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  45581. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  45582. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  45583. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  45584. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  45585. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  45586. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  45587. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  45588. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  45589. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  45590. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  45591. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  45592. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  45593. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  45594. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  45595. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  45596. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  45597. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  45598. e4pIb4tF9g==
  45599. -----END CERTIFICATE-----
  45600. Entrust Root Certification Authority - EC1
  45601. ==========================================
  45602. -----BEGIN CERTIFICATE-----
  45603. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  45604. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  45605. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  45606. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  45607. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  45608. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  45609. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  45610. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  45611. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  45612. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  45613. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  45614. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  45615. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  45616. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  45617. -----END CERTIFICATE-----
  45618. CFCA EV ROOT
  45619. ============
  45620. -----BEGIN CERTIFICATE-----
  45621. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  45622. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  45623. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  45624. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  45625. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  45626. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  45627. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  45628. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  45629. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  45630. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  45631. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  45632. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  45633. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  45634. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  45635. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  45636. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  45637. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  45638. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  45639. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  45640. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  45641. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  45642. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  45643. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  45644. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  45645. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  45646. -----END CERTIFICATE-----
  45647. OISTE WISeKey Global Root GB CA
  45648. ===============================
  45649. -----BEGIN CERTIFICATE-----
  45650. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  45651. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  45652. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  45653. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  45654. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  45655. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  45656. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  45657. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  45658. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  45659. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  45660. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  45661. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  45662. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  45663. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  45664. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  45665. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  45666. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  45667. -----END CERTIFICATE-----
  45668. SZAFIR ROOT CA2
  45669. ===============
  45670. -----BEGIN CERTIFICATE-----
  45671. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  45672. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  45673. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  45674. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  45675. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  45676. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  45677. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  45678. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  45679. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  45680. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  45681. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  45682. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  45683. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  45684. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  45685. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  45686. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  45687. -----END CERTIFICATE-----
  45688. Certum Trusted Network CA 2
  45689. ===========================
  45690. -----BEGIN CERTIFICATE-----
  45691. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  45692. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  45693. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  45694. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  45695. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  45696. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  45697. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  45698. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  45699. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  45700. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  45701. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  45702. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  45703. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  45704. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  45705. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  45706. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  45707. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  45708. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  45709. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  45710. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  45711. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  45712. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  45713. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  45714. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  45715. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  45716. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  45717. zAYspsbiDrW5viSP
  45718. -----END CERTIFICATE-----
  45719. Hellenic Academic and Research Institutions RootCA 2015
  45720. =======================================================
  45721. -----BEGIN CERTIFICATE-----
  45722. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  45723. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  45724. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  45725. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  45726. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  45727. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  45728. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  45729. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  45730. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  45731. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  45732. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  45733. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  45734. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  45735. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  45736. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  45737. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  45738. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  45739. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  45740. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  45741. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  45742. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  45743. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  45744. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  45745. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  45746. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  45747. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  45748. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  45749. p/UsQu0yrbYhnr68
  45750. -----END CERTIFICATE-----
  45751. Hellenic Academic and Research Institutions ECC RootCA 2015
  45752. ===========================================================
  45753. -----BEGIN CERTIFICATE-----
  45754. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  45755. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  45756. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  45757. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  45758. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  45759. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  45760. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  45761. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  45762. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  45763. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  45764. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  45765. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  45766. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  45767. -----END CERTIFICATE-----
  45768. ISRG Root X1
  45769. ============
  45770. -----BEGIN CERTIFICATE-----
  45771. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  45772. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  45773. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  45774. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  45775. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  45776. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  45777. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  45778. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  45779. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  45780. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  45781. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  45782. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  45783. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  45784. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  45785. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  45786. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  45787. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  45788. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  45789. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  45790. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  45791. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  45792. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  45793. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  45794. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  45795. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  45796. -----END CERTIFICATE-----
  45797. AC RAIZ FNMT-RCM
  45798. ================
  45799. -----BEGIN CERTIFICATE-----
  45800. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  45801. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  45802. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  45803. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  45804. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  45805. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  45806. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  45807. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  45808. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  45809. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  45810. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  45811. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  45812. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  45813. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  45814. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  45815. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  45816. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  45817. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  45818. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  45819. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  45820. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  45821. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  45822. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  45823. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  45824. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  45825. -----END CERTIFICATE-----
  45826. Amazon Root CA 1
  45827. ================
  45828. -----BEGIN CERTIFICATE-----
  45829. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  45830. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  45831. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  45832. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  45833. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  45834. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  45835. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  45836. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  45837. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  45838. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  45839. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  45840. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  45841. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  45842. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  45843. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  45844. -----END CERTIFICATE-----
  45845. Amazon Root CA 2
  45846. ================
  45847. -----BEGIN CERTIFICATE-----
  45848. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  45849. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  45850. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  45851. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  45852. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  45853. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  45854. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  45855. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  45856. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  45857. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  45858. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  45859. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  45860. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  45861. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  45862. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  45863. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  45864. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  45865. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  45866. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  45867. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  45868. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  45869. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  45870. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  45871. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  45872. -----END CERTIFICATE-----
  45873. Amazon Root CA 3
  45874. ================
  45875. -----BEGIN CERTIFICATE-----
  45876. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  45877. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  45878. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  45879. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  45880. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  45881. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  45882. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  45883. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  45884. -----END CERTIFICATE-----
  45885. Amazon Root CA 4
  45886. ================
  45887. -----BEGIN CERTIFICATE-----
  45888. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  45889. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  45890. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  45891. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  45892. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  45893. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  45894. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  45895. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  45896. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  45897. -----END CERTIFICATE-----
  45898. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  45899. =============================================
  45900. -----BEGIN CERTIFICATE-----
  45901. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  45902. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  45903. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  45904. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  45905. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  45906. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  45907. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  45908. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  45909. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  45910. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  45911. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  45912. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  45913. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  45914. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  45915. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  45916. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  45917. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  45918. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  45919. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  45920. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  45921. -----END CERTIFICATE-----
  45922. GDCA TrustAUTH R5 ROOT
  45923. ======================
  45924. -----BEGIN CERTIFICATE-----
  45925. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  45926. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  45927. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  45928. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  45929. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  45930. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  45931. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  45932. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  45933. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  45934. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  45935. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  45936. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  45937. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  45938. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  45939. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  45940. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  45941. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  45942. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  45943. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  45944. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  45945. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  45946. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  45947. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  45948. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  45949. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  45950. -----END CERTIFICATE-----
  45951. SSL.com Root Certification Authority RSA
  45952. ========================================
  45953. -----BEGIN CERTIFICATE-----
  45954. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  45955. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  45956. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  45957. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  45958. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  45959. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  45960. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  45961. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  45962. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  45963. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  45964. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  45965. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  45966. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  45967. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  45968. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  45969. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  45970. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  45971. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  45972. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  45973. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  45974. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  45975. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  45976. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  45977. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  45978. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  45979. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  45980. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  45981. -----END CERTIFICATE-----
  45982. SSL.com Root Certification Authority ECC
  45983. ========================================
  45984. -----BEGIN CERTIFICATE-----
  45985. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  45986. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  45987. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  45988. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  45989. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  45990. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  45991. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  45992. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  45993. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  45994. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  45995. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  45996. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  45997. -----END CERTIFICATE-----
  45998. SSL.com EV Root Certification Authority RSA R2
  45999. ==============================================
  46000. -----BEGIN CERTIFICATE-----
  46001. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  46002. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  46003. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  46004. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  46005. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  46006. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  46007. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  46008. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  46009. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  46010. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  46011. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  46012. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  46013. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  46014. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  46015. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  46016. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  46017. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  46018. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  46019. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  46020. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  46021. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  46022. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  46023. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  46024. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  46025. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  46026. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  46027. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  46028. -----END CERTIFICATE-----
  46029. SSL.com EV Root Certification Authority ECC
  46030. ===========================================
  46031. -----BEGIN CERTIFICATE-----
  46032. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  46033. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  46034. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  46035. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  46036. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  46037. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  46038. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  46039. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  46040. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  46041. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  46042. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  46043. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  46044. -----END CERTIFICATE-----
  46045. GlobalSign Root CA - R6
  46046. =======================
  46047. -----BEGIN CERTIFICATE-----
  46048. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  46049. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  46050. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  46051. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  46052. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  46053. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  46054. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  46055. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  46056. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  46057. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  46058. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  46059. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  46060. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  46061. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  46062. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  46063. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  46064. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  46065. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  46066. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  46067. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  46068. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  46069. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  46070. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  46071. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  46072. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  46073. -----END CERTIFICATE-----
  46074. OISTE WISeKey Global Root GC CA
  46075. ===============================
  46076. -----BEGIN CERTIFICATE-----
  46077. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  46078. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  46079. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  46080. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  46081. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  46082. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  46083. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  46084. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  46085. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  46086. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  46087. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  46088. -----END CERTIFICATE-----
  46089. UCA Global G2 Root
  46090. ==================
  46091. -----BEGIN CERTIFICATE-----
  46092. MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQG
  46093. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBHbG9iYWwgRzIgUm9vdDAeFw0x
  46094. NjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0xCzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlU
  46095. cnVzdDEbMBkGA1UEAwwSVUNBIEdsb2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  46096. MIICCgKCAgEAxeYrb3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmT
  46097. oni9kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzmVHqUwCoV
  46098. 8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/RVogvGjqNO7uCEeBHANBS
  46099. h6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDcC/Vkw85DvG1xudLeJ1uK6NjGruFZfc8o
  46100. LTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIjtm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/
  46101. R+zvWr9LesGtOxdQXGLYD0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBe
  46102. KW4bHAyvj5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6DlNaBa
  46103. 4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6iIis7nCs+dwp4wwc
  46104. OxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznPO6Q0ibd5Ei9Hxeepl2n8pndntd97
  46105. 8XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
  46106. BBYEFIHEjMz15DD/pQwIX4wVZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo
  46107. 5sOASD0Ee/ojL3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5
  46108. 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl1qnN3e92mI0A
  46109. Ds0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oUb3n09tDh05S60FdRvScFDcH9
  46110. yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX
  46111. c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo
  46112. jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk
  46113. bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x
  46114. ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn
  46115. RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A==
  46116. -----END CERTIFICATE-----
  46117. UCA Extended Validation Root
  46118. ============================
  46119. -----BEGIN CERTIFICATE-----
  46120. MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG
  46121. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u
  46122. IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G
  46123. A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi
  46124. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs
  46125. iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF
  46126. Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu
  46127. eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR
  46128. 59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH
  46129. 0mK1lTnj8/FtDw5lhIpjVMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KR
  46130. el7sFsLzKuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/TuDv
  46131. B0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41Gsx2VYVdWf6/wFlth
  46132. WG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs1+lvK9JKBZP8nm9rZ/+I8U6laUpS
  46133. NwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQDfwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS
  46134. 3H5aBZ8eNJr34RQwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
  46135. BQADggIBADaNl8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR
  46136. ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQVBcZEhrxH9cM
  46137. aVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5c6sq1WnIeJEmMX3ixzDx/BR4
  46138. dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb
  46139. +7lsq+KePRXBOy5nAliRn+/4Qh8st2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOW
  46140. F3sGPjLtx7dCvHaj2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwi
  46141. GpWOvpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc
  46142. GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi
  46143. djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr
  46144. dhh2n1ax
  46145. -----END CERTIFICATE-----
  46146. Certigna Root CA
  46147. ================
  46148. -----BEGIN CERTIFICATE-----
  46149. MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE
  46150. BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ
  46151. MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda
  46152. MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz
  46153. MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  46154. DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX
  46155. stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz
  46156. KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8
  46157. JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16
  46158. XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq
  46159. 4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej
  46160. wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWTCo/1VTp2lc5ZmIoJ
  46161. lXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1kJWumIWmbat10TWuXekG9qxf5kBdI
  46162. jzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp/
  46163. /TBt2dzhauH8XwIDAQABo4IBGjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
  46164. HQYDVR0OBBYEFBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of
  46165. 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczovL3d3d3cuY2Vy
  46166. dGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilodHRwOi8vY3JsLmNlcnRpZ25h
  46167. LmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYraHR0cDovL2NybC5kaGlteW90aXMuY29tL2Nl
  46168. cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt
  46169. OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP
  46170. TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq
  46171. 7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3
  46172. 4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd
  46173. 8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS
  46174. 6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY
  46175. tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
  46176. aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
  46177. E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
  46178. -----END CERTIFICATE-----
  46179. emSign Root CA - G1
  46180. ===================
  46181. -----BEGIN CERTIFICATE-----
  46182. MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
  46183. MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
  46184. ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
  46185. ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk
  46186. aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB
  46187. IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN
  46188. LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1
  46189. cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW
  46190. DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ
  46191. 6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH
  46192. hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG
  46193. MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2
  46194. vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q
  46195. NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q
  46196. +Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih
  46197. U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx
  46198. iN66zB+Afko=
  46199. -----END CERTIFICATE-----
  46200. emSign ECC Root CA - G3
  46201. =======================
  46202. -----BEGIN CERTIFICATE-----
  46203. MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG
  46204. A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg
  46205. MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4
  46206. MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11
  46207. ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g
  46208. RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc
  46209. 58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr
  46210. MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC
  46211. AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D
  46212. CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7
  46213. jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj
  46214. -----END CERTIFICATE-----
  46215. emSign Root CA - C1
  46216. ===================
  46217. -----BEGIN CERTIFICATE-----
  46218. MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx
  46219. EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp
  46220. Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE
  46221. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD
  46222. ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up
  46223. ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/
  46224. Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX
  46225. OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V
  46226. I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms
  46227. lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+
  46228. XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
  46229. ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp
  46230. /6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1
  46231. NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9
  46232. wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ
  46233. BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI=
  46234. -----END CERTIFICATE-----
  46235. emSign ECC Root CA - C3
  46236. =======================
  46237. -----BEGIN CERTIFICATE-----
  46238. MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG
  46239. A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF
  46240. Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE
  46241. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD
  46242. ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd
  46243. 6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9
  46244. SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA
  46245. B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA
  46246. MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU
  46247. ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==
  46248. -----END CERTIFICATE-----
  46249. Hongkong Post Root CA 3
  46250. =======================
  46251. -----BEGIN CERTIFICATE-----
  46252. MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG
  46253. A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK
  46254. Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2
  46255. MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv
  46256. bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX
  46257. SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz
  46258. iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf
  46259. jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim
  46260. 5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe
  46261. sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj
  46262. 0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/
  46263. JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZbx39ri1UbSsUgYT2u
  46264. y1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+l2oBlKN8W4UdKjk60FSh0Tlxnf0h
  46265. +bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YKTE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsG
  46266. xVd7GYYKecsAyVKvQv83j+GjHno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwID
  46267. AQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e
  46268. i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEwDQYJKoZIhvcN
  46269. AQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG7BJ8dNVI0lkUmcDrudHr9Egw
  46270. W62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCkMpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWld
  46271. y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
  46272. +BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
  46273. eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
  46274. 9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
  46275. nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
  46276. hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
  46277. 60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
  46278. dBb9HxEGmpv0
  46279. -----END CERTIFICATE-----
  46280. Microsoft ECC Root Certificate Authority 2017
  46281. =============================================
  46282. -----BEGIN CERTIFICATE-----
  46283. MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  46284. UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND
  46285. IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4
  46286. MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw
  46287. NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ
  46288. BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6
  46289. thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB
  46290. eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM
  46291. +Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf
  46292. Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR
  46293. eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M=
  46294. -----END CERTIFICATE-----
  46295. Microsoft RSA Root Certificate Authority 2017
  46296. =============================================
  46297. -----BEGIN CERTIFICATE-----
  46298. MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG
  46299. EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg
  46300. UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw
  46301. NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u
  46302. MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw
  46303. ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml
  46304. 7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e
  46305. S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7
  46306. 1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+
  46307. dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F
  46308. yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS
  46309. MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr
  46310. lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ
  46311. 0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ
  46312. ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw
  46313. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC
  46314. NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og
  46315. 6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80
  46316. dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk
  46317. +ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex
  46318. /2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy
  46319. AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW
  46320. ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE
  46321. 7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT
  46322. c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D
  46323. 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E
  46324. -----END CERTIFICATE-----
  46325. e-Szigno Root CA 2017
  46326. =====================
  46327. -----BEGIN CERTIFICATE-----
  46328. MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw
  46329. DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt
  46330. MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa
  46331. Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE
  46332. CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp
  46333. Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx
  46334. s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G
  46335. A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv
  46336. vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA
  46337. tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO
  46338. svxyqltZ+efcMQ==
  46339. -----END CERTIFICATE-----
  46340. certSIGN Root CA G2
  46341. ===================
  46342. -----BEGIN CERTIFICATE-----
  46343. MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw
  46344. EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy
  46345. MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH
  46346. TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  46347. ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05
  46348. N0IwvlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZuIt4Imfk
  46349. abBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhpn+Sc8CnTXPnGFiWeI8Mg
  46350. wT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKscpc/I1mbySKEwQdPzH/iV8oScLumZfNp
  46351. dWO9lfsbl83kqK/20U6o2YpxJM02PbyWxPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91Qqh
  46352. ngLjYl/rNUssuHLoPj1PrCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732
  46353. jcZZroiFDsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fxDTvf
  46354. 95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgyLcsUDFDYg2WD7rlc
  46355. z8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6CeWRgKRM+o/1Pcmqr4tTluCRVLERL
  46356. iohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1Ud
  46357. DgQWBBSCIS1mxteg4BXrzkwJd8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOB
  46358. ywaK8SJJ6ejqkX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC
  46359. b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQlqiCA2ClV9+BB
  46360. /AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0OJD7uNGzcgbJceaBxXntC6Z5
  46361. 8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5
  46362. BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW
  46363. atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU
  46364. Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M
  46365. NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N
  46366. 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc=
  46367. -----END CERTIFICATE-----
  46368. Trustwave Global Certification Authority
  46369. ========================================
  46370. -----BEGIN CERTIFICATE-----
  46371. MIIF2jCCA8KgAwIBAgIMBfcOhtpJ80Y1LrqyMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJV
  46372. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  46373. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  46374. IEF1dGhvcml0eTAeFw0xNzA4MjMxOTM0MTJaFw00MjA4MjMxOTM0MTJaMIGIMQswCQYDVQQGEwJV
  46375. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  46376. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  46377. IEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALldUShLPDeS0YLOvR29
  46378. zd24q88KPuFd5dyqCblXAj7mY2Hf8g+CY66j96xz0XznswuvCAAJWX/NKSqIk4cXGIDtiLK0thAf
  46379. LdZfVaITXdHG6wZWiYj+rDKd/VzDBcdu7oaJuogDnXIhhpCujwOl3J+IKMujkkkP7NAP4m1ET4Bq
  46380. stTnoApTAbqOl5F2brz81Ws25kCI1nsvXwXoLG0R8+eyvpJETNKXpP7ScoFDB5zpET71ixpZfR9o
  46381. WN0EACyW80OzfpgZdNmcc9kYvkHHNHnZ9GLCQ7mzJ7Aiy/k9UscwR7PJPrhq4ufogXBeQotPJqX+
  46382. OsIgbrv4Fo7NDKm0G2x2EOFYeUY+VM6AqFcJNykbmROPDMjWLBz7BegIlT1lRtzuzWniTY+HKE40
  46383. Cz7PFNm73bZQmq131BnW2hqIyE4bJ3XYsgjxroMwuREOzYfwhI0Vcnyh78zyiGG69Gm7DIwLdVcE
  46384. uE4qFC49DxweMqZiNu5m4iK4BUBjECLzMx10coos9TkpoNPnG4CELcU9402x/RpvumUHO1jsQkUm
  46385. +9jaJXLE9gCxInm943xZYkqcBW89zubWR2OZxiRvchLIrH+QtAuRcOi35hYQcRfO3gZPSEF9NUqj
  46386. ifLJS3tBEW1ntwiYTOURGa5CgNz7kAXU+FDKvuStx8KU1xad5hePrzb7AgMBAAGjQjBAMA8GA1Ud
  46387. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFJngGWcNYtt2s9o9uFvo/ULSMQ6HMA4GA1UdDwEB/wQEAwIB
  46388. BjANBgkqhkiG9w0BAQsFAAOCAgEAmHNw4rDT7TnsTGDZqRKGFx6W0OhUKDtkLSGm+J1WE2pIPU/H
  46389. PinbbViDVD2HfSMF1OQc3Og4ZYbFdada2zUFvXfeuyk3QAUHw5RSn8pk3fEbK9xGChACMf1KaA0H
  46390. ZJDmHvUqoai7PF35owgLEQzxPy0QlG/+4jSHg9bP5Rs1bdID4bANqKCqRieCNqcVtgimQlRXtpla
  46391. 4gt5kNdXElE1GYhBaCXUNxeEFfsBctyV3lImIJgm4nb1J2/6ADtKYdkNy1GTKv0WBpanI5ojSP5R
  46392. vbbEsLFUzt5sQa0WZ37b/TjNuThOssFgy50X31ieemKyJo90lZvkWx3SD92YHJtZuSPTMaCm/zjd
  46393. zyBP6VhWOmfD0faZmZ26NraAL4hHT4a/RDqA5Dccprrql5gR0IRiR2Qequ5AvzSxnI9O4fKSTx+O
  46394. 856X3vOmeWqJcU9LJxdI/uz0UA9PSX3MReO9ekDFQdxhVicGaeVyQYHTtgGJoC86cnn+OjC/QezH
  46395. Yj6RS8fZMXZC+fc8Y+wmjHMMfRod6qh8h6jCJ3zhM0EPz8/8AKAigJ5Kp28AsEFFtyLKaEjFQqKu
  46396. 3R3y4G5OBVixwJAWKqQ9EEC+j2Jjg6mcgn0tAumDMHzLJ8n9HmYAsC7TIS+OMxZsmO0QqAfWzJPP
  46397. 29FpHOTKyeC2nOnOcXHebD8WpHk=
  46398. -----END CERTIFICATE-----
  46399. Trustwave Global ECC P256 Certification Authority
  46400. =================================================
  46401. -----BEGIN CERTIFICATE-----
  46402. MIICYDCCAgegAwIBAgIMDWpfCD8oXD5Rld9dMAoGCCqGSM49BAMCMIGRMQswCQYDVQQGEwJVUzER
  46403. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  46404. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1NiBDZXJ0aWZp
  46405. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM1MTBaFw00MjA4MjMxOTM1MTBaMIGRMQswCQYD
  46406. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  46407. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1
  46408. NiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABH77bOYj
  46409. 43MyCMpg5lOcunSNGLB4kFKA3TjASh3RqMyTpJcGOMoNFWLGjgEqZZ2q3zSRLoHB5DOSMcT9CTqm
  46410. P62jQzBBMA8GA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAwcGADAdBgNVHQ4EFgQUo0EGrJBt
  46411. 0UrrdaVKEJmzsaGLSvcwCgYIKoZIzj0EAwIDRwAwRAIgB+ZU2g6gWrKuEZ+Hxbb/ad4lvvigtwjz
  46412. RM4q3wghDDcCIC0mA6AFvWvR9lz4ZcyGbbOcNEhjhAnFjXca4syc4XR7
  46413. -----END CERTIFICATE-----
  46414. Trustwave Global ECC P384 Certification Authority
  46415. =================================================
  46416. -----BEGIN CERTIFICATE-----
  46417. MIICnTCCAiSgAwIBAgIMCL2Fl2yZJ6SAaEc7MAoGCCqGSM49BAMDMIGRMQswCQYDVQQGEwJVUzER
  46418. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  46419. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4NCBDZXJ0aWZp
  46420. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM2NDNaFw00MjA4MjMxOTM2NDNaMIGRMQswCQYD
  46421. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  46422. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4
  46423. NCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvaDXU1CDFH
  46424. Ba5FmVXxERMuSvgQMSOjfoPTfygIOiYaOs+Xgh+AtycJj9GOMMQKmw6sWASr9zZ9lCOkmwqKi6vr
  46425. /TklZvFe/oyujUF5nQlgziip04pt89ZF1PKYhDhloKNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNV
  46426. HQ8BAf8EBQMDBwYAMB0GA1UdDgQWBBRVqYSJ0sEyvRjLbKYHTsjnnb6CkDAKBggqhkjOPQQDAwNn
  46427. ADBkAjA3AZKXRRJ+oPM+rRk6ct30UJMDEr5E0k9BpIycnR+j9sKS50gU/k6bpZFXrsY3crsCMGcl
  46428. CrEMXu6pY5Jv5ZAL/mYiykf9ijH3g/56vxC+GCsej/YpHpRZ744hN8tRmKVuSw==
  46429. -----END CERTIFICATE-----
  46430. NAVER Global Root Certification Authority
  46431. =========================================
  46432. -----BEGIN CERTIFICATE-----
  46433. MIIFojCCA4qgAwIBAgIUAZQwHqIL3fXFMyqxQ0Rx+NZQTQ0wDQYJKoZIhvcNAQEMBQAwaTELMAkG
  46434. A1UEBhMCS1IxJjAkBgNVBAoMHU5BVkVSIEJVU0lORVNTIFBMQVRGT1JNIENvcnAuMTIwMAYDVQQD
  46435. DClOQVZFUiBHbG9iYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MTgwODU4
  46436. NDJaFw0zNzA4MTgyMzU5NTlaMGkxCzAJBgNVBAYTAktSMSYwJAYDVQQKDB1OQVZFUiBCVVNJTkVT
  46437. UyBQTEFURk9STSBDb3JwLjEyMDAGA1UEAwwpTkFWRVIgR2xvYmFsIFJvb3QgQ2VydGlmaWNhdGlv
  46438. biBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC21PGTXLVAiQqrDZBb
  46439. UGOukJR0F0Vy1ntlWilLp1agS7gvQnXp2XskWjFlqxcX0TM62RHcQDaH38dq6SZeWYp34+hInDEW
  46440. +j6RscrJo+KfziFTowI2MMtSAuXaMl3Dxeb57hHHi8lEHoSTGEq0n+USZGnQJoViAbbJAh2+g1G7
  46441. XNr4rRVqmfeSVPc0W+m/6imBEtRTkZazkVrd/pBzKPswRrXKCAfHcXLJZtM0l/aM9BhK4dA9WkW2
  46442. aacp+yPOiNgSnABIqKYPszuSjXEOdMWLyEz59JuOuDxp7W87UC9Y7cSw0BwbagzivESq2M0UXZR4
  46443. Yb8ObtoqvC8MC3GmsxY/nOb5zJ9TNeIDoKAYv7vxvvTWjIcNQvcGufFt7QSUqP620wbGQGHfnZ3z
  46444. VHbOUzoBppJB7ASjjw2i1QnK1sua8e9DXcCrpUHPXFNwcMmIpi3Ua2FzUCaGYQ5fG8Ir4ozVu53B
  46445. A0K6lNpfqbDKzE0K70dpAy8i+/Eozr9dUGWokG2zdLAIx6yo0es+nPxdGoMuK8u180SdOqcXYZai
  46446. cdNwlhVNt0xz7hlcxVs+Qf6sdWA7G2POAN3aCJBitOUt7kinaxeZVL6HSuOpXgRM6xBtVNbv8ejy
  46447. YhbLgGvtPe31HzClrkvJE+2KAQHJuFFYwGY6sWZLxNUxAmLpdIQM201GLQIDAQABo0IwQDAdBgNV
  46448. HQ4EFgQU0p+I36HNLL3s9TsBAZMzJ7LrYEswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMB
  46449. Af8wDQYJKoZIhvcNAQEMBQADggIBADLKgLOdPVQG3dLSLvCkASELZ0jKbY7gyKoNqo0hV4/GPnrK
  46450. 21HUUrPUloSlWGB/5QuOH/XcChWB5Tu2tyIvCZwTFrFsDDUIbatjcu3cvuzHV+YwIHHW1xDBE1UB
  46451. jCpD5EHxzzp6U5LOogMFDTjfArsQLtk70pt6wKGm+LUx5vR1yblTmXVHIloUFcd4G7ad6Qz4G3bx
  46452. hYTeodoS76TiEJd6eN4MUZeoIUCLhr0N8F5OSza7OyAfikJW4Qsav3vQIkMsRIz75Sq0bBwcupTg
  46453. E34h5prCy8VCZLQelHsIJchxzIdFV4XTnyliIoNRlwAYl3dqmJLJfGBs32x9SuRwTMKeuB330DTH
  46454. D8z7p/8Dvq1wkNoL3chtl1+afwkyQf3NosxabUzyqkn+Zvjp2DXrDige7kgvOtB5CTh8piKCk5XQ
  46455. A76+AqAF3SAi428diDRgxuYKuQl1C/AH6GmWNcf7I4GOODm4RStDeKLRLBT/DShycpWbXgnbiUSY
  46456. qqFJu3FS8r/2/yehNq+4tneI3TqkbZs0kNwUXTC/t+sX5Ie3cdCh13cV1ELX8vMxmV2b3RZtP+oG
  46457. I/hGoiLtk/bdmuYqh7GYVPEi92tF4+KOdh2ajcQGjTa3FPOdVGm3jjzVpG2Tgbet9r1ke8LJaDmg
  46458. kpzNNIaRkPpkUZ3+/uul9XXeifdy
  46459. -----END CERTIFICATE-----
  46460. AC RAIZ FNMT-RCM SERVIDORES SEGUROS
  46461. ===================================
  46462. -----BEGIN CERTIFICATE-----
  46463. MIICbjCCAfOgAwIBAgIQYvYybOXE42hcG2LdnC6dlTAKBggqhkjOPQQDAzB4MQswCQYDVQQGEwJF
  46464. UzERMA8GA1UECgwIRk5NVC1SQ00xDjAMBgNVBAsMBUNlcmVzMRgwFgYDVQRhDA9WQVRFUy1RMjgy
  46465. NjAwNEoxLDAqBgNVBAMMI0FDIFJBSVogRk5NVC1SQ00gU0VSVklET1JFUyBTRUdVUk9TMB4XDTE4
  46466. MTIyMDA5MzczM1oXDTQzMTIyMDA5MzczM1oweDELMAkGA1UEBhMCRVMxETAPBgNVBAoMCEZOTVQt
  46467. UkNNMQ4wDAYDVQQLDAVDZXJlczEYMBYGA1UEYQwPVkFURVMtUTI4MjYwMDRKMSwwKgYDVQQDDCNB
  46468. QyBSQUlaIEZOTVQtUkNNIFNFUlZJRE9SRVMgU0VHVVJPUzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  46469. BPa6V1PIyqvfNkpSIeSX0oNnnvBlUdBeh8dHsVnyV0ebAAKTRBdp20LHsbI6GA60XYyzZl2hNPk2
  46470. LEnb80b8s0RpRBNm/dfF/a82Tc4DTQdxz69qBdKiQ1oKUm8BA06Oi6NCMEAwDwYDVR0TAQH/BAUw
  46471. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFAG5L++/EYZg8k/QQW6rcx/n0m5JMAoGCCqG
  46472. SM49BAMDA2kAMGYCMQCuSuMrQMN0EfKVrRYj3k4MGuZdpSRea0R7/DjiT8ucRRcRTBQnJlU5dUoD
  46473. zBOQn5ICMQD6SmxgiHPz7riYYqnOK8LZiqZwMR2vsJRM60/G49HzYqc8/5MuB1xJAWdpEgJyv+c=
  46474. -----END CERTIFICATE-----
  46475. GlobalSign Root R46
  46476. ===================
  46477. -----BEGIN CERTIFICATE-----
  46478. MIIFWjCCA0KgAwIBAgISEdK7udcjGJ5AXwqdLdDfJWfRMA0GCSqGSIb3DQEBDAUAMEYxCzAJBgNV
  46479. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJv
  46480. b3QgUjQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAX
  46481. BgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBSNDYwggIi
  46482. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCsrHQy6LNl5brtQyYdpokNRbopiLKkHWPd08Es
  46483. CVeJOaFV6Wc0dwxu5FUdUiXSE2te4R2pt32JMl8Nnp8semNgQB+msLZ4j5lUlghYruQGvGIFAha/
  46484. r6gjA7aUD7xubMLL1aa7DOn2wQL7Id5m3RerdELv8HQvJfTqa1VbkNud316HCkD7rRlr+/fKYIje
  46485. 2sGP1q7Vf9Q8g+7XFkyDRTNrJ9CG0Bwta/OrffGFqfUo0q3v84RLHIf8E6M6cqJaESvWJ3En7YEt
  46486. bWaBkoe0G1h6zD8K+kZPTXhc+CtI4wSEy132tGqzZfxCnlEmIyDLPRT5ge1lFgBPGmSXZgjPjHvj
  46487. K8Cd+RTyG/FWaha/LIWFzXg4mutCagI0GIMXTpRW+LaCtfOW3T3zvn8gdz57GSNrLNRyc0NXfeD4
  46488. 12lPFzYE+cCQYDdF3uYM2HSNrpyibXRdQr4G9dlkbgIQrImwTDsHTUB+JMWKmIJ5jqSngiCNI/on
  46489. ccnfxkF0oE32kRbcRoxfKWMxWXEM2G/CtjJ9++ZdU6Z+Ffy7dXxd7Pj2Fxzsx2sZy/N78CsHpdls
  46490. eVR2bJ0cpm4O6XkMqCNqo98bMDGfsVR7/mrLZqrcZdCinkqaByFrgY/bxFn63iLABJzjqls2k+g9
  46491. vXqhnQt2sQvHnf3PmKgGwvgqo6GDoLclcqUC4wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYD
  46492. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA1yrc4GHqMywptWU4jaWSf8FmSwwDQYJKoZIhvcNAQEM
  46493. BQADggIBAHx47PYCLLtbfpIrXTncvtgdokIzTfnvpCo7RGkerNlFo048p9gkUbJUHJNOxO97k4Vg
  46494. JuoJSOD1u8fpaNK7ajFxzHmuEajwmf3lH7wvqMxX63bEIaZHU1VNaL8FpO7XJqti2kM3S+LGteWy
  46495. gxk6x9PbTZ4IevPuzz5i+6zoYMzRx6Fcg0XERczzF2sUyQQCPtIkpnnpHs6i58FZFZ8d4kuaPp92
  46496. CC1r2LpXFNqD6v6MVenQTqnMdzGxRBF6XLE+0xRFFRhiJBPSy03OXIPBNvIQtQ6IbbjhVp+J3pZm
  46497. OUdkLG5NrmJ7v2B0GbhWrJKsFjLtrWhV/pi60zTe9Mlhww6G9kuEYO4Ne7UyWHmRVSyBQ7N0H3qq
  46498. JZ4d16GLuc1CLgSkZoNNiTW2bKg2SnkheCLQQrzRQDGQob4Ez8pn7fXwgNNgyYMqIgXQBztSvwye
  46499. qiv5u+YfjyW6hY0XHgL+XVAEV8/+LbzvXMAaq7afJMbfc2hIkCwU9D9SGuTSyxTDYWnP4vkYxboz
  46500. nxSjBF25cfe1lNj2M8FawTSLfJvdkzrnE6JwYZ+vj+vYxXX4M2bUdGc6N3ec592kD3ZDZopD8p/7
  46501. DEJ4Y9HiD2971KE9dJeFt0g5QdYg/NA6s/rob8SKunE3vouXsXgxT7PntgMTzlSdriVZzH81Xwj3
  46502. QEUxeCp6
  46503. -----END CERTIFICATE-----
  46504. GlobalSign Root E46
  46505. ===================
  46506. -----BEGIN CERTIFICATE-----
  46507. MIICCzCCAZGgAwIBAgISEdK7ujNu1LzmJGjFDYQdmOhDMAoGCCqGSM49BAMDMEYxCzAJBgNVBAYT
  46508. AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJvb3Qg
  46509. RTQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNV
  46510. BAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBFNDYwdjAQBgcq
  46511. hkjOPQIBBgUrgQQAIgNiAAScDrHPt+ieUnd1NPqlRqetMhkytAepJ8qUuwzSChDH2omwlwxwEwkB
  46512. jtjqR+q+soArzfwoDdusvKSGN+1wCAB16pMLey5SnCNoIwZD7JIvU4Tb+0cUB+hflGddyXqBPCCj
  46513. QjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQxCpCPtsad0kRL
  46514. gLWi5h+xEk8blTAKBggqhkjOPQQDAwNoADBlAjEA31SQ7Zvvi5QCkxeCmb6zniz2C5GMn0oUsfZk
  46515. vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+
  46516. CAezNIm8BZ/3Hobui3A=
  46517. -----END CERTIFICATE-----
  46518. GLOBALTRUST 2020
  46519. ================
  46520. -----BEGIN CERTIFICATE-----
  46521. MIIFgjCCA2qgAwIBAgILWku9WvtPilv6ZeUwDQYJKoZIhvcNAQELBQAwTTELMAkGA1UEBhMCQVQx
  46522. IzAhBgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVT
  46523. VCAyMDIwMB4XDTIwMDIxMDAwMDAwMFoXDTQwMDYxMDAwMDAwMFowTTELMAkGA1UEBhMCQVQxIzAh
  46524. BgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVTVCAy
  46525. MDIwMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAri5WrRsc7/aVj6B3GyvTY4+ETUWi
  46526. D59bRatZe1E0+eyLinjF3WuvvcTfk0Uev5E4C64OFudBc/jbu9G4UeDLgztzOG53ig9ZYybNpyrO
  46527. VPu44sB8R85gfD+yc/LAGbaKkoc1DZAoouQVBGM+uq/ufF7MpotQsjj3QWPKzv9pj2gOlTblzLmM
  46528. CcpL3TGQlsjMH/1WljTbjhzqLL6FLmPdqqmV0/0plRPwyJiT2S0WR5ARg6I6IqIoV6Lr/sCMKKCm
  46529. fecqQjuCgGOlYx8ZzHyyZqjC0203b+J+BlHZRYQfEs4kUmSFC0iAToexIiIwquuuvuAC4EDosEKA
  46530. A1GqtH6qRNdDYfOiaxaJSaSjpCuKAsR49GiKweR6NrFvG5Ybd0mN1MkGco/PU+PcF4UgStyYJ9OR
  46531. JitHHmkHr96i5OTUawuzXnzUJIBHKWk7buis/UDr2O1xcSvy6Fgd60GXIsUf1DnQJ4+H4xj04KlG
  46532. DfV0OoIu0G4skaMxXDtG6nsEEFZegB31pWXogvziB4xiRfUg3kZwhqG8k9MedKZssCz3AwyIDMvU
  46533. clOGvGBG85hqwvG/Q/lwIHfKN0F5VVJjjVsSn8VoxIidrPIwq7ejMZdnrY8XD2zHc+0klGvIg5rQ
  46534. mjdJBKuxFshsSUktq6HQjJLyQUp5ISXbY9e2nKd+Qmn7OmMCAwEAAaNjMGEwDwYDVR0TAQH/BAUw
  46535. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFNwuH9FhN3nkq9XVsxJxaD1qaJwiMB8GA1Ud
  46536. IwQYMBaAFNwuH9FhN3nkq9XVsxJxaD1qaJwiMA0GCSqGSIb3DQEBCwUAA4ICAQCR8EICaEDuw2jA
  46537. VC/f7GLDw56KoDEoqoOOpFaWEhCGVrqXctJUMHytGdUdaG/7FELYjQ7ztdGl4wJCXtzoRlgHNQIw
  46538. 4Lx0SsFDKv/bGtCwr2zD/cuz9X9tAy5ZVp0tLTWMstZDFyySCstd6IwPS3BD0IL/qMy/pJTAvoe9
  46539. iuOTe8aPmxadJ2W8esVCgmxcB9CpwYhgROmYhRZf+I/KARDOJcP5YBugxZfD0yyIMaK9MOzQ0MAS
  46540. 8cE54+X1+NZK3TTN+2/BT+MAi1bikvcoskJ3ciNnxz8RFbLEAwW+uxF7Cr+obuf/WEPPm2eggAe2
  46541. HcqtbepBEX4tdJP7wry+UUTF72glJ4DjyKDUEuzZpTcdN3y0kcra1LGWge9oXHYQSa9+pTeAsRxS
  46542. vTOBTI/53WXZFM2KJVj04sWDpQmQ1GwUY7VA3+vA/MRYfg0UFodUJ25W5HCEuGwyEn6CMUO+1918
  46543. oa2u1qsgEu8KwxCMSZY13At1XrFP1U80DhEgB3VDRemjEdqso5nCtnkn4rnvyOL2NSl6dPrFf4IF
  46544. YqYK6miyeUcGbvJXqBUzxvd4Sj1Ce2t+/vdG6tHrju+IaFvowdlxfv1k7/9nR4hYJS8+hge9+6jl
  46545. gqispdNpQ80xiEmEU5LAsTkbOYMBMMTyqfrQA71yN2BWHzZ8vTmR9W0Nv3vXkg==
  46546. -----END CERTIFICATE-----
  46547. ANF Secure Server Root CA
  46548. =========================
  46549. -----BEGIN CERTIFICATE-----
  46550. MIIF7zCCA9egAwIBAgIIDdPjvGz5a7EwDQYJKoZIhvcNAQELBQAwgYQxEjAQBgNVBAUTCUc2MzI4
  46551. NzUxMDELMAkGA1UEBhMCRVMxJzAlBgNVBAoTHkFORiBBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lv
  46552. bjEUMBIGA1UECxMLQU5GIENBIFJhaXoxIjAgBgNVBAMTGUFORiBTZWN1cmUgU2VydmVyIFJvb3Qg
  46553. Q0EwHhcNMTkwOTA0MTAwMDM4WhcNMzkwODMwMTAwMDM4WjCBhDESMBAGA1UEBRMJRzYzMjg3NTEw
  46554. MQswCQYDVQQGEwJFUzEnMCUGA1UEChMeQU5GIEF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uMRQw
  46555. EgYDVQQLEwtBTkYgQ0EgUmFpejEiMCAGA1UEAxMZQU5GIFNlY3VyZSBTZXJ2ZXIgUm9vdCBDQTCC
  46556. AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANvrayvmZFSVgpCjcqQZAZ2cC4Ffc0m6p6zz
  46557. BE57lgvsEeBbphzOG9INgxwruJ4dfkUyYA8H6XdYfp9qyGFOtibBTI3/TO80sh9l2Ll49a2pcbnv
  46558. T1gdpd50IJeh7WhM3pIXS7yr/2WanvtH2Vdy8wmhrnZEE26cLUQ5vPnHO6RYPUG9tMJJo8gN0pcv
  46559. B2VSAKduyK9o7PQUlrZXH1bDOZ8rbeTzPvY1ZNoMHKGESy9LS+IsJJ1tk0DrtSOOMspvRdOoiXse
  46560. zx76W0OLzc2oD2rKDF65nkeP8Nm2CgtYZRczuSPkdxl9y0oukntPLxB3sY0vaJxizOBQ+OyRp1RM
  46561. VwnVdmPF6GUe7m1qzwmd+nxPrWAI/VaZDxUse6mAq4xhj0oHdkLePfTdsiQzW7i1o0TJrH93PB0j
  46562. 7IKppuLIBkwC/qxcmZkLLxCKpvR/1Yd0DVlJRfbwcVw5Kda/SiOL9V8BY9KHcyi1Swr1+KuCLH5z
  46563. JTIdC2MKF4EA/7Z2Xue0sUDKIbvVgFHlSFJnLNJhiQcND85Cd8BEc5xEUKDbEAotlRyBr+Qc5RQe
  46564. 8TZBAQIvfXOn3kLMTOmJDVb3n5HUA8ZsyY/b2BzgQJhdZpmYgG4t/wHFzstGH6wCxkPmrqKEPMVO
  46565. Hj1tyRRM4y5Bu8o5vzY8KhmqQYdOpc5LMnndkEl/AgMBAAGjYzBhMB8GA1UdIwQYMBaAFJxf0Gxj
  46566. o1+TypOYCK2Mh6UsXME3MB0GA1UdDgQWBBScX9BsY6Nfk8qTmAitjIelLFzBNzAOBgNVHQ8BAf8E
  46567. BAMCAYYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEATh65isagmD9uw2nAalxJ
  46568. UqzLK114OMHVVISfk/CHGT0sZonrDUL8zPB1hT+L9IBdeeUXZ701guLyPI59WzbLWoAAKfLOKyzx
  46569. j6ptBZNscsdW699QIyjlRRA96Gejrw5VD5AJYu9LWaL2U/HANeQvwSS9eS9OICI7/RogsKQOLHDt
  46570. dD+4E5UGUcjohybKpFtqFiGS3XNgnhAY3jyB6ugYw3yJ8otQPr0R4hUDqDZ9MwFsSBXXiJCZBMXM
  46571. 5gf0vPSQ7RPi6ovDj6MzD8EpTBNO2hVWcXNyglD2mjN8orGoGjR0ZVzO0eurU+AagNjqOknkJjCb
  46572. 5RyKqKkVMoaZkgoQI1YS4PbOTOK7vtuNknMBZi9iPrJyJ0U27U1W45eZ/zo1PqVUSlJZS2Db7v54
  46573. EX9K3BR5YLZrZAPbFYPhor72I5dQ8AkzNqdxliXzuUJ92zg/LFis6ELhDtjTO0wugumDLmsx2d1H
  46574. hk9tl5EuT+IocTUW0fJz/iUrB0ckYyfI+PbZa/wSMVYIwFNCr5zQM378BvAxRAMU8Vjq8moNqRGy
  46575. g77FGr8H6lnco4g175x2MjxNBiLOFeXdntiP2t7SxDnlF4HPOEfrf4htWRvfn0IUrn7PqLBmZdo3
  46576. r5+qPeoott7VMVgWglvquxl1AnMaykgaIZOQCo6ThKd9OyMYkomgjaw=
  46577. -----END CERTIFICATE-----
  46578. Certum EC-384 CA
  46579. ================
  46580. -----BEGIN CERTIFICATE-----
  46581. MIICZTCCAeugAwIBAgIQeI8nXIESUiClBNAt3bpz9DAKBggqhkjOPQQDAzB0MQswCQYDVQQGEwJQ
  46582. TDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2Vy
  46583. dGlmaWNhdGlvbiBBdXRob3JpdHkxGTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwHhcNMTgwMzI2
  46584. MDcyNDU0WhcNNDMwMzI2MDcyNDU0WjB0MQswCQYDVQQGEwJQTDEhMB8GA1UEChMYQXNzZWNvIERh
  46585. dGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx
  46586. GTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATEKI6rGFtq
  46587. vm5kN2PkzeyrOvfMobgOgknXhimfoZTy42B4mIF4Bk3y7JoOV2CDn7TmFy8as10CW4kjPMIRBSqn
  46588. iBMY81CE1700LCeJVf/OTOffph8oxPBUw7l8t1Ot68KjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  46589. VR0OBBYEFI0GZnQkdjrzife81r1HfS+8EF9LMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNo
  46590. ADBlAjADVS2m5hjEfO/JUG7BJw+ch69u1RsIGL2SKcHvlJF40jocVYli5RsJHrpka/F2tNQCMQC0
  46591. QoSZ/6vnnvuRlydd3LBbMHHOXjgaatkl5+r3YZJW+OraNsKHZZYuciUvf9/DE8k=
  46592. -----END CERTIFICATE-----
  46593. Certum Trusted Root CA
  46594. ======================
  46595. -----BEGIN CERTIFICATE-----
  46596. MIIFwDCCA6igAwIBAgIQHr9ZULjJgDdMBvfrVU+17TANBgkqhkiG9w0BAQ0FADB6MQswCQYDVQQG
  46597. EwJQTDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0g
  46598. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0Ew
  46599. HhcNMTgwMzE2MTIxMDEzWhcNNDMwMzE2MTIxMDEzWjB6MQswCQYDVQQGEwJQTDEhMB8GA1UEChMY
  46600. QXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBB
  46601. dXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEB
  46602. AQUAA4ICDwAwggIKAoICAQDRLY67tzbqbTeRn06TpwXkKQMlzhyC93yZn0EGze2jusDbCSzBfN8p
  46603. fktlL5On1AFrAygYo9idBcEq2EXxkd7fO9CAAozPOA/qp1x4EaTByIVcJdPTsuclzxFUl6s1wB52
  46604. HO8AU5853BSlLCIls3Jy/I2z5T4IHhQqNwuIPMqw9MjCoa68wb4pZ1Xi/K1ZXP69VyywkI3C7Te2
  46605. fJmItdUDmj0VDT06qKhF8JVOJVkdzZhpu9PMMsmN74H+rX2Ju7pgE8pllWeg8xn2A1bUatMn4qGt
  46606. g/BKEiJ3HAVz4hlxQsDsdUaakFjgao4rpUYwBI4Zshfjvqm6f1bxJAPXsiEodg42MEx51UGamqi4
  46607. NboMOvJEGyCI98Ul1z3G4z5D3Yf+xOr1Uz5MZf87Sst4WmsXXw3Hw09Omiqi7VdNIuJGmj8PkTQk
  46608. fVXjjJU30xrwCSss0smNtA0Aq2cpKNgB9RkEth2+dv5yXMSFytKAQd8FqKPVhJBPC/PgP5sZ0jeJ
  46609. P/J7UhyM9uH3PAeXjA6iWYEMspA90+NZRu0PqafegGtaqge2Gcu8V/OXIXoMsSt0Puvap2ctTMSY
  46610. njYJdmZm/Bo/6khUHL4wvYBQv3y1zgD2DGHZ5yQD4OMBgQ692IU0iL2yNqh7XAjlRICMb/gv1SHK
  46611. HRzQ+8S1h9E6Tsd2tTVItQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSM+xx1
  46612. vALTn04uSNn5YFSqxLNP+jAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQENBQADggIBAEii1QAL
  46613. LtA/vBzVtVRJHlpr9OTy4EA34MwUe7nJ+jW1dReTagVphZzNTxl4WxmB82M+w85bj/UvXgF2Ez8s
  46614. ALnNllI5SW0ETsXpD4YN4fqzX4IS8TrOZgYkNCvozMrnadyHncI013nR03e4qllY/p0m+jiGPp2K
  46615. h2RX5Rc64vmNueMzeMGQ2Ljdt4NR5MTMI9UGfOZR0800McD2RrsLrfw9EAUqO0qRJe6M1ISHgCq8
  46616. CYyqOhNf6DR5UMEQGfnTKB7U0VEwKbOukGfWHwpjscWpxkIxYxeU72nLL/qMFH3EQxiJ2fAyQOaA
  46617. 4kZf5ePBAFmo+eggvIksDkc0C+pXwlM2/KfUrzHN/gLldfq5Jwn58/U7yn2fqSLLiMmq0Uc9Nneo
  46618. WWRrJ8/vJ8HjJLWG965+Mk2weWjROeiQWMODvA8s1pfrzgzhIMfatz7DP78v3DSk+yshzWePS/Tj
  46619. 6tQ/50+6uaWTRRxmHyH6ZF5v4HaUMst19W7l9o/HuKTMqJZ9ZPskWkoDbGs4xugDQ5r3V7mzKWmT
  46620. OPQD8rv7gmsHINFSH5pkAnuYZttcTVoP0ISVoDwUQwbKytu4QTbaakRnh6+v40URFWkIsr4WOZck
  46621. bxJF0WddCajJFdr60qZfE2Efv4WstK2tBZQIgx51F9NxO5NQI1mg7TyRVJ12AMXDuDjb
  46622. -----END CERTIFICATE-----
  46623. TunTrust Root CA
  46624. ================
  46625. -----BEGIN CERTIFICATE-----
  46626. MIIFszCCA5ugAwIBAgIUEwLV4kBMkkaGFmddtLu7sms+/BMwDQYJKoZIhvcNAQELBQAwYTELMAkG
  46627. A1UEBhMCVE4xNzA1BgNVBAoMLkFnZW5jZSBOYXRpb25hbGUgZGUgQ2VydGlmaWNhdGlvbiBFbGVj
  46628. dHJvbmlxdWUxGTAXBgNVBAMMEFR1blRydXN0IFJvb3QgQ0EwHhcNMTkwNDI2MDg1NzU2WhcNNDQw
  46629. NDI2MDg1NzU2WjBhMQswCQYDVQQGEwJUTjE3MDUGA1UECgwuQWdlbmNlIE5hdGlvbmFsZSBkZSBD
  46630. ZXJ0aWZpY2F0aW9uIEVsZWN0cm9uaXF1ZTEZMBcGA1UEAwwQVHVuVHJ1c3QgUm9vdCBDQTCCAiIw
  46631. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMPN0/y9BFPdDCA61YguBUtB9YOCfvdZn56eY+hz
  46632. 2vYGqU8ftPkLHzmMmiDQfgbU7DTZhrx1W4eI8NLZ1KMKsmwb60ksPqxd2JQDoOw05TDENX37Jk0b
  46633. bjBU2PWARZw5rZzJJQRNmpA+TkBuimvNKWfGzC3gdOgFVwpIUPp6Q9p+7FuaDmJ2/uqdHYVy7BG7
  46634. NegfJ7/Boce7SBbdVtfMTqDhuazb1YMZGoXRlJfXyqNlC/M4+QKu3fZnz8k/9YosRxqZbwUN/dAd
  46635. gjH8KcwAWJeRTIAAHDOFli/LQcKLEITDCSSJH7UP2dl3RxiSlGBcx5kDPP73lad9UKGAwqmDrViW
  46636. VSHbhlnUr8a83YFuB9tgYv7sEG7aaAH0gxupPqJbI9dkxt/con3YS7qC0lH4Zr8GRuR5KiY2eY8f
  46637. Tpkdso8MDhz/yV3A/ZAQprE38806JG60hZC/gLkMjNWb1sjxVj8agIl6qeIbMlEsPvLfe/ZdeikZ
  46638. juXIvTZxi11Mwh0/rViizz1wTaZQmCXcI/m4WEEIcb9PuISgjwBUFfyRbVinljvrS5YnzWuioYas
  46639. DXxU5mZMZl+QviGaAkYt5IPCgLnPSz7ofzwB7I9ezX/SKEIBlYrilz0QIX32nRzFNKHsLA4KUiwS
  46640. VXAkPcvCFDVDXSdOvsC9qnyW5/yeYa1E0wCXAgMBAAGjYzBhMB0GA1UdDgQWBBQGmpsfU33x9aTI
  46641. 04Y+oXNZtPdEITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFAaamx9TffH1pMjThj6hc1m0
  46642. 90QhMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAqgVutt0Vyb+zxiD2BkewhpMl
  46643. 0425yAA/l/VSJ4hxyXT968pk21vvHl26v9Hr7lxpuhbI87mP0zYuQEkHDVneixCwSQXi/5E/S7fd
  46644. Ao74gShczNxtr18UnH1YeA32gAm56Q6XKRm4t+v4FstVEuTGfbvE7Pi1HE4+Z7/FXxttbUcoqgRY
  46645. YdZ2vyJ/0Adqp2RT8JeNnYA/u8EH22Wv5psymsNUk8QcCMNE+3tjEUPRahphanltkE8pjkcFwRJp
  46646. adbGNjHh/PqAulxPxOu3Mqz4dWEX1xAZufHSCe96Qp1bWgvUxpVOKs7/B9dPfhgGiPEZtdmYu65x
  46647. xBzndFlY7wyJz4sfdZMaBBSSSFCp61cpABbjNhzI+L/wM9VBD8TMPN3pM0MBkRArHtG5Xc0yGYuP
  46648. jCB31yLEQtyEFpslbei0VXF/sHyz03FJuc9SpAQ/3D2gu68zngowYI7bnV2UqL1g52KAdoGDDIzM
  46649. MEZJ4gzSqK/rYXHv5yJiqfdcZGyfFoxnNidF9Ql7v/YQCvGwjVRDjAS6oz/v4jXH+XTgbzRB0L9z
  46650. ZVcg+ZtnemZoJE6AZb0QmQZZ8mWvuMZHu/2QeItBcy6vVR/cO5JyboTT0GFMDcx2V+IthSIVNg3r
  46651. AZ3r2OvEhJn7wAzMMujjd9qDRIueVSjAi1jTkD5OGwDxFa2DK5o=
  46652. -----END CERTIFICATE-----
  46653. HARICA TLS RSA Root CA 2021
  46654. ===========================
  46655. -----BEGIN CERTIFICATE-----
  46656. MIIFpDCCA4ygAwIBAgIQOcqTHO9D88aOk8f0ZIk4fjANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQG
  46657. EwJHUjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  46658. cyBDQTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBSU0EgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTEwNTUz
  46659. OFoXDTQ1MDIxMzEwNTUzN1owbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRl
  46660. bWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgUlNB
  46661. IFJvb3QgQ0EgMjAyMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIvC569lmwVnlskN
  46662. JLnQDmT8zuIkGCyEf3dRywQRNrhe7Wlxp57kJQmXZ8FHws+RFjZiPTgE4VGC/6zStGndLuwRo0Xu
  46663. a2s7TL+MjaQenRG56Tj5eg4MmOIjHdFOY9TnuEFE+2uva9of08WRiFukiZLRgeaMOVig1mlDqa2Y
  46664. Ulhu2wr7a89o+uOkXjpFc5gH6l8Cct4MpbOfrqkdtx2z/IpZ525yZa31MJQjB/OCFks1mJxTuy/K
  46665. 5FrZx40d/JiZ+yykgmvwKh+OC19xXFyuQnspiYHLA6OZyoieC0AJQTPb5lh6/a6ZcMBaD9YThnEv
  46666. dmn8kN3bLW7R8pv1GmuebxWMevBLKKAiOIAkbDakO/IwkfN4E8/BPzWr8R0RI7VDIp4BkrcYAuUR
  46667. 0YLbFQDMYTfBKnya4dC6s1BG7oKsnTH4+yPiAwBIcKMJJnkVU2DzOFytOOqBAGMUuTNe3QvboEUH
  46668. GjMJ+E20pwKmafTCWQWIZYVWrkvL4N48fS0ayOn7H6NhStYqE613TBoYm5EPWNgGVMWX+Ko/IIqm
  46669. haZ39qb8HOLubpQzKoNQhArlT4b4UEV4AIHrW2jjJo3Me1xR9BQsQL4aYB16cmEdH2MtiKrOokWQ
  46670. CPxrvrNQKlr9qEgYRtaQQJKQCoReaDH46+0N0x3GfZkYVVYnZS6NRcUk7M7jAgMBAAGjQjBAMA8G
  46671. A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFApII6ZgpJIKM+qTW8VX6iVNvRLuMA4GA1UdDwEB/wQE
  46672. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAPpBIqm5iFSVmewzVjIuJndftTgfvnNAUX15QvWiWkKQU
  46673. EapobQk1OUAJ2vQJLDSle1mESSmXdMgHHkdt8s4cUCbjnj1AUz/3f5Z2EMVGpdAgS1D0NTsY9FVq
  46674. QRtHBmg8uwkIYtlfVUKqrFOFrJVWNlar5AWMxajaH6NpvVMPxP/cyuN+8kyIhkdGGvMA9YCRotxD
  46675. QpSbIPDRzbLrLFPCU3hKTwSUQZqPJzLB5UkZv/HywouoCjkxKLR9YjYsTewfM7Z+d21+UPCfDtcR
  46676. j88YxeMn/ibvBZ3PzzfF0HvaO7AWhAw6k9a+F9sPPg4ZeAnHqQJyIkv3N3a6dcSFA1pj1bF1BcK5
  46677. vZStjBWZp5N99sXzqnTPBIWUmAD04vnKJGW/4GKvyMX6ssmeVkjaef2WdhW+o45WxLM0/L5H9MG0
  46678. qPzVMIho7suuyWPEdr6sOBjhXlzPrjoiUevRi7PzKzMHVIf6tLITe7pTBGIBnfHAT+7hOtSLIBD6
  46679. Alfm78ELt5BGnBkpjNxvoEppaZS3JGWg/6w/zgH7IS79aPib8qXPMThcFarmlwDB31qlpzmq6YR/
  46680. PFGoOtmUW4y/Twhx5duoXNTSpv4Ao8YWxw/ogM4cKGR0GQjTQuPOAF1/sdwTsOEFy9EgqoZ0njnn
  46681. kf3/W9b3raYvAwtt41dU63ZTGI0RmLo=
  46682. -----END CERTIFICATE-----
  46683. HARICA TLS ECC Root CA 2021
  46684. ===========================
  46685. -----BEGIN CERTIFICATE-----
  46686. MIICVDCCAdugAwIBAgIQZ3SdjXfYO2rbIvT/WeK/zjAKBggqhkjOPQQDAzBsMQswCQYDVQQGEwJH
  46687. UjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBD
  46688. QTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBFQ0MgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTExMDExMFoX
  46689. DTQ1MDIxMzExMDEwOVowbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRlbWlj
  46690. IGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgRUNDIFJv
  46691. b3QgQ0EgMjAyMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDgI/rGgltJ6rK9JOtDA4MM7KKrxcm1l
  46692. AEeIhPyaJmuqS7psBAqIXhfyVYf8MLA04jRYVxqEU+kw2anylnTDUR9YSTHMmE5gEYd103KUkE+b
  46693. ECUqqHgtvpBBWJAVcqeht6NCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUyRtTgRL+BNUW
  46694. 0aq8mm+3oJUZbsowDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2cAMGQCMBHervjcToiwqfAi
  46695. rcJRQO9gcS3ujwLEXQNwSaSS6sUUiHCm0w2wqsosQJz76YJumgIwK0eaB8bRwoF8yguWGEEbo/Qw
  46696. CZ61IygNnxS2PFOiTAZpffpskcYqSUXm7LcT4Tps
  46697. -----END CERTIFICATE-----
  46698. Autoridad de Certificacion Firmaprofesional CIF A62634068
  46699. =========================================================
  46700. -----BEGIN CERTIFICATE-----
  46701. MIIGFDCCA/ygAwIBAgIIG3Dp0v+ubHEwDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCRVMxQjBA
  46702. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  46703. MjYzNDA2ODAeFw0xNDA5MjMxNTIyMDdaFw0zNjA1MDUxNTIyMDdaMFExCzAJBgNVBAYTAkVTMUIw
  46704. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  46705. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  46706. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  46707. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  46708. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  46709. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  46710. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  46711. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  46712. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  46713. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  46714. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMB0GA1Ud
  46715. DgQWBBRlzeurNR4APn7VdMActHNHDhpkLzASBgNVHRMBAf8ECDAGAQH/AgEBMIGmBgNVHSAEgZ4w
  46716. gZswgZgGBFUdIAAwgY8wLwYIKwYBBQUHAgEWI2h0dHA6Ly93d3cuZmlybWFwcm9mZXNpb25hbC5j
  46717. b20vY3BzMFwGCCsGAQUFBwICMFAeTgBQAGEAcwBlAG8AIABkAGUAIABsAGEAIABCAG8AbgBhAG4A
  46718. bwB2AGEAIAA0ADcAIABCAGEAcgBjAGUAbABvAG4AYQAgADAAOAAwADEANzAOBgNVHQ8BAf8EBAMC
  46719. AQYwDQYJKoZIhvcNAQELBQADggIBAHSHKAIrdx9miWTtj3QuRhy7qPj4Cx2Dtjqn6EWKB7fgPiDL
  46720. 4QjbEwj4KKE1soCzC1HA01aajTNFSa9J8OA9B3pFE1r/yJfY0xgsfZb43aJlQ3CTkBW6kN/oGbDb
  46721. LIpgD7dvlAceHabJhfa9NPhAeGIQcDq+fUs5gakQ1JZBu/hfHAsdCPKxsIl68veg4MSPi3i1O1il
  46722. I45PVf42O+AMt8oqMEEgtIDNrvx2ZnOorm7hfNoD6JQg5iKj0B+QXSBTFCZX2lSX3xZEEAEeiGaP
  46723. cjiT3SC3NL7X8e5jjkd5KAb881lFJWAiMxujX6i6KtoaPc1A6ozuBRWV1aUsIC+nmCjuRfzxuIgA
  46724. LI9C2lHVnOUTaHFFQ4ueCyE8S1wF3BqfmI7avSKecs2tCsvMo2ebKHTEm9caPARYpoKdrcd7b/+A
  46725. lun4jWq9GJAd/0kakFI3ky88Al2CdgtR5xbHV/g4+afNmyJU72OwFW1TZQNKXkqgsqeOSQBZONXH
  46726. 9IBk9W6VULgRfhVwOEqwf9DEMnDAGf/JOC0ULGb0QkTmVXYbgBVX/8Cnp6o5qtjTcNAuuuuUavpf
  46727. NIbnYrX9ivAwhZTJryQCL2/W3Wf+47BVTwSYT6RBVuKT0Gro1vP7ZeDOdcQxWQzugsgMYDNKGbqE
  46728. ZycPvEJdvSRUDewdcAZfpLz6IHxV
  46729. -----END CERTIFICATE-----
  46730. vTrus ECC Root CA
  46731. =================
  46732. -----BEGIN CERTIFICATE-----
  46733. MIICDzCCAZWgAwIBAgIUbmq8WapTvpg5Z6LSa6Q75m0c1towCgYIKoZIzj0EAwMwRzELMAkGA1UE
  46734. BhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xGjAYBgNVBAMTEXZUcnVzIEVDQyBS
  46735. b290IENBMB4XDTE4MDczMTA3MjY0NFoXDTQzMDczMTA3MjY0NFowRzELMAkGA1UEBhMCQ04xHDAa
  46736. BgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xGjAYBgNVBAMTEXZUcnVzIEVDQyBSb290IENBMHYw
  46737. EAYHKoZIzj0CAQYFK4EEACIDYgAEZVBKrox5lkqqHAjDo6LN/llWQXf9JpRCux3NCNtzslt188+c
  46738. ToL0v/hhJoVs1oVbcnDS/dtitN9Ti72xRFhiQgnH+n9bEOf+QP3A2MMrMudwpremIFUde4BdS49n
  46739. TPEQo0IwQDAdBgNVHQ4EFgQUmDnNvtiyjPeyq+GtJK97fKHbH88wDwYDVR0TAQH/BAUwAwEB/zAO
  46740. BgNVHQ8BAf8EBAMCAQYwCgYIKoZIzj0EAwMDaAAwZQIwV53dVvHH4+m4SVBrm2nDb+zDfSXkV5UT
  46741. QJtS0zvzQBm8JsctBp61ezaf9SXUY2sAAjEA6dPGnlaaKsyh2j/IZivTWJwghfqrkYpwcBE4YGQL
  46742. YgmRWAD5Tfs0aNoJrSEGGJTO
  46743. -----END CERTIFICATE-----
  46744. vTrus Root CA
  46745. =============
  46746. -----BEGIN CERTIFICATE-----
  46747. MIIFVjCCAz6gAwIBAgIUQ+NxE9izWRRdt86M/TX9b7wFjUUwDQYJKoZIhvcNAQELBQAwQzELMAkG
  46748. A1UEBhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xFjAUBgNVBAMTDXZUcnVzIFJv
  46749. b3QgQ0EwHhcNMTgwNzMxMDcyNDA1WhcNNDMwNzMxMDcyNDA1WjBDMQswCQYDVQQGEwJDTjEcMBoG
  46750. A1UEChMTaVRydXNDaGluYSBDby4sTHRkLjEWMBQGA1UEAxMNdlRydXMgUm9vdCBDQTCCAiIwDQYJ
  46751. KoZIhvcNAQEBBQADggIPADCCAgoCggIBAL1VfGHTuB0EYgWgrmy3cLRB6ksDXhA/kFocizuwZots
  46752. SKYcIrrVQJLuM7IjWcmOvFjai57QGfIvWcaMY1q6n6MLsLOaXLoRuBLpDLvPbmyAhykUAyyNJJrI
  46753. ZIO1aqwTLDPxn9wsYTwaP3BVm60AUn/PBLn+NvqcwBauYv6WTEN+VRS+GrPSbcKvdmaVayqwlHeF
  46754. XgQPYh1jdfdr58tbmnDsPmcF8P4HCIDPKNsFxhQnL4Z98Cfe/+Z+M0jnCx5Y0ScrUw5XSmXX+6KA
  46755. YPxMvDVTAWqXcoKv8R1w6Jz1717CbMdHflqUhSZNO7rrTOiwCcJlwp2dCZtOtZcFrPUGoPc2BX70
  46756. kLJrxLT5ZOrpGgrIDajtJ8nU57O5q4IikCc9Kuh8kO+8T/3iCiSn3mUkpF3qwHYw03dQ+A0Em5Q2
  46757. AXPKBlim0zvc+gRGE1WKyURHuFE5Gi7oNOJ5y1lKCn+8pu8fA2dqWSslYpPZUxlmPCdiKYZNpGvu
  46758. /9ROutW04o5IWgAZCfEF2c6Rsffr6TlP9m8EQ5pV9T4FFL2/s1m02I4zhKOQUqqzApVg+QxMaPnu
  46759. 1RcN+HFXtSXkKe5lXa/R7jwXC1pDxaWG6iSe4gUH3DRCEpHWOXSuTEGC2/KmSNGzm/MzqvOmwMVO
  46760. 9fSddmPmAsYiS8GVP1BkLFTltvA8Kc9XAgMBAAGjQjBAMB0GA1UdDgQWBBRUYnBj8XWEQ1iO0RYg
  46761. scasGrz2iTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOC
  46762. AgEAKbqSSaet8PFww+SX8J+pJdVrnjT+5hpk9jprUrIQeBqfTNqK2uwcN1LgQkv7bHbKJAs5EhWd
  46763. nxEt/Hlk3ODg9d3gV8mlsnZwUKT+twpw1aA08XXXTUm6EdGz2OyC/+sOxL9kLX1jbhd47F18iMjr
  46764. jld22VkE+rxSH0Ws8HqA7Oxvdq6R2xCOBNyS36D25q5J08FsEhvMKar5CKXiNxTKsbhm7xqC5PD4
  46765. 8acWabfbqWE8n/Uxy+QARsIvdLGx14HuqCaVvIivTDUHKgLKeBRtRytAVunLKmChZwOgzoy8sHJn
  46766. xDHO2zTlJQNgJXtxmOTAGytfdELSS8VZCAeHvsXDf+eW2eHcKJfWjwXj9ZtOyh1QRwVTsMo554Wg
  46767. icEFOwE30z9J4nfrI8iIZjs9OXYhRvHsXyO466JmdXTBQPfYaJqT4i2pLr0cox7IdMakLXogqzu4
  46768. sEb9b91fUlV1YvCXoHzXOP0l382gmxDPi7g4Xl7FtKYCNqEeXxzP4padKar9mK5S4fNBUvupLnKW
  46769. nyfjqnN9+BojZns7q2WwMgFLFT49ok8MKzWixtlnEjUwzXYuFrOZnk1PTi07NEPhmg4NpGaXutIc
  46770. SkwsKouLgU9xGqndXHt7CMUADTdA43x7VF8vhV929vensBxXVsFy6K2ir40zSbofitzmdHxghm+H
  46771. l3s=
  46772. -----END CERTIFICATE-----
  46773. ISRG Root X2
  46774. ============
  46775. -----BEGIN CERTIFICATE-----
  46776. MIICGzCCAaGgAwIBAgIQQdKd0XLq7qeAwSxs6S+HUjAKBggqhkjOPQQDAzBPMQswCQYDVQQGEwJV
  46777. UzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElT
  46778. UkcgUm9vdCBYMjAeFw0yMDA5MDQwMDAwMDBaFw00MDA5MTcxNjAwMDBaME8xCzAJBgNVBAYTAlVT
  46779. MSkwJwYDVQQKEyBJbnRlcm5ldCBTZWN1cml0eSBSZXNlYXJjaCBHcm91cDEVMBMGA1UEAxMMSVNS
  46780. RyBSb290IFgyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEzZvVn4CDCuwJSvMWSj5cz3es3mcFDR0H
  46781. ttwW+1qLFNvicWDEukWVEYmO6gbf9yoWHKS5xcUy4APgHoIYOIvXRdgKam7mAHf7AlF9ItgKbppb
  46782. d9/w+kHsOdx1ymgHDB/qo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV
  46783. HQ4EFgQUfEKWrt5LSDv6kviejM9ti6lyN5UwCgYIKoZIzj0EAwMDaAAwZQIwe3lORlCEwkSHRhtF
  46784. cP9Ymd70/aTSVaYgLXTWNLxBo1BfASdWtL4ndQavEi51mI38AjEAi/V3bNTIZargCyzuFJ0nN6T5
  46785. U6VR5CmD1/iQMVtCnwr1/q4AaOeMSQ+2b1tbFfLn
  46786. -----END CERTIFICATE-----
  46787. HiPKI Root CA - G1
  46788. ==================
  46789. -----BEGIN CERTIFICATE-----
  46790. MIIFajCCA1KgAwIBAgIQLd2szmKXlKFD6LDNdmpeYDANBgkqhkiG9w0BAQsFADBPMQswCQYDVQQG
  46791. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xGzAZBgNVBAMMEkhpUEtJ
  46792. IFJvb3QgQ0EgLSBHMTAeFw0xOTAyMjIwOTQ2MDRaFw0zNzEyMzExNTU5NTlaME8xCzAJBgNVBAYT
  46793. AlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEbMBkGA1UEAwwSSGlQS0kg
  46794. Um9vdCBDQSAtIEcxMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA9B5/UnMyDHPkvRN0
  46795. o9QwqNCuS9i233VHZvR85zkEHmpwINJaR3JnVfSl6J3VHiGh8Ge6zCFovkRTv4354twvVcg3Px+k
  46796. wJyz5HdcoEb+d/oaoDjq7Zpy3iu9lFc6uux55199QmQ5eiY29yTw1S+6lZgRZq2XNdZ1AYDgr/SE
  46797. YYwNHl98h5ZeQa/rh+r4XfEuiAU+TCK72h8q3VJGZDnzQs7ZngyzsHeXZJzA9KMuH5UHsBffMNsA
  46798. GJZMoYFL3QRtU6M9/Aes1MU3guvklQgZKILSQjqj2FPseYlgSGDIcpJQ3AOPgz+yQlda22rpEZfd
  46799. hSi8MEyr48KxRURHH+CKFgeW0iEPU8DtqX7UTuybCeyvQqww1r/REEXgphaypcXTT3OUM3ECoWqj
  46800. 1jOXTyFjHluP2cFeRXF3D4FdXyGarYPM+l7WjSNfGz1BryB1ZlpK9p/7qxj3ccC2HTHsOyDry+K4
  46801. 9a6SsvfhhEvyovKTmiKe0xRvNlS9H15ZFblzqMF8b3ti6RZsR1pl8w4Rm0bZ/W3c1pzAtH2lsN0/
  46802. Vm+h+fbkEkj9Bn8SV7apI09bA8PgcSojt/ewsTu8mL3WmKgMa/aOEmem8rJY5AIJEzypuxC00jBF
  46803. 8ez3ABHfZfjcK0NVvxaXxA/VLGGEqnKG/uY6fsI/fe78LxQ+5oXdUG+3Se0CAwEAAaNCMEAwDwYD
  46804. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU8ncX+l6o/vY9cdVouslGDDjYr7AwDgYDVR0PAQH/BAQD
  46805. AgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBQUfB13HAE4/+qddRxosuej6ip0691x1TPOhwEmSKsxBHi
  46806. 7zNKpiMdDg1H2DfHb680f0+BazVP6XKlMeJ45/dOlBhbQH3PayFUhuaVevvGyuqcSE5XCV0vrPSl
  46807. tJczWNWseanMX/mF+lLFjfiRFOs6DRfQUsJ748JzjkZ4Bjgs6FzaZsT0pPBWGTMpWmWSBUdGSquE
  46808. wx4noR8RkpkndZMPvDY7l1ePJlsMu5wP1G4wB9TcXzZoZjmDlicmisjEOf6aIW/Vcobpf2Lll07Q
  46809. JNBAsNB1CI69aO4I1258EHBGG3zgiLKecoaZAeO/n0kZtCW+VmWuF2PlHt/o/0elv+EmBYTksMCv
  46810. 5wiZqAxeJoBF1PhoL5aPruJKHJwWDBNvOIf2u8g0X5IDUXlwpt/L9ZlNec1OvFefQ05rLisY+Gpz
  46811. jLrFNe85akEez3GoorKGB1s6yeHvP2UEgEcyRHCVTjFnanRbEEV16rCf0OY1/k6fi8wrkkVbbiVg
  46812. hUbN0aqwdmaTd5a+g744tiROJgvM7XpWGuDpWsZkrUx6AEhEL7lAuxM+vhV4nYWBSipX3tUZQ9rb
  46813. yltHhoMLP7YNdnhzeSJesYAfz77RP1YQmCuVh6EfnWQUYDksswBVLuT1sw5XxJFBAJw/6KXf6vb/
  46814. yPCtbVKoF6ubYfwSUTXkJf2vqmqGOQ==
  46815. -----END CERTIFICATE-----
  46816. GlobalSign ECC Root CA - R4
  46817. ===========================
  46818. -----BEGIN CERTIFICATE-----
  46819. MIIB3DCCAYOgAwIBAgINAgPlfvU/k/2lCSGypjAKBggqhkjOPQQDAjBQMSQwIgYDVQQLExtHbG9i
  46820. YWxTaWduIEVDQyBSb290IENBIC0gUjQxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  46821. b2JhbFNpZ24wHhcNMTIxMTEzMDAwMDAwWhcNMzgwMTE5MDMxNDA3WjBQMSQwIgYDVQQLExtHbG9i
  46822. YWxTaWduIEVDQyBSb290IENBIC0gUjQxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  46823. b2JhbFNpZ24wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAS4xnnTj2wlDp8uORkcA6SumuU5BwkW
  46824. ymOxuYb4ilfBV85C+nOh92VC/x7BALJucw7/xyHlGKSq2XE/qNS5zowdo0IwQDAOBgNVHQ8BAf8E
  46825. BAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVLB7rUW44kB/+wpu+74zyTyjhNUwCgYI
  46826. KoZIzj0EAwIDRwAwRAIgIk90crlgr/HmnKAWBVBfw147bmF0774BxL4YSFlhgjICICadVGNA3jdg
  46827. UM/I2O2dgq43mLyjj0xMqTQrbO/7lZsm
  46828. -----END CERTIFICATE-----
  46829. GTS Root R1
  46830. ===========
  46831. -----BEGIN CERTIFICATE-----
  46832. MIIFVzCCAz+gAwIBAgINAgPlk28xsBNJiGuiFzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQGEwJV
  46833. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  46834. UjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  46835. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIiMA0G
  46836. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx9vaM
  46837. f/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7wCl7raKb0
  46838. xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjwTcLCeoiKu7rPWRnWr4+w
  46839. B7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0PfyblqAj+lug8aJRT7oM6iCsVlgmy4HqMLnXW
  46840. nOunVmSPlk9orj2XwoSPwLxAwAtcvfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly4cpk
  46841. 9+aCEI3oncKKiPo4Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr06zq
  46842. kUspzBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92wO1A
  46843. K/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70paDPvOmbsB4om3xPX
  46844. V2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrNVjzRlwW5y0vtOUucxD/SVRNuJLDW
  46845. cfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0T
  46846. AQH/BAUwAwEB/zAdBgNVHQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEMBQAD
  46847. ggIBAJ+qQibbC5u+/x6Wki4+omVKapi6Ist9wTrYggoGxval3sBOh2Z5ofmmWJyq+bXmYOfg6LEe
  46848. QkEzCzc9zolwFcq1JKjPa7XSQCGYzyI0zzvFIoTgxQ6KfF2I5DUkzps+GlQebtuyh6f88/qBVRRi
  46849. ClmpIgUxPoLW7ttXNLwzldMXG+gnoot7TiYaelpkttGsN/H9oPM47HLwEXWdyzRSjeZ2axfG34ar
  46850. J45JK3VmgRAhpuo+9K4l/3wV3s6MJT/KYnAK9y8JZgfIPxz88NtFMN9iiMG1D53Dn0reWVlHxYci
  46851. NuaCp+0KueIHoI17eko8cdLiA6EfMgfdG+RCzgwARWGAtQsgWSl4vflVy2PFPEz0tv/bal8xa5me
  46852. LMFrUKTX5hgUvYU/Z6tGn6D/Qqc6f1zLXbBwHSs09dR2CQzreExZBfMzQsNhFRAbd03OIozUhfJF
  46853. fbdT6u9AWpQKXCBfTkBdYiJ23//OYb2MI3jSNwLgjt7RETeJ9r/tSQdirpLsQBqvFAnZ0E6yove+
  46854. 7u7Y/9waLd64NnHi/Hm3lCXRSHNboTXns5lndcEZOitHTtNCjv0xyBZm2tIMPNuzjsmhDYAPexZ3
  46855. FL//2wmUspO8IFgV6dtxQ/PeEMMA3KgqlbbC1j+Qa3bbbP6MvPJwNQzcmRk13NfIRmPVNnGuV/u3
  46856. gm3c
  46857. -----END CERTIFICATE-----
  46858. GTS Root R2
  46859. ===========
  46860. -----BEGIN CERTIFICATE-----
  46861. MIIFVzCCAz+gAwIBAgINAgPlrsWNBCUaqxElqjANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQGEwJV
  46862. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  46863. UjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  46864. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIiMA0G
  46865. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTukk3Lv
  46866. CvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3KgGjSY6Dlo7JUl
  46867. e3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9BuXvAuMC6C/Pq8tBcKSOWIm8Wb
  46868. a96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOdre7kRXuJVfeKH2JShBKzwkCX44ofR5GmdFrS
  46869. +LFjKBC4swm4VndAoiaYecb+3yXuPuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbuak7M
  46870. kogwTZq9TwtImoS1mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscszcTJG
  46871. r61K8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqjx5RWIr9q
  46872. S34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z+2et1VsRnTKaG73VululycslaVNV
  46873. J1zgyjbLiGH7HrfQy+4W+9OmTN6SpdTi3/UGVN4unUu0kzCqgc7dGtxRcw1PcOnlthYhGXmy5okL
  46874. dWTK1au8CcEYof/UVKGFPP0UJAOyh9OktwIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0T
  46875. AQH/BAUwAwEB/zAdBgNVHQ4EFgQUu//KjiOfT5nK2+JopqUVJxce2Q4wDQYJKoZIhvcNAQEMBQAD
  46876. ggIBAB/Kzt3HvqGf2SdMC9wXmBFqiN495nFWcrKeGk6c1SuYJF2ba3uwM4IJvd8lRuqYnrYb/oM8
  46877. 0mJhwQTtzuDFycgTE1XnqGOtjHsB/ncw4c5omwX4Eu55MaBBRTUoCnGkJE+M3DyCB19m3H0Q/gxh
  46878. swWV7uGugQ+o+MePTagjAiZrHYNSVc61LwDKgEDg4XSsYPWHgJ2uNmSRXbBoGOqKYcl3qJfEycel
  46879. /FVL8/B/uWU9J2jQzGv6U53hkRrJXRqWbTKH7QMgyALOWr7Z6v2yTcQvG99fevX4i8buMTolUVVn
  46880. jWQye+mew4K6Ki3pHrTgSAai/GevHyICc/sgCq+dVEuhzf9gR7A/Xe8bVr2XIZYtCtFenTgCR2y5
  46881. 9PYjJbigapordwj6xLEokCZYCDzifqrXPW+6MYgKBesntaFJ7qBFVHvmJ2WZICGoo7z7GJa7Um8M
  46882. 7YNRTOlZ4iBgxcJlkoKM8xAfDoqXvneCbT+PHV28SSe9zE8P4c52hgQjxcCMElv924SgJPFI/2R8
  46883. 0L5cFtHvma3AH/vLrrw4IgYmZNralw4/KBVEqE8AyvCazM90arQ+POuV7LXTWtiBmelDGDfrs7vR
  46884. WGJB82bSj6p4lVQgw1oudCvV0b4YacCs1aTPObpRhANl6WLAYv7YTVWW4tAR+kg0Eeye7QUd5MjW
  46885. HYbL
  46886. -----END CERTIFICATE-----
  46887. GTS Root R3
  46888. ===========
  46889. -----BEGIN CERTIFICATE-----
  46890. MIICCTCCAY6gAwIBAgINAgPluILrIPglJ209ZjAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJVUzEi
  46891. MCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMw
  46892. HhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZ
  46893. R29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcqhkjO
  46894. PQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUURout
  46895. 736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24CejQjBA
  46896. MA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP0/Eq
  46897. Er24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEA9uEglRR7VKOQFhG/hMjqb2sXnh5GmCCbn9MN2azT
  46898. L818+FsuVbu/3ZL3pAzcMeGiAjEA/JdmZuVDFhOD3cffL74UOO0BzrEXGhF16b0DjyZ+hOXJYKaV
  46899. 11RZt+cRLInUue4X
  46900. -----END CERTIFICATE-----
  46901. GTS Root R4
  46902. ===========
  46903. -----BEGIN CERTIFICATE-----
  46904. MIICCTCCAY6gAwIBAgINAgPlwGjvYxqccpBQUjAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJVUzEi
  46905. MCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQw
  46906. HhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZ
  46907. R29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcqhkjO
  46908. PQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa6zzu
  46909. hXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqjQjBA
  46910. MA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV2Py1
  46911. PsVq8JQdjDAKBggqhkjOPQQDAwNpADBmAjEA6ED/g94D9J+uHXqnLrmvT/aDHQ4thQEd0dlq7A/C
  46912. r8deVl5c1RxYIigL9zC2L7F8AjEA8GE8p/SgguMh1YQdc4acLa/KNJvxn7kjNuK8YAOdgLOaVsjh
  46913. 4rsUecrNIdSUtUlD
  46914. -----END CERTIFICATE-----
  46915. Telia Root CA v2
  46916. ================
  46917. -----BEGIN CERTIFICATE-----
  46918. MIIFdDCCA1ygAwIBAgIPAWdfJ9b+euPkrL4JWwWeMA0GCSqGSIb3DQEBCwUAMEQxCzAJBgNVBAYT
  46919. AkZJMRowGAYDVQQKDBFUZWxpYSBGaW5sYW5kIE95ajEZMBcGA1UEAwwQVGVsaWEgUm9vdCBDQSB2
  46920. MjAeFw0xODExMjkxMTU1NTRaFw00MzExMjkxMTU1NTRaMEQxCzAJBgNVBAYTAkZJMRowGAYDVQQK
  46921. DBFUZWxpYSBGaW5sYW5kIE95ajEZMBcGA1UEAwwQVGVsaWEgUm9vdCBDQSB2MjCCAiIwDQYJKoZI
  46922. hvcNAQEBBQADggIPADCCAgoCggIBALLQPwe84nvQa5n44ndp586dpAO8gm2h/oFlH0wnrI4AuhZ7
  46923. 6zBqAMCzdGh+sq/H1WKzej9Qyow2RCRj0jbpDIX2Q3bVTKFgcmfiKDOlyzG4OiIjNLh9vVYiQJ3q
  46924. 9HsDrWj8soFPmNB06o3lfc1jw6P23pLCWBnglrvFxKk9pXSW/q/5iaq9lRdU2HhE8Qx3FZLgmEKn
  46925. pNaqIJLNwaCzlrI6hEKNfdWV5Nbb6WLEWLN5xYzTNTODn3WhUidhOPFZPY5Q4L15POdslv5e2QJl
  46926. tI5c0BE0312/UqeBAMN/mUWZFdUXyApT7GPzmX3MaRKGwhfwAZ6/hLzRUssbkmbOpFPlob/E2wnW
  46927. 5olWK8jjfN7j/4nlNW4o6GwLI1GpJQXrSPjdscr6bAhR77cYbETKJuFzxokGgeWKrLDiKca5JLNr
  46928. RBH0pUPCTEPlcDaMtjNXepUugqD0XBCzYYP2AgWGLnwtbNwDRm41k9V6lS/eINhbfpSQBGq6WT0E
  46929. BXWdN6IOLj3rwaRSg/7Qa9RmjtzG6RJOHSpXqhC8fF6CfaamyfItufUXJ63RDolUK5X6wK0dmBR4
  46930. M0KGCqlztft0DbcbMBnEWg4cJ7faGND/isgFuvGqHKI3t+ZIpEYslOqodmJHixBTB0hXbOKSTbau
  46931. BcvcwUpej6w9GU7C7WB1K9vBykLVAgMBAAGjYzBhMB8GA1UdIwQYMBaAFHKs5DN5qkWH9v2sHZ7W
  46932. xy+G2CQ5MB0GA1UdDgQWBBRyrOQzeapFh/b9rB2e1scvhtgkOTAOBgNVHQ8BAf8EBAMCAQYwDwYD
  46933. VR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAoDtZpwmUPjaE0n4vOaWWl/oRrfxn83EJ
  46934. 8rKJhGdEr7nv7ZbsnGTbMjBvZ5qsfl+yqwE2foH65IRe0qw24GtixX1LDoJt0nZi0f6X+J8wfBj5
  46935. tFJ3gh1229MdqfDBmgC9bXXYfef6xzijnHDoRnkDry5023X4blMMA8iZGok1GTzTyVR8qPAs5m4H
  46936. eW9q4ebqkYJpCh3DflminmtGFZhb069GHWLIzoBSSRE/yQQSwxN8PzuKlts8oB4KtItUsiRnDe+C
  46937. y748fdHif64W1lZYudogsYMVoe+KTTJvQS8TUoKU1xrBeKJR3Stwbbca+few4GeXVtt8YVMJAygC
  46938. QMez2P2ccGrGKMOF6eLtGpOg3kuYooQ+BXcBlj37tCAPnHICehIv1aO6UXivKitEZU61/Qrowc15
  46939. h2Er3oBXRb9n8ZuRXqWk7FlIEA04x7D6w0RtBPV4UBySllva9bguulvP5fBqnUsvWHMtTy3EHD70
  46940. sz+rFQ47GUGKpMFXEmZxTPpT41frYpUJnlTd0cI8Vzy9OK2YZLe4A5pTVmBds9hCG1xLEooc6+t9
  46941. xnppxyd/pPiL8uSUZodL6ZQHCRJ5irLrdATczvREWeAWysUsWNc8e89ihmpQfTU2Zqf7N+cox9jQ
  46942. raVplI/owd8k+BsHMYeB2F326CjYSlKArBPuUBQemMc=
  46943. -----END CERTIFICATE-----
  46944. D-TRUST BR Root CA 1 2020
  46945. =========================
  46946. -----BEGIN CERTIFICATE-----
  46947. MIIC2zCCAmCgAwIBAgIQfMmPK4TX3+oPyWWa00tNljAKBggqhkjOPQQDAzBIMQswCQYDVQQGEwJE
  46948. RTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEJSIFJvb3QgQ0EgMSAy
  46949. MDIwMB4XDTIwMDIxMTA5NDUwMFoXDTM1MDIxMTA5NDQ1OVowSDELMAkGA1UEBhMCREUxFTATBgNV
  46950. BAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBCUiBSb290IENBIDEgMjAyMDB2MBAG
  46951. ByqGSM49AgEGBSuBBAAiA2IABMbLxyjR+4T1mu9CFCDhQ2tuda38KwOE1HaTJddZO0Flax7mNCq7
  46952. dPYSzuht56vkPE4/RAiLzRZxy7+SmfSk1zxQVFKQhYN4lGdnoxwJGT11NIXe7WB9xwy0QVK5buXu
  46953. QqOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFHOREKv/VbNafAkl1bK6CKBrqx9t
  46954. MA4GA1UdDwEB/wQEAwIBBjCBxgYDVR0fBIG+MIG7MD6gPKA6hjhodHRwOi8vY3JsLmQtdHJ1c3Qu
  46955. bmV0L2NybC9kLXRydXN0X2JyX3Jvb3RfY2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVj
  46956. dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwQlIlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxP
  46957. PUQtVHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjOPQQD
  46958. AwNpADBmAjEAlJAtE/rhY/hhY+ithXhUkZy4kzg+GkHaQBZTQgjKL47xPoFWwKrY7RjEsK70Pvom
  46959. AjEA8yjixtsrmfu3Ubgko6SUeho/5jbiA1czijDLgsfWFBHVdWNbFJWcHwHP2NVypw87
  46960. -----END CERTIFICATE-----
  46961. D-TRUST EV Root CA 1 2020
  46962. =========================
  46963. -----BEGIN CERTIFICATE-----
  46964. MIIC2zCCAmCgAwIBAgIQXwJB13qHfEwDo6yWjfv/0DAKBggqhkjOPQQDAzBIMQswCQYDVQQGEwJE
  46965. RTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEVWIFJvb3QgQ0EgMSAy
  46966. MDIwMB4XDTIwMDIxMTEwMDAwMFoXDTM1MDIxMTA5NTk1OVowSDELMAkGA1UEBhMCREUxFTATBgNV
  46967. BAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBFViBSb290IENBIDEgMjAyMDB2MBAG
  46968. ByqGSM49AgEGBSuBBAAiA2IABPEL3YZDIBnfl4XoIkqbz52Yv7QFJsnL46bSj8WeeHsxiamJrSc8
  46969. ZRCC/N/DnU7wMyPE0jL1HLDfMxddxfCxivnvubcUyilKwg+pf3VlSSowZ/Rk99Yad9rDwpdhQntJ
  46970. raOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFH8QARY3OqQo5FD4pPfsazK2/umL
  46971. MA4GA1UdDwEB/wQEAwIBBjCBxgYDVR0fBIG+MIG7MD6gPKA6hjhodHRwOi8vY3JsLmQtdHJ1c3Qu
  46972. bmV0L2NybC9kLXRydXN0X2V2X3Jvb3RfY2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVj
  46973. dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwRVYlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxP
  46974. PUQtVHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjOPQQD
  46975. AwNpADBmAjEAyjzGKnXCXnViOTYAYFqLwZOZzNnbQTs7h5kXO9XMT8oi96CAy/m0sRtW9XLS/BnR
  46976. AjEAkfcwkz8QRitxpNA7RJvAKQIFskF3UfN5Wp6OFKBOQtJbgfM0agPnIjhQW+0ZT0MW
  46977. -----END CERTIFICATE-----
  46978. DigiCert TLS ECC P384 Root G5
  46979. =============================
  46980. -----BEGIN CERTIFICATE-----
  46981. MIICGTCCAZ+gAwIBAgIQCeCTZaz32ci5PhwLBCou8zAKBggqhkjOPQQDAzBOMQswCQYDVQQGEwJV
  46982. UzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJjAkBgNVBAMTHURpZ2lDZXJ0IFRMUyBFQ0MgUDM4
  46983. NCBSb290IEc1MB4XDTIxMDExNTAwMDAwMFoXDTQ2MDExNDIzNTk1OVowTjELMAkGA1UEBhMCVVMx
  46984. FzAVBgNVBAoTDkRpZ2lDZXJ0LCBJbmMuMSYwJAYDVQQDEx1EaWdpQ2VydCBUTFMgRUNDIFAzODQg
  46985. Um9vdCBHNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABMFEoc8Rl1Ca3iOCNQfN0MsYndLxf3c1Tzvd
  46986. lHJS7cI7+Oz6e2tYIOyZrsn8aLN1udsJ7MgT9U7GCh1mMEy7H0cKPGEQQil8pQgO4CLp0zVozptj
  46987. n4S1mU1YoI71VOeVyaNCMEAwHQYDVR0OBBYEFMFRRVBZqz7nLFr6ICISB4CIfBFqMA4GA1UdDwEB
  46988. /wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQCJao1H5+z8blUD2Wds
  46989. Jk6Dxv3J+ysTvLd6jLRl0mlpYxNjOyZQLgGheQaRnUi/wr4CMEfDFXuxoJGZSZOoPHzoRgaLLPIx
  46990. AJSdYsiJvRmEFOml+wG4DXZDjC5Ty3zfDBeWUA==
  46991. -----END CERTIFICATE-----
  46992. DigiCert TLS RSA4096 Root G5
  46993. ============================
  46994. -----BEGIN CERTIFICATE-----
  46995. MIIFZjCCA06gAwIBAgIQCPm0eKj6ftpqMzeJ3nzPijANBgkqhkiG9w0BAQwFADBNMQswCQYDVQQG
  46996. EwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJTAjBgNVBAMTHERpZ2lDZXJ0IFRMUyBSU0E0
  46997. MDk2IFJvb3QgRzUwHhcNMjEwMTE1MDAwMDAwWhcNNDYwMTE0MjM1OTU5WjBNMQswCQYDVQQGEwJV
  46998. UzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJTAjBgNVBAMTHERpZ2lDZXJ0IFRMUyBSU0E0MDk2
  46999. IFJvb3QgRzUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz0PTJeRGd/fxmgefM1eS8
  47000. 7IE+ajWOLrfn3q/5B03PMJ3qCQuZvWxX2hhKuHisOjmopkisLnLlvevxGs3npAOpPxG02C+JFvuU
  47001. AT27L/gTBaF4HI4o4EXgg/RZG5Wzrn4DReW+wkL+7vI8toUTmDKdFqgpwgscONyfMXdcvyej/Ces
  47002. tyu9dJsXLfKB2l2w4SMXPohKEiPQ6s+d3gMXsUJKoBZMpG2T6T867jp8nVid9E6P/DsjyG244gXa
  47003. zOvswzH016cpVIDPRFtMbzCe88zdH5RDnU1/cHAN1DrRN/BsnZvAFJNY781BOHW8EwOVfH/jXOnV
  47004. DdXifBBiqmvwPXbzP6PosMH976pXTayGpxi0KcEsDr9kvimM2AItzVwv8n/vFfQMFawKsPHTDU9q
  47005. TXeXAaDxZre3zu/O7Oyldcqs4+Fj97ihBMi8ez9dLRYiVu1ISf6nL3kwJZu6ay0/nTvEF+cdLvvy
  47006. z6b84xQslpghjLSR6Rlgg/IwKwZzUNWYOwbpx4oMYIwo+FKbbuH2TbsGJJvXKyY//SovcfXWJL5/
  47007. MZ4PbeiPT02jP/816t9JXkGPhvnxd3lLG7SjXi/7RgLQZhNeXoVPzthwiHvOAbWWl9fNff2C+MIk
  47008. wcoBOU+NosEUQB+cZtUMCUbW8tDRSHZWOkPLtgoRObqME2wGtZ7P6wIDAQABo0IwQDAdBgNVHQ4E
  47009. FgQUUTMc7TZArxfTJc1paPKvTiM+s0EwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8w
  47010. DQYJKoZIhvcNAQEMBQADggIBAGCmr1tfV9qJ20tQqcQjNSH/0GEwhJG3PxDPJY7Jv0Y02cEhJhxw
  47011. GXIeo8mH/qlDZJY6yFMECrZBu8RHANmfGBg7sg7zNOok992vIGCukihfNudd5N7HPNtQOa27PShN
  47012. lnx2xlv0wdsUpasZYgcYQF+Xkdycx6u1UQ3maVNVzDl92sURVXLFO4uJ+DQtpBflF+aZfTCIITfN
  47013. MBc9uPK8qHWgQ9w+iUuQrm0D4ByjoJYJu32jtyoQREtGBzRj7TG5BO6jm5qu5jF49OokYTurWGT/
  47014. u4cnYiWB39yhL/btp/96j1EuMPikAdKFOV8BmZZvWltwGUb+hmA+rYAQCd05JS9Yf7vSdPD3Rh9G
  47015. OUrYU9DzLjtxpdRv/PNn5AeP3SYZ4Y1b+qOTEZvpyDrDVWiakuFSdjjo4bq9+0/V77PnSIMx8IIh
  47016. 47a+p6tv75/fTM8BuGJqIz3nCU2AG3swpMPdB380vqQmsvZB6Akd4yCYqjdP//fx4ilwMUc/dNAU
  47017. FvohigLVigmUdy7yWSiLfFCSCmZ4OIN1xLVaqBHG5cGdZlXPU8Sv13WFqUITVuwhd4GTWgzqltlJ
  47018. yqEI8pc7bZsEGCREjnwB8twl2F6GmrE52/WRMmrRpnCKovfepEWFJqgejF0pW8hL2JpqA15w8oVP
  47019. bEtoL8pU9ozaMv7Da4M/OMZ+
  47020. -----END CERTIFICATE-----
  47021. Certainly Root R1
  47022. =================
  47023. -----BEGIN CERTIFICATE-----
  47024. MIIFRzCCAy+gAwIBAgIRAI4P+UuQcWhlM1T01EQ5t+AwDQYJKoZIhvcNAQELBQAwPTELMAkGA1UE
  47025. BhMCVVMxEjAQBgNVBAoTCUNlcnRhaW5seTEaMBgGA1UEAxMRQ2VydGFpbmx5IFJvb3QgUjEwHhcN
  47026. MjEwNDAxMDAwMDAwWhcNNDYwNDAxMDAwMDAwWjA9MQswCQYDVQQGEwJVUzESMBAGA1UEChMJQ2Vy
  47027. dGFpbmx5MRowGAYDVQQDExFDZXJ0YWlubHkgUm9vdCBSMTCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  47028. ADCCAgoCggIBANA21B/q3avk0bbm+yLA3RMNansiExyXPGhjZjKcA7WNpIGD2ngwEc/csiu+kr+O
  47029. 5MQTvqRoTNoCaBZ0vrLdBORrKt03H2As2/X3oXyVtwxwhi7xOu9S98zTm/mLvg7fMbedaFySpvXl
  47030. 8wo0tf97ouSHocavFwDvA5HtqRxOcT3Si2yJ9HiG5mpJoM610rCrm/b01C7jcvk2xusVtyWMOvwl
  47031. DbMicyF0yEqWYZL1LwsYpfSt4u5BvQF5+paMjRcCMLT5r3gajLQ2EBAHBXDQ9DGQilHFhiZ5shGI
  47032. XsXwClTNSaa/ApzSRKft43jvRl5tcdF5cBxGX1HpyTfcX35pe0HfNEXgO4T0oYoKNp43zGJS4YkN
  47033. KPl6I7ENPT2a/Z2B7yyQwHtETrtJ4A5KVpK8y7XdeReJkd5hiXSSqOMyhb5OhaRLWcsrxXiOcVTQ
  47034. AjeZjOVJ6uBUcqQRBi8LjMFbvrWhsFNunLhgkR9Za/kt9JQKl7XsxXYDVBtlUrpMklZRNaBA2Cnb
  47035. rlJ2Oy0wQJuK0EJWtLeIAaSHO1OWzaMWj/Nmqhexx2DgwUMFDO6bW2BvBlyHWyf5QBGenDPBt+U1
  47036. VwV/J84XIIwc/PH72jEpSe31C4SnT8H2TsIonPru4K8H+zMReiFPCyEQtkA6qyI6BJyLm4SGcprS
  47037. p6XEtHWRqSsjAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud
  47038. DgQWBBTgqj8ljZ9EXME66C6ud0yEPmcM9DANBgkqhkiG9w0BAQsFAAOCAgEAuVevuBLaV4OPaAsz
  47039. HQNTVfSVcOQrPbA56/qJYv331hgELyE03fFo8NWWWt7CgKPBjcZq91l3rhVkz1t5BXdm6ozTaw3d
  47040. 8VkswTOlMIAVRQdFGjEitpIAq5lNOo93r6kiyi9jyhXWx8bwPWz8HA2YEGGeEaIi1wrykXprOQ4v
  47041. MMM2SZ/g6Q8CRFA3lFV96p/2O7qUpUzpvD5RtOjKkjZUbVwlKNrdrRT90+7iIgXr0PK3aBLXWopB
  47042. GsaSpVo7Y0VPv+E6dyIvXL9G+VoDhRNCX8reU9ditaY1BMJH/5n9hN9czulegChB8n3nHpDYT3Y+
  47043. gjwN/KUD+nsa2UUeYNrEjvn8K8l7lcUq/6qJ34IxD3L/DCfXCh5WAFAeDJDBlrXYFIW7pw0WwfgH
  47044. JBu6haEaBQmAupVjyTrsJZ9/nbqkRxWbRHDxakvWOF5D8xh+UG7pWijmZeZ3Gzr9Hb4DJqPb1OG7
  47045. fpYnKx3upPvaJVQTA945xsMfTZDsjxtK0hzthZU4UHlG1sGQUDGpXJpuHfUzVounmdLyyCwzk5Iw
  47046. x06MZTMQZBf9JBeW0Y3COmor6xOLRPIh80oat3df1+2IpHLlOR+Vnb5nwXARPbv0+Em34yaXOp/S
  47047. X3z7wJl8OSngex2/DaeP0ik0biQVy96QXr8axGbqwua6OV+KmalBWQewLK8=
  47048. -----END CERTIFICATE-----
  47049. Certainly Root E1
  47050. =================
  47051. -----BEGIN CERTIFICATE-----
  47052. MIIB9zCCAX2gAwIBAgIQBiUzsUcDMydc+Y2aub/M+DAKBggqhkjOPQQDAzA9MQswCQYDVQQGEwJV
  47053. UzESMBAGA1UEChMJQ2VydGFpbmx5MRowGAYDVQQDExFDZXJ0YWlubHkgUm9vdCBFMTAeFw0yMTA0
  47054. MDEwMDAwMDBaFw00NjA0MDEwMDAwMDBaMD0xCzAJBgNVBAYTAlVTMRIwEAYDVQQKEwlDZXJ0YWlu
  47055. bHkxGjAYBgNVBAMTEUNlcnRhaW5seSBSb290IEUxMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE3m/4
  47056. fxzf7flHh4axpMCK+IKXgOqPyEpeKn2IaKcBYhSRJHpcnqMXfYqGITQYUBsQ3tA3SybHGWCA6TS9
  47057. YBk2QNYphwk8kXr2vBMj3VlOBF7PyAIcGFPBMdjaIOlEjeR2o0IwQDAOBgNVHQ8BAf8EBAMCAQYw
  47058. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU8ygYy2R17ikq6+2uI1g4hevIIgcwCgYIKoZIzj0E
  47059. AwMDaAAwZQIxALGOWiDDshliTd6wT99u0nCK8Z9+aozmut6Dacpps6kFtZaSF4fC0urQe87YQVt8
  47060. rgIwRt7qy12a7DLCZRawTDBcMPPaTnOGBtjOiQRINzf43TNRnXCve1XYAS59BWQOhriR
  47061. -----END CERTIFICATE-----
  47062. Security Communication ECC RootCA1
  47063. ==================================
  47064. -----BEGIN CERTIFICATE-----
  47065. MIICODCCAb6gAwIBAgIJANZdm7N4gS7rMAoGCCqGSM49BAMDMGExCzAJBgNVBAYTAkpQMSUwIwYD
  47066. VQQKExxTRUNPTSBUcnVzdCBTeXN0ZW1zIENPLixMVEQuMSswKQYDVQQDEyJTZWN1cml0eSBDb21t
  47067. dW5pY2F0aW9uIEVDQyBSb290Q0ExMB4XDTE2MDYxNjA1MTUyOFoXDTM4MDExODA1MTUyOFowYTEL
  47068. MAkGA1UEBhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xKzApBgNV
  47069. BAMTIlNlY3VyaXR5IENvbW11bmljYXRpb24gRUNDIFJvb3RDQTEwdjAQBgcqhkjOPQIBBgUrgQQA
  47070. IgNiAASkpW9gAwPDvTH00xecK4R1rOX9PVdu12O/5gSJko6BnOPpR27KkBLIE+CnnfdldB9sELLo
  47071. 5OnvbYUymUSxXv3MdhDYW72ixvnWQuRXdtyQwjWpS4g8EkdtXP9JTxpKULGjQjBAMB0GA1UdDgQW
  47072. BBSGHOf+LaVKiwj+KBH6vqNm+GBZLzAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAK
  47073. BggqhkjOPQQDAwNoADBlAjAVXUI9/Lbu9zuxNuie9sRGKEkz0FhDKmMpzE2xtHqiuQ04pV1IKv3L
  47074. snNdo4gIxwwCMQDAqy0Obe0YottT6SXbVQjgUMzfRGEWgqtJsLKB7HOHeLRMsmIbEvoWTSVLY70e
  47075. N9k=
  47076. -----END CERTIFICATE-----
  47077. BJCA Global Root CA1
  47078. ====================
  47079. -----BEGIN CERTIFICATE-----
  47080. MIIFdDCCA1ygAwIBAgIQVW9l47TZkGobCdFsPsBsIDANBgkqhkiG9w0BAQsFADBUMQswCQYDVQQG
  47081. EwJDTjEmMCQGA1UECgwdQkVJSklORyBDRVJUSUZJQ0FURSBBVVRIT1JJVFkxHTAbBgNVBAMMFEJK
  47082. Q0EgR2xvYmFsIFJvb3QgQ0ExMB4XDTE5MTIxOTAzMTYxN1oXDTQ0MTIxMjAzMTYxN1owVDELMAkG
  47083. A1UEBhMCQ04xJjAkBgNVBAoMHUJFSUpJTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZMR0wGwYDVQQD
  47084. DBRCSkNBIEdsb2JhbCBSb290IENBMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAPFm
  47085. CL3ZxRVhy4QEQaVpN3cdwbB7+sN3SJATcmTRuHyQNZ0YeYjjlwE8R4HyDqKYDZ4/N+AZspDyRhyS
  47086. sTphzvq3Rp4Dhtczbu33RYx2N95ulpH3134rhxfVizXuhJFyV9xgw8O558dnJCNPYwpj9mZ9S1Wn
  47087. P3hkSWkSl+BMDdMJoDIwOvqfwPKcxRIqLhy1BDPapDgRat7GGPZHOiJBhyL8xIkoVNiMpTAK+BcW
  47088. yqw3/XmnkRd4OJmtWO2y3syJfQOcs4ll5+M7sSKGjwZteAf9kRJ/sGsciQ35uMt0WwfCyPQ10WRj
  47089. eulumijWML3mG90Vr4TqnMfK9Q7q8l0ph49pczm+LiRvRSGsxdRpJQaDrXpIhRMsDQa4bHlW/KNn
  47090. MoH1V6XKV0Jp6VwkYe/iMBhORJhVb3rCk9gZtt58R4oRTklH2yiUAguUSiz5EtBP6DF+bHq/pj+b
  47091. OT0CFqMYs2esWz8sgytnOYFcuX6U1WTdno9uruh8W7TXakdI136z1C2OVnZOz2nxbkRs1CTqjSSh
  47092. GL+9V/6pmTW12xB3uD1IutbB5/EjPtffhZ0nPNRAvQoMvfXnjSXWgXSHRtQpdaJCbPdzied9v3pK
  47093. H9MiyRVVz99vfFXQpIsHETdfg6YmV6YBW37+WGgHqel62bno/1Afq8K0wM7o6v0PvY1NuLxxAgMB
  47094. AAGjQjBAMB0GA1UdDgQWBBTF7+3M2I0hxkjk49cULqcWk+WYATAPBgNVHRMBAf8EBTADAQH/MA4G
  47095. A1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAUoKsITQfI/Ki2Pm4rzc2IInRNwPWaZ+4
  47096. YRC6ojGYWUfo0Q0lHhVBDOAqVdVXUsv45Mdpox1NcQJeXyFFYEhcCY5JEMEE3KliawLwQ8hOnThJ
  47097. dMkycFRtwUf8jrQ2ntScvd0g1lPJGKm1Vrl2i5VnZu69mP6u775u+2D2/VnGKhs/I0qUJDAnyIm8
  47098. 60Qkmss9vk/Ves6OF8tiwdneHg56/0OGNFK8YT88X7vZdrRTvJez/opMEi4r89fO4aL/3Xtw+zuh
  47099. TaRjAv04l5U/BXCga99igUOLtFkNSoxUnMW7gZ/NfaXvCyUeOiDbHPwfmGcCCtRzRBPbUYQaVQNW
  47100. 4AB+dAb/OMRyHdOoP2gxXdMJxy6MW2Pg6Nwe0uxhHvLe5e/2mXZgLR6UcnHGCyoyx5JO1UbXHfmp
  47101. GQrI+pXObSOYqgs4rZpWDW+N8TEAiMEXnM0ZNjX+VVOg4DwzX5Ze4jLp3zO7Bkqp2IRzznfSxqxx
  47102. 4VyjHQy7Ct9f4qNx2No3WqB4K/TUfet27fJhcKVlmtOJNBir+3I+17Q9eVzYH6Eze9mCUAyTF6ps
  47103. 3MKCuwJXNq+YJyo5UOGwifUll35HaBC07HPKs5fRJNz2YqAo07WjuGS3iGJCz51TzZm+ZGiPTx4S
  47104. SPfSKcOYKMryMguTjClPPGAyzQWWYezyr/6zcCwupvI=
  47105. -----END CERTIFICATE-----
  47106. BJCA Global Root CA2
  47107. ====================
  47108. -----BEGIN CERTIFICATE-----
  47109. MIICJTCCAaugAwIBAgIQLBcIfWQqwP6FGFkGz7RK6zAKBggqhkjOPQQDAzBUMQswCQYDVQQGEwJD
  47110. TjEmMCQGA1UECgwdQkVJSklORyBDRVJUSUZJQ0FURSBBVVRIT1JJVFkxHTAbBgNVBAMMFEJKQ0Eg
  47111. R2xvYmFsIFJvb3QgQ0EyMB4XDTE5MTIxOTAzMTgyMVoXDTQ0MTIxMjAzMTgyMVowVDELMAkGA1UE
  47112. BhMCQ04xJjAkBgNVBAoMHUJFSUpJTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZMR0wGwYDVQQDDBRC
  47113. SkNBIEdsb2JhbCBSb290IENBMjB2MBAGByqGSM49AgEGBSuBBAAiA2IABJ3LgJGNU2e1uVCxA/jl
  47114. SR9BIgmwUVJY1is0j8USRhTFiy8shP8sbqjV8QnjAyEUxEM9fMEsxEtqSs3ph+B99iK++kpRuDCK
  47115. /eHeGBIK9ke35xe/J4rUQUyWPGCWwf0VHKNCMEAwHQYDVR0OBBYEFNJKsVF/BvDRgh9Obl+rg/xI
  47116. 1LCRMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49BAMDA2gAMGUCMBq8
  47117. W9f+qdJUDkpd0m2xQNz0Q9XSSpkZElaA94M04TVOSG0ED1cxMDAtsaqdAzjbBgIxAMvMh1PLet8g
  47118. UXOQwKhbYdDFUDn9hf7B43j4ptZLvZuHjw/l1lOWqzzIQNph91Oj9w==
  47119. -----END CERTIFICATE-----
  47120. Sectigo Public Server Authentication Root E46
  47121. =============================================
  47122. -----BEGIN CERTIFICATE-----
  47123. MIICOjCCAcGgAwIBAgIQQvLM2htpN0RfFf51KBC49DAKBggqhkjOPQQDAzBfMQswCQYDVQQGEwJH
  47124. QjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0aWdvIFB1YmxpYyBTZXJ2
  47125. ZXIgQXV0aGVudGljYXRpb24gUm9vdCBFNDYwHhcNMjEwMzIyMDAwMDAwWhcNNDYwMzIxMjM1OTU5
  47126. WjBfMQswCQYDVQQGEwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0
  47127. aWdvIFB1YmxpYyBTZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBFNDYwdjAQBgcqhkjOPQIBBgUr
  47128. gQQAIgNiAAR2+pmpbiDt+dd34wc7qNs9Xzjoq1WmVk/WSOrsfy2qw7LFeeyZYX8QeccCWvkEN/U0
  47129. NSt3zn8gj1KjAIns1aeibVvjS5KToID1AZTc8GgHHs3u/iVStSBDHBv+6xnOQ6OjQjBAMB0GA1Ud
  47130. DgQWBBTRItpMWfFLXyY4qp3W7usNw/upYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  47131. /zAKBggqhkjOPQQDAwNnADBkAjAn7qRaqCG76UeXlImldCBteU/IvZNeWBj7LRoAasm4PdCkT0RH
  47132. lAFWovgzJQxC36oCMB3q4S6ILuH5px0CMk7yn2xVdOOurvulGu7t0vzCAxHrRVxgED1cf5kDW21U
  47133. SAGKcw==
  47134. -----END CERTIFICATE-----
  47135. Sectigo Public Server Authentication Root R46
  47136. =============================================
  47137. -----BEGIN CERTIFICATE-----
  47138. MIIFijCCA3KgAwIBAgIQdY39i658BwD6qSWn4cetFDANBgkqhkiG9w0BAQwFADBfMQswCQYDVQQG
  47139. EwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0aWdvIFB1YmxpYyBT
  47140. ZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBSNDYwHhcNMjEwMzIyMDAwMDAwWhcNNDYwMzIxMjM1
  47141. OTU5WjBfMQswCQYDVQQGEwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1T
  47142. ZWN0aWdvIFB1YmxpYyBTZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBSNDYwggIiMA0GCSqGSIb3
  47143. DQEBAQUAA4ICDwAwggIKAoICAQCTvtU2UnXYASOgHEdCSe5jtrch/cSV1UgrJnwUUxDaef0rty2k
  47144. 1Cz66jLdScK5vQ9IPXtamFSvnl0xdE8H/FAh3aTPaE8bEmNtJZlMKpnzSDBh+oF8HqcIStw+Kxwf
  47145. GExxqjWMrfhu6DtK2eWUAtaJhBOqbchPM8xQljeSM9xfiOefVNlI8JhD1mb9nxc4Q8UBUQvX4yMP
  47146. FF1bFOdLvt30yNoDN9HWOaEhUTCDsG3XME6WW5HwcCSrv0WBZEMNvSE6Lzzpng3LILVCJ8zab5vu
  47147. ZDCQOc2TZYEhMbUjUDM3IuM47fgxMMxF/mL50V0yeUKH32rMVhlATc6qu/m1dkmU8Sf4kaWD5Qaz
  47148. Yw6A3OASVYCmO2a0OYctyPDQ0RTp5A1NDvZdV3LFOxxHVp3i1fuBYYzMTYCQNFu31xR13NgESJ/A
  47149. wSiItOkcyqex8Va3e0lMWeUgFaiEAin6OJRpmkkGj80feRQXEgyDet4fsZfu+Zd4KKTIRJLpfSYF
  47150. plhym3kT2BFfrsU4YjRosoYwjviQYZ4ybPUHNs2iTG7sijbt8uaZFURww3y8nDnAtOFr94MlI1fZ
  47151. EoDlSfB1D++N6xybVCi0ITz8fAr/73trdf+LHaAZBav6+CuBQug4urv7qv094PPK306Xlynt8xhW
  47152. 6aWWrL3DkJiy4Pmi1KZHQ3xtzwIDAQABo0IwQDAdBgNVHQ4EFgQUVnNYZJX5khqwEioEYnmhQBWI
  47153. IUkwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAC9c
  47154. mTz8Bl6MlC5w6tIyMY208FHVvArzZJ8HXtXBc2hkeqK5Duj5XYUtqDdFqij0lgVQYKlJfp/imTYp
  47155. E0RHap1VIDzYm/EDMrraQKFz6oOht0SmDpkBm+S8f74TlH7Kph52gDY9hAaLMyZlbcp+nv4fjFg4
  47156. exqDsQ+8FxG75gbMY/qB8oFM2gsQa6H61SilzwZAFv97fRheORKkU55+MkIQpiGRqRxOF3yEvJ+M
  47157. 0ejf5lG5Nkc/kLnHvALcWxxPDkjBJYOcCj+esQMzEhonrPcibCTRAUH4WAP+JWgiH5paPHxsnnVI
  47158. 84HxZmduTILA7rpXDhjvLpr3Etiga+kFpaHpaPi8TD8SHkXoUsCjvxInebnMMTzD9joiFgOgyY9m
  47159. pFuiTdaBJQbpdqQACj7LzTWb4OE4y2BThihCQRxEV+ioratF4yUQvNs+ZUH7G6aXD+u5dHn5Hrwd
  47160. Vw1Hr8Mvn4dGp+smWg9WY7ViYG4A++MnESLn/pmPNPW56MORcr3Ywx65LvKRRFHQV80MNNVIIb/b
  47161. E/FmJUNS0nAiNs2fxBx1IK1jcmMGDw4nztJqDby1ORrp0XZ60Vzk50lJLVU3aPAaOpg+VBeHVOmm
  47162. J1CJeyAvP/+/oYtKR5j/K3tJPsMpRmAYQqszKbrAKbkTidOIijlBO8n9pu0f9GBj39ItVQGL
  47163. -----END CERTIFICATE-----
  47164. SSL.com TLS RSA Root CA 2022
  47165. ============================
  47166. -----BEGIN CERTIFICATE-----
  47167. MIIFiTCCA3GgAwIBAgIQb77arXO9CEDii02+1PdbkTANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQG
  47168. EwJVUzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQDDBxTU0wuY29tIFRMUyBSU0Eg
  47169. Um9vdCBDQSAyMDIyMB4XDTIyMDgyNTE2MzQyMloXDTQ2MDgxOTE2MzQyMVowTjELMAkGA1UEBhMC
  47170. VVMxGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgUlNBIFJv
  47171. b3QgQ0EgMjAyMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANCkCXJPQIgSYT41I57u
  47172. 9nTPL3tYPc48DRAokC+X94xI2KDYJbFMsBFMF3NQ0CJKY7uB0ylu1bUJPiYYf7ISf5OYt6/wNr/y
  47173. 7hienDtSxUcZXXTzZGbVXcdotL8bHAajvI9AI7YexoS9UcQbOcGV0insS657Lb85/bRi3pZ7Qcac
  47174. oOAGcvvwB5cJOYF0r/c0WRFXCsJbwST0MXMwgsadugL3PnxEX4MN8/HdIGkWCVDi1FW24IBydm5M
  47175. R7d1VVm0U3TZlMZBrViKMWYPHqIbKUBOL9975hYsLfy/7PO0+r4Y9ptJ1O4Fbtk085zx7AGL0SDG
  47176. D6C1vBdOSHtRwvzpXGk3R2azaPgVKPC506QVzFpPulJwoxJF3ca6TvvC0PeoUidtbnm1jPx7jMEW
  47177. TO6Af77wdr5BUxIzrlo4QqvXDz5BjXYHMtWrifZOZ9mxQnUjbvPNQrL8VfVThxc7wDNY8VLS+YCk
  47178. 8OjwO4s4zKTGkH8PnP2L0aPP2oOnaclQNtVcBdIKQXTbYxE3waWglksejBYSd66UNHsef8JmAOSq
  47179. g+qKkK3ONkRN0VHpvB/zagX9wHQfJRlAUW7qglFA35u5CCoGAtUjHBPW6dvbxrB6y3snm/vg1UYk
  47180. 7RBLY0ulBY+6uB0rpvqR4pJSvezrZ5dtmi2fgTIFZzL7SAg/2SW4BCUvAgMBAAGjYzBhMA8GA1Ud
  47181. EwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAU+y437uOEeicuzRk1sTN8/9REQrkwHQYDVR0OBBYEFPsu
  47182. N+7jhHonLs0ZNbEzfP/UREK5MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAjYlt
  47183. hEUY8U+zoO9opMAdrDC8Z2awms22qyIZZtM7QbUQnRC6cm4pJCAcAZli05bg4vsMQtfhWsSWTVTN
  47184. j8pDU/0quOr4ZcoBwq1gaAafORpR2eCNJvkLTqVTJXojpBzOCBvfR4iyrT7gJ4eLSYwfqUdYe5by
  47185. iB0YrrPRpgqU+tvT5TgKa3kSM/tKWTcWQA673vWJDPFs0/dRa1419dvAJuoSc06pkZCmF8NsLzjU
  47186. o3KUQyxi4U5cMj29TH0ZR6LDSeeWP4+a0zvkEdiLA9z2tmBVGKaBUfPhqBVq6+AL8BQx1rmMRTqo
  47187. ENjwuSfr98t67wVylrXEj5ZzxOhWc5y8aVFjvO9nHEMaX3cZHxj4HCUp+UmZKbaSPaKDN7Egkaib
  47188. MOlqbLQjk2UEqxHzDh1TJElTHaE/nUiSEeJ9DU/1172iWD54nR4fK/4huxoTtrEoZP2wAgDHbICi
  47189. vRZQIA9ygV/MlP+7mea6kMvq+cYMwq7FGc4zoWtcu358NFcXrfA/rs3qr5nsLFR+jM4uElZI7xc7
  47190. P0peYNLcdDa8pUNjyw9bowJWCZ4kLOGGgYz+qxcs+sjiMho6/4UIyYOf8kpIEFR3N+2ivEC+5BB0
  47191. 9+Rbu7nzifmPQdjH5FCQNYA+HLhNkNPU98OwoX6EyneSMSy4kLGCenROmxMmtNVQZlR4rmA=
  47192. -----END CERTIFICATE-----
  47193. SSL.com TLS ECC Root CA 2022
  47194. ============================
  47195. -----BEGIN CERTIFICATE-----
  47196. MIICOjCCAcCgAwIBAgIQFAP1q/s3ixdAW+JDsqXRxDAKBggqhkjOPQQDAzBOMQswCQYDVQQGEwJV
  47197. UzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQDDBxTU0wuY29tIFRMUyBFQ0MgUm9v
  47198. dCBDQSAyMDIyMB4XDTIyMDgyNTE2MzM0OFoXDTQ2MDgxOTE2MzM0N1owTjELMAkGA1UEBhMCVVMx
  47199. GDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgRUNDIFJvb3Qg
  47200. Q0EgMjAyMjB2MBAGByqGSM49AgEGBSuBBAAiA2IABEUpNXP6wrgjzhR9qLFNoFs27iosU8NgCTWy
  47201. JGYmacCzldZdkkAZDsalE3D07xJRKF3nzL35PIXBz5SQySvOkkJYWWf9lCcQZIxPBLFNSeR7T5v1
  47202. 5wj4A4j3p8OSSxlUgaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBSJjy+j6CugFFR7
  47203. 81a4Jl9nOAuc0DAdBgNVHQ4EFgQUiY8vo+groBRUe/NWuCZfZzgLnNAwDgYDVR0PAQH/BAQDAgGG
  47204. MAoGCCqGSM49BAMDA2gAMGUCMFXjIlbp15IkWE8elDIPDAI2wv2sdDJO4fscgIijzPvX6yv/N33w
  47205. 7deedWo1dlJF4AIxAMeNb0Igj762TVntd00pxCAgRWSGOlDGxK0tk/UYfXLtqc/ErFc2KAhl3zx5
  47206. Zn6g6g==
  47207. -----END CERTIFICATE-----
  47208. Atos TrustedRoot Root CA ECC TLS 2021
  47209. =====================================
  47210. -----BEGIN CERTIFICATE-----
  47211. MIICFTCCAZugAwIBAgIQPZg7pmY9kGP3fiZXOATvADAKBggqhkjOPQQDAzBMMS4wLAYDVQQDDCVB
  47212. dG9zIFRydXN0ZWRSb290IFJvb3QgQ0EgRUNDIFRMUyAyMDIxMQ0wCwYDVQQKDARBdG9zMQswCQYD
  47213. VQQGEwJERTAeFw0yMTA0MjIwOTI2MjNaFw00MTA0MTcwOTI2MjJaMEwxLjAsBgNVBAMMJUF0b3Mg
  47214. VHJ1c3RlZFJvb3QgUm9vdCBDQSBFQ0MgVExTIDIwMjExDTALBgNVBAoMBEF0b3MxCzAJBgNVBAYT
  47215. AkRFMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEloZYKDcKZ9Cg3iQZGeHkBQcfl+3oZIK59sRxUM6K
  47216. DP/XtXa7oWyTbIOiaG6l2b4siJVBzV3dscqDY4PMwL502eCdpO5KTlbgmClBk1IQ1SQ4AjJn8ZQS
  47217. b+/Xxd4u/RmAo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR2KCXWfeBmmnoJsmo7jjPX
  47218. NtNPojAOBgNVHQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwMDaAAwZQIwW5kp85wxtolrbNa9d+F851F+
  47219. uDrNozZffPc8dz7kUK2o59JZDCaOMDtuCCrCp1rIAjEAmeMM56PDr9NJLkaCI2ZdyQAUEv049OGY
  47220. a3cpetskz2VAv9LcjBHo9H1/IISpQuQo
  47221. -----END CERTIFICATE-----
  47222. Atos TrustedRoot Root CA RSA TLS 2021
  47223. =====================================
  47224. -----BEGIN CERTIFICATE-----
  47225. MIIFZDCCA0ygAwIBAgIQU9XP5hmTC/srBRLYwiqipDANBgkqhkiG9w0BAQwFADBMMS4wLAYDVQQD
  47226. DCVBdG9zIFRydXN0ZWRSb290IFJvb3QgQ0EgUlNBIFRMUyAyMDIxMQ0wCwYDVQQKDARBdG9zMQsw
  47227. CQYDVQQGEwJERTAeFw0yMTA0MjIwOTIxMTBaFw00MTA0MTcwOTIxMDlaMEwxLjAsBgNVBAMMJUF0
  47228. b3MgVHJ1c3RlZFJvb3QgUm9vdCBDQSBSU0EgVExTIDIwMjExDTALBgNVBAoMBEF0b3MxCzAJBgNV
  47229. BAYTAkRFMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtoAOxHm9BYx9sKOdTSJNy/BB
  47230. l01Z4NH+VoyX8te9j2y3I49f1cTYQcvyAh5x5en2XssIKl4w8i1mx4QbZFc4nXUtVsYvYe+W/CBG
  47231. vevUez8/fEc4BKkbqlLfEzfTFRVOvV98r61jx3ncCHvVoOX3W3WsgFWZkmGbzSoXfduP9LVq6hdK
  47232. ZChmFSlsAvFr1bqjM9xaZ6cF4r9lthawEO3NUDPJcFDsGY6wx/J0W2tExn2WuZgIWWbeKQGb9Cpt
  47233. 0xU6kGpn8bRrZtkh68rZYnxGEFzedUlnnkL5/nWpo63/dgpnQOPF943HhZpZnmKaau1Fh5hnstVK
  47234. PNe0OwANwI8f4UDErmwh3El+fsqyjW22v5MvoVw+j8rtgI5Y4dtXz4U2OLJxpAmMkokIiEjxQGMY
  47235. sluMWuPD0xeqqxmjLBvk1cbiZnrXghmmOxYsL3GHX0WelXOTwkKBIROW1527k2gV+p2kHYzygeBY
  47236. Br3JtuP2iV2J+axEoctr+hbxx1A9JNr3w+SH1VbxT5Aw+kUJWdo0zuATHAR8ANSbhqRAvNncTFd+
  47237. rrcztl524WWLZt+NyteYr842mIycg5kDcPOvdO3GDjbnvezBc6eUWsuSZIKmAMFwoW4sKeFYV+xa
  47238. fJlrJaSQOoD0IJ2azsct+bJLKZWD6TWNp0lIpw9MGZHQ9b8Q4HECAwEAAaNCMEAwDwYDVR0TAQH/
  47239. BAUwAwEB/zAdBgNVHQ4EFgQUdEmZ0f+0emhFdcN+tNzMzjkz2ggwDgYDVR0PAQH/BAQDAgGGMA0G
  47240. CSqGSIb3DQEBDAUAA4ICAQAjQ1MkYlxt/T7Cz1UAbMVWiLkO3TriJQ2VSpfKgInuKs1l+NsW4AmS
  47241. 4BjHeJi78+xCUvuppILXTdiK/ORO/auQxDh1MoSf/7OwKwIzNsAQkG8dnK/haZPso0UvFJ/1TCpl
  47242. Q3IM98P4lYsU84UgYt1UU90s3BiVaU+DR3BAM1h3Egyi61IxHkzJqM7F78PRreBrAwA0JrRUITWX
  47243. AdxfG/F851X6LWh3e9NpzNMOa7pNdkTWwhWaJuywxfW70Xp0wmzNxbVe9kzmWy2B27O3Opee7c9G
  47244. slA9hGCZcbUztVdF5kJHdWoOsAgMrr3e97sPWD2PAzHoPYJQyi9eDF20l74gNAf0xBLh7tew2Vkt
  47245. afcxBPTy+av5EzH4AXcOPUIjJsyacmdRIXrMPIWo6iFqO9taPKU0nprALN+AnCng33eU0aKAQv9q
  47246. TFsR0PXNor6uzFFcw9VUewyu1rkGd4Di7wcaaMxZUa1+XGdrudviB0JbuAEFWDlN5LuYo7Ey7Nmj
  47247. 1m+UI/87tyll5gfp77YZ6ufCOB0yiJA8EytuzO+rdwY0d4RPcuSBhPm5dDTedk+SKlOxJTnbPP/l
  47248. PqYO5Wue/9vsL3SD3460s6neFE3/MaNFcyT6lSnMEpcEoji2jbDwN/zIIX8/syQbPYtuzE2wFg2W
  47249. HYMfRsCbvUOZ58SWLs5fyQ==
  47250. -----END CERTIFICATE-----
  47251. TrustAsia Global Root CA G3
  47252. ===========================
  47253. -----BEGIN CERTIFICATE-----
  47254. MIIFpTCCA42gAwIBAgIUZPYOZXdhaqs7tOqFhLuxibhxkw8wDQYJKoZIhvcNAQEMBQAwWjELMAkG
  47255. A1UEBhMCQ04xJTAjBgNVBAoMHFRydXN0QXNpYSBUZWNobm9sb2dpZXMsIEluYy4xJDAiBgNVBAMM
  47256. G1RydXN0QXNpYSBHbG9iYWwgUm9vdCBDQSBHMzAeFw0yMTA1MjAwMjEwMTlaFw00NjA1MTkwMjEw
  47257. MTlaMFoxCzAJBgNVBAYTAkNOMSUwIwYDVQQKDBxUcnVzdEFzaWEgVGVjaG5vbG9naWVzLCBJbmMu
  47258. MSQwIgYDVQQDDBtUcnVzdEFzaWEgR2xvYmFsIFJvb3QgQ0EgRzMwggIiMA0GCSqGSIb3DQEBAQUA
  47259. A4ICDwAwggIKAoICAQDAMYJhkuSUGwoqZdC+BqmHO1ES6nBBruL7dOoKjbmzTNyPtxNST1QY4Sxz
  47260. lZHFZjtqz6xjbYdT8PfxObegQ2OwxANdV6nnRM7EoYNl9lA+sX4WuDqKAtCWHwDNBSHvBm3dIZwZ
  47261. Q0WhxeiAysKtQGIXBsaqvPPW5vxQfmZCHzyLpnl5hkA1nyDvP+uLRx+PjsXUjrYsyUQE49RDdT/V
  47262. P68czH5GX6zfZBCK70bwkPAPLfSIC7Epqq+FqklYqL9joDiR5rPmd2jE+SoZhLsO4fWvieylL1Ag
  47263. dB4SQXMeJNnKziyhWTXAyB1GJ2Faj/lN03J5Zh6fFZAhLf3ti1ZwA0pJPn9pMRJpxx5cynoTi+jm
  47264. 9WAPzJMshH/x/Gr8m0ed262IPfN2dTPXS6TIi/n1Q1hPy8gDVI+lhXgEGvNz8teHHUGf59gXzhqc
  47265. D0r83ERoVGjiQTz+LISGNzzNPy+i2+f3VANfWdP3kXjHi3dqFuVJhZBFcnAvkV34PmVACxmZySYg
  47266. WmjBNb9Pp1Hx2BErW+Canig7CjoKH8GB5S7wprlppYiU5msTf9FkPz2ccEblooV7WIQn3MSAPmea
  47267. mseaMQ4w7OYXQJXZRe0Blqq/DPNL0WP3E1jAuPP6Z92bfW1K/zJMtSU7/xxnD4UiWQWRkUF3gdCF
  47268. TIcQcf+eQxuulXUtgQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFEDk5PIj
  47269. 7zjKsK5Xf/IhMBY027ySMB0GA1UdDgQWBBRA5OTyI+84yrCuV3/yITAWNNu8kjAOBgNVHQ8BAf8E
  47270. BAMCAQYwDQYJKoZIhvcNAQEMBQADggIBACY7UeFNOPMyGLS0XuFlXsSUT9SnYaP4wM8zAQLpw6o1
  47271. D/GUE3d3NZ4tVlFEbuHGLige/9rsR82XRBf34EzC4Xx8MnpmyFq2XFNFV1pF1AWZLy4jVe5jaN/T
  47272. G3inEpQGAHUNcoTpLrxaatXeL1nHo+zSh2bbt1S1JKv0Q3jbSwTEb93mPmY+KfJLaHEih6D4sTNj
  47273. duMNhXJEIlU/HHzp/LgV6FL6qj6jITk1dImmasI5+njPtqzn59ZW/yOSLlALqbUHM/Q4X6RJpstl
  47274. cHboCoWASzY9M/eVVHUl2qzEc4Jl6VL1XP04lQJqaTDFHApXB64ipCz5xUG3uOyfT0gA+QEEVcys
  47275. +TIxxHWVBqB/0Y0n3bOppHKH/lmLmnp0Ft0WpWIp6zqW3IunaFnT63eROfjXy9mPX1onAX1daBli
  47276. 2MjN9LdyR75bl87yraKZk62Uy5P2EgmVtqvXO9A/EcswFi55gORngS1d7XB4tmBZrOFdRWOPyN9y
  47277. aFvqHbgB8X7754qz41SgOAngPN5C8sLtLpvzHzW2NtjjgKGLzZlkD8Kqq7HK9W+eQ42EVJmzbsAS
  47278. ZthwEPEGNTNDqJwuuhQxzhB/HIbjj9LV+Hfsm6vxL2PZQl/gZ4FkkfGXL/xuJvYz+NO1+MRiqzFR
  47279. JQJ6+N1rZdVtTTDIZbpoFGWsJwt0ivKH
  47280. -----END CERTIFICATE-----
  47281. TrustAsia Global Root CA G4
  47282. ===========================
  47283. -----BEGIN CERTIFICATE-----
  47284. MIICVTCCAdygAwIBAgIUTyNkuI6XY57GU4HBdk7LKnQV1tcwCgYIKoZIzj0EAwMwWjELMAkGA1UE
  47285. BhMCQ04xJTAjBgNVBAoMHFRydXN0QXNpYSBUZWNobm9sb2dpZXMsIEluYy4xJDAiBgNVBAMMG1Ry
  47286. dXN0QXNpYSBHbG9iYWwgUm9vdCBDQSBHNDAeFw0yMTA1MjAwMjEwMjJaFw00NjA1MTkwMjEwMjJa
  47287. MFoxCzAJBgNVBAYTAkNOMSUwIwYDVQQKDBxUcnVzdEFzaWEgVGVjaG5vbG9naWVzLCBJbmMuMSQw
  47288. IgYDVQQDDBtUcnVzdEFzaWEgR2xvYmFsIFJvb3QgQ0EgRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNi
  47289. AATxs8045CVD5d4ZCbuBeaIVXxVjAd7Cq92zphtnS4CDr5nLrBfbK5bKfFJV4hrhPVbwLxYI+hW8
  47290. m7tH5j/uqOFMjPXTNvk4XatwmkcN4oFBButJ+bAp3TPsUKV/eSm4IJijYzBhMA8GA1UdEwEB/wQF
  47291. MAMBAf8wHwYDVR0jBBgwFoAUpbtKl86zK3+kMd6Xg1mDpm9xy94wHQYDVR0OBBYEFKW7SpfOsyt/
  47292. pDHel4NZg6ZvccveMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNnADBkAjBe8usGzEkxn0AA
  47293. bbd+NvBNEU/zy4k6LHiRUKNbwMp1JvK/kF0LgoxgKJ/GcJpo5PECMFxYDlZ2z1jD1xCMuo6u47xk
  47294. dUfFVZDj/bpV6wfEU6s3qe4hsiFbYI89MvHVI5TWWA==
  47295. -----END CERTIFICATE-----
  47296. CommScope Public Trust ECC Root-01
  47297. ==================================
  47298. -----BEGIN CERTIFICATE-----
  47299. MIICHTCCAaOgAwIBAgIUQ3CCd89NXTTxyq4yLzf39H91oJ4wCgYIKoZIzj0EAwMwTjELMAkGA1UE
  47300. BhMCVVMxEjAQBgNVBAoMCUNvbW1TY29wZTErMCkGA1UEAwwiQ29tbVNjb3BlIFB1YmxpYyBUcnVz
  47301. dCBFQ0MgUm9vdC0wMTAeFw0yMTA0MjgxNzM1NDNaFw00NjA0MjgxNzM1NDJaME4xCzAJBgNVBAYT
  47302. AlVTMRIwEAYDVQQKDAlDb21tU2NvcGUxKzApBgNVBAMMIkNvbW1TY29wZSBQdWJsaWMgVHJ1c3Qg
  47303. RUNDIFJvb3QtMDEwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAARLNumuV16ocNfQj3Rid8NeeqrltqLx
  47304. eP0CflfdkXmcbLlSiFS8LwS+uM32ENEp7LXQoMPwiXAZu1FlxUOcw5tjnSCDPgYLpkJEhRGnSjot
  47305. 6dZoL0hOUysHP029uax3OVejQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0G
  47306. A1UdDgQWBBSOB2LAUN3GGQYARnQE9/OufXVNMDAKBggqhkjOPQQDAwNoADBlAjEAnDPfQeMjqEI2
  47307. Jpc1XHvr20v4qotzVRVcrHgpD7oh2MSg2NED3W3ROT3Ek2DS43KyAjB8xX6I01D1HiXo+k515liW
  47308. pDVfG2XqYZpwI7UNo5uSUm9poIyNStDuiw7LR47QjRE=
  47309. -----END CERTIFICATE-----
  47310. CommScope Public Trust ECC Root-02
  47311. ==================================
  47312. -----BEGIN CERTIFICATE-----
  47313. MIICHDCCAaOgAwIBAgIUKP2ZYEFHpgE6yhR7H+/5aAiDXX0wCgYIKoZIzj0EAwMwTjELMAkGA1UE
  47314. BhMCVVMxEjAQBgNVBAoMCUNvbW1TY29wZTErMCkGA1UEAwwiQ29tbVNjb3BlIFB1YmxpYyBUcnVz
  47315. dCBFQ0MgUm9vdC0wMjAeFw0yMTA0MjgxNzQ0NTRaFw00NjA0MjgxNzQ0NTNaME4xCzAJBgNVBAYT
  47316. AlVTMRIwEAYDVQQKDAlDb21tU2NvcGUxKzApBgNVBAMMIkNvbW1TY29wZSBQdWJsaWMgVHJ1c3Qg
  47317. RUNDIFJvb3QtMDIwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAR4MIHoYx7l63FRD/cHB8o5mXxO1Q/M
  47318. MDALj2aTPs+9xYa9+bG3tD60B8jzljHz7aRP+KNOjSkVWLjVb3/ubCK1sK9IRQq9qEmUv4RDsNuE
  47319. SgMjGWdqb8FuvAY5N9GIIvejQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0G
  47320. A1UdDgQWBBTmGHX/72DehKT1RsfeSlXjMjZ59TAKBggqhkjOPQQDAwNnADBkAjAmc0l6tqvmSfR9
  47321. Uj/UQQSugEODZXW5hYA4O9Zv5JOGq4/nich/m35rChJVYaoR4HkCMHfoMXGsPHED1oQmHhS48zs7
  47322. 3u1Z/GtMMH9ZzkXpc2AVmkzw5l4lIhVtwodZ0LKOag==
  47323. -----END CERTIFICATE-----
  47324. CommScope Public Trust RSA Root-01
  47325. ==================================
  47326. -----BEGIN CERTIFICATE-----
  47327. MIIFbDCCA1SgAwIBAgIUPgNJgXUWdDGOTKvVxZAplsU5EN0wDQYJKoZIhvcNAQELBQAwTjELMAkG
  47328. A1UEBhMCVVMxEjAQBgNVBAoMCUNvbW1TY29wZTErMCkGA1UEAwwiQ29tbVNjb3BlIFB1YmxpYyBU
  47329. cnVzdCBSU0EgUm9vdC0wMTAeFw0yMTA0MjgxNjQ1NTRaFw00NjA0MjgxNjQ1NTNaME4xCzAJBgNV
  47330. BAYTAlVTMRIwEAYDVQQKDAlDb21tU2NvcGUxKzApBgNVBAMMIkNvbW1TY29wZSBQdWJsaWMgVHJ1
  47331. c3QgUlNBIFJvb3QtMDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwSGWjDR1C45Ft
  47332. nYSkYZYSwu3D2iM0GXb26v1VWvZVAVMP8syMl0+5UMuzAURWlv2bKOx7dAvnQmtVzslhsuitQDy6
  47333. uUEKBU8bJoWPQ7VAtYXR1HHcg0Hz9kXHgKKEUJdGzqAMxGBWBB0HW0alDrJLpA6lfO741GIDuZNq
  47334. ihS4cPgugkY4Iw50x2tBt9Apo52AsH53k2NC+zSDO3OjWiE260f6GBfZumbCk6SP/F2krfxQapWs
  47335. vCQz0b2If4b19bJzKo98rwjyGpg/qYFlP8GMicWWMJoKz/TUyDTtnS+8jTiGU+6Xn6myY5QXjQ/c
  47336. Zip8UlF1y5mO6D1cv547KI2DAg+pn3LiLCuz3GaXAEDQpFSOm117RTYm1nJD68/A6g3czhLmfTif
  47337. BSeolz7pUcZsBSjBAg/pGG3svZwG1KdJ9FQFa2ww8esD1eo9anbCyxooSU1/ZOD6K9pzg4H/kQO9
  47338. lLvkuI6cMmPNn7togbGEW682v3fuHX/3SZtS7NJ3Wn2RnU3COS3kuoL4b/JOHg9O5j9ZpSPcPYeo
  47339. KFgo0fEbNttPxP/hjFtyjMcmAyejOQoBqsCyMWCDIqFPEgkBEa801M/XrmLTBQe0MXXgDW1XT2mH
  47340. +VepuhX2yFJtocucH+X8eKg1mp9BFM6ltM6UCBwJrVbl2rZJmkrqYxhTnCwuwwIDAQABo0IwQDAP
  47341. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUN12mmnQywsL5x6YVEFm4
  47342. 5P3luG0wDQYJKoZIhvcNAQELBQADggIBAK+nz97/4L1CjU3lIpbfaOp9TSp90K09FlxD533Ahuh6
  47343. NWPxzIHIxgvoLlI1pKZJkGNRrDSsBTtXAOnTYtPZKdVUvhwQkZyybf5Z/Xn36lbQnmhUQo8mUuJM
  47344. 3y+Xpi/SB5io82BdS5pYV4jvguX6r2yBS5KPQJqTRlnLX3gWsWc+QgvfKNmwrZggvkN80V4aCRck
  47345. jXtdlemrwWCrWxhkgPut4AZ9HcpZuPN4KWfGVh2vtrV0KnahP/t1MJ+UXjulYPPLXAziDslg+Mkf
  47346. Foom3ecnf+slpoq9uC02EJqxWE2aaE9gVOX2RhOOiKy8IUISrcZKiX2bwdgt6ZYD9KJ0DLwAHb/W
  47347. NyVntHKLr4W96ioDj8z7PEQkguIBpQtZtjSNMgsSDesnwv1B10A8ckYpwIzqug/xBpMu95yo9GA+
  47348. o/E4Xo4TwbM6l4c/ksp4qRyv0LAbJh6+cOx69TOY6lz/KwsETkPdY34Op054A5U+1C0wlREQKC6/
  47349. oAI+/15Z0wUOlV9TRe9rh9VIzRamloPh37MG88EU26fsHItdkJANclHnYfkUyq+Dj7+vsQpZXdxc
  47350. 1+SWrVtgHdqul7I52Qb1dgAT+GhMIbA1xNxVssnBQVocicCMb3SgazNNtQEo/a2tiRc7ppqEvOuM
  47351. 6sRxJKi6KfkIsidWNTJf6jn7MZrVGczw
  47352. -----END CERTIFICATE-----
  47353. CommScope Public Trust RSA Root-02
  47354. ==================================
  47355. -----BEGIN CERTIFICATE-----
  47356. MIIFbDCCA1SgAwIBAgIUVBa/O345lXGN0aoApYYNK496BU4wDQYJKoZIhvcNAQELBQAwTjELMAkG
  47357. A1UEBhMCVVMxEjAQBgNVBAoMCUNvbW1TY29wZTErMCkGA1UEAwwiQ29tbVNjb3BlIFB1YmxpYyBU
  47358. cnVzdCBSU0EgUm9vdC0wMjAeFw0yMTA0MjgxNzE2NDNaFw00NjA0MjgxNzE2NDJaME4xCzAJBgNV
  47359. BAYTAlVTMRIwEAYDVQQKDAlDb21tU2NvcGUxKzApBgNVBAMMIkNvbW1TY29wZSBQdWJsaWMgVHJ1
  47360. c3QgUlNBIFJvb3QtMDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDh+g77aAASyE3V
  47361. rCLENQE7xVTlWXZjpX/rwcRqmL0yjReA61260WI9JSMZNRTpf4mnG2I81lDnNJUDMrG0kyI9p+Kx
  47362. 7eZ7Ti6Hmw0zdQreqjXnfuU2mKKuJZ6VszKWpCtYHu8//mI0SFHRtI1CrWDaSWqVcN3SAOLMV2MC
  47363. e5bdSZdbkk6V0/nLKR8YSvgBKtJjCW4k6YnS5cciTNxzhkcAqg2Ijq6FfUrpuzNPDlJwnZXjfG2W
  47364. Wy09X6GDRl224yW4fKcZgBzqZUPckXk2LHR88mcGyYnJ27/aaL8j7dxrrSiDeS/sOKUNNwFnJ5rp
  47365. M9kzXzehxfCrPfp4sOcsn/Y+n2Dg70jpkEUeBVF4GiwSLFworA2iI540jwXmojPOEXcT1A6kHkIf
  47366. hs1w/tkuFT0du7jyU1fbzMZ0KZwYszZ1OC4PVKH4kh+Jlk+71O6d6Ts2QrUKOyrUZHk2EOH5kQMr
  47367. eyBUzQ0ZGshBMjTRsJnhkB4BQDa1t/qp5Xd1pCKBXbCL5CcSD1SIxtuFdOa3wNemKfrb3vOTlycE
  47368. VS8KbzfFPROvCgCpLIscgSjX74Yxqa7ybrjKaixUR9gqiC6vwQcQeKwRoi9C8DfF8rhW3Q5iLc4t
  47369. Vn5V8qdE9isy9COoR+jUKgF4z2rDN6ieZdIs5fq6M8EGRPbmz6UNp2YINIos8wIDAQABo0IwQDAP
  47370. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUR9DnsSL/nSz12Vdgs7Gx
  47371. cJXvYXowDQYJKoZIhvcNAQELBQADggIBAIZpsU0v6Z9PIpNojuQhmaPORVMbc0RTAIFhzTHjCLqB
  47372. KCh6krm2qMhDnscTJk3C2OVVnJJdUNjCK9v+5qiXz1I6JMNlZFxHMaNlNRPDk7n3+VGXu6TwYofF
  47373. 1gbTl4MgqX67tiHCpQ2EAOHyJxCDut0DgdXdaMNmEMjRdrSzbymeAPnCKfWxkxlSaRosTKCL4BWa
  47374. MS/TiJVZbuXEs1DIFAhKm4sTg7GkcrI7djNB3NyqpgdvHSQSn8h2vS/ZjvQs7rfSOBAkNlEv41xd
  47375. gSGn2rtO/+YHqP65DSdsu3BaVXoT6fEqSWnHX4dXTEN5bTpl6TBcQe7rd6VzEojov32u5cSoHw2O
  47376. HG1QAk8mGEPej1WFsQs3BWDJVTkSBKEqz3EWnzZRSb9wO55nnPt7eck5HHisd5FUmrh1CoFSl+Nm
  47377. YWvtPjgelmFV4ZFUjO2MJB+ByRCac5krFk5yAD9UG/iNuovnFNa2RU9g7Jauwy8CTl2dlklyALKr
  47378. dVwPaFsdZcJfMw8eD/A7hvWwTruc9+olBdytoptLFwG+Qt81IR2tq670v64fG9PiO/yzcnMcmyiQ
  47379. iRM9HcEARwmWmjgb3bHPDcK0RPOWlc4yOo80nOAXx17Org3bhzjlP1v9mxnhMUF6cKojawHhRUzN
  47380. lM47ni3niAIi9G7oyOzWPPO5std3eqx7
  47381. -----END CERTIFICATE-----
  47382. Telekom Security TLS ECC Root 2020
  47383. ==================================
  47384. -----BEGIN CERTIFICATE-----
  47385. MIICQjCCAcmgAwIBAgIQNjqWjMlcsljN0AFdxeVXADAKBggqhkjOPQQDAzBjMQswCQYDVQQGEwJE
  47386. RTEnMCUGA1UECgweRGV1dHNjaGUgVGVsZWtvbSBTZWN1cml0eSBHbWJIMSswKQYDVQQDDCJUZWxl
  47387. a29tIFNlY3VyaXR5IFRMUyBFQ0MgUm9vdCAyMDIwMB4XDTIwMDgyNTA3NDgyMFoXDTQ1MDgyNTIz
  47388. NTk1OVowYzELMAkGA1UEBhMCREUxJzAlBgNVBAoMHkRldXRzY2hlIFRlbGVrb20gU2VjdXJpdHkg
  47389. R21iSDErMCkGA1UEAwwiVGVsZWtvbSBTZWN1cml0eSBUTFMgRUNDIFJvb3QgMjAyMDB2MBAGByqG
  47390. SM49AgEGBSuBBAAiA2IABM6//leov9Wq9xCazbzREaK9Z0LMkOsVGJDZos0MKiXrPk/OtdKPD/M1
  47391. 2kOLAoC+b1EkHQ9rK8qfwm9QMuU3ILYg/4gND21Ju9sGpIeQkpT0CdDPf8iAC8GXs7s1J8nCG6NC
  47392. MEAwHQYDVR0OBBYEFONyzG6VmUex5rNhTNHLq+O6zd6fMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  47393. AQH/BAQDAgEGMAoGCCqGSM49BAMDA2cAMGQCMHVSi7ekEE+uShCLsoRbQuHmKjYC2qBuGT8lv9pZ
  47394. Mo7k+5Dck2TOrbRBR2Diz6fLHgIwN0GMZt9Ba9aDAEH9L1r3ULRn0SyocddDypwnJJGDSA3PzfdU
  47395. ga/sf+Rn27iQ7t0l
  47396. -----END CERTIFICATE-----
  47397. Telekom Security TLS RSA Root 2023
  47398. ==================================
  47399. -----BEGIN CERTIFICATE-----
  47400. MIIFszCCA5ugAwIBAgIQIZxULej27HF3+k7ow3BXlzANBgkqhkiG9w0BAQwFADBjMQswCQYDVQQG
  47401. EwJERTEnMCUGA1UECgweRGV1dHNjaGUgVGVsZWtvbSBTZWN1cml0eSBHbWJIMSswKQYDVQQDDCJU
  47402. ZWxla29tIFNlY3VyaXR5IFRMUyBSU0EgUm9vdCAyMDIzMB4XDTIzMDMyODEyMTY0NVoXDTQ4MDMy
  47403. NzIzNTk1OVowYzELMAkGA1UEBhMCREUxJzAlBgNVBAoMHkRldXRzY2hlIFRlbGVrb20gU2VjdXJp
  47404. dHkgR21iSDErMCkGA1UEAwwiVGVsZWtvbSBTZWN1cml0eSBUTFMgUlNBIFJvb3QgMjAyMzCCAiIw
  47405. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAO01oYGA88tKaVvC+1GDrib94W7zgRJ9cUD/h3VC
  47406. KSHtgVIs3xLBGYSJwb3FKNXVS2xE1kzbB5ZKVXrKNoIENqil/Cf2SfHVcp6R+SPWcHu79ZvB7JPP
  47407. GeplfohwoHP89v+1VmLhc2o0mD6CuKyVU/QBoCcHcqMAU6DksquDOFczJZSfvkgdmOGjup5czQRx
  47408. UX11eKvzWarE4GC+j4NSuHUaQTXtvPM6Y+mpFEXX5lLRbtLevOP1Czvm4MS9Q2QTps70mDdsipWo
  47409. l8hHD/BeEIvnHRz+sTugBTNoBUGCwQMrAcjnj02r6LX2zWtEtefdi+zqJbQAIldNsLGyMcEWzv/9
  47410. FIS3R/qy8XDe24tsNlikfLMR0cN3f1+2JeANxdKz+bi4d9s3cXFH42AYTyS2dTd4uaNir73Jco4v
  47411. zLuu2+QVUhkHM/tqty1LkCiCc/4YizWN26cEar7qwU02OxY2kTLvtkCJkUPg8qKrBC7m8kwOFjQg
  47412. rIfBLX7JZkcXFBGk8/ehJImr2BrIoVyxo/eMbcgByU/J7MT8rFEz0ciD0cmfHdRHNCk+y7AO+oML
  47413. KFjlKdw/fKifybYKu6boRhYPluV75Gp6SG12mAWl3G0eQh5C2hrgUve1g8Aae3g1LDj1H/1Joy7S
  47414. WWO/gLCMk3PLNaaZlSJhZQNg+y+TS/qanIA7AgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBBjAdBgNV
  47415. HQ4EFgQUtqeXgj10hZv3PJ+TmpV5dVKMbUcwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS2
  47416. p5eCPXSFm/c8n5OalXl1UoxtRzANBgkqhkiG9w0BAQwFAAOCAgEAqMxhpr51nhVQpGv7qHBFfLp+
  47417. sVr8WyP6Cnf4mHGCDG3gXkaqk/QeoMPhk9tLrbKmXauw1GLLXrtm9S3ul0A8Yute1hTWjOKWi0Fp
  47418. kzXmuZlrYrShF2Y0pmtjxrlO8iLpWA1WQdH6DErwM807u20hOq6OcrXDSvvpfeWxm4bu4uB9tPcy
  47419. /SKE8YXJN3nptT+/XOR0so8RYgDdGGah2XsjX/GO1WfoVNpbOms2b/mBsTNHM3dA+VKq3dSDz4V4
  47420. mZqTuXNnQkYRIer+CqkbGmVps4+uFrb2S1ayLfmlyOw7YqPta9BO1UAJpB+Y1zqlklkg5LB9zVtz
  47421. aL1txKITDmcZuI1CfmwMmm6gJC3VRRvcxAIU/oVbZZfKTpBQCHpCNfnqwmbU+AGuHrS+w6jv/naa
  47422. oqYfRvaE7fzbzsQCzndILIyy7MMAo+wsVRjBfhnu4S/yrYObnqsZ38aKL4x35bcF7DvB7L6Gs4a8
  47423. wPfc5+pbrrLMtTWGS9DiP7bY+A4A7l3j941Y/8+LN+ljX273CXE2whJdV/LItM3z7gLfEdxquVeE
  47424. HVlNjM7IDiPCtyaaEBRx/pOyiriA8A4QntOoUAw3gi/q4Iqd4Sw5/7W0cwDk90imc6y/st53BIe0
  47425. o82bNSQ3+pCTE4FCxpgmdTdmQRCsu/WU48IxK63nI1bMNSWSs1A=
  47426. -----END CERTIFICATE-----
  47427. FIRMAPROFESIONAL CA ROOT-A WEB
  47428. ==============================
  47429. -----BEGIN CERTIFICATE-----
  47430. MIICejCCAgCgAwIBAgIQMZch7a+JQn81QYehZ1ZMbTAKBggqhkjOPQQDAzBuMQswCQYDVQQGEwJF
  47431. UzEcMBoGA1UECgwTRmlybWFwcm9mZXNpb25hbCBTQTEYMBYGA1UEYQwPVkFURVMtQTYyNjM0MDY4
  47432. MScwJQYDVQQDDB5GSVJNQVBST0ZFU0lPTkFMIENBIFJPT1QtQSBXRUIwHhcNMjIwNDA2MDkwMTM2
  47433. WhcNNDcwMzMxMDkwMTM2WjBuMQswCQYDVQQGEwJFUzEcMBoGA1UECgwTRmlybWFwcm9mZXNpb25h
  47434. bCBTQTEYMBYGA1UEYQwPVkFURVMtQTYyNjM0MDY4MScwJQYDVQQDDB5GSVJNQVBST0ZFU0lPTkFM
  47435. IENBIFJPT1QtQSBXRUIwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAARHU+osEaR3xyrq89Zfe9MEkVz6
  47436. iMYiuYMQYneEMy3pA4jU4DP37XcsSmDq5G+tbbT4TIqk5B/K6k84Si6CcyvHZpsKjECcfIr28jlg
  47437. st7L7Ljkb+qbXbdTkBgyVcUgt5SjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUk+FD
  47438. Y1w8ndYn81LsF7Kpryz3dvgwHQYDVR0OBBYEFJPhQ2NcPJ3WJ/NS7Beyqa8s93b4MA4GA1UdDwEB
  47439. /wQEAwIBBjAKBggqhkjOPQQDAwNoADBlAjAdfKR7w4l1M+E7qUW/Runpod3JIha3RxEL2Jq68cgL
  47440. cFBTApFwhVmpHqTm6iMxoAACMQD94vizrxa5HnPEluPBMBnYfubDl94cT7iJLzPrSA8Z94dGXSaQ
  47441. pYXFuXqUPoeovQA=
  47442. -----END CERTIFICATE-----
  47443. TWCA CYBER Root CA
  47444. ==================
  47445. -----BEGIN CERTIFICATE-----
  47446. MIIFjTCCA3WgAwIBAgIQQAE0jMIAAAAAAAAAATzyxjANBgkqhkiG9w0BAQwFADBQMQswCQYDVQQG
  47447. EwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJUV0NB
  47448. IENZQkVSIFJvb3QgQ0EwHhcNMjIxMTIyMDY1NDI5WhcNNDcxMTIyMTU1OTU5WjBQMQswCQYDVQQG
  47449. EwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJUV0NB
  47450. IENZQkVSIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDG+Moe2Qkgfh1s
  47451. Ts6P40czRJzHyWmqOlt47nDSkvgEs1JSHWdyKKHfi12VCv7qze33Kc7wb3+szT3vsxxFavcokPFh
  47452. V8UMxKNQXd7UtcsZyoC5dc4pztKFIuwCY8xEMCDa6pFbVuYdHNWdZsc/34bKS1PE2Y2yHer43CdT
  47453. o0fhYcx9tbD47nORxc5zb87uEB8aBs/pJ2DFTxnk684iJkXXYJndzk834H/nY62wuFm40AZoNWDT
  47454. Nq5xQwTxaWV4fPMf88oon1oglWa0zbfuj3ikRRjpJi+NmykosaS3Om251Bw4ckVYsV7r8Cibt4LK
  47455. /c/WMw+f+5eesRycnupfXtuq3VTpMCEobY5583WSjCb+3MX2w7DfRFlDo7YDKPYIMKoNM+HvnKkH
  47456. IuNZW0CP2oi3aQiotyMuRAlZN1vH4xfyIutuOVLF3lSnmMlLIJXcRolftBL5hSmO68gnFSDAS9TM
  47457. fAxsNAwmmyYxpjyn9tnQS6Jk/zuZQXLB4HCX8SS7K8R0IrGsayIyJNN4KsDAoS/xUgXJP+92ZuJF
  47458. 2A09rZXIx4kmyA+upwMu+8Ff+iDhcK2wZSA3M2Cw1a/XDBzCkHDXShi8fgGwsOsVHkQGzaRP6AzR
  47459. wyAQ4VRlnrZR0Bp2a0JaWHY06rc3Ga4udfmW5cFZ95RXKSWNOkyrTZpB0F8mAwIDAQABo2MwYTAO
  47460. BgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBSdhWEUfMFib5do5E83
  47461. QOGt4A1WNzAdBgNVHQ4EFgQUnYVhFHzBYm+XaORPN0DhreANVjcwDQYJKoZIhvcNAQEMBQADggIB
  47462. AGSPesRiDrWIzLjHhg6hShbNcAu3p4ULs3a2D6f/CIsLJc+o1IN1KriWiLb73y0ttGlTITVX1olN
  47463. c79pj3CjYcya2x6a4CD4bLubIp1dhDGaLIrdaqHXKGnK/nZVekZn68xDiBaiA9a5F/gZbG0jAn/x
  47464. X9AKKSM70aoK7akXJlQKTcKlTfjF/biBzysseKNnTKkHmvPfXvt89YnNdJdhEGoHK4Fa0o635yDR
  47465. IG4kqIQnoVesqlVYL9zZyvpoBJ7tRCT5dEA7IzOrg1oYJkK2bVS1FmAwbLGg+LhBoF1JSdJlBTrq
  47466. /p1hvIbZv97Tujqxf36SNI7JAG7cmL3c7IAFrQI932XtCwP39xaEBDG6k5TY8hL4iuO/Qq+n1M0R
  47467. FxbIQh0UqEL20kCGoE8jypZFVmAGzbdVAaYBlGX+bgUJurSkquLvWL69J1bY73NxW0Qz8ppy6rBe
  47468. Pm6pUlvscG21h483XjyMnM7k8M4MZ0HMzvaAq07MTFb1wWFZk7Q+ptq4NxKfKjLji7gh7MMrZQzv
  47469. It6IKTtM1/r+t+FHvpw+PoP7UV31aPcuIYXcv/Fa4nzXxeSDwWrruoBa3lwtcHb4yOWHh8qgnaHl
  47470. IhInD0Q9HWzq1MKLL295q39QpsQZp6F6t5b5wR9iWqJDB0BeJsas7a5wFsWqynKKTbDPAYsDP27X
  47471. -----END CERTIFICATE-----
  47472. SecureSign Root CA12
  47473. ====================
  47474. -----BEGIN CERTIFICATE-----
  47475. MIIDcjCCAlqgAwIBAgIUZvnHwa/swlG07VOX5uaCwysckBYwDQYJKoZIhvcNAQELBQAwUTELMAkG
  47476. A1UEBhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28uLCBMdGQuMR0wGwYDVQQDExRT
  47477. ZWN1cmVTaWduIFJvb3QgQ0ExMjAeFw0yMDA0MDgwNTM2NDZaFw00MDA0MDgwNTM2NDZaMFExCzAJ
  47478. BgNVBAYTAkpQMSMwIQYDVQQKExpDeWJlcnRydXN0IEphcGFuIENvLiwgTHRkLjEdMBsGA1UEAxMU
  47479. U2VjdXJlU2lnbiBSb290IENBMTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6OcE3
  47480. emhFKxS06+QT61d1I02PJC0W6K6OyX2kVzsqdiUzg2zqMoqUm048luT9Ub+ZyZN+v/mtp7JIKwcc
  47481. J/VMvHASd6SFVLX9kHrko+RRWAPNEHl57muTH2SOa2SroxPjcf59q5zdJ1M3s6oYwlkm7Fsf0uZl
  47482. fO+TvdhYXAvA42VvPMfKWeP+bl+sg779XSVOKik71gurFzJ4pOE+lEa+Ym6b3kaosRbnhW70CEBF
  47483. EaCeVESE99g2zvVQR9wsMJvuwPWW0v4JhscGWa5Pro4RmHvzC1KqYiaqId+OJTN5lxZJjfU+1Uef
  47484. NzFJM3IFTQy2VYzxV4+Kh9GtxRESOaCtAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  47485. AQH/BAQDAgEGMB0GA1UdDgQWBBRXNPN0zwRL1SXm8UC2LEzZLemgrTANBgkqhkiG9w0BAQsFAAOC
  47486. AQEAPrvbFxbS8hQBICw4g0utvsqFepq2m2um4fylOqyttCg6r9cBg0krY6LdmmQOmFxv3Y67ilQi
  47487. LUoT865AQ9tPkbeGGuwAtEGBpE/6aouIs3YIcipJQMPTw4WJmBClnW8Zt7vPemVV2zfrPIpyMpce
  47488. mik+rY3moxtt9XUa5rBouVui7mlHJzWhhpmA8zNL4WukJsPvdFlseqJkth5Ew1DgDzk9qTPxpfPS
  47489. vWKErI4cqc1avTc7bgoitPQV55FYxTpE05Uo2cBl6XLK0A+9H7MV2anjpEcJnuDLN/v9vZfVvhga
  47490. aaI5gdka9at/yOPiZwud9AzqVN/Ssq+xIvEg37xEHA==
  47491. -----END CERTIFICATE-----
  47492. SecureSign Root CA14
  47493. ====================
  47494. -----BEGIN CERTIFICATE-----
  47495. MIIFcjCCA1qgAwIBAgIUZNtaDCBO6Ncpd8hQJ6JaJ90t8sswDQYJKoZIhvcNAQEMBQAwUTELMAkG
  47496. A1UEBhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28uLCBMdGQuMR0wGwYDVQQDExRT
  47497. ZWN1cmVTaWduIFJvb3QgQ0ExNDAeFw0yMDA0MDgwNzA2MTlaFw00NTA0MDgwNzA2MTlaMFExCzAJ
  47498. BgNVBAYTAkpQMSMwIQYDVQQKExpDeWJlcnRydXN0IEphcGFuIENvLiwgTHRkLjEdMBsGA1UEAxMU
  47499. U2VjdXJlU2lnbiBSb290IENBMTQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDF0nqh
  47500. 1oq/FjHQmNE6lPxauG4iwWL3pwon71D2LrGeaBLwbCRjOfHw3xDG3rdSINVSW0KZnvOgvlIfX8xn
  47501. bacuUKLBl422+JX1sLrcneC+y9/3OPJH9aaakpUqYllQC6KxNedlsmGy6pJxaeQp8E+BgQQ8sqVb
  47502. 1MWoWWd7VRxJq3qdwudzTe/NCcLEVxLbAQ4jeQkHO6Lo/IrPj8BGJJw4J+CDnRugv3gVEOuGTgpa
  47503. /d/aLIJ+7sr2KeH6caH3iGicnPCNvg9JkdjqOvn90Ghx2+m1K06Ckm9mH+Dw3EzsytHqunQG+bOE
  47504. kJTRX45zGRBdAuVwpcAQ0BB8b8VYSbSwbprafZX1zNoCr7gsfXmPvkPx+SgojQlD+Ajda8iLLCSx
  47505. jVIHvXiby8posqTdDEx5YMaZ0ZPxMBoH064iwurO8YQJzOAUbn8/ftKChazcqRZOhaBgy/ac18iz
  47506. ju3Gm5h1DVXoX+WViwKkrkMpKBGk5hIwAUt1ax5mnXkvpXYvHUC0bcl9eQjs0Wq2XSqypWa9a4X0
  47507. dFbD9ed1Uigspf9mR6XU/v6eVL9lfgHWMI+lNpyiUBzuOIABSMbHdPTGrMNASRZhdCyvjG817XsY
  47508. AFs2PJxQDcqSMxDxJklt33UkN4Ii1+iW/RVLApY+B3KVfqs9TC7XyvDf4Fg/LS8EmjijAQIDAQAB
  47509. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUBpOjCl4oaTeq
  47510. YR3r6/wtbyPk86AwDQYJKoZIhvcNAQEMBQADggIBAJaAcgkGfpzMkwQWu6A6jZJOtxEaCnFxEM0E
  47511. rX+lRVAQZk5KQaID2RFPeje5S+LGjzJmdSX7684/AykmjbgWHfYfM25I5uj4V7Ibed87hwriZLoA
  47512. ymzvftAj63iP/2SbNDefNWWipAA9EiOWWF3KY4fGoweITedpdopTzfFP7ELyk+OZpDc8h7hi2/Ds
  47513. Hzc/N19DzFGdtfCXwreFamgLRB7lUe6TzktuhsHSDCRZNhqfLJGP4xjblJUK7ZGqDpncllPjYYPG
  47514. FrojutzdfhrGe0K22VoF3Jpf1d+42kd92jjbrDnVHmtsKheMYc2xbXIBw8MgAGJoFjHVdqqGuw6q
  47515. nsb58Nn4DSEC5MUoFlkRudlpcyqSeLiSV5sI8jrlL5WwWLdrIBRtFO8KvH7YVdiI2i/6GaX7i+B/
  47516. OfVyK4XELKzvGUWSTLNhB9xNH27SgRNcmvMSZ4PPmz+Ln52kuaiWA3rF7iDeM9ovnhp6dB7h7sxa
  47517. OgTdsxoEqBRjrLdHEoOabPXm6RUVkRqEGQ6UROcSjiVbgGcZ3GOTEAtlLor6CZpO2oYofaphNdgO
  47518. pygau1LgePhsumywbrmHXumZNTfxPWQrqaA0k89jL9WB365jJ6UeTo3cKXhZ+PmhIIynJkBugnLN
  47519. eLLIjzwec+fBH7/PzqUqm9tEZDKgu39cJRNItX+S
  47520. -----END CERTIFICATE-----
  47521. SecureSign Root CA15
  47522. ====================
  47523. -----BEGIN CERTIFICATE-----
  47524. MIICIzCCAamgAwIBAgIUFhXHw9hJp75pDIqI7fBw+d23PocwCgYIKoZIzj0EAwMwUTELMAkGA1UE
  47525. BhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28uLCBMdGQuMR0wGwYDVQQDExRTZWN1
  47526. cmVTaWduIFJvb3QgQ0ExNTAeFw0yMDA0MDgwODMyNTZaFw00NTA0MDgwODMyNTZaMFExCzAJBgNV
  47527. BAYTAkpQMSMwIQYDVQQKExpDeWJlcnRydXN0IEphcGFuIENvLiwgTHRkLjEdMBsGA1UEAxMUU2Vj
  47528. dXJlU2lnbiBSb290IENBMTUwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQLUHSNZDKZmbPSYAi4Io5G
  47529. dCx4wCtELW1fHcmuS1Iggz24FG1Th2CeX2yF2wYUleDHKP+dX+Sq8bOLbe1PL0vJSpSRZHX+AezB
  47530. 2Ot6lHhWGENfa4HL9rzatAy2KZMIaY+jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD
  47531. AgEGMB0GA1UdDgQWBBTrQciu/NWeUUj1vYv0hyCTQSvT9DAKBggqhkjOPQQDAwNoADBlAjEA2S6J
  47532. fl5OpBEHvVnCB96rMjhTKkZEBhd6zlHp4P9mLQlO4E/0BdGF9jVg3PVys0Z9AjBEmEYagoUeYWmJ
  47533. SwdLZrWeqrqgHkHZAXQ6bkU6iYAZezKYVWOr62Nuk22rGwlgMU4=
  47534. -----END CERTIFICATE-----
  47535. D-TRUST BR Root CA 2 2023
  47536. =========================
  47537. -----BEGIN CERTIFICATE-----
  47538. MIIFqTCCA5GgAwIBAgIQczswBEhb2U14LnNLyaHcZjANBgkqhkiG9w0BAQ0FADBIMQswCQYDVQQG
  47539. EwJERTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEJSIFJvb3QgQ0Eg
  47540. MiAyMDIzMB4XDTIzMDUwOTA4NTYzMVoXDTM4MDUwOTA4NTYzMFowSDELMAkGA1UEBhMCREUxFTAT
  47541. BgNVBAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBCUiBSb290IENBIDIgMjAyMzCC
  47542. AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK7/CVmRgApKaOYkP7in5Mg6CjoWzckjYaCT
  47543. cfKri3OPoGdlYNJUa2NRb0kz4HIHE304zQaSBylSa053bATTlfrdTIzZXcFhfUvnKLNEgXtRr90z
  47544. sWh81k5M/itoucpmacTsXld/9w3HnDY25QdgrMBM6ghs7wZ8T1soegj8k12b9py0i4a6Ibn08OhZ
  47545. WiihNIQaJZG2tY/vsvmA+vk9PBFy2OMvhnbFeSzBqZCTRphny4NqoFAjpzv2gTng7fC5v2Xx2Mt6
  47546. ++9zA84A9H3X4F07ZrjcjrqDy4d2A/wl2ecjbwb9Z/Pg/4S8R7+1FhhGaRTMBffb00msa8yr5LUL
  47547. QyReS2tNZ9/WtT5PeB+UcSTq3nD88ZP+npNa5JRal1QMNXtfbO4AHyTsA7oC9Xb0n9Sa7YUsOCIv
  47548. x9gvdhFP/Wxc6PWOJ4d/GUohR5AdeY0cW/jPSoXk7bNbjb7EZChdQcRurDhaTyN0dKkSw/bSuREV
  47549. MweR2Ds3OmMwBtHFIjYoYiMQ4EbMl6zWK11kJNXuHA7e+whadSr2Y23OC0K+0bpwHJwh5Q8xaRfX
  47550. /Aq03u2AnMuStIv13lmiWAmlY0cL4UEyNEHZmrHZqLAbWt4NDfTisl01gLmB1IRpkQLLddCNxbU9
  47551. CZEJjxShFHR5PtbJFR2kWVki3PaKRT08EtY+XTIvAgMBAAGjgY4wgYswDwYDVR0TAQH/BAUwAwEB
  47552. /zAdBgNVHQ4EFgQUZ5Dw1t61GNVGKX5cq/ieCLxklRAwDgYDVR0PAQH/BAQDAgEGMEkGA1UdHwRC
  47553. MEAwPqA8oDqGOGh0dHA6Ly9jcmwuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3RfYnJfcm9vdF9jYV8y
  47554. XzIwMjMuY3JsMA0GCSqGSIb3DQEBDQUAA4ICAQA097N3U9swFrktpSHxQCF16+tIFoE9c+CeJyrr
  47555. d6kTpGoKWloUMz1oH4Guaf2Mn2VsNELZLdB/eBaxOqwjMa1ef67nriv6uvw8l5VAk1/DLQOj7aRv
  47556. U9f6QA4w9QAgLABMjDu0ox+2v5Eyq6+SmNMW5tTRVFxDWy6u71cqqLRvpO8NVhTaIasgdp4D/Ca4
  47557. nj8+AybmTNudX0KEPUUDAxxZiMrcLmEkWqTqJwtzEr5SswrPMhfiHocaFpVIbVrg0M8JkiZmkdij
  47558. YQ6qgYF/6FKC0ULn4B0Y+qSFNueG4A3rvNTJ1jxD8V1Jbn6Bm2m1iWKPiFLY1/4nwSPFyysCu7Ff
  47559. /vtDhQNGvl3GyiEm/9cCnnRK3PgTFbGBVzbLZVzRHTF36SXDw7IyN9XxmAnkbWOACKsGkoHU6XCP
  47560. pz+y7YaMgmo1yEJagtFSGkUPFaUA8JR7ZSdXOUPPfH/mvTWze/EZTN46ls/pdu4D58JDUjxqgejB
  47561. WoC9EV2Ta/vH5mQ/u2kc6d0li690yVRAysuTEwrt+2aSEcr1wPrYg1UDfNPFIkZ1cGt5SAYqgpq/
  47562. 5usWDiJFAbzdNpQ0qTUmiteXue4Icr80knCDgKs4qllo3UCkGJCy89UDyibK79XH4I9TjvAA46jt
  47563. n/mtd+ArY0+ew+43u3gJhJ65bvspmZDogNOfJA==
  47564. -----END CERTIFICATE-----
  47565. D-TRUST EV Root CA 2 2023
  47566. =========================
  47567. -----BEGIN CERTIFICATE-----
  47568. MIIFqTCCA5GgAwIBAgIQaSYJfoBLTKCnjHhiU19abzANBgkqhkiG9w0BAQ0FADBIMQswCQYDVQQG
  47569. EwJERTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEVWIFJvb3QgQ0Eg
  47570. MiAyMDIzMB4XDTIzMDUwOTA5MTAzM1oXDTM4MDUwOTA5MTAzMlowSDELMAkGA1UEBhMCREUxFTAT
  47571. BgNVBAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBFViBSb290IENBIDIgMjAyMzCC
  47572. AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANiOo4mAC7JXUtypU0w3uX9jFxPvp1sjW2l1
  47573. sJkKF8GLxNuo4MwxusLyzV3pt/gdr2rElYfXR8mV2IIEUD2BCP/kPbOx1sWy/YgJ25yE7CUXFId/
  47574. MHibaljJtnMoPDT3mfd/06b4HEV8rSyMlD/YZxBTfiLNTiVR8CUkNRFeEMbsh2aJgWi6zCudR3Mf
  47575. vc2RpHJqnKIbGKBv7FD0fUDCqDDPvXPIEysQEx6Lmqg6lHPTGGkKSv/BAQP/eX+1SH977ugpbzZM
  47576. lWGG2Pmic4ruri+W7mjNPU0oQvlFKzIbRlUWaqZLKfm7lVa/Rh3sHZMdwGWyH6FDrlaeoLGPaxK3
  47577. YG14C8qKXO0elg6DpkiVjTujIcSuWMYAsoS0I6SWhjW42J7YrDRJmGOVxcttSEfi8i4YHtAxq910
  47578. 7PncjLgcjmgjutDzUNzPZY9zOjLHfP7KgiJPvo5iR2blzYfi6NUPGJ/lBHJLRjwQ8kTCZFZxTnXo
  47579. nMkmdMV9WdEKWw9t/p51HBjGGjp82A0EzM23RWV6sY+4roRIPrN6TagD4uJ+ARZZaBhDM7DS3LAa
  47580. QzXupdqpRlyuhoFBAUp0JuyfBr/CBTdkdXgpaP3F9ev+R/nkhbDhezGdpn9yo7nELC7MmVcOIQxF
  47581. AZRl62UJxmMiCzNJkkg8/M3OsD6Onov4/knFNXJHAgMBAAGjgY4wgYswDwYDVR0TAQH/BAUwAwEB
  47582. /zAdBgNVHQ4EFgQUqvyREBuHkV8Wub9PS5FeAByxMoAwDgYDVR0PAQH/BAQDAgEGMEkGA1UdHwRC
  47583. MEAwPqA8oDqGOGh0dHA6Ly9jcmwuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3RfZXZfcm9vdF9jYV8y
  47584. XzIwMjMuY3JsMA0GCSqGSIb3DQEBDQUAA4ICAQCTy6UfmRHsmg1fLBWTxj++EI14QvBukEdHjqOS
  47585. Mo1wj/Zbjb6JzkcBahsgIIlbyIIQbODnmaprxiqgYzWRaoUlrRc4pZt+UPJ26oUFKidBK7GB0aL2
  47586. QHWpDsvxVUjY7NHss+jOFKE17MJeNRqrphYBBo7q3C+jisosketSjl8MmxfPy3MHGcRqwnNU73xD
  47587. UmPBEcrCRbH0O1P1aa4846XerOhUt7KR/aypH/KH5BfGSah82ApB9PI+53c0BFLd6IHyTS9URZ0V
  47588. 4U/M5d40VxDJI3IXcI1QcB9WbMy5/zpaT2N6w25lBx2Eof+pDGOJbbJAiDnXH3dotfyc1dZnaVuo
  47589. dNv8ifYbMvekJKZ2t0dT741Jj6m2g1qllpBFYfXeA08mD6iL8AOWsKwV0HFaanuU5nCT2vFp4LJi
  47590. TZ6P/4mdm13NRemUAiKN4DV/6PEEeXFsVIP4M7kFMhtYVRFP0OUnR3Hs7dpn1mKmS00PaaLJvOwi
  47591. S5THaJQXfuKOKD62xur1NGyfN4gHONuGcfrNlUhDbqNPgofXNJhuS5N5YHVpD/Aa1VP6IQzCP+k/
  47592. HxiMkl14p3ZnGbuy6n/pcAlWVqOwDAstNl7F6cTVg8uGF5csbBNvh1qvSaYd2804BC5f4ko1Di1L
  47593. +KIkBI3Y4WNeApI02phhXBxvWHZks/wCuPWdCg==
  47594. -----END CERTIFICATE-----
  47595. <?php
  47596. namespace Composer\CaBundle;
  47597. use Psr\Log\LoggerInterface;
  47598. use Symfony\Component\Process\PhpProcess;
  47599. class CaBundle
  47600. {
  47601. private static $caPath;
  47602. private static $caFileValidity = array();
  47603. public static function getSystemCaRootBundlePath(?LoggerInterface $logger = null)
  47604. {
  47605. if (self::$caPath !== null) {
  47606. return self::$caPath;
  47607. }
  47608. $caBundlePaths = array();
  47609. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
  47610. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_DIR');
  47611. $caBundlePaths[] = ini_get('openssl.cafile');
  47612. $caBundlePaths[] = ini_get('openssl.capath');
  47613. $otherLocations = array(
  47614. '/etc/pki/tls/certs/ca-bundle.crt',
  47615. '/etc/ssl/certs/ca-certificates.crt',
  47616. '/etc/ssl/ca-bundle.pem',
  47617. '/usr/ssl/certs/ca-bundle.crt',
  47618. '/opt/local/share/curl/curl-ca-bundle.crt',
  47619. '/usr/local/share/curl/curl-ca-bundle.crt',
  47620. '/usr/share/ssl/certs/ca-bundle.crt',
  47621. '/etc/ssl/cert.pem',
  47622. '/usr/local/etc/openssl/cert.pem',
  47623. '/usr/local/etc/openssl@1.1/cert.pem',
  47624. '/opt/homebrew/etc/openssl@3/cert.pem',
  47625. '/opt/homebrew/etc/openssl@1.1/cert.pem',
  47626. '/etc/pki/tls/certs',
  47627. '/etc/ssl/certs',
  47628. );
  47629. $caBundlePaths = array_merge($caBundlePaths, $otherLocations);
  47630. foreach ($caBundlePaths as $caBundle) {
  47631. if ($caBundle && self::caFileUsable($caBundle, $logger)) {
  47632. return self::$caPath = $caBundle;
  47633. }
  47634. if ($caBundle && self::caDirUsable($caBundle, $logger)) {
  47635. return self::$caPath = $caBundle;
  47636. }
  47637. }
  47638. return self::$caPath = static::getBundledCaBundlePath();
  47639. }
  47640. public static function getBundledCaBundlePath()
  47641. {
  47642. $caBundleFile = __DIR__.'/../res/cacert.pem';
  47643. if (0 === strpos($caBundleFile, 'phar://')) {
  47644. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-');
  47645. if (false === $tempCaBundleFile) {
  47646. throw new \RuntimeException('Could not create a temporary file to store the bundled CA file');
  47647. }
  47648. file_put_contents(
  47649. $tempCaBundleFile,
  47650. file_get_contents($caBundleFile)
  47651. );
  47652. register_shutdown_function(function() use ($tempCaBundleFile) {
  47653. @unlink($tempCaBundleFile);
  47654. });
  47655. $caBundleFile = $tempCaBundleFile;
  47656. }
  47657. return $caBundleFile;
  47658. }
  47659. public static function validateCaFile($filename, ?LoggerInterface $logger = null)
  47660. {
  47661. static $warned = false;
  47662. if (isset(self::$caFileValidity[$filename])) {
  47663. return self::$caFileValidity[$filename];
  47664. }
  47665. $contents = file_get_contents($filename);
  47666. if (is_string($contents) && strlen($contents) > 0) {
  47667. $contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
  47668. if (null === $contents) {
  47669. $isValid = false;
  47670. } else {
  47671. $isValid = (bool) openssl_x509_parse($contents);
  47672. }
  47673. } else {
  47674. $isValid = false;
  47675. }
  47676. if ($logger) {
  47677. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  47678. }
  47679. return self::$caFileValidity[$filename] = $isValid;
  47680. }
  47681. public static function isOpensslParseSafe()
  47682. {
  47683. return true;
  47684. }
  47685. public static function reset()
  47686. {
  47687. self::$caFileValidity = array();
  47688. self::$caPath = null;
  47689. }
  47690. private static function getEnvVariable($name)
  47691. {
  47692. if (isset($_SERVER[$name])) {
  47693. return (string) $_SERVER[$name];
  47694. }
  47695. if (PHP_SAPI === 'cli' && ($value = getenv($name)) !== false && $value !== null) {
  47696. return (string) $value;
  47697. }
  47698. return false;
  47699. }
  47700. private static function caFileUsable($certFile, ?LoggerInterface $logger = null)
  47701. {
  47702. return $certFile
  47703. && self::isFile($certFile, $logger)
  47704. && self::isReadable($certFile, $logger)
  47705. && self::validateCaFile($certFile, $logger);
  47706. }
  47707. private static function caDirUsable($certDir, ?LoggerInterface $logger = null)
  47708. {
  47709. return $certDir
  47710. && self::isDir($certDir, $logger)
  47711. && self::isReadable($certDir, $logger)
  47712. && self::glob($certDir . '/*', $logger);
  47713. }
  47714. private static function isFile($certFile, ?LoggerInterface $logger = null)
  47715. {
  47716. $isFile = @is_file($certFile);
  47717. if (!$isFile && $logger) {
  47718. $logger->debug(sprintf('Checked CA file %s does not exist or it is not a file.', $certFile));
  47719. }
  47720. return $isFile;
  47721. }
  47722. private static function isDir($certDir, ?LoggerInterface $logger = null)
  47723. {
  47724. $isDir = @is_dir($certDir);
  47725. if (!$isDir && $logger) {
  47726. $logger->debug(sprintf('Checked directory %s does not exist or it is not a directory.', $certDir));
  47727. }
  47728. return $isDir;
  47729. }
  47730. private static function isReadable($certFileOrDir, ?LoggerInterface $logger = null)
  47731. {
  47732. $isReadable = @is_readable($certFileOrDir);
  47733. if (!$isReadable && $logger) {
  47734. $logger->debug(sprintf('Checked file or directory %s is not readable.', $certFileOrDir));
  47735. }
  47736. return $isReadable;
  47737. }
  47738. private static function glob($pattern, ?LoggerInterface $logger = null)
  47739. {
  47740. $certs = glob($pattern);
  47741. if ($certs === false) {
  47742. if ($logger) {
  47743. $logger->debug(sprintf("An error occurred while trying to find certificates for pattern: %s", $pattern));
  47744. }
  47745. return false;
  47746. }
  47747. if (count($certs) === 0) {
  47748. if ($logger) {
  47749. $logger->debug(sprintf("No CA files found for pattern: %s", $pattern));
  47750. }
  47751. return false;
  47752. }
  47753. return true;
  47754. }
  47755. }
  47756. Copyright (C) 2022 Composer
  47757. Permission is hereby granted, free of charge, to any person obtaining a copy of
  47758. this software and associated documentation files (the "Software"), to deal in
  47759. the Software without restriction, including without limitation the rights to
  47760. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  47761. of the Software, and to permit persons to whom the Software is furnished to do
  47762. so, subject to the following conditions:
  47763. The above copyright notice and this permission notice shall be included in all
  47764. copies or substantial portions of the Software.
  47765. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47766. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47767. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47768. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47769. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47770. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  47771. SOFTWARE.
  47772. <?php declare(strict_types=1);
  47773. namespace Composer\ClassMapGenerator;
  47774. use Composer\Pcre\Preg;
  47775. class ClassMap implements \Countable
  47776. {
  47777. public $map = [];
  47778. private $ambiguousClasses = [];
  47779. private $psrViolations = [];
  47780. public function getMap(): array
  47781. {
  47782. return $this->map;
  47783. }
  47784. public function getPsrViolations(): array
  47785. {
  47786. if (\count($this->psrViolations) === 0) {
  47787. return [];
  47788. }
  47789. return array_map(static function (array $violation): string {
  47790. return $violation['warning'];
  47791. }, array_merge(...array_values($this->psrViolations)));
  47792. }
  47793. public function getAmbiguousClasses($duplicatesFilter = '{/(test|fixture|example|stub)s?/}i'): array
  47794. {
  47795. if (false === $duplicatesFilter) {
  47796. return $this->ambiguousClasses;
  47797. }
  47798. if (true === $duplicatesFilter) {
  47799. throw new \InvalidArgumentException('$duplicatesFilter should be false or a string with a valid regex, got true.');
  47800. }
  47801. $ambiguousClasses = [];
  47802. foreach ($this->ambiguousClasses as $class => $paths) {
  47803. $paths = array_filter($paths, function ($path) use ($duplicatesFilter) {
  47804. return !Preg::isMatch($duplicatesFilter, strtr($path, '\\', '/'));
  47805. });
  47806. if (\count($paths) > 0) {
  47807. $ambiguousClasses[$class] = array_values($paths);
  47808. }
  47809. }
  47810. return $ambiguousClasses;
  47811. }
  47812. public function sort(): void
  47813. {
  47814. ksort($this->map);
  47815. }
  47816. public function addClass(string $className, string $path): void
  47817. {
  47818. unset($this->psrViolations[strtr($path, '\\', '/')]);
  47819. $this->map[$className] = $path;
  47820. }
  47821. public function getClassPath(string $className): string
  47822. {
  47823. if (!isset($this->map[$className])) {
  47824. throw new \OutOfBoundsException('Class '.$className.' is not present in the map');
  47825. }
  47826. return $this->map[$className];
  47827. }
  47828. public function hasClass(string $className): bool
  47829. {
  47830. return isset($this->map[$className]);
  47831. }
  47832. public function addPsrViolation(string $warning, string $className, string $path): void
  47833. {
  47834. $path = rtrim(strtr($path, '\\', '/'), '/');
  47835. $this->psrViolations[$path][] = ['warning' => $warning, 'className' => $className];
  47836. }
  47837. public function clearPsrViolationsByPath(string $pathPrefix): void
  47838. {
  47839. $pathPrefix = rtrim(strtr($pathPrefix, '\\', '/'), '/');
  47840. foreach ($this->psrViolations as $path => $violations) {
  47841. if ($path === $pathPrefix || 0 === \strpos($path, $pathPrefix.'/')) {
  47842. unset($this->psrViolations[$path]);
  47843. }
  47844. }
  47845. }
  47846. public function addAmbiguousClass(string $className, string $path): void
  47847. {
  47848. $this->ambiguousClasses[$className][] = $path;
  47849. }
  47850. public function count(): int
  47851. {
  47852. return \count($this->map);
  47853. }
  47854. public function getRawPsrViolations(): array
  47855. {
  47856. return $this->psrViolations;
  47857. }
  47858. }
  47859. <?php declare(strict_types=1);
  47860. namespace Composer\ClassMapGenerator;
  47861. use Composer\Pcre\Preg;
  47862. use Symfony\Component\Finder\Finder;
  47863. use Composer\IO\IOInterface;
  47864. class ClassMapGenerator
  47865. {
  47866. private $extensions;
  47867. private $scannedFiles = null;
  47868. private $classMap;
  47869. private $streamWrappersRegex;
  47870. public function __construct(array $extensions = ['php', 'inc'])
  47871. {
  47872. $this->extensions = $extensions;
  47873. $this->classMap = new ClassMap;
  47874. $this->streamWrappersRegex = sprintf('{^(?:%s)://}', implode('|', array_map('preg_quote', stream_get_wrappers())));
  47875. }
  47876. public function avoidDuplicateScans(?FileList $scannedFiles = null): self
  47877. {
  47878. $this->scannedFiles = $scannedFiles ?? new FileList;
  47879. return $this;
  47880. }
  47881. public static function createMap($path): array
  47882. {
  47883. $generator = new self();
  47884. $generator->scanPaths($path);
  47885. return $generator->getClassMap()->getMap();
  47886. }
  47887. public function getClassMap(): ClassMap
  47888. {
  47889. return $this->classMap;
  47890. }
  47891. public function scanPaths($path, ?string $excluded = null, string $autoloadType = 'classmap', ?string $namespace = null, array $excludedDirs = []): void
  47892. {
  47893. if (!in_array($autoloadType, ['psr-0', 'psr-4', 'classmap'], true)) {
  47894. throw new \InvalidArgumentException('$autoloadType must be one of: "psr-0", "psr-4" or "classmap"');
  47895. }
  47896. if ('classmap' !== $autoloadType) {
  47897. if (!is_string($path)) {
  47898. throw new \InvalidArgumentException('$path must be a string when specifying a psr-0 or psr-4 autoload type');
  47899. }
  47900. if (!is_string($namespace)) {
  47901. 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');
  47902. }
  47903. $basePath = $path;
  47904. }
  47905. if (is_string($path)) {
  47906. if (is_file($path)) {
  47907. $path = [new \SplFileInfo($path)];
  47908. } elseif (is_dir($path) || strpos($path, '*') !== false) {
  47909. $path = Finder::create()
  47910. ->files()
  47911. ->followLinks()
  47912. ->name('/\.(?:'.implode('|', array_map('preg_quote', $this->extensions)).')$/')
  47913. ->in($path)
  47914. ->exclude($excludedDirs);
  47915. } else {
  47916. throw new \RuntimeException(
  47917. 'Could not scan for classes inside "'.$path.'" which does not appear to be a file nor a folder'
  47918. );
  47919. }
  47920. }
  47921. $cwd = realpath(self::getCwd());
  47922. foreach ($path as $file) {
  47923. $filePath = $file->getPathname();
  47924. if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), $this->extensions, true)) {
  47925. continue;
  47926. }
  47927. $isStreamWrapperPath = Preg::isMatch($this->streamWrappersRegex, $filePath);
  47928. if (!self::isAbsolutePath($filePath) && !$isStreamWrapperPath) {
  47929. $filePath = $cwd . '/' . $filePath;
  47930. $filePath = self::normalizePath($filePath);
  47931. } else {
  47932. $filePath = Preg::replace('{(?<!:)[\\\\/]{2,}}', '/', $filePath);
  47933. }
  47934. if ('' === $filePath) {
  47935. throw new \LogicException('Got an empty $filePath for '.$file->getPathname());
  47936. }
  47937. $realPath = $isStreamWrapperPath
  47938. ? $filePath
  47939. : realpath($filePath);
  47940. if (false === $realPath) {
  47941. throw new \RuntimeException('realpath of '.$filePath.' failed to resolve, got false');
  47942. }
  47943. if ($this->scannedFiles !== null && $this->scannedFiles->contains($realPath)) {
  47944. continue;
  47945. }
  47946. if (null !== $excluded && Preg::isMatch($excluded, strtr($realPath, '\\', '/'))) {
  47947. continue;
  47948. }
  47949. if (null !== $excluded && Preg::isMatch($excluded, strtr($filePath, '\\', '/'))) {
  47950. continue;
  47951. }
  47952. $classes = PhpFileParser::findClasses($filePath);
  47953. if ('classmap' !== $autoloadType && isset($namespace)) {
  47954. $classes = $this->filterByNamespace($classes, $filePath, $namespace, $autoloadType, $basePath);
  47955. if (\count($classes) > 0 && $this->scannedFiles !== null) {
  47956. $this->scannedFiles->add($realPath);
  47957. }
  47958. } elseif ($this->scannedFiles !== null) {
  47959. $this->scannedFiles->add($realPath);
  47960. }
  47961. foreach ($classes as $class) {
  47962. if (!$this->classMap->hasClass($class)) {
  47963. $this->classMap->addClass($class, $filePath);
  47964. } elseif ($filePath !== $this->classMap->getClassPath($class)) {
  47965. $this->classMap->addAmbiguousClass($class, $filePath);
  47966. }
  47967. }
  47968. }
  47969. }
  47970. private function filterByNamespace(array $classes, string $filePath, string $baseNamespace, string $namespaceType, string $basePath): array
  47971. {
  47972. $validClasses = [];
  47973. $rejectedClasses = [];
  47974. $realSubPath = substr($filePath, strlen($basePath) + 1);
  47975. $dotPosition = strrpos($realSubPath, '.');
  47976. $realSubPath = substr($realSubPath, 0, $dotPosition === false ? PHP_INT_MAX : $dotPosition);
  47977. foreach ($classes as $class) {
  47978. if ('psr-0' === $namespaceType) {
  47979. $namespaceLength = strrpos($class, '\\');
  47980. if (false !== $namespaceLength) {
  47981. $namespace = substr($class, 0, $namespaceLength + 1);
  47982. $className = substr($class, $namespaceLength + 1);
  47983. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)
  47984. . str_replace('_', DIRECTORY_SEPARATOR, $className);
  47985. } else {
  47986. $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
  47987. }
  47988. } elseif ('psr-4' === $namespaceType) {
  47989. $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;
  47990. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $subNamespace);
  47991. } else {
  47992. throw new \InvalidArgumentException('$namespaceType must be "psr-0" or "psr-4"');
  47993. }
  47994. if ($subPath === $realSubPath) {
  47995. $validClasses[] = $class;
  47996. } else {
  47997. $rejectedClasses[] = $class;
  47998. }
  47999. }
  48000. if (\count($validClasses) === 0) {
  48001. $cwd = realpath(self::getCwd());
  48002. if ($cwd === false) {
  48003. $cwd = self::getCwd();
  48004. }
  48005. $cwd = self::normalizePath($cwd);
  48006. $shortPath = Preg::replace('{^'.preg_quote($cwd).'}', '.', self::normalizePath($filePath), 1);
  48007. $shortBasePath = Preg::replace('{^'.preg_quote($cwd).'}', '.', self::normalizePath($basePath), 1);
  48008. foreach ($rejectedClasses as $class) {
  48009. $this->classMap->addPsrViolation("Class $class located in $shortPath does not comply with $namespaceType autoloading standard (rule: $baseNamespace => $shortBasePath). Skipping.", $class, $filePath);
  48010. }
  48011. return [];
  48012. }
  48013. return $validClasses;
  48014. }
  48015. private static function isAbsolutePath(string $path)
  48016. {
  48017. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  48018. }
  48019. private static function normalizePath(string $path)
  48020. {
  48021. $parts = [];
  48022. $path = strtr($path, '\\', '/');
  48023. $prefix = '';
  48024. $absolute = '';
  48025. if (strpos($path, '//') === 0 && \strlen($path) > 2) {
  48026. $absolute = '//';
  48027. $path = substr($path, 2);
  48028. }
  48029. if (Preg::isMatchStrictGroups('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  48030. $prefix = $match[1];
  48031. $path = substr($path, \strlen($prefix));
  48032. }
  48033. if (strpos($path, '/') === 0) {
  48034. $absolute = '/';
  48035. $path = substr($path, 1);
  48036. }
  48037. $up = false;
  48038. foreach (explode('/', $path) as $chunk) {
  48039. if ('..' === $chunk && (\strlen($absolute) > 0 || $up)) {
  48040. array_pop($parts);
  48041. $up = !(\count($parts) === 0 || '..' === end($parts));
  48042. } elseif ('.' !== $chunk && '' !== $chunk) {
  48043. $parts[] = $chunk;
  48044. $up = '..' !== $chunk;
  48045. }
  48046. }
  48047. $prefix = Preg::replaceCallback('{(?:^|://)[a-z]:$}i', function (array $m) { return strtoupper((string) $m[0]); }, $prefix);
  48048. return $prefix.$absolute.implode('/', $parts);
  48049. }
  48050. private static function getCwd(): string
  48051. {
  48052. $cwd = getcwd();
  48053. if (false === $cwd) {
  48054. throw new \RuntimeException('Could not determine the current working directory');
  48055. }
  48056. return $cwd;
  48057. }
  48058. }
  48059. <?php declare(strict_types=1);
  48060. namespace Composer\ClassMapGenerator;
  48061. class FileList
  48062. {
  48063. public $files = [];
  48064. public function add(string $path): void
  48065. {
  48066. $this->files[$path] = true;
  48067. }
  48068. public function contains(string $path): bool
  48069. {
  48070. return isset($this->files[$path]);
  48071. }
  48072. }
  48073. <?php declare(strict_types=1);
  48074. namespace Composer\ClassMapGenerator;
  48075. use Composer\Pcre\Preg;
  48076. class PhpFileCleaner
  48077. {
  48078. private static $typeConfig;
  48079. private static $restPattern;
  48080. private $contents;
  48081. private $len;
  48082. private $maxMatches;
  48083. private $index = 0;
  48084. public static function setTypeConfig(array $types): void
  48085. {
  48086. foreach ($types as $type) {
  48087. self::$typeConfig[$type[0]] = array(
  48088. 'name' => $type,
  48089. 'length' => \strlen($type),
  48090. 'pattern' => '{.\b(?<![\$:>])'.$type.'\s++[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+}Ais',
  48091. );
  48092. }
  48093. self::$restPattern = '{[^?"\'</'.implode('', array_keys(self::$typeConfig)).']+}A';
  48094. }
  48095. public function __construct(string $contents, int $maxMatches)
  48096. {
  48097. $this->contents = $contents;
  48098. $this->len = \strlen($this->contents);
  48099. $this->maxMatches = $maxMatches;
  48100. }
  48101. public function clean(): string
  48102. {
  48103. $clean = '';
  48104. while ($this->index < $this->len) {
  48105. $this->skipToPhp();
  48106. $clean .= '<?';
  48107. while ($this->index < $this->len) {
  48108. $char = $this->contents[$this->index];
  48109. if ($char === '?' && $this->peek('>')) {
  48110. $clean .= '?>';
  48111. $this->index += 2;
  48112. continue 2;
  48113. }
  48114. if ($char === '"') {
  48115. $this->skipString('"');
  48116. $clean .= 'null';
  48117. continue;
  48118. }
  48119. if ($char === "'") {
  48120. $this->skipString("'");
  48121. $clean .= 'null';
  48122. continue;
  48123. }
  48124. 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)) {
  48125. $this->index += \strlen($match[0]);
  48126. $this->skipHeredoc($match[2]);
  48127. $clean .= 'null';
  48128. continue;
  48129. }
  48130. if ($char === '/') {
  48131. if ($this->peek('/')) {
  48132. $this->skipToNewline();
  48133. continue;
  48134. }
  48135. if ($this->peek('*')) {
  48136. $this->skipComment();
  48137. continue;
  48138. }
  48139. }
  48140. if ($this->maxMatches === 1 && isset(self::$typeConfig[$char])) {
  48141. $type = self::$typeConfig[$char];
  48142. if (
  48143. \substr($this->contents, $this->index, $type['length']) === $type['name']
  48144. && Preg::isMatch($type['pattern'], $this->contents, $match, 0, $this->index - 1)
  48145. ) {
  48146. $clean .= $match[0];
  48147. return $clean;
  48148. }
  48149. }
  48150. $this->index += 1;
  48151. if ($this->match(self::$restPattern, $match)) {
  48152. $clean .= $char . $match[0];
  48153. $this->index += \strlen($match[0]);
  48154. } else {
  48155. $clean .= $char;
  48156. }
  48157. }
  48158. }
  48159. return $clean;
  48160. }
  48161. private function skipToPhp(): void
  48162. {
  48163. while ($this->index < $this->len) {
  48164. if ($this->contents[$this->index] === '<' && $this->peek('?')) {
  48165. $this->index += 2;
  48166. break;
  48167. }
  48168. $this->index += 1;
  48169. }
  48170. }
  48171. private function skipString(string $delimiter): void
  48172. {
  48173. $this->index += 1;
  48174. while ($this->index < $this->len) {
  48175. if ($this->contents[$this->index] === '\\' && ($this->peek('\\') || $this->peek($delimiter))) {
  48176. $this->index += 2;
  48177. continue;
  48178. }
  48179. if ($this->contents[$this->index] === $delimiter) {
  48180. $this->index += 1;
  48181. break;
  48182. }
  48183. $this->index += 1;
  48184. }
  48185. }
  48186. private function skipComment(): void
  48187. {
  48188. $this->index += 2;
  48189. while ($this->index < $this->len) {
  48190. if ($this->contents[$this->index] === '*' && $this->peek('/')) {
  48191. $this->index += 2;
  48192. break;
  48193. }
  48194. $this->index += 1;
  48195. }
  48196. }
  48197. private function skipToNewline(): void
  48198. {
  48199. while ($this->index < $this->len) {
  48200. if ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n") {
  48201. return;
  48202. }
  48203. $this->index += 1;
  48204. }
  48205. }
  48206. private function skipHeredoc(string $delimiter): void
  48207. {
  48208. $firstDelimiterChar = $delimiter[0];
  48209. $delimiterLength = \strlen($delimiter);
  48210. $delimiterPattern = '{'.preg_quote($delimiter).'(?![a-zA-Z0-9_\x80-\xff])}A';
  48211. while ($this->index < $this->len) {
  48212. switch ($this->contents[$this->index]) {
  48213. case "\t":
  48214. case " ":
  48215. $this->index += 1;
  48216. continue 2;
  48217. case $firstDelimiterChar:
  48218. if (
  48219. \substr($this->contents, $this->index, $delimiterLength) === $delimiter
  48220. && $this->match($delimiterPattern)
  48221. ) {
  48222. $this->index += $delimiterLength;
  48223. return;
  48224. }
  48225. break;
  48226. }
  48227. while ($this->index < $this->len) {
  48228. $this->skipToNewline();
  48229. while ($this->index < $this->len && ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n")) {
  48230. $this->index += 1;
  48231. }
  48232. break;
  48233. }
  48234. }
  48235. }
  48236. private function peek(string $char): bool
  48237. {
  48238. return $this->index + 1 < $this->len && $this->contents[$this->index + 1] === $char;
  48239. }
  48240. private function match(string $regex, ?array &$match = null): bool
  48241. {
  48242. return Preg::isMatchStrictGroups($regex, $this->contents, $match, 0, $this->index);
  48243. }
  48244. }
  48245. <?php declare(strict_types=1);
  48246. namespace Composer\ClassMapGenerator;
  48247. use Composer\Pcre\Preg;
  48248. class PhpFileParser
  48249. {
  48250. public static function findClasses(string $path): array
  48251. {
  48252. $extraTypes = self::getExtraTypes();
  48253. if (!function_exists('php_strip_whitespace')) {
  48254. throw new \RuntimeException('Classmap generation relies on the php_strip_whitespace function, but it has been disabled by the disable_functions directive.');
  48255. }
  48256. $contents = @php_strip_whitespace($path);
  48257. if ('' === $contents) {
  48258. if (!file_exists($path)) {
  48259. $message = 'File at "%s" does not exist, check your classmap definitions';
  48260. } elseif (!self::isReadable($path)) {
  48261. $message = 'File at "%s" is not readable, check its permissions';
  48262. } elseif ('' === trim((string) file_get_contents($path))) {
  48263. return array();
  48264. } else {
  48265. $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
  48266. }
  48267. $error = error_get_last();
  48268. if (isset($error['message'])) {
  48269. $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
  48270. }
  48271. throw new \RuntimeException(sprintf($message, $path));
  48272. }
  48273. Preg::matchAllStrictGroups('{\b(?:class|interface|trait'.$extraTypes.')\s}i', $contents, $matches);
  48274. if (0 === \count($matches)) {
  48275. return array();
  48276. }
  48277. $p = new PhpFileCleaner($contents, count($matches[0]));
  48278. $contents = $p->clean();
  48279. unset($p);
  48280. Preg::matchAll('{
  48281. (?:
  48282. \b(?<![\\\\$:>])(?P<type>class|interface|trait'.$extraTypes.') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
  48283. | \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*+ [\{;]
  48284. )
  48285. }ix', $contents, $matches);
  48286. $classes = array();
  48287. $namespace = '';
  48288. for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
  48289. if (isset($matches['ns'][$i]) && $matches['ns'][$i] !== '') {
  48290. $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', (string) $matches['nsname'][$i]) . '\\';
  48291. } else {
  48292. $name = $matches['name'][$i];
  48293. assert(is_string($name));
  48294. if ($name === 'extends' || $name === 'implements') {
  48295. continue;
  48296. }
  48297. if ($name[0] === ':') {
  48298. $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
  48299. } elseif (strtolower((string) $matches['type'][$i]) === 'enum') {
  48300. $colonPos = strrpos($name, ':');
  48301. if (false !== $colonPos) {
  48302. $name = substr($name, 0, $colonPos);
  48303. }
  48304. }
  48305. $className = ltrim($namespace . $name, '\\');
  48306. $classes[] = $className;
  48307. }
  48308. }
  48309. return $classes;
  48310. }
  48311. private static function getExtraTypes(): string
  48312. {
  48313. static $extraTypes = null;
  48314. if (null === $extraTypes) {
  48315. $extraTypes = '';
  48316. if (PHP_VERSION_ID >= 80100 || (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>='))) {
  48317. $extraTypes .= '|enum';
  48318. }
  48319. $extraTypesArray = array_filter(explode('|', $extraTypes), function (string $type) {
  48320. return $type !== '';
  48321. });
  48322. PhpFileCleaner::setTypeConfig(array_merge(['class', 'interface', 'trait'], $extraTypesArray));
  48323. }
  48324. return $extraTypes;
  48325. }
  48326. private static function isReadable(string $path)
  48327. {
  48328. if (is_readable($path)) {
  48329. return true;
  48330. }
  48331. if (is_file($path)) {
  48332. return false !== @file_get_contents($path, false, null, 0, 1);
  48333. }
  48334. return false;
  48335. }
  48336. }
  48337. {
  48338. "packages": [
  48339. {
  48340. "name": "composer/ca-bundle",
  48341. "version": "1.5.6",
  48342. "version_normalized": "1.5.6.0",
  48343. "source": {
  48344. "type": "git",
  48345. "url": "https://github.com/composer/ca-bundle.git",
  48346. "reference": "f65c239c970e7f072f067ab78646e9f0b2935175"
  48347. },
  48348. "dist": {
  48349. "type": "zip",
  48350. "url": "https://api.github.com/repos/composer/ca-bundle/zipball/f65c239c970e7f072f067ab78646e9f0b2935175",
  48351. "reference": "f65c239c970e7f072f067ab78646e9f0b2935175",
  48352. "shasum": ""
  48353. },
  48354. "require": {
  48355. "ext-openssl": "*",
  48356. "ext-pcre": "*",
  48357. "php": "^7.2 || ^8.0"
  48358. },
  48359. "require-dev": {
  48360. "phpstan/phpstan": "^1.10",
  48361. "phpunit/phpunit": "^8 || ^9",
  48362. "psr/log": "^1.0 || ^2.0 || ^3.0",
  48363. "symfony/process": "^4.0 || ^5.0 || ^6.0 || ^7.0"
  48364. },
  48365. "time": "2025-03-06T14:30:56+00:00",
  48366. "type": "library",
  48367. "extra": {
  48368. "branch-alias": {
  48369. "dev-main": "1.x-dev"
  48370. }
  48371. },
  48372. "installation-source": "dist",
  48373. "autoload": {
  48374. "psr-4": {
  48375. "Composer\\CaBundle\\": "src"
  48376. }
  48377. },
  48378. "notification-url": "https://packagist.org/downloads/",
  48379. "license": [
  48380. "MIT"
  48381. ],
  48382. "authors": [
  48383. {
  48384. "name": "Jordi Boggiano",
  48385. "email": "j.boggiano@seld.be",
  48386. "homepage": "http://seld.be"
  48387. }
  48388. ],
  48389. "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.",
  48390. "keywords": [
  48391. "cabundle",
  48392. "cacert",
  48393. "certificate",
  48394. "ssl",
  48395. "tls"
  48396. ],
  48397. "support": {
  48398. "irc": "irc://irc.freenode.org/composer",
  48399. "issues": "https://github.com/composer/ca-bundle/issues",
  48400. "source": "https://github.com/composer/ca-bundle/tree/1.5.6"
  48401. },
  48402. "funding": [
  48403. {
  48404. "url": "https://packagist.com",
  48405. "type": "custom"
  48406. },
  48407. {
  48408. "url": "https://github.com/composer",
  48409. "type": "github"
  48410. },
  48411. {
  48412. "url": "https://tidelift.com/funding/github/packagist/composer/composer",
  48413. "type": "tidelift"
  48414. }
  48415. ],
  48416. "install-path": "./ca-bundle"
  48417. },
  48418. {
  48419. "name": "composer/class-map-generator",
  48420. "version": "1.6.1",
  48421. "version_normalized": "1.6.1.0",
  48422. "source": {
  48423. "type": "git",
  48424. "url": "https://github.com/composer/class-map-generator.git",
  48425. "reference": "134b705ddb0025d397d8318a75825fe3c9d1da34"
  48426. },
  48427. "dist": {
  48428. "type": "zip",
  48429. "url": "https://api.github.com/repos/composer/class-map-generator/zipball/134b705ddb0025d397d8318a75825fe3c9d1da34",
  48430. "reference": "134b705ddb0025d397d8318a75825fe3c9d1da34",
  48431. "shasum": ""
  48432. },
  48433. "require": {
  48434. "composer/pcre": "^2.1 || ^3.1",
  48435. "php": "^7.2 || ^8.0",
  48436. "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7"
  48437. },
  48438. "require-dev": {
  48439. "phpstan/phpstan": "^1.12 || ^2",
  48440. "phpstan/phpstan-deprecation-rules": "^1 || ^2",
  48441. "phpstan/phpstan-phpunit": "^1 || ^2",
  48442. "phpstan/phpstan-strict-rules": "^1.1 || ^2",
  48443. "phpunit/phpunit": "^8",
  48444. "symfony/filesystem": "^5.4 || ^6"
  48445. },
  48446. "time": "2025-03-24T13:50:44+00:00",
  48447. "type": "library",
  48448. "extra": {
  48449. "branch-alias": {
  48450. "dev-main": "1.x-dev"
  48451. }
  48452. },
  48453. "installation-source": "dist",
  48454. "autoload": {
  48455. "psr-4": {
  48456. "Composer\\ClassMapGenerator\\": "src"
  48457. }
  48458. },
  48459. "notification-url": "https://packagist.org/downloads/",
  48460. "license": [
  48461. "MIT"
  48462. ],
  48463. "authors": [
  48464. {
  48465. "name": "Jordi Boggiano",
  48466. "email": "j.boggiano@seld.be",
  48467. "homepage": "https://seld.be"
  48468. }
  48469. ],
  48470. "description": "Utilities to scan PHP code and generate class maps.",
  48471. "keywords": [
  48472. "classmap"
  48473. ],
  48474. "support": {
  48475. "issues": "https://github.com/composer/class-map-generator/issues",
  48476. "source": "https://github.com/composer/class-map-generator/tree/1.6.1"
  48477. },
  48478. "funding": [
  48479. {
  48480. "url": "https://packagist.com",
  48481. "type": "custom"
  48482. },
  48483. {
  48484. "url": "https://github.com/composer",
  48485. "type": "github"
  48486. },
  48487. {
  48488. "url": "https://tidelift.com/funding/github/packagist/composer/composer",
  48489. "type": "tidelift"
  48490. }
  48491. ],
  48492. "install-path": "./class-map-generator"
  48493. },
  48494. {
  48495. "name": "composer/metadata-minifier",
  48496. "version": "1.0.0",
  48497. "version_normalized": "1.0.0.0",
  48498. "source": {
  48499. "type": "git",
  48500. "url": "https://github.com/composer/metadata-minifier.git",
  48501. "reference": "c549d23829536f0d0e984aaabbf02af91f443207"
  48502. },
  48503. "dist": {
  48504. "type": "zip",
  48505. "url": "https://api.github.com/repos/composer/metadata-minifier/zipball/c549d23829536f0d0e984aaabbf02af91f443207",
  48506. "reference": "c549d23829536f0d0e984aaabbf02af91f443207",
  48507. "shasum": ""
  48508. },
  48509. "require": {
  48510. "php": "^5.3.2 || ^7.0 || ^8.0"
  48511. },
  48512. "require-dev": {
  48513. "composer/composer": "^2",
  48514. "phpstan/phpstan": "^0.12.55",
  48515. "symfony/phpunit-bridge": "^4.2 || ^5"
  48516. },
  48517. "time": "2021-04-07T13:37:33+00:00",
  48518. "type": "library",
  48519. "extra": {
  48520. "branch-alias": {
  48521. "dev-main": "1.x-dev"
  48522. }
  48523. },
  48524. "installation-source": "dist",
  48525. "autoload": {
  48526. "psr-4": {
  48527. "Composer\\MetadataMinifier\\": "src"
  48528. }
  48529. },
  48530. "notification-url": "https://packagist.org/downloads/",
  48531. "license": [
  48532. "MIT"
  48533. ],
  48534. "authors": [
  48535. {
  48536. "name": "Jordi Boggiano",
  48537. "email": "j.boggiano@seld.be",
  48538. "homepage": "http://seld.be"
  48539. }
  48540. ],
  48541. "description": "Small utility library that handles metadata minification and expansion.",
  48542. "keywords": [
  48543. "composer",
  48544. "compression"
  48545. ],
  48546. "support": {
  48547. "issues": "https://github.com/composer/metadata-minifier/issues",
  48548. "source": "https://github.com/composer/metadata-minifier/tree/1.0.0"
  48549. },
  48550. "funding": [
  48551. {
  48552. "url": "https://packagist.com",
  48553. "type": "custom"
  48554. },
  48555. {
  48556. "url": "https://github.com/composer",
  48557. "type": "github"
  48558. },
  48559. {
  48560. "url": "https://tidelift.com/funding/github/packagist/composer/composer",
  48561. "type": "tidelift"
  48562. }
  48563. ],
  48564. "install-path": "./metadata-minifier"
  48565. },
  48566. {
  48567. "name": "composer/pcre",
  48568. "version": "2.3.2",
  48569. "version_normalized": "2.3.2.0",
  48570. "source": {
  48571. "type": "git",
  48572. "url": "https://github.com/composer/pcre.git",
  48573. "reference": "ebb81df8f52b40172d14062ae96a06939d80a069"
  48574. },
  48575. "dist": {
  48576. "type": "zip",
  48577. "url": "https://api.github.com/repos/composer/pcre/zipball/ebb81df8f52b40172d14062ae96a06939d80a069",
  48578. "reference": "ebb81df8f52b40172d14062ae96a06939d80a069",
  48579. "shasum": ""
  48580. },
  48581. "require": {
  48582. "php": "^7.2 || ^8.0"
  48583. },
  48584. "conflict": {
  48585. "phpstan/phpstan": "<1.11.10"
  48586. },
  48587. "require-dev": {
  48588. "phpstan/phpstan": "^1.12 || ^2",
  48589. "phpstan/phpstan-strict-rules": "^1 || ^2",
  48590. "phpunit/phpunit": "^8 || ^9"
  48591. },
  48592. "time": "2024-11-12T16:24:47+00:00",
  48593. "type": "library",
  48594. "extra": {
  48595. "phpstan": {
  48596. "includes": [
  48597. "extension.neon"
  48598. ]
  48599. },
  48600. "branch-alias": {
  48601. "dev-main": "2.x-dev"
  48602. }
  48603. },
  48604. "installation-source": "dist",
  48605. "autoload": {
  48606. "psr-4": {
  48607. "Composer\\Pcre\\": "src"
  48608. }
  48609. },
  48610. "notification-url": "https://packagist.org/downloads/",
  48611. "license": [
  48612. "MIT"
  48613. ],
  48614. "authors": [
  48615. {
  48616. "name": "Jordi Boggiano",
  48617. "email": "j.boggiano@seld.be",
  48618. "homepage": "http://seld.be"
  48619. }
  48620. ],
  48621. "description": "PCRE wrapping library that offers type-safe preg_* replacements.",
  48622. "keywords": [
  48623. "PCRE",
  48624. "preg",
  48625. "regex",
  48626. "regular expression"
  48627. ],
  48628. "support": {
  48629. "issues": "https://github.com/composer/pcre/issues",
  48630. "source": "https://github.com/composer/pcre/tree/2.3.2"
  48631. },
  48632. "funding": [
  48633. {
  48634. "url": "https://packagist.com",
  48635. "type": "custom"
  48636. },
  48637. {
  48638. "url": "https://github.com/composer",
  48639. "type": "github"
  48640. },
  48641. {
  48642. "url": "https://tidelift.com/funding/github/packagist/composer/composer",
  48643. "type": "tidelift"
  48644. }
  48645. ],
  48646. "install-path": "./pcre"
  48647. },
  48648. {
  48649. "name": "composer/semver",
  48650. "version": "3.4.3",
  48651. "version_normalized": "3.4.3.0",
  48652. "source": {
  48653. "type": "git",
  48654. "url": "https://github.com/composer/semver.git",
  48655. "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12"
  48656. },
  48657. "dist": {
  48658. "type": "zip",
  48659. "url": "https://api.github.com/repos/composer/semver/zipball/4313d26ada5e0c4edfbd1dc481a92ff7bff91f12",
  48660. "reference": "4313d26ada5e0c4edfbd1dc481a92ff7bff91f12",
  48661. "shasum": ""
  48662. },
  48663. "require": {
  48664. "php": "^5.3.2 || ^7.0 || ^8.0"
  48665. },
  48666. "require-dev": {
  48667. "phpstan/phpstan": "^1.11",
  48668. "symfony/phpunit-bridge": "^3 || ^7"
  48669. },
  48670. "time": "2024-09-19T14:15:21+00:00",
  48671. "type": "library",
  48672. "extra": {
  48673. "branch-alias": {
  48674. "dev-main": "3.x-dev"
  48675. }
  48676. },
  48677. "installation-source": "dist",
  48678. "autoload": {
  48679. "psr-4": {
  48680. "Composer\\Semver\\": "src"
  48681. }
  48682. },
  48683. "notification-url": "https://packagist.org/downloads/",
  48684. "license": [
  48685. "MIT"
  48686. ],
  48687. "authors": [
  48688. {
  48689. "name": "Nils Adermann",
  48690. "email": "naderman@naderman.de",
  48691. "homepage": "http://www.naderman.de"
  48692. },
  48693. {
  48694. "name": "Jordi Boggiano",
  48695. "email": "j.boggiano@seld.be",
  48696. "homepage": "http://seld.be"
  48697. },
  48698. {
  48699. "name": "Rob Bast",
  48700. "email": "rob.bast@gmail.com",
  48701. "homepage": "http://robbast.nl"
  48702. }
  48703. ],
  48704. "description": "Semver library that offers utilities, version constraint parsing and validation.",
  48705. "keywords": [
  48706. "semantic",
  48707. "semver",
  48708. "validation",
  48709. "versioning"
  48710. ],
  48711. "support": {
  48712. "irc": "ircs://irc.libera.chat:6697/composer",
  48713. "issues": "https://github.com/composer/semver/issues",
  48714. "source": "https://github.com/composer/semver/tree/3.4.3"
  48715. },
  48716. "funding": [
  48717. {
  48718. "url": "https://packagist.com",
  48719. "type": "custom"
  48720. },
  48721. {
  48722. "url": "https://github.com/composer",
  48723. "type": "github"
  48724. },
  48725. {
  48726. "url": "https://tidelift.com/funding/github/packagist/composer/composer",
  48727. "type": "tidelift"
  48728. }
  48729. ],
  48730. "install-path": "./semver"
  48731. },
  48732. {
  48733. "name": "composer/spdx-licenses",
  48734. "version": "1.5.8",
  48735. "version_normalized": "1.5.8.0",
  48736. "source": {
  48737. "type": "git",
  48738. "url": "https://github.com/composer/spdx-licenses.git",
  48739. "reference": "560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a"
  48740. },
  48741. "dist": {
  48742. "type": "zip",
  48743. "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a",
  48744. "reference": "560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a",
  48745. "shasum": ""
  48746. },
  48747. "require": {
  48748. "php": "^5.3.2 || ^7.0 || ^8.0"
  48749. },
  48750. "require-dev": {
  48751. "phpstan/phpstan": "^0.12.55",
  48752. "symfony/phpunit-bridge": "^4.2 || ^5"
  48753. },
  48754. "time": "2023-11-20T07:44:33+00:00",
  48755. "type": "library",
  48756. "extra": {
  48757. "branch-alias": {
  48758. "dev-main": "1.x-dev"
  48759. }
  48760. },
  48761. "installation-source": "dist",
  48762. "autoload": {
  48763. "psr-4": {
  48764. "Composer\\Spdx\\": "src"
  48765. }
  48766. },
  48767. "notification-url": "https://packagist.org/downloads/",
  48768. "license": [
  48769. "MIT"
  48770. ],
  48771. "authors": [
  48772. {
  48773. "name": "Nils Adermann",
  48774. "email": "naderman@naderman.de",
  48775. "homepage": "http://www.naderman.de"
  48776. },
  48777. {
  48778. "name": "Jordi Boggiano",
  48779. "email": "j.boggiano@seld.be",
  48780. "homepage": "http://seld.be"
  48781. },
  48782. {
  48783. "name": "Rob Bast",
  48784. "email": "rob.bast@gmail.com",
  48785. "homepage": "http://robbast.nl"
  48786. }
  48787. ],
  48788. "description": "SPDX licenses list and validation library.",
  48789. "keywords": [
  48790. "license",
  48791. "spdx",
  48792. "validator"
  48793. ],
  48794. "support": {
  48795. "irc": "ircs://irc.libera.chat:6697/composer",
  48796. "issues": "https://github.com/composer/spdx-licenses/issues",
  48797. "source": "https://github.com/composer/spdx-licenses/tree/1.5.8"
  48798. },
  48799. "funding": [
  48800. {
  48801. "url": "https://packagist.com",
  48802. "type": "custom"
  48803. },
  48804. {
  48805. "url": "https://github.com/composer",
  48806. "type": "github"
  48807. },
  48808. {
  48809. "url": "https://tidelift.com/funding/github/packagist/composer/composer",
  48810. "type": "tidelift"
  48811. }
  48812. ],
  48813. "install-path": "./spdx-licenses"
  48814. },
  48815. {
  48816. "name": "composer/xdebug-handler",
  48817. "version": "3.0.5",
  48818. "version_normalized": "3.0.5.0",
  48819. "source": {
  48820. "type": "git",
  48821. "url": "https://github.com/composer/xdebug-handler.git",
  48822. "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef"
  48823. },
  48824. "dist": {
  48825. "type": "zip",
  48826. "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef",
  48827. "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef",
  48828. "shasum": ""
  48829. },
  48830. "require": {
  48831. "composer/pcre": "^1 || ^2 || ^3",
  48832. "php": "^7.2.5 || ^8.0",
  48833. "psr/log": "^1 || ^2 || ^3"
  48834. },
  48835. "require-dev": {
  48836. "phpstan/phpstan": "^1.0",
  48837. "phpstan/phpstan-strict-rules": "^1.1",
  48838. "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5"
  48839. },
  48840. "time": "2024-05-06T16:37:16+00:00",
  48841. "type": "library",
  48842. "installation-source": "dist",
  48843. "autoload": {
  48844. "psr-4": {
  48845. "Composer\\XdebugHandler\\": "src"
  48846. }
  48847. },
  48848. "notification-url": "https://packagist.org/downloads/",
  48849. "license": [
  48850. "MIT"
  48851. ],
  48852. "authors": [
  48853. {
  48854. "name": "John Stevenson",
  48855. "email": "john-stevenson@blueyonder.co.uk"
  48856. }
  48857. ],
  48858. "description": "Restarts a process without Xdebug.",
  48859. "keywords": [
  48860. "Xdebug",
  48861. "performance"
  48862. ],
  48863. "support": {
  48864. "irc": "ircs://irc.libera.chat:6697/composer",
  48865. "issues": "https://github.com/composer/xdebug-handler/issues",
  48866. "source": "https://github.com/composer/xdebug-handler/tree/3.0.5"
  48867. },
  48868. "funding": [
  48869. {
  48870. "url": "https://packagist.com",
  48871. "type": "custom"
  48872. },
  48873. {
  48874. "url": "https://github.com/composer",
  48875. "type": "github"
  48876. },
  48877. {
  48878. "url": "https://tidelift.com/funding/github/packagist/composer/composer",
  48879. "type": "tidelift"
  48880. }
  48881. ],
  48882. "install-path": "./xdebug-handler"
  48883. },
  48884. {
  48885. "name": "justinrainbow/json-schema",
  48886. "version": "6.4.1",
  48887. "version_normalized": "6.4.1.0",
  48888. "source": {
  48889. "type": "git",
  48890. "url": "https://github.com/jsonrainbow/json-schema.git",
  48891. "reference": "35d262c94959571e8736db1e5c9bc36ab94ae900"
  48892. },
  48893. "dist": {
  48894. "type": "zip",
  48895. "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/35d262c94959571e8736db1e5c9bc36ab94ae900",
  48896. "reference": "35d262c94959571e8736db1e5c9bc36ab94ae900",
  48897. "shasum": ""
  48898. },
  48899. "require": {
  48900. "ext-json": "*",
  48901. "marc-mabe/php-enum": "^4.0",
  48902. "php": "^7.2 || ^8.0"
  48903. },
  48904. "require-dev": {
  48905. "friendsofphp/php-cs-fixer": "3.3.0",
  48906. "json-schema/json-schema-test-suite": "1.2.0",
  48907. "marc-mabe/php-enum-phpstan": "^2.0",
  48908. "phpspec/prophecy": "^1.19",
  48909. "phpstan/phpstan": "^1.12",
  48910. "phpunit/phpunit": "^8.5"
  48911. },
  48912. "time": "2025-04-04T13:08:07+00:00",
  48913. "bin": [
  48914. "bin/validate-json"
  48915. ],
  48916. "type": "library",
  48917. "extra": {
  48918. "branch-alias": {
  48919. "dev-master": "6.x-dev"
  48920. }
  48921. },
  48922. "installation-source": "dist",
  48923. "autoload": {
  48924. "psr-4": {
  48925. "JsonSchema\\": "src/JsonSchema/"
  48926. }
  48927. },
  48928. "notification-url": "https://packagist.org/downloads/",
  48929. "license": [
  48930. "MIT"
  48931. ],
  48932. "authors": [
  48933. {
  48934. "name": "Bruno Prieto Reis",
  48935. "email": "bruno.p.reis@gmail.com"
  48936. },
  48937. {
  48938. "name": "Justin Rainbow",
  48939. "email": "justin.rainbow@gmail.com"
  48940. },
  48941. {
  48942. "name": "Igor Wiedler",
  48943. "email": "igor@wiedler.ch"
  48944. },
  48945. {
  48946. "name": "Robert Schönthal",
  48947. "email": "seroscho@googlemail.com"
  48948. }
  48949. ],
  48950. "description": "A library to validate a json schema.",
  48951. "homepage": "https://github.com/jsonrainbow/json-schema",
  48952. "keywords": [
  48953. "json",
  48954. "schema"
  48955. ],
  48956. "support": {
  48957. "issues": "https://github.com/jsonrainbow/json-schema/issues",
  48958. "source": "https://github.com/jsonrainbow/json-schema/tree/6.4.1"
  48959. },
  48960. "install-path": "../justinrainbow/json-schema"
  48961. },
  48962. {
  48963. "name": "marc-mabe/php-enum",
  48964. "version": "v4.7.1",
  48965. "version_normalized": "4.7.1.0",
  48966. "source": {
  48967. "type": "git",
  48968. "url": "https://github.com/marc-mabe/php-enum.git",
  48969. "reference": "7159809e5cfa041dca28e61f7f7ae58063aae8ed"
  48970. },
  48971. "dist": {
  48972. "type": "zip",
  48973. "url": "https://api.github.com/repos/marc-mabe/php-enum/zipball/7159809e5cfa041dca28e61f7f7ae58063aae8ed",
  48974. "reference": "7159809e5cfa041dca28e61f7f7ae58063aae8ed",
  48975. "shasum": ""
  48976. },
  48977. "require": {
  48978. "ext-reflection": "*",
  48979. "php": "^7.1 | ^8.0"
  48980. },
  48981. "require-dev": {
  48982. "phpbench/phpbench": "^0.16.10 || ^1.0.4",
  48983. "phpstan/phpstan": "^1.3.1",
  48984. "phpunit/phpunit": "^7.5.20 | ^8.5.22 | ^9.5.11",
  48985. "vimeo/psalm": "^4.17.0 | ^5.26.1"
  48986. },
  48987. "time": "2024-11-28T04:54:44+00:00",
  48988. "type": "library",
  48989. "extra": {
  48990. "branch-alias": {
  48991. "dev-3.x": "3.2-dev",
  48992. "dev-master": "4.7-dev"
  48993. }
  48994. },
  48995. "installation-source": "dist",
  48996. "autoload": {
  48997. "psr-4": {
  48998. "MabeEnum\\": "src/"
  48999. },
  49000. "classmap": [
  49001. "stubs/Stringable.php"
  49002. ]
  49003. },
  49004. "notification-url": "https://packagist.org/downloads/",
  49005. "license": [
  49006. "BSD-3-Clause"
  49007. ],
  49008. "authors": [
  49009. {
  49010. "name": "Marc Bennewitz",
  49011. "email": "dev@mabe.berlin",
  49012. "homepage": "https://mabe.berlin/",
  49013. "role": "Lead"
  49014. }
  49015. ],
  49016. "description": "Simple and fast implementation of enumerations with native PHP",
  49017. "homepage": "https://github.com/marc-mabe/php-enum",
  49018. "keywords": [
  49019. "enum",
  49020. "enum-map",
  49021. "enum-set",
  49022. "enumeration",
  49023. "enumerator",
  49024. "enummap",
  49025. "enumset",
  49026. "map",
  49027. "set",
  49028. "type",
  49029. "type-hint",
  49030. "typehint"
  49031. ],
  49032. "support": {
  49033. "issues": "https://github.com/marc-mabe/php-enum/issues",
  49034. "source": "https://github.com/marc-mabe/php-enum/tree/v4.7.1"
  49035. },
  49036. "install-path": "../marc-mabe/php-enum"
  49037. },
  49038. {
  49039. "name": "psr/container",
  49040. "version": "1.1.1",
  49041. "version_normalized": "1.1.1.0",
  49042. "source": {
  49043. "type": "git",
  49044. "url": "https://github.com/php-fig/container.git",
  49045. "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
  49046. },
  49047. "dist": {
  49048. "type": "zip",
  49049. "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
  49050. "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
  49051. "shasum": ""
  49052. },
  49053. "require": {
  49054. "php": ">=7.2.0"
  49055. },
  49056. "time": "2021-03-05T17:36:06+00:00",
  49057. "type": "library",
  49058. "installation-source": "dist",
  49059. "autoload": {
  49060. "psr-4": {
  49061. "Psr\\Container\\": "src/"
  49062. }
  49063. },
  49064. "notification-url": "https://packagist.org/downloads/",
  49065. "license": [
  49066. "MIT"
  49067. ],
  49068. "authors": [
  49069. {
  49070. "name": "PHP-FIG",
  49071. "homepage": "https://www.php-fig.org/"
  49072. }
  49073. ],
  49074. "description": "Common Container Interface (PHP FIG PSR-11)",
  49075. "homepage": "https://github.com/php-fig/container",
  49076. "keywords": [
  49077. "PSR-11",
  49078. "container",
  49079. "container-interface",
  49080. "container-interop",
  49081. "psr"
  49082. ],
  49083. "support": {
  49084. "issues": "https://github.com/php-fig/container/issues",
  49085. "source": "https://github.com/php-fig/container/tree/1.1.1"
  49086. },
  49087. "install-path": "../psr/container"
  49088. },
  49089. {
  49090. "name": "psr/log",
  49091. "version": "1.1.4",
  49092. "version_normalized": "1.1.4.0",
  49093. "source": {
  49094. "type": "git",
  49095. "url": "https://github.com/php-fig/log.git",
  49096. "reference": "d49695b909c3b7628b6289db5479a1c204601f11"
  49097. },
  49098. "dist": {
  49099. "type": "zip",
  49100. "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
  49101. "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
  49102. "shasum": ""
  49103. },
  49104. "require": {
  49105. "php": ">=5.3.0"
  49106. },
  49107. "time": "2021-05-03T11:20:27+00:00",
  49108. "type": "library",
  49109. "extra": {
  49110. "branch-alias": {
  49111. "dev-master": "1.1.x-dev"
  49112. }
  49113. },
  49114. "installation-source": "dist",
  49115. "autoload": {
  49116. "psr-4": {
  49117. "Psr\\Log\\": "Psr/Log/"
  49118. }
  49119. },
  49120. "notification-url": "https://packagist.org/downloads/",
  49121. "license": [
  49122. "MIT"
  49123. ],
  49124. "authors": [
  49125. {
  49126. "name": "PHP-FIG",
  49127. "homepage": "https://www.php-fig.org/"
  49128. }
  49129. ],
  49130. "description": "Common interface for logging libraries",
  49131. "homepage": "https://github.com/php-fig/log",
  49132. "keywords": [
  49133. "log",
  49134. "psr",
  49135. "psr-3"
  49136. ],
  49137. "support": {
  49138. "source": "https://github.com/php-fig/log/tree/1.1.4"
  49139. },
  49140. "install-path": "../psr/log"
  49141. },
  49142. {
  49143. "name": "react/promise",
  49144. "version": "v3.2.0",
  49145. "version_normalized": "3.2.0.0",
  49146. "source": {
  49147. "type": "git",
  49148. "url": "https://github.com/reactphp/promise.git",
  49149. "reference": "8a164643313c71354582dc850b42b33fa12a4b63"
  49150. },
  49151. "dist": {
  49152. "type": "zip",
  49153. "url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63",
  49154. "reference": "8a164643313c71354582dc850b42b33fa12a4b63",
  49155. "shasum": ""
  49156. },
  49157. "require": {
  49158. "php": ">=7.1.0"
  49159. },
  49160. "require-dev": {
  49161. "phpstan/phpstan": "1.10.39 || 1.4.10",
  49162. "phpunit/phpunit": "^9.6 || ^7.5"
  49163. },
  49164. "time": "2024-05-24T10:39:05+00:00",
  49165. "type": "library",
  49166. "installation-source": "dist",
  49167. "autoload": {
  49168. "files": [
  49169. "src/functions_include.php"
  49170. ],
  49171. "psr-4": {
  49172. "React\\Promise\\": "src/"
  49173. }
  49174. },
  49175. "notification-url": "https://packagist.org/downloads/",
  49176. "license": [
  49177. "MIT"
  49178. ],
  49179. "authors": [
  49180. {
  49181. "name": "Jan Sorgalla",
  49182. "email": "jsorgalla@gmail.com",
  49183. "homepage": "https://sorgalla.com/"
  49184. },
  49185. {
  49186. "name": "Christian Lück",
  49187. "email": "christian@clue.engineering",
  49188. "homepage": "https://clue.engineering/"
  49189. },
  49190. {
  49191. "name": "Cees-Jan Kiewiet",
  49192. "email": "reactphp@ceesjankiewiet.nl",
  49193. "homepage": "https://wyrihaximus.net/"
  49194. },
  49195. {
  49196. "name": "Chris Boden",
  49197. "email": "cboden@gmail.com",
  49198. "homepage": "https://cboden.dev/"
  49199. }
  49200. ],
  49201. "description": "A lightweight implementation of CommonJS Promises/A for PHP",
  49202. "keywords": [
  49203. "promise",
  49204. "promises"
  49205. ],
  49206. "support": {
  49207. "issues": "https://github.com/reactphp/promise/issues",
  49208. "source": "https://github.com/reactphp/promise/tree/v3.2.0"
  49209. },
  49210. "funding": [
  49211. {
  49212. "url": "https://opencollective.com/reactphp",
  49213. "type": "open_collective"
  49214. }
  49215. ],
  49216. "install-path": "../react/promise"
  49217. },
  49218. {
  49219. "name": "seld/jsonlint",
  49220. "version": "1.11.0",
  49221. "version_normalized": "1.11.0.0",
  49222. "source": {
  49223. "type": "git",
  49224. "url": "https://github.com/Seldaek/jsonlint.git",
  49225. "reference": "1748aaf847fc731cfad7725aec413ee46f0cc3a2"
  49226. },
  49227. "dist": {
  49228. "type": "zip",
  49229. "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/1748aaf847fc731cfad7725aec413ee46f0cc3a2",
  49230. "reference": "1748aaf847fc731cfad7725aec413ee46f0cc3a2",
  49231. "shasum": ""
  49232. },
  49233. "require": {
  49234. "php": "^5.3 || ^7.0 || ^8.0"
  49235. },
  49236. "require-dev": {
  49237. "phpstan/phpstan": "^1.11",
  49238. "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0 || ^8.5.13"
  49239. },
  49240. "time": "2024-07-11T14:55:45+00:00",
  49241. "bin": [
  49242. "bin/jsonlint"
  49243. ],
  49244. "type": "library",
  49245. "installation-source": "dist",
  49246. "autoload": {
  49247. "psr-4": {
  49248. "Seld\\JsonLint\\": "src/Seld/JsonLint/"
  49249. }
  49250. },
  49251. "notification-url": "https://packagist.org/downloads/",
  49252. "license": [
  49253. "MIT"
  49254. ],
  49255. "authors": [
  49256. {
  49257. "name": "Jordi Boggiano",
  49258. "email": "j.boggiano@seld.be",
  49259. "homepage": "https://seld.be"
  49260. }
  49261. ],
  49262. "description": "JSON Linter",
  49263. "keywords": [
  49264. "json",
  49265. "linter",
  49266. "parser",
  49267. "validator"
  49268. ],
  49269. "support": {
  49270. "issues": "https://github.com/Seldaek/jsonlint/issues",
  49271. "source": "https://github.com/Seldaek/jsonlint/tree/1.11.0"
  49272. },
  49273. "funding": [
  49274. {
  49275. "url": "https://github.com/Seldaek",
  49276. "type": "github"
  49277. },
  49278. {
  49279. "url": "https://tidelift.com/funding/github/packagist/seld/jsonlint",
  49280. "type": "tidelift"
  49281. }
  49282. ],
  49283. "install-path": "../seld/jsonlint"
  49284. },
  49285. {
  49286. "name": "seld/phar-utils",
  49287. "version": "1.2.1",
  49288. "version_normalized": "1.2.1.0",
  49289. "source": {
  49290. "type": "git",
  49291. "url": "https://github.com/Seldaek/phar-utils.git",
  49292. "reference": "ea2f4014f163c1be4c601b9b7bd6af81ba8d701c"
  49293. },
  49294. "dist": {
  49295. "type": "zip",
  49296. "url": "https://api.github.com/repos/Seldaek/phar-utils/zipball/ea2f4014f163c1be4c601b9b7bd6af81ba8d701c",
  49297. "reference": "ea2f4014f163c1be4c601b9b7bd6af81ba8d701c",
  49298. "shasum": ""
  49299. },
  49300. "require": {
  49301. "php": ">=5.3"
  49302. },
  49303. "time": "2022-08-31T10:31:18+00:00",
  49304. "type": "library",
  49305. "extra": {
  49306. "branch-alias": {
  49307. "dev-master": "1.x-dev"
  49308. }
  49309. },
  49310. "installation-source": "dist",
  49311. "autoload": {
  49312. "psr-4": {
  49313. "Seld\\PharUtils\\": "src/"
  49314. }
  49315. },
  49316. "notification-url": "https://packagist.org/downloads/",
  49317. "license": [
  49318. "MIT"
  49319. ],
  49320. "authors": [
  49321. {
  49322. "name": "Jordi Boggiano",
  49323. "email": "j.boggiano@seld.be"
  49324. }
  49325. ],
  49326. "description": "PHAR file format utilities, for when PHP phars you up",
  49327. "keywords": [
  49328. "phar"
  49329. ],
  49330. "support": {
  49331. "issues": "https://github.com/Seldaek/phar-utils/issues",
  49332. "source": "https://github.com/Seldaek/phar-utils/tree/1.2.1"
  49333. },
  49334. "install-path": "../seld/phar-utils"
  49335. },
  49336. {
  49337. "name": "seld/signal-handler",
  49338. "version": "2.0.2",
  49339. "version_normalized": "2.0.2.0",
  49340. "source": {
  49341. "type": "git",
  49342. "url": "https://github.com/Seldaek/signal-handler.git",
  49343. "reference": "04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98"
  49344. },
  49345. "dist": {
  49346. "type": "zip",
  49347. "url": "https://api.github.com/repos/Seldaek/signal-handler/zipball/04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98",
  49348. "reference": "04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98",
  49349. "shasum": ""
  49350. },
  49351. "require": {
  49352. "php": ">=7.2.0"
  49353. },
  49354. "require-dev": {
  49355. "phpstan/phpstan": "^1",
  49356. "phpstan/phpstan-deprecation-rules": "^1.0",
  49357. "phpstan/phpstan-phpunit": "^1",
  49358. "phpstan/phpstan-strict-rules": "^1.3",
  49359. "phpunit/phpunit": "^7.5.20 || ^8.5.23",
  49360. "psr/log": "^1 || ^2 || ^3"
  49361. },
  49362. "time": "2023-09-03T09:24:00+00:00",
  49363. "type": "library",
  49364. "extra": {
  49365. "branch-alias": {
  49366. "dev-main": "2.x-dev"
  49367. }
  49368. },
  49369. "installation-source": "dist",
  49370. "autoload": {
  49371. "psr-4": {
  49372. "Seld\\Signal\\": "src/"
  49373. }
  49374. },
  49375. "notification-url": "https://packagist.org/downloads/",
  49376. "license": [
  49377. "MIT"
  49378. ],
  49379. "authors": [
  49380. {
  49381. "name": "Jordi Boggiano",
  49382. "email": "j.boggiano@seld.be",
  49383. "homepage": "http://seld.be"
  49384. }
  49385. ],
  49386. "description": "Simple unix signal handler that silently fails where signals are not supported for easy cross-platform development",
  49387. "keywords": [
  49388. "posix",
  49389. "sigint",
  49390. "signal",
  49391. "sigterm",
  49392. "unix"
  49393. ],
  49394. "support": {
  49395. "issues": "https://github.com/Seldaek/signal-handler/issues",
  49396. "source": "https://github.com/Seldaek/signal-handler/tree/2.0.2"
  49397. },
  49398. "install-path": "../seld/signal-handler"
  49399. },
  49400. {
  49401. "name": "symfony/console",
  49402. "version": "v5.4.47",
  49403. "version_normalized": "5.4.47.0",
  49404. "source": {
  49405. "type": "git",
  49406. "url": "https://github.com/symfony/console.git",
  49407. "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed"
  49408. },
  49409. "dist": {
  49410. "type": "zip",
  49411. "url": "https://api.github.com/repos/symfony/console/zipball/c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed",
  49412. "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed",
  49413. "shasum": ""
  49414. },
  49415. "require": {
  49416. "php": ">=7.2.5",
  49417. "symfony/deprecation-contracts": "^2.1|^3",
  49418. "symfony/polyfill-mbstring": "~1.0",
  49419. "symfony/polyfill-php73": "^1.9",
  49420. "symfony/polyfill-php80": "^1.16",
  49421. "symfony/service-contracts": "^1.1|^2|^3",
  49422. "symfony/string": "^5.1|^6.0"
  49423. },
  49424. "conflict": {
  49425. "psr/log": ">=3",
  49426. "symfony/dependency-injection": "<4.4",
  49427. "symfony/dotenv": "<5.1",
  49428. "symfony/event-dispatcher": "<4.4",
  49429. "symfony/lock": "<4.4",
  49430. "symfony/process": "<4.4"
  49431. },
  49432. "provide": {
  49433. "psr/log-implementation": "1.0|2.0"
  49434. },
  49435. "require-dev": {
  49436. "psr/log": "^1|^2",
  49437. "symfony/config": "^4.4|^5.0|^6.0",
  49438. "symfony/dependency-injection": "^4.4|^5.0|^6.0",
  49439. "symfony/event-dispatcher": "^4.4|^5.0|^6.0",
  49440. "symfony/lock": "^4.4|^5.0|^6.0",
  49441. "symfony/process": "^4.4|^5.0|^6.0",
  49442. "symfony/var-dumper": "^4.4|^5.0|^6.0"
  49443. },
  49444. "suggest": {
  49445. "psr/log": "For using the console logger",
  49446. "symfony/event-dispatcher": "",
  49447. "symfony/lock": "",
  49448. "symfony/process": ""
  49449. },
  49450. "time": "2024-11-06T11:30:55+00:00",
  49451. "type": "library",
  49452. "installation-source": "dist",
  49453. "autoload": {
  49454. "psr-4": {
  49455. "Symfony\\Component\\Console\\": ""
  49456. },
  49457. "exclude-from-classmap": [
  49458. "/Tests/"
  49459. ]
  49460. },
  49461. "notification-url": "https://packagist.org/downloads/",
  49462. "license": [
  49463. "MIT"
  49464. ],
  49465. "authors": [
  49466. {
  49467. "name": "Fabien Potencier",
  49468. "email": "fabien@symfony.com"
  49469. },
  49470. {
  49471. "name": "Symfony Community",
  49472. "homepage": "https://symfony.com/contributors"
  49473. }
  49474. ],
  49475. "description": "Eases the creation of beautiful and testable command line interfaces",
  49476. "homepage": "https://symfony.com",
  49477. "keywords": [
  49478. "cli",
  49479. "command-line",
  49480. "console",
  49481. "terminal"
  49482. ],
  49483. "support": {
  49484. "source": "https://github.com/symfony/console/tree/v5.4.47"
  49485. },
  49486. "funding": [
  49487. {
  49488. "url": "https://symfony.com/sponsor",
  49489. "type": "custom"
  49490. },
  49491. {
  49492. "url": "https://github.com/fabpot",
  49493. "type": "github"
  49494. },
  49495. {
  49496. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  49497. "type": "tidelift"
  49498. }
  49499. ],
  49500. "install-path": "../symfony/console"
  49501. },
  49502. {
  49503. "name": "symfony/deprecation-contracts",
  49504. "version": "v2.5.4",
  49505. "version_normalized": "2.5.4.0",
  49506. "source": {
  49507. "type": "git",
  49508. "url": "https://github.com/symfony/deprecation-contracts.git",
  49509. "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918"
  49510. },
  49511. "dist": {
  49512. "type": "zip",
  49513. "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918",
  49514. "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918",
  49515. "shasum": ""
  49516. },
  49517. "require": {
  49518. "php": ">=7.1"
  49519. },
  49520. "time": "2024-09-25T14:11:13+00:00",
  49521. "type": "library",
  49522. "extra": {
  49523. "thanks": {
  49524. "url": "https://github.com/symfony/contracts",
  49525. "name": "symfony/contracts"
  49526. },
  49527. "branch-alias": {
  49528. "dev-main": "2.5-dev"
  49529. }
  49530. },
  49531. "installation-source": "dist",
  49532. "autoload": {
  49533. "files": [
  49534. "function.php"
  49535. ]
  49536. },
  49537. "notification-url": "https://packagist.org/downloads/",
  49538. "license": [
  49539. "MIT"
  49540. ],
  49541. "authors": [
  49542. {
  49543. "name": "Nicolas Grekas",
  49544. "email": "p@tchwork.com"
  49545. },
  49546. {
  49547. "name": "Symfony Community",
  49548. "homepage": "https://symfony.com/contributors"
  49549. }
  49550. ],
  49551. "description": "A generic function and convention to trigger deprecation notices",
  49552. "homepage": "https://symfony.com",
  49553. "support": {
  49554. "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4"
  49555. },
  49556. "funding": [
  49557. {
  49558. "url": "https://symfony.com/sponsor",
  49559. "type": "custom"
  49560. },
  49561. {
  49562. "url": "https://github.com/fabpot",
  49563. "type": "github"
  49564. },
  49565. {
  49566. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  49567. "type": "tidelift"
  49568. }
  49569. ],
  49570. "install-path": "../symfony/deprecation-contracts"
  49571. },
  49572. {
  49573. "name": "symfony/filesystem",
  49574. "version": "v5.4.45",
  49575. "version_normalized": "5.4.45.0",
  49576. "source": {
  49577. "type": "git",
  49578. "url": "https://github.com/symfony/filesystem.git",
  49579. "reference": "57c8294ed37d4a055b77057827c67f9558c95c54"
  49580. },
  49581. "dist": {
  49582. "type": "zip",
  49583. "url": "https://api.github.com/repos/symfony/filesystem/zipball/57c8294ed37d4a055b77057827c67f9558c95c54",
  49584. "reference": "57c8294ed37d4a055b77057827c67f9558c95c54",
  49585. "shasum": ""
  49586. },
  49587. "require": {
  49588. "php": ">=7.2.5",
  49589. "symfony/polyfill-ctype": "~1.8",
  49590. "symfony/polyfill-mbstring": "~1.8",
  49591. "symfony/polyfill-php80": "^1.16"
  49592. },
  49593. "require-dev": {
  49594. "symfony/process": "^5.4|^6.4"
  49595. },
  49596. "time": "2024-10-22T13:05:35+00:00",
  49597. "type": "library",
  49598. "installation-source": "dist",
  49599. "autoload": {
  49600. "psr-4": {
  49601. "Symfony\\Component\\Filesystem\\": ""
  49602. },
  49603. "exclude-from-classmap": [
  49604. "/Tests/"
  49605. ]
  49606. },
  49607. "notification-url": "https://packagist.org/downloads/",
  49608. "license": [
  49609. "MIT"
  49610. ],
  49611. "authors": [
  49612. {
  49613. "name": "Fabien Potencier",
  49614. "email": "fabien@symfony.com"
  49615. },
  49616. {
  49617. "name": "Symfony Community",
  49618. "homepage": "https://symfony.com/contributors"
  49619. }
  49620. ],
  49621. "description": "Provides basic utilities for the filesystem",
  49622. "homepage": "https://symfony.com",
  49623. "support": {
  49624. "source": "https://github.com/symfony/filesystem/tree/v5.4.45"
  49625. },
  49626. "funding": [
  49627. {
  49628. "url": "https://symfony.com/sponsor",
  49629. "type": "custom"
  49630. },
  49631. {
  49632. "url": "https://github.com/fabpot",
  49633. "type": "github"
  49634. },
  49635. {
  49636. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  49637. "type": "tidelift"
  49638. }
  49639. ],
  49640. "install-path": "../symfony/filesystem"
  49641. },
  49642. {
  49643. "name": "symfony/finder",
  49644. "version": "v5.4.45",
  49645. "version_normalized": "5.4.45.0",
  49646. "source": {
  49647. "type": "git",
  49648. "url": "https://github.com/symfony/finder.git",
  49649. "reference": "63741784cd7b9967975eec610b256eed3ede022b"
  49650. },
  49651. "dist": {
  49652. "type": "zip",
  49653. "url": "https://api.github.com/repos/symfony/finder/zipball/63741784cd7b9967975eec610b256eed3ede022b",
  49654. "reference": "63741784cd7b9967975eec610b256eed3ede022b",
  49655. "shasum": ""
  49656. },
  49657. "require": {
  49658. "php": ">=7.2.5",
  49659. "symfony/deprecation-contracts": "^2.1|^3",
  49660. "symfony/polyfill-php80": "^1.16"
  49661. },
  49662. "time": "2024-09-28T13:32:08+00:00",
  49663. "type": "library",
  49664. "installation-source": "dist",
  49665. "autoload": {
  49666. "psr-4": {
  49667. "Symfony\\Component\\Finder\\": ""
  49668. },
  49669. "exclude-from-classmap": [
  49670. "/Tests/"
  49671. ]
  49672. },
  49673. "notification-url": "https://packagist.org/downloads/",
  49674. "license": [
  49675. "MIT"
  49676. ],
  49677. "authors": [
  49678. {
  49679. "name": "Fabien Potencier",
  49680. "email": "fabien@symfony.com"
  49681. },
  49682. {
  49683. "name": "Symfony Community",
  49684. "homepage": "https://symfony.com/contributors"
  49685. }
  49686. ],
  49687. "description": "Finds files and directories via an intuitive fluent interface",
  49688. "homepage": "https://symfony.com",
  49689. "support": {
  49690. "source": "https://github.com/symfony/finder/tree/v5.4.45"
  49691. },
  49692. "funding": [
  49693. {
  49694. "url": "https://symfony.com/sponsor",
  49695. "type": "custom"
  49696. },
  49697. {
  49698. "url": "https://github.com/fabpot",
  49699. "type": "github"
  49700. },
  49701. {
  49702. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  49703. "type": "tidelift"
  49704. }
  49705. ],
  49706. "install-path": "../symfony/finder"
  49707. },
  49708. {
  49709. "name": "symfony/polyfill-ctype",
  49710. "version": "v1.31.0",
  49711. "version_normalized": "1.31.0.0",
  49712. "source": {
  49713. "type": "git",
  49714. "url": "https://github.com/symfony/polyfill-ctype.git",
  49715. "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
  49716. },
  49717. "dist": {
  49718. "type": "zip",
  49719. "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
  49720. "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
  49721. "shasum": ""
  49722. },
  49723. "require": {
  49724. "php": ">=7.2"
  49725. },
  49726. "provide": {
  49727. "ext-ctype": "*"
  49728. },
  49729. "suggest": {
  49730. "ext-ctype": "For best performance"
  49731. },
  49732. "time": "2024-09-09T11:45:10+00:00",
  49733. "type": "library",
  49734. "extra": {
  49735. "thanks": {
  49736. "url": "https://github.com/symfony/polyfill",
  49737. "name": "symfony/polyfill"
  49738. }
  49739. },
  49740. "installation-source": "dist",
  49741. "autoload": {
  49742. "files": [
  49743. "bootstrap.php"
  49744. ],
  49745. "psr-4": {
  49746. "Symfony\\Polyfill\\Ctype\\": ""
  49747. }
  49748. },
  49749. "notification-url": "https://packagist.org/downloads/",
  49750. "license": [
  49751. "MIT"
  49752. ],
  49753. "authors": [
  49754. {
  49755. "name": "Gert de Pagter",
  49756. "email": "BackEndTea@gmail.com"
  49757. },
  49758. {
  49759. "name": "Symfony Community",
  49760. "homepage": "https://symfony.com/contributors"
  49761. }
  49762. ],
  49763. "description": "Symfony polyfill for ctype functions",
  49764. "homepage": "https://symfony.com",
  49765. "keywords": [
  49766. "compatibility",
  49767. "ctype",
  49768. "polyfill",
  49769. "portable"
  49770. ],
  49771. "support": {
  49772. "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0"
  49773. },
  49774. "funding": [
  49775. {
  49776. "url": "https://symfony.com/sponsor",
  49777. "type": "custom"
  49778. },
  49779. {
  49780. "url": "https://github.com/fabpot",
  49781. "type": "github"
  49782. },
  49783. {
  49784. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  49785. "type": "tidelift"
  49786. }
  49787. ],
  49788. "install-path": "../symfony/polyfill-ctype"
  49789. },
  49790. {
  49791. "name": "symfony/polyfill-intl-grapheme",
  49792. "version": "v1.31.0",
  49793. "version_normalized": "1.31.0.0",
  49794. "source": {
  49795. "type": "git",
  49796. "url": "https://github.com/symfony/polyfill-intl-grapheme.git",
  49797. "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe"
  49798. },
  49799. "dist": {
  49800. "type": "zip",
  49801. "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe",
  49802. "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe",
  49803. "shasum": ""
  49804. },
  49805. "require": {
  49806. "php": ">=7.2"
  49807. },
  49808. "suggest": {
  49809. "ext-intl": "For best performance"
  49810. },
  49811. "time": "2024-09-09T11:45:10+00:00",
  49812. "type": "library",
  49813. "extra": {
  49814. "thanks": {
  49815. "url": "https://github.com/symfony/polyfill",
  49816. "name": "symfony/polyfill"
  49817. }
  49818. },
  49819. "installation-source": "dist",
  49820. "autoload": {
  49821. "files": [
  49822. "bootstrap.php"
  49823. ],
  49824. "psr-4": {
  49825. "Symfony\\Polyfill\\Intl\\Grapheme\\": ""
  49826. }
  49827. },
  49828. "notification-url": "https://packagist.org/downloads/",
  49829. "license": [
  49830. "MIT"
  49831. ],
  49832. "authors": [
  49833. {
  49834. "name": "Nicolas Grekas",
  49835. "email": "p@tchwork.com"
  49836. },
  49837. {
  49838. "name": "Symfony Community",
  49839. "homepage": "https://symfony.com/contributors"
  49840. }
  49841. ],
  49842. "description": "Symfony polyfill for intl's grapheme_* functions",
  49843. "homepage": "https://symfony.com",
  49844. "keywords": [
  49845. "compatibility",
  49846. "grapheme",
  49847. "intl",
  49848. "polyfill",
  49849. "portable",
  49850. "shim"
  49851. ],
  49852. "support": {
  49853. "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0"
  49854. },
  49855. "funding": [
  49856. {
  49857. "url": "https://symfony.com/sponsor",
  49858. "type": "custom"
  49859. },
  49860. {
  49861. "url": "https://github.com/fabpot",
  49862. "type": "github"
  49863. },
  49864. {
  49865. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  49866. "type": "tidelift"
  49867. }
  49868. ],
  49869. "install-path": "../symfony/polyfill-intl-grapheme"
  49870. },
  49871. {
  49872. "name": "symfony/polyfill-intl-normalizer",
  49873. "version": "v1.31.0",
  49874. "version_normalized": "1.31.0.0",
  49875. "source": {
  49876. "type": "git",
  49877. "url": "https://github.com/symfony/polyfill-intl-normalizer.git",
  49878. "reference": "3833d7255cc303546435cb650316bff708a1c75c"
  49879. },
  49880. "dist": {
  49881. "type": "zip",
  49882. "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c",
  49883. "reference": "3833d7255cc303546435cb650316bff708a1c75c",
  49884. "shasum": ""
  49885. },
  49886. "require": {
  49887. "php": ">=7.2"
  49888. },
  49889. "suggest": {
  49890. "ext-intl": "For best performance"
  49891. },
  49892. "time": "2024-09-09T11:45:10+00:00",
  49893. "type": "library",
  49894. "extra": {
  49895. "thanks": {
  49896. "url": "https://github.com/symfony/polyfill",
  49897. "name": "symfony/polyfill"
  49898. }
  49899. },
  49900. "installation-source": "dist",
  49901. "autoload": {
  49902. "files": [
  49903. "bootstrap.php"
  49904. ],
  49905. "psr-4": {
  49906. "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
  49907. },
  49908. "classmap": [
  49909. "Resources/stubs"
  49910. ]
  49911. },
  49912. "notification-url": "https://packagist.org/downloads/",
  49913. "license": [
  49914. "MIT"
  49915. ],
  49916. "authors": [
  49917. {
  49918. "name": "Nicolas Grekas",
  49919. "email": "p@tchwork.com"
  49920. },
  49921. {
  49922. "name": "Symfony Community",
  49923. "homepage": "https://symfony.com/contributors"
  49924. }
  49925. ],
  49926. "description": "Symfony polyfill for intl's Normalizer class and related functions",
  49927. "homepage": "https://symfony.com",
  49928. "keywords": [
  49929. "compatibility",
  49930. "intl",
  49931. "normalizer",
  49932. "polyfill",
  49933. "portable",
  49934. "shim"
  49935. ],
  49936. "support": {
  49937. "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0"
  49938. },
  49939. "funding": [
  49940. {
  49941. "url": "https://symfony.com/sponsor",
  49942. "type": "custom"
  49943. },
  49944. {
  49945. "url": "https://github.com/fabpot",
  49946. "type": "github"
  49947. },
  49948. {
  49949. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  49950. "type": "tidelift"
  49951. }
  49952. ],
  49953. "install-path": "../symfony/polyfill-intl-normalizer"
  49954. },
  49955. {
  49956. "name": "symfony/polyfill-mbstring",
  49957. "version": "v1.31.0",
  49958. "version_normalized": "1.31.0.0",
  49959. "source": {
  49960. "type": "git",
  49961. "url": "https://github.com/symfony/polyfill-mbstring.git",
  49962. "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341"
  49963. },
  49964. "dist": {
  49965. "type": "zip",
  49966. "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341",
  49967. "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341",
  49968. "shasum": ""
  49969. },
  49970. "require": {
  49971. "php": ">=7.2"
  49972. },
  49973. "provide": {
  49974. "ext-mbstring": "*"
  49975. },
  49976. "suggest": {
  49977. "ext-mbstring": "For best performance"
  49978. },
  49979. "time": "2024-09-09T11:45:10+00:00",
  49980. "type": "library",
  49981. "extra": {
  49982. "thanks": {
  49983. "url": "https://github.com/symfony/polyfill",
  49984. "name": "symfony/polyfill"
  49985. }
  49986. },
  49987. "installation-source": "dist",
  49988. "autoload": {
  49989. "files": [
  49990. "bootstrap.php"
  49991. ],
  49992. "psr-4": {
  49993. "Symfony\\Polyfill\\Mbstring\\": ""
  49994. }
  49995. },
  49996. "notification-url": "https://packagist.org/downloads/",
  49997. "license": [
  49998. "MIT"
  49999. ],
  50000. "authors": [
  50001. {
  50002. "name": "Nicolas Grekas",
  50003. "email": "p@tchwork.com"
  50004. },
  50005. {
  50006. "name": "Symfony Community",
  50007. "homepage": "https://symfony.com/contributors"
  50008. }
  50009. ],
  50010. "description": "Symfony polyfill for the Mbstring extension",
  50011. "homepage": "https://symfony.com",
  50012. "keywords": [
  50013. "compatibility",
  50014. "mbstring",
  50015. "polyfill",
  50016. "portable",
  50017. "shim"
  50018. ],
  50019. "support": {
  50020. "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0"
  50021. },
  50022. "funding": [
  50023. {
  50024. "url": "https://symfony.com/sponsor",
  50025. "type": "custom"
  50026. },
  50027. {
  50028. "url": "https://github.com/fabpot",
  50029. "type": "github"
  50030. },
  50031. {
  50032. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  50033. "type": "tidelift"
  50034. }
  50035. ],
  50036. "install-path": "../symfony/polyfill-mbstring"
  50037. },
  50038. {
  50039. "name": "symfony/polyfill-php73",
  50040. "version": "v1.31.0",
  50041. "version_normalized": "1.31.0.0",
  50042. "source": {
  50043. "type": "git",
  50044. "url": "https://github.com/symfony/polyfill-php73.git",
  50045. "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb"
  50046. },
  50047. "dist": {
  50048. "type": "zip",
  50049. "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb",
  50050. "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb",
  50051. "shasum": ""
  50052. },
  50053. "require": {
  50054. "php": ">=7.2"
  50055. },
  50056. "time": "2024-09-09T11:45:10+00:00",
  50057. "type": "library",
  50058. "extra": {
  50059. "thanks": {
  50060. "url": "https://github.com/symfony/polyfill",
  50061. "name": "symfony/polyfill"
  50062. }
  50063. },
  50064. "installation-source": "dist",
  50065. "autoload": {
  50066. "files": [
  50067. "bootstrap.php"
  50068. ],
  50069. "psr-4": {
  50070. "Symfony\\Polyfill\\Php73\\": ""
  50071. },
  50072. "classmap": [
  50073. "Resources/stubs"
  50074. ]
  50075. },
  50076. "notification-url": "https://packagist.org/downloads/",
  50077. "license": [
  50078. "MIT"
  50079. ],
  50080. "authors": [
  50081. {
  50082. "name": "Nicolas Grekas",
  50083. "email": "p@tchwork.com"
  50084. },
  50085. {
  50086. "name": "Symfony Community",
  50087. "homepage": "https://symfony.com/contributors"
  50088. }
  50089. ],
  50090. "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
  50091. "homepage": "https://symfony.com",
  50092. "keywords": [
  50093. "compatibility",
  50094. "polyfill",
  50095. "portable",
  50096. "shim"
  50097. ],
  50098. "support": {
  50099. "source": "https://github.com/symfony/polyfill-php73/tree/v1.31.0"
  50100. },
  50101. "funding": [
  50102. {
  50103. "url": "https://symfony.com/sponsor",
  50104. "type": "custom"
  50105. },
  50106. {
  50107. "url": "https://github.com/fabpot",
  50108. "type": "github"
  50109. },
  50110. {
  50111. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  50112. "type": "tidelift"
  50113. }
  50114. ],
  50115. "install-path": "../symfony/polyfill-php73"
  50116. },
  50117. {
  50118. "name": "symfony/polyfill-php80",
  50119. "version": "v1.31.0",
  50120. "version_normalized": "1.31.0.0",
  50121. "source": {
  50122. "type": "git",
  50123. "url": "https://github.com/symfony/polyfill-php80.git",
  50124. "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8"
  50125. },
  50126. "dist": {
  50127. "type": "zip",
  50128. "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
  50129. "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8",
  50130. "shasum": ""
  50131. },
  50132. "require": {
  50133. "php": ">=7.2"
  50134. },
  50135. "time": "2024-09-09T11:45:10+00:00",
  50136. "type": "library",
  50137. "extra": {
  50138. "thanks": {
  50139. "url": "https://github.com/symfony/polyfill",
  50140. "name": "symfony/polyfill"
  50141. }
  50142. },
  50143. "installation-source": "dist",
  50144. "autoload": {
  50145. "files": [
  50146. "bootstrap.php"
  50147. ],
  50148. "psr-4": {
  50149. "Symfony\\Polyfill\\Php80\\": ""
  50150. },
  50151. "classmap": [
  50152. "Resources/stubs"
  50153. ]
  50154. },
  50155. "notification-url": "https://packagist.org/downloads/",
  50156. "license": [
  50157. "MIT"
  50158. ],
  50159. "authors": [
  50160. {
  50161. "name": "Ion Bazan",
  50162. "email": "ion.bazan@gmail.com"
  50163. },
  50164. {
  50165. "name": "Nicolas Grekas",
  50166. "email": "p@tchwork.com"
  50167. },
  50168. {
  50169. "name": "Symfony Community",
  50170. "homepage": "https://symfony.com/contributors"
  50171. }
  50172. ],
  50173. "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
  50174. "homepage": "https://symfony.com",
  50175. "keywords": [
  50176. "compatibility",
  50177. "polyfill",
  50178. "portable",
  50179. "shim"
  50180. ],
  50181. "support": {
  50182. "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0"
  50183. },
  50184. "funding": [
  50185. {
  50186. "url": "https://symfony.com/sponsor",
  50187. "type": "custom"
  50188. },
  50189. {
  50190. "url": "https://github.com/fabpot",
  50191. "type": "github"
  50192. },
  50193. {
  50194. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  50195. "type": "tidelift"
  50196. }
  50197. ],
  50198. "install-path": "../symfony/polyfill-php80"
  50199. },
  50200. {
  50201. "name": "symfony/polyfill-php81",
  50202. "version": "v1.31.0",
  50203. "version_normalized": "1.31.0.0",
  50204. "source": {
  50205. "type": "git",
  50206. "url": "https://github.com/symfony/polyfill-php81.git",
  50207. "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c"
  50208. },
  50209. "dist": {
  50210. "type": "zip",
  50211. "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c",
  50212. "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c",
  50213. "shasum": ""
  50214. },
  50215. "require": {
  50216. "php": ">=7.2"
  50217. },
  50218. "time": "2024-09-09T11:45:10+00:00",
  50219. "type": "library",
  50220. "extra": {
  50221. "thanks": {
  50222. "url": "https://github.com/symfony/polyfill",
  50223. "name": "symfony/polyfill"
  50224. }
  50225. },
  50226. "installation-source": "dist",
  50227. "autoload": {
  50228. "files": [
  50229. "bootstrap.php"
  50230. ],
  50231. "psr-4": {
  50232. "Symfony\\Polyfill\\Php81\\": ""
  50233. },
  50234. "classmap": [
  50235. "Resources/stubs"
  50236. ]
  50237. },
  50238. "notification-url": "https://packagist.org/downloads/",
  50239. "license": [
  50240. "MIT"
  50241. ],
  50242. "authors": [
  50243. {
  50244. "name": "Nicolas Grekas",
  50245. "email": "p@tchwork.com"
  50246. },
  50247. {
  50248. "name": "Symfony Community",
  50249. "homepage": "https://symfony.com/contributors"
  50250. }
  50251. ],
  50252. "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions",
  50253. "homepage": "https://symfony.com",
  50254. "keywords": [
  50255. "compatibility",
  50256. "polyfill",
  50257. "portable",
  50258. "shim"
  50259. ],
  50260. "support": {
  50261. "source": "https://github.com/symfony/polyfill-php81/tree/v1.31.0"
  50262. },
  50263. "funding": [
  50264. {
  50265. "url": "https://symfony.com/sponsor",
  50266. "type": "custom"
  50267. },
  50268. {
  50269. "url": "https://github.com/fabpot",
  50270. "type": "github"
  50271. },
  50272. {
  50273. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  50274. "type": "tidelift"
  50275. }
  50276. ],
  50277. "install-path": "../symfony/polyfill-php81"
  50278. },
  50279. {
  50280. "name": "symfony/process",
  50281. "version": "v5.4.47",
  50282. "version_normalized": "5.4.47.0",
  50283. "source": {
  50284. "type": "git",
  50285. "url": "https://github.com/symfony/process.git",
  50286. "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d"
  50287. },
  50288. "dist": {
  50289. "type": "zip",
  50290. "url": "https://api.github.com/repos/symfony/process/zipball/5d1662fb32ebc94f17ddb8d635454a776066733d",
  50291. "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d",
  50292. "shasum": ""
  50293. },
  50294. "require": {
  50295. "php": ">=7.2.5",
  50296. "symfony/polyfill-php80": "^1.16"
  50297. },
  50298. "time": "2024-11-06T11:36:42+00:00",
  50299. "type": "library",
  50300. "installation-source": "dist",
  50301. "autoload": {
  50302. "psr-4": {
  50303. "Symfony\\Component\\Process\\": ""
  50304. },
  50305. "exclude-from-classmap": [
  50306. "/Tests/"
  50307. ]
  50308. },
  50309. "notification-url": "https://packagist.org/downloads/",
  50310. "license": [
  50311. "MIT"
  50312. ],
  50313. "authors": [
  50314. {
  50315. "name": "Fabien Potencier",
  50316. "email": "fabien@symfony.com"
  50317. },
  50318. {
  50319. "name": "Symfony Community",
  50320. "homepage": "https://symfony.com/contributors"
  50321. }
  50322. ],
  50323. "description": "Executes commands in sub-processes",
  50324. "homepage": "https://symfony.com",
  50325. "support": {
  50326. "source": "https://github.com/symfony/process/tree/v5.4.47"
  50327. },
  50328. "funding": [
  50329. {
  50330. "url": "https://symfony.com/sponsor",
  50331. "type": "custom"
  50332. },
  50333. {
  50334. "url": "https://github.com/fabpot",
  50335. "type": "github"
  50336. },
  50337. {
  50338. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  50339. "type": "tidelift"
  50340. }
  50341. ],
  50342. "install-path": "../symfony/process"
  50343. },
  50344. {
  50345. "name": "symfony/service-contracts",
  50346. "version": "v2.5.4",
  50347. "version_normalized": "2.5.4.0",
  50348. "source": {
  50349. "type": "git",
  50350. "url": "https://github.com/symfony/service-contracts.git",
  50351. "reference": "f37b419f7aea2e9abf10abd261832cace12e3300"
  50352. },
  50353. "dist": {
  50354. "type": "zip",
  50355. "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f37b419f7aea2e9abf10abd261832cace12e3300",
  50356. "reference": "f37b419f7aea2e9abf10abd261832cace12e3300",
  50357. "shasum": ""
  50358. },
  50359. "require": {
  50360. "php": ">=7.2.5",
  50361. "psr/container": "^1.1",
  50362. "symfony/deprecation-contracts": "^2.1|^3"
  50363. },
  50364. "conflict": {
  50365. "ext-psr": "<1.1|>=2"
  50366. },
  50367. "suggest": {
  50368. "symfony/service-implementation": ""
  50369. },
  50370. "time": "2024-09-25T14:11:13+00:00",
  50371. "type": "library",
  50372. "extra": {
  50373. "thanks": {
  50374. "url": "https://github.com/symfony/contracts",
  50375. "name": "symfony/contracts"
  50376. },
  50377. "branch-alias": {
  50378. "dev-main": "2.5-dev"
  50379. }
  50380. },
  50381. "installation-source": "dist",
  50382. "autoload": {
  50383. "psr-4": {
  50384. "Symfony\\Contracts\\Service\\": ""
  50385. }
  50386. },
  50387. "notification-url": "https://packagist.org/downloads/",
  50388. "license": [
  50389. "MIT"
  50390. ],
  50391. "authors": [
  50392. {
  50393. "name": "Nicolas Grekas",
  50394. "email": "p@tchwork.com"
  50395. },
  50396. {
  50397. "name": "Symfony Community",
  50398. "homepage": "https://symfony.com/contributors"
  50399. }
  50400. ],
  50401. "description": "Generic abstractions related to writing services",
  50402. "homepage": "https://symfony.com",
  50403. "keywords": [
  50404. "abstractions",
  50405. "contracts",
  50406. "decoupling",
  50407. "interfaces",
  50408. "interoperability",
  50409. "standards"
  50410. ],
  50411. "support": {
  50412. "source": "https://github.com/symfony/service-contracts/tree/v2.5.4"
  50413. },
  50414. "funding": [
  50415. {
  50416. "url": "https://symfony.com/sponsor",
  50417. "type": "custom"
  50418. },
  50419. {
  50420. "url": "https://github.com/fabpot",
  50421. "type": "github"
  50422. },
  50423. {
  50424. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  50425. "type": "tidelift"
  50426. }
  50427. ],
  50428. "install-path": "../symfony/service-contracts"
  50429. },
  50430. {
  50431. "name": "symfony/string",
  50432. "version": "v5.4.47",
  50433. "version_normalized": "5.4.47.0",
  50434. "source": {
  50435. "type": "git",
  50436. "url": "https://github.com/symfony/string.git",
  50437. "reference": "136ca7d72f72b599f2631aca474a4f8e26719799"
  50438. },
  50439. "dist": {
  50440. "type": "zip",
  50441. "url": "https://api.github.com/repos/symfony/string/zipball/136ca7d72f72b599f2631aca474a4f8e26719799",
  50442. "reference": "136ca7d72f72b599f2631aca474a4f8e26719799",
  50443. "shasum": ""
  50444. },
  50445. "require": {
  50446. "php": ">=7.2.5",
  50447. "symfony/polyfill-ctype": "~1.8",
  50448. "symfony/polyfill-intl-grapheme": "~1.0",
  50449. "symfony/polyfill-intl-normalizer": "~1.0",
  50450. "symfony/polyfill-mbstring": "~1.0",
  50451. "symfony/polyfill-php80": "~1.15"
  50452. },
  50453. "conflict": {
  50454. "symfony/translation-contracts": ">=3.0"
  50455. },
  50456. "require-dev": {
  50457. "symfony/error-handler": "^4.4|^5.0|^6.0",
  50458. "symfony/http-client": "^4.4|^5.0|^6.0",
  50459. "symfony/translation-contracts": "^1.1|^2",
  50460. "symfony/var-exporter": "^4.4|^5.0|^6.0"
  50461. },
  50462. "time": "2024-11-10T20:33:58+00:00",
  50463. "type": "library",
  50464. "installation-source": "dist",
  50465. "autoload": {
  50466. "files": [
  50467. "Resources/functions.php"
  50468. ],
  50469. "psr-4": {
  50470. "Symfony\\Component\\String\\": ""
  50471. },
  50472. "exclude-from-classmap": [
  50473. "/Tests/"
  50474. ]
  50475. },
  50476. "notification-url": "https://packagist.org/downloads/",
  50477. "license": [
  50478. "MIT"
  50479. ],
  50480. "authors": [
  50481. {
  50482. "name": "Nicolas Grekas",
  50483. "email": "p@tchwork.com"
  50484. },
  50485. {
  50486. "name": "Symfony Community",
  50487. "homepage": "https://symfony.com/contributors"
  50488. }
  50489. ],
  50490. "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way",
  50491. "homepage": "https://symfony.com",
  50492. "keywords": [
  50493. "grapheme",
  50494. "i18n",
  50495. "string",
  50496. "unicode",
  50497. "utf-8",
  50498. "utf8"
  50499. ],
  50500. "support": {
  50501. "source": "https://github.com/symfony/string/tree/v5.4.47"
  50502. },
  50503. "funding": [
  50504. {
  50505. "url": "https://symfony.com/sponsor",
  50506. "type": "custom"
  50507. },
  50508. {
  50509. "url": "https://github.com/fabpot",
  50510. "type": "github"
  50511. },
  50512. {
  50513. "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
  50514. "type": "tidelift"
  50515. }
  50516. ],
  50517. "install-path": "../symfony/string"
  50518. }
  50519. ],
  50520. "dev": false,
  50521. "dev-package-names": []
  50522. }
  50523. <?php return array(
  50524. 'root' => array(
  50525. 'name' => 'composer/composer',
  50526. 'pretty_version' => '2.8.8',
  50527. 'version' => '2.8.8.0',
  50528. 'reference' => '85ff84d6c5260ba21740a7c5c9a111890805d6e7',
  50529. 'type' => 'library',
  50530. 'install_path' => __DIR__ . '/../../',
  50531. 'aliases' => array(),
  50532. 'dev' => false,
  50533. ),
  50534. 'versions' => array(
  50535. 'composer/ca-bundle' => array(
  50536. 'pretty_version' => '1.5.6',
  50537. 'version' => '1.5.6.0',
  50538. 'reference' => 'f65c239c970e7f072f067ab78646e9f0b2935175',
  50539. 'type' => 'library',
  50540. 'install_path' => __DIR__ . '/./ca-bundle',
  50541. 'aliases' => array(),
  50542. 'dev_requirement' => false,
  50543. ),
  50544. 'composer/class-map-generator' => array(
  50545. 'pretty_version' => '1.6.1',
  50546. 'version' => '1.6.1.0',
  50547. 'reference' => '134b705ddb0025d397d8318a75825fe3c9d1da34',
  50548. 'type' => 'library',
  50549. 'install_path' => __DIR__ . '/./class-map-generator',
  50550. 'aliases' => array(),
  50551. 'dev_requirement' => false,
  50552. ),
  50553. 'composer/composer' => array(
  50554. 'pretty_version' => '2.8.8',
  50555. 'version' => '2.8.8.0',
  50556. 'reference' => '85ff84d6c5260ba21740a7c5c9a111890805d6e7',
  50557. 'type' => 'library',
  50558. 'install_path' => __DIR__ . '/../../',
  50559. 'aliases' => array(),
  50560. 'dev_requirement' => false,
  50561. ),
  50562. 'composer/metadata-minifier' => array(
  50563. 'pretty_version' => '1.0.0',
  50564. 'version' => '1.0.0.0',
  50565. 'reference' => 'c549d23829536f0d0e984aaabbf02af91f443207',
  50566. 'type' => 'library',
  50567. 'install_path' => __DIR__ . '/./metadata-minifier',
  50568. 'aliases' => array(),
  50569. 'dev_requirement' => false,
  50570. ),
  50571. 'composer/pcre' => array(
  50572. 'pretty_version' => '2.3.2',
  50573. 'version' => '2.3.2.0',
  50574. 'reference' => 'ebb81df8f52b40172d14062ae96a06939d80a069',
  50575. 'type' => 'library',
  50576. 'install_path' => __DIR__ . '/./pcre',
  50577. 'aliases' => array(),
  50578. 'dev_requirement' => false,
  50579. ),
  50580. 'composer/semver' => array(
  50581. 'pretty_version' => '3.4.3',
  50582. 'version' => '3.4.3.0',
  50583. 'reference' => '4313d26ada5e0c4edfbd1dc481a92ff7bff91f12',
  50584. 'type' => 'library',
  50585. 'install_path' => __DIR__ . '/./semver',
  50586. 'aliases' => array(),
  50587. 'dev_requirement' => false,
  50588. ),
  50589. 'composer/spdx-licenses' => array(
  50590. 'pretty_version' => '1.5.8',
  50591. 'version' => '1.5.8.0',
  50592. 'reference' => '560bdcf8deb88ae5d611c80a2de8ea9d0358cc0a',
  50593. 'type' => 'library',
  50594. 'install_path' => __DIR__ . '/./spdx-licenses',
  50595. 'aliases' => array(),
  50596. 'dev_requirement' => false,
  50597. ),
  50598. 'composer/xdebug-handler' => array(
  50599. 'pretty_version' => '3.0.5',
  50600. 'version' => '3.0.5.0',
  50601. 'reference' => '6c1925561632e83d60a44492e0b344cf48ab85ef',
  50602. 'type' => 'library',
  50603. 'install_path' => __DIR__ . '/./xdebug-handler',
  50604. 'aliases' => array(),
  50605. 'dev_requirement' => false,
  50606. ),
  50607. 'justinrainbow/json-schema' => array(
  50608. 'pretty_version' => '6.4.1',
  50609. 'version' => '6.4.1.0',
  50610. 'reference' => '35d262c94959571e8736db1e5c9bc36ab94ae900',
  50611. 'type' => 'library',
  50612. 'install_path' => __DIR__ . '/../justinrainbow/json-schema',
  50613. 'aliases' => array(),
  50614. 'dev_requirement' => false,
  50615. ),
  50616. 'marc-mabe/php-enum' => array(
  50617. 'pretty_version' => 'v4.7.1',
  50618. 'version' => '4.7.1.0',
  50619. 'reference' => '7159809e5cfa041dca28e61f7f7ae58063aae8ed',
  50620. 'type' => 'library',
  50621. 'install_path' => __DIR__ . '/../marc-mabe/php-enum',
  50622. 'aliases' => array(),
  50623. 'dev_requirement' => false,
  50624. ),
  50625. 'psr/container' => array(
  50626. 'pretty_version' => '1.1.1',
  50627. 'version' => '1.1.1.0',
  50628. 'reference' => '8622567409010282b7aeebe4bb841fe98b58dcaf',
  50629. 'type' => 'library',
  50630. 'install_path' => __DIR__ . '/../psr/container',
  50631. 'aliases' => array(),
  50632. 'dev_requirement' => false,
  50633. ),
  50634. 'psr/log' => array(
  50635. 'pretty_version' => '1.1.4',
  50636. 'version' => '1.1.4.0',
  50637. 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
  50638. 'type' => 'library',
  50639. 'install_path' => __DIR__ . '/../psr/log',
  50640. 'aliases' => array(),
  50641. 'dev_requirement' => false,
  50642. ),
  50643. 'psr/log-implementation' => array(
  50644. 'dev_requirement' => false,
  50645. 'provided' => array(
  50646. 0 => '1.0|2.0',
  50647. ),
  50648. ),
  50649. 'react/promise' => array(
  50650. 'pretty_version' => 'v3.2.0',
  50651. 'version' => '3.2.0.0',
  50652. 'reference' => '8a164643313c71354582dc850b42b33fa12a4b63',
  50653. 'type' => 'library',
  50654. 'install_path' => __DIR__ . '/../react/promise',
  50655. 'aliases' => array(),
  50656. 'dev_requirement' => false,
  50657. ),
  50658. 'seld/jsonlint' => array(
  50659. 'pretty_version' => '1.11.0',
  50660. 'version' => '1.11.0.0',
  50661. 'reference' => '1748aaf847fc731cfad7725aec413ee46f0cc3a2',
  50662. 'type' => 'library',
  50663. 'install_path' => __DIR__ . '/../seld/jsonlint',
  50664. 'aliases' => array(),
  50665. 'dev_requirement' => false,
  50666. ),
  50667. 'seld/phar-utils' => array(
  50668. 'pretty_version' => '1.2.1',
  50669. 'version' => '1.2.1.0',
  50670. 'reference' => 'ea2f4014f163c1be4c601b9b7bd6af81ba8d701c',
  50671. 'type' => 'library',
  50672. 'install_path' => __DIR__ . '/../seld/phar-utils',
  50673. 'aliases' => array(),
  50674. 'dev_requirement' => false,
  50675. ),
  50676. 'seld/signal-handler' => array(
  50677. 'pretty_version' => '2.0.2',
  50678. 'version' => '2.0.2.0',
  50679. 'reference' => '04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98',
  50680. 'type' => 'library',
  50681. 'install_path' => __DIR__ . '/../seld/signal-handler',
  50682. 'aliases' => array(),
  50683. 'dev_requirement' => false,
  50684. ),
  50685. 'symfony/console' => array(
  50686. 'pretty_version' => 'v5.4.47',
  50687. 'version' => '5.4.47.0',
  50688. 'reference' => 'c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed',
  50689. 'type' => 'library',
  50690. 'install_path' => __DIR__ . '/../symfony/console',
  50691. 'aliases' => array(),
  50692. 'dev_requirement' => false,
  50693. ),
  50694. 'symfony/deprecation-contracts' => array(
  50695. 'pretty_version' => 'v2.5.4',
  50696. 'version' => '2.5.4.0',
  50697. 'reference' => '605389f2a7e5625f273b53960dc46aeaf9c62918',
  50698. 'type' => 'library',
  50699. 'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
  50700. 'aliases' => array(),
  50701. 'dev_requirement' => false,
  50702. ),
  50703. 'symfony/filesystem' => array(
  50704. 'pretty_version' => 'v5.4.45',
  50705. 'version' => '5.4.45.0',
  50706. 'reference' => '57c8294ed37d4a055b77057827c67f9558c95c54',
  50707. 'type' => 'library',
  50708. 'install_path' => __DIR__ . '/../symfony/filesystem',
  50709. 'aliases' => array(),
  50710. 'dev_requirement' => false,
  50711. ),
  50712. 'symfony/finder' => array(
  50713. 'pretty_version' => 'v5.4.45',
  50714. 'version' => '5.4.45.0',
  50715. 'reference' => '63741784cd7b9967975eec610b256eed3ede022b',
  50716. 'type' => 'library',
  50717. 'install_path' => __DIR__ . '/../symfony/finder',
  50718. 'aliases' => array(),
  50719. 'dev_requirement' => false,
  50720. ),
  50721. 'symfony/polyfill-ctype' => array(
  50722. 'pretty_version' => 'v1.31.0',
  50723. 'version' => '1.31.0.0',
  50724. 'reference' => 'a3cc8b044a6ea513310cbd48ef7333b384945638',
  50725. 'type' => 'library',
  50726. 'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
  50727. 'aliases' => array(),
  50728. 'dev_requirement' => false,
  50729. ),
  50730. 'symfony/polyfill-intl-grapheme' => array(
  50731. 'pretty_version' => 'v1.31.0',
  50732. 'version' => '1.31.0.0',
  50733. 'reference' => 'b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe',
  50734. 'type' => 'library',
  50735. 'install_path' => __DIR__ . '/../symfony/polyfill-intl-grapheme',
  50736. 'aliases' => array(),
  50737. 'dev_requirement' => false,
  50738. ),
  50739. 'symfony/polyfill-intl-normalizer' => array(
  50740. 'pretty_version' => 'v1.31.0',
  50741. 'version' => '1.31.0.0',
  50742. 'reference' => '3833d7255cc303546435cb650316bff708a1c75c',
  50743. 'type' => 'library',
  50744. 'install_path' => __DIR__ . '/../symfony/polyfill-intl-normalizer',
  50745. 'aliases' => array(),
  50746. 'dev_requirement' => false,
  50747. ),
  50748. 'symfony/polyfill-mbstring' => array(
  50749. 'pretty_version' => 'v1.31.0',
  50750. 'version' => '1.31.0.0',
  50751. 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341',
  50752. 'type' => 'library',
  50753. 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
  50754. 'aliases' => array(),
  50755. 'dev_requirement' => false,
  50756. ),
  50757. 'symfony/polyfill-php73' => array(
  50758. 'pretty_version' => 'v1.31.0',
  50759. 'version' => '1.31.0.0',
  50760. 'reference' => '0f68c03565dcaaf25a890667542e8bd75fe7e5bb',
  50761. 'type' => 'library',
  50762. 'install_path' => __DIR__ . '/../symfony/polyfill-php73',
  50763. 'aliases' => array(),
  50764. 'dev_requirement' => false,
  50765. ),
  50766. 'symfony/polyfill-php80' => array(
  50767. 'pretty_version' => 'v1.31.0',
  50768. 'version' => '1.31.0.0',
  50769. 'reference' => '60328e362d4c2c802a54fcbf04f9d3fb892b4cf8',
  50770. 'type' => 'library',
  50771. 'install_path' => __DIR__ . '/../symfony/polyfill-php80',
  50772. 'aliases' => array(),
  50773. 'dev_requirement' => false,
  50774. ),
  50775. 'symfony/polyfill-php81' => array(
  50776. 'pretty_version' => 'v1.31.0',
  50777. 'version' => '1.31.0.0',
  50778. 'reference' => '4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c',
  50779. 'type' => 'library',
  50780. 'install_path' => __DIR__ . '/../symfony/polyfill-php81',
  50781. 'aliases' => array(),
  50782. 'dev_requirement' => false,
  50783. ),
  50784. 'symfony/process' => array(
  50785. 'pretty_version' => 'v5.4.47',
  50786. 'version' => '5.4.47.0',
  50787. 'reference' => '5d1662fb32ebc94f17ddb8d635454a776066733d',
  50788. 'type' => 'library',
  50789. 'install_path' => __DIR__ . '/../symfony/process',
  50790. 'aliases' => array(),
  50791. 'dev_requirement' => false,
  50792. ),
  50793. 'symfony/service-contracts' => array(
  50794. 'pretty_version' => 'v2.5.4',
  50795. 'version' => '2.5.4.0',
  50796. 'reference' => 'f37b419f7aea2e9abf10abd261832cace12e3300',
  50797. 'type' => 'library',
  50798. 'install_path' => __DIR__ . '/../symfony/service-contracts',
  50799. 'aliases' => array(),
  50800. 'dev_requirement' => false,
  50801. ),
  50802. 'symfony/string' => array(
  50803. 'pretty_version' => 'v5.4.47',
  50804. 'version' => '5.4.47.0',
  50805. 'reference' => '136ca7d72f72b599f2631aca474a4f8e26719799',
  50806. 'type' => 'library',
  50807. 'install_path' => __DIR__ . '/../symfony/string',
  50808. 'aliases' => array(),
  50809. 'dev_requirement' => false,
  50810. ),
  50811. ),
  50812. );
  50813. Copyright (C) 2021 Composer
  50814. Permission is hereby granted, free of charge, to any person obtaining a copy of
  50815. this software and associated documentation files (the "Software"), to deal in
  50816. the Software without restriction, including without limitation the rights to
  50817. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  50818. of the Software, and to permit persons to whom the Software is furnished to do
  50819. so, subject to the following conditions:
  50820. The above copyright notice and this permission notice shall be included in all
  50821. copies or substantial portions of the Software.
  50822. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  50823. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  50824. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  50825. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  50826. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  50827. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  50828. SOFTWARE.
  50829. <?php
  50830. namespace Composer\MetadataMinifier;
  50831. class MetadataMinifier
  50832. {
  50833. public static function expand(array $versions)
  50834. {
  50835. $expanded = array();
  50836. $expandedVersion = null;
  50837. foreach ($versions as $versionData) {
  50838. if (!$expandedVersion) {
  50839. $expandedVersion = $versionData;
  50840. $expanded[] = $expandedVersion;
  50841. continue;
  50842. }
  50843. foreach ($versionData as $key => $val) {
  50844. if ($val === '__unset') {
  50845. unset($expandedVersion[$key]);
  50846. } else {
  50847. $expandedVersion[$key] = $val;
  50848. }
  50849. }
  50850. $expanded[] = $expandedVersion;
  50851. }
  50852. return $expanded;
  50853. }
  50854. public static function minify(array $versions)
  50855. {
  50856. $minifiedVersions = array();
  50857. $lastKnownVersionData = null;
  50858. foreach ($versions as $version) {
  50859. if (!$lastKnownVersionData) {
  50860. $lastKnownVersionData = $version;
  50861. $minifiedVersions[] = $version;
  50862. continue;
  50863. }
  50864. $minifiedVersion = array();
  50865. foreach ($version as $key => $val) {
  50866. if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) {
  50867. $minifiedVersion[$key] = $val;
  50868. $lastKnownVersionData[$key] = $val;
  50869. }
  50870. }
  50871. foreach ($lastKnownVersionData as $key => $val) {
  50872. if (!isset($version[$key])) {
  50873. $minifiedVersion[$key] = "__unset";
  50874. unset($lastKnownVersionData[$key]);
  50875. }
  50876. }
  50877. $minifiedVersions[] = $minifiedVersion;
  50878. }
  50879. return $minifiedVersions;
  50880. }
  50881. }
  50882. Copyright (C) 2021 Composer
  50883. Permission is hereby granted, free of charge, to any person obtaining a copy of
  50884. this software and associated documentation files (the "Software"), to deal in
  50885. the Software without restriction, including without limitation the rights to
  50886. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  50887. of the Software, and to permit persons to whom the Software is furnished to do
  50888. so, subject to the following conditions:
  50889. The above copyright notice and this permission notice shall be included in all
  50890. copies or substantial portions of the Software.
  50891. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  50892. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  50893. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  50894. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  50895. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  50896. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  50897. SOFTWARE.
  50898. <?php
  50899. namespace Composer\Pcre;
  50900. final class MatchAllResult
  50901. {
  50902. public $matches;
  50903. public $count;
  50904. public $matched;
  50905. public function __construct(int $count, array $matches)
  50906. {
  50907. $this->matches = $matches;
  50908. $this->matched = (bool) $count;
  50909. $this->count = $count;
  50910. }
  50911. }
  50912. <?php
  50913. namespace Composer\Pcre;
  50914. final class MatchAllStrictGroupsResult
  50915. {
  50916. public $matches;
  50917. public $count;
  50918. public $matched;
  50919. public function __construct(int $count, array $matches)
  50920. {
  50921. $this->matches = $matches;
  50922. $this->matched = (bool) $count;
  50923. $this->count = $count;
  50924. }
  50925. }
  50926. <?php
  50927. namespace Composer\Pcre;
  50928. final class MatchAllWithOffsetsResult
  50929. {
  50930. public $matches;
  50931. public $count;
  50932. public $matched;
  50933. public function __construct(int $count, array $matches)
  50934. {
  50935. $this->matches = $matches;
  50936. $this->matched = (bool) $count;
  50937. $this->count = $count;
  50938. }
  50939. }
  50940. <?php
  50941. namespace Composer\Pcre;
  50942. final class MatchResult
  50943. {
  50944. public $matches;
  50945. public $matched;
  50946. public function __construct(int $count, array $matches)
  50947. {
  50948. $this->matches = $matches;
  50949. $this->matched = (bool) $count;
  50950. }
  50951. }
  50952. <?php
  50953. namespace Composer\Pcre;
  50954. final class MatchStrictGroupsResult
  50955. {
  50956. public $matches;
  50957. public $matched;
  50958. public function __construct(int $count, array $matches)
  50959. {
  50960. $this->matches = $matches;
  50961. $this->matched = (bool) $count;
  50962. }
  50963. }
  50964. <?php
  50965. namespace Composer\Pcre;
  50966. final class MatchWithOffsetsResult
  50967. {
  50968. public $matches;
  50969. public $matched;
  50970. public function __construct(int $count, array $matches)
  50971. {
  50972. $this->matches = $matches;
  50973. $this->matched = (bool) $count;
  50974. }
  50975. }
  50976. <?php declare(strict_types = 1);
  50977. namespace Composer\Pcre\PHPStan;
  50978. use Composer\Pcre\Preg;
  50979. use Composer\Pcre\Regex;
  50980. use Composer\Pcre\PcreException;
  50981. use Nette\Utils\RegexpException;
  50982. use Nette\Utils\Strings;
  50983. use PhpParser\Node;
  50984. use PhpParser\Node\Expr\StaticCall;
  50985. use PhpParser\Node\Name\FullyQualified;
  50986. use PHPStan\Analyser\Scope;
  50987. use PHPStan\Rules\Rule;
  50988. use PHPStan\Rules\RuleErrorBuilder;
  50989. use function in_array;
  50990. use function sprintf;
  50991. class InvalidRegexPatternRule implements Rule
  50992. {
  50993. public function getNodeType(): string
  50994. {
  50995. return StaticCall::class;
  50996. }
  50997. public function processNode(Node $node, Scope $scope): array
  50998. {
  50999. $patterns = $this->extractPatterns($node, $scope);
  51000. $errors = [];
  51001. foreach ($patterns as $pattern) {
  51002. $errorMessage = $this->validatePattern($pattern);
  51003. if ($errorMessage === null) {
  51004. continue;
  51005. }
  51006. $errors[] = RuleErrorBuilder::message(sprintf('Regex pattern is invalid: %s', $errorMessage))->identifier('regexp.pattern')->build();
  51007. }
  51008. return $errors;
  51009. }
  51010. private function extractPatterns(StaticCall $node, Scope $scope): array
  51011. {
  51012. if (!$node->class instanceof FullyQualified) {
  51013. return [];
  51014. }
  51015. $isRegex = $node->class->toString() === Regex::class;
  51016. $isPreg = $node->class->toString() === Preg::class;
  51017. if (!$isRegex && !$isPreg) {
  51018. return [];
  51019. }
  51020. if (!$node->name instanceof Node\Identifier || !Preg::isMatch('{^(match|isMatch|grep|replace|split)}', $node->name->name)) {
  51021. return [];
  51022. }
  51023. $functionName = $node->name->name;
  51024. if (!isset($node->getArgs()[0])) {
  51025. return [];
  51026. }
  51027. $patternNode = $node->getArgs()[0]->value;
  51028. $patternType = $scope->getType($patternNode);
  51029. $patternStrings = [];
  51030. foreach ($patternType->getConstantStrings() as $constantStringType) {
  51031. if ($functionName === 'replaceCallbackArray') {
  51032. continue;
  51033. }
  51034. $patternStrings[] = $constantStringType->getValue();
  51035. }
  51036. foreach ($patternType->getConstantArrays() as $constantArrayType) {
  51037. if (
  51038. in_array($functionName, [
  51039. 'replace',
  51040. 'replaceCallback',
  51041. ], true)
  51042. ) {
  51043. foreach ($constantArrayType->getValueTypes() as $arrayKeyType) {
  51044. foreach ($arrayKeyType->getConstantStrings() as $constantString) {
  51045. $patternStrings[] = $constantString->getValue();
  51046. }
  51047. }
  51048. }
  51049. if ($functionName !== 'replaceCallbackArray') {
  51050. continue;
  51051. }
  51052. foreach ($constantArrayType->getKeyTypes() as $arrayKeyType) {
  51053. foreach ($arrayKeyType->getConstantStrings() as $constantString) {
  51054. $patternStrings[] = $constantString->getValue();
  51055. }
  51056. }
  51057. }
  51058. return $patternStrings;
  51059. }
  51060. private function validatePattern(string $pattern): ?string
  51061. {
  51062. try {
  51063. $msg = null;
  51064. $prev = set_error_handler(function (int $severity, string $message, string $file) use (&$msg): bool {
  51065. $msg = preg_replace("#^preg_match(_all)?\\(.*?\\): #", '', $message);
  51066. return true;
  51067. });
  51068. if ($pattern === '') {
  51069. return 'Empty string is not a valid regular expression';
  51070. }
  51071. Preg::match($pattern, '');
  51072. if ($msg !== null) {
  51073. return $msg;
  51074. }
  51075. } catch (PcreException $e) {
  51076. if ($e->getCode() === PREG_INTERNAL_ERROR && $msg !== null) {
  51077. return $msg;
  51078. }
  51079. return preg_replace('{.*? failed executing ".*": }', '', $e->getMessage());
  51080. } finally {
  51081. restore_error_handler();
  51082. }
  51083. return null;
  51084. }
  51085. }
  51086. <?php declare(strict_types=1);
  51087. namespace Composer\Pcre\PHPStan;
  51088. use PHPStan\Analyser\Scope;
  51089. use PHPStan\Type\ArrayType;
  51090. use PHPStan\Type\Constant\ConstantArrayType;
  51091. use PHPStan\Type\Constant\ConstantIntegerType;
  51092. use PHPStan\Type\IntersectionType;
  51093. use PHPStan\Type\TypeCombinator;
  51094. use PHPStan\Type\Type;
  51095. use PhpParser\Node\Arg;
  51096. use PHPStan\Type\Php\RegexArrayShapeMatcher;
  51097. use PHPStan\Type\TypeTraverser;
  51098. use PHPStan\Type\UnionType;
  51099. final class PregMatchFlags
  51100. {
  51101. static public function getType(?Arg $flagsArg, Scope $scope): ?Type
  51102. {
  51103. if ($flagsArg === null) {
  51104. return new ConstantIntegerType(PREG_UNMATCHED_AS_NULL | RegexArrayShapeMatcher::PREG_UNMATCHED_AS_NULL_ON_72_73);
  51105. }
  51106. $flagsType = $scope->getType($flagsArg->value);
  51107. $constantScalars = $flagsType->getConstantScalarValues();
  51108. if ($constantScalars === []) {
  51109. return null;
  51110. }
  51111. $internalFlagsTypes = [];
  51112. foreach ($flagsType->getConstantScalarValues() as $constantScalarValue) {
  51113. if (!is_int($constantScalarValue)) {
  51114. return null;
  51115. }
  51116. $internalFlagsTypes[] = new ConstantIntegerType($constantScalarValue | PREG_UNMATCHED_AS_NULL | RegexArrayShapeMatcher::PREG_UNMATCHED_AS_NULL_ON_72_73);
  51117. }
  51118. return TypeCombinator::union(...$internalFlagsTypes);
  51119. }
  51120. static public function removeNullFromMatches(Type $matchesType): Type
  51121. {
  51122. return TypeTraverser::map($matchesType, static function (Type $type, callable $traverse): Type {
  51123. if ($type instanceof UnionType || $type instanceof IntersectionType) {
  51124. return $traverse($type);
  51125. }
  51126. if ($type instanceof ConstantArrayType) {
  51127. return new ConstantArrayType(
  51128. $type->getKeyTypes(),
  51129. array_map(static function (Type $valueType) use ($traverse): Type {
  51130. return $traverse($valueType);
  51131. }, $type->getValueTypes()),
  51132. $type->getNextAutoIndexes(),
  51133. [],
  51134. $type->isList()
  51135. );
  51136. }
  51137. if ($type instanceof ArrayType) {
  51138. return new ArrayType($type->getKeyType(), $traverse($type->getItemType()));
  51139. }
  51140. return TypeCombinator::removeNull($type);
  51141. });
  51142. }
  51143. }
  51144. <?php declare(strict_types=1);
  51145. namespace Composer\Pcre\PHPStan;
  51146. use Composer\Pcre\Preg;
  51147. use PhpParser\Node\Expr\StaticCall;
  51148. use PHPStan\Analyser\Scope;
  51149. use PHPStan\Reflection\MethodReflection;
  51150. use PHPStan\Reflection\ParameterReflection;
  51151. use PHPStan\TrinaryLogic;
  51152. use PHPStan\Type\Php\RegexArrayShapeMatcher;
  51153. use PHPStan\Type\StaticMethodParameterOutTypeExtension;
  51154. use PHPStan\Type\Type;
  51155. final class PregMatchParameterOutTypeExtension implements StaticMethodParameterOutTypeExtension
  51156. {
  51157. private $regexShapeMatcher;
  51158. public function __construct(
  51159. RegexArrayShapeMatcher $regexShapeMatcher
  51160. )
  51161. {
  51162. $this->regexShapeMatcher = $regexShapeMatcher;
  51163. }
  51164. public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool
  51165. {
  51166. return
  51167. $methodReflection->getDeclaringClass()->getName() === Preg::class
  51168. && in_array($methodReflection->getName(), [
  51169. 'match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups',
  51170. 'matchAll', 'isMatchAll', 'matchAllStrictGroups', 'isMatchAllStrictGroups'
  51171. ], true)
  51172. && $parameter->getName() === 'matches';
  51173. }
  51174. public function getParameterOutTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type
  51175. {
  51176. $args = $methodCall->getArgs();
  51177. $patternArg = $args[0] ?? null;
  51178. $matchesArg = $args[2] ?? null;
  51179. $flagsArg = $args[3] ?? null;
  51180. if (
  51181. $patternArg === null || $matchesArg === null
  51182. ) {
  51183. return null;
  51184. }
  51185. $flagsType = PregMatchFlags::getType($flagsArg, $scope);
  51186. if ($flagsType === null) {
  51187. return null;
  51188. }
  51189. if (stripos($methodReflection->getName(), 'matchAll') !== false) {
  51190. return $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope);
  51191. }
  51192. return $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope);
  51193. }
  51194. }
  51195. <?php declare(strict_types=1);
  51196. namespace Composer\Pcre\PHPStan;
  51197. use Composer\Pcre\Preg;
  51198. use PhpParser\Node\Expr\StaticCall;
  51199. use PHPStan\Analyser\Scope;
  51200. use PHPStan\Analyser\SpecifiedTypes;
  51201. use PHPStan\Analyser\TypeSpecifier;
  51202. use PHPStan\Analyser\TypeSpecifierAwareExtension;
  51203. use PHPStan\Analyser\TypeSpecifierContext;
  51204. use PHPStan\Reflection\MethodReflection;
  51205. use PHPStan\TrinaryLogic;
  51206. use PHPStan\Type\Constant\ConstantArrayType;
  51207. use PHPStan\Type\Php\RegexArrayShapeMatcher;
  51208. use PHPStan\Type\StaticMethodTypeSpecifyingExtension;
  51209. use PHPStan\Type\TypeCombinator;
  51210. use PHPStan\Type\Type;
  51211. final class PregMatchTypeSpecifyingExtension implements StaticMethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
  51212. {
  51213. private $typeSpecifier;
  51214. private $regexShapeMatcher;
  51215. public function __construct(RegexArrayShapeMatcher $regexShapeMatcher)
  51216. {
  51217. $this->regexShapeMatcher = $regexShapeMatcher;
  51218. }
  51219. public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void
  51220. {
  51221. $this->typeSpecifier = $typeSpecifier;
  51222. }
  51223. public function getClass(): string
  51224. {
  51225. return Preg::class;
  51226. }
  51227. public function isStaticMethodSupported(MethodReflection $methodReflection, StaticCall $node, TypeSpecifierContext $context): bool
  51228. {
  51229. return in_array($methodReflection->getName(), [
  51230. 'match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups',
  51231. 'matchAll', 'isMatchAll', 'matchAllStrictGroups', 'isMatchAllStrictGroups'
  51232. ], true)
  51233. && !$context->null();
  51234. }
  51235. public function specifyTypes(MethodReflection $methodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
  51236. {
  51237. $args = $node->getArgs();
  51238. $patternArg = $args[0] ?? null;
  51239. $matchesArg = $args[2] ?? null;
  51240. $flagsArg = $args[3] ?? null;
  51241. if (
  51242. $patternArg === null || $matchesArg === null
  51243. ) {
  51244. return new SpecifiedTypes();
  51245. }
  51246. $flagsType = PregMatchFlags::getType($flagsArg, $scope);
  51247. if ($flagsType === null) {
  51248. return new SpecifiedTypes();
  51249. }
  51250. if (stripos($methodReflection->getName(), 'matchAll') !== false) {
  51251. $matchedType = $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
  51252. } else {
  51253. $matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
  51254. }
  51255. if ($matchedType === null) {
  51256. return new SpecifiedTypes();
  51257. }
  51258. if (
  51259. in_array($methodReflection->getName(), ['matchStrictGroups', 'isMatchStrictGroups', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], true)
  51260. ) {
  51261. $matchedType = PregMatchFlags::removeNullFromMatches($matchedType);
  51262. }
  51263. $overwrite = false;
  51264. if ($context->false()) {
  51265. $overwrite = true;
  51266. $context = $context->negate();
  51267. }
  51268. if (method_exists('PHPStan\Analyser\SpecifiedTypes', 'setRootExpr')) {
  51269. $typeSpecifier = $this->typeSpecifier->create(
  51270. $matchesArg->value,
  51271. $matchedType,
  51272. $context,
  51273. $scope
  51274. )->setRootExpr($node);
  51275. return $overwrite ? $typeSpecifier->setAlwaysOverwriteTypes() : $typeSpecifier;
  51276. }
  51277. return $this->typeSpecifier->create(
  51278. $matchesArg->value,
  51279. $matchedType,
  51280. $context,
  51281. $overwrite,
  51282. $scope,
  51283. $node
  51284. );
  51285. }
  51286. }
  51287. <?php declare(strict_types=1);
  51288. namespace Composer\Pcre\PHPStan;
  51289. use Composer\Pcre\Preg;
  51290. use Composer\Pcre\Regex;
  51291. use PhpParser\Node\Expr\StaticCall;
  51292. use PHPStan\Analyser\Scope;
  51293. use PHPStan\Reflection\MethodReflection;
  51294. use PHPStan\Reflection\Native\NativeParameterReflection;
  51295. use PHPStan\Reflection\ParameterReflection;
  51296. use PHPStan\TrinaryLogic;
  51297. use PHPStan\Type\ClosureType;
  51298. use PHPStan\Type\Php\RegexArrayShapeMatcher;
  51299. use PHPStan\Type\StaticMethodParameterClosureTypeExtension;
  51300. use PHPStan\Type\StringType;
  51301. use PHPStan\Type\Type;
  51302. final class PregReplaceCallbackClosureTypeExtension implements StaticMethodParameterClosureTypeExtension
  51303. {
  51304. private $regexShapeMatcher;
  51305. public function __construct(RegexArrayShapeMatcher $regexShapeMatcher)
  51306. {
  51307. $this->regexShapeMatcher = $regexShapeMatcher;
  51308. }
  51309. public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool
  51310. {
  51311. return in_array($methodReflection->getDeclaringClass()->getName(), [Preg::class, Regex::class], true)
  51312. && in_array($methodReflection->getName(), ['replaceCallback'], true)
  51313. && $parameter->getName() === 'replacement';
  51314. }
  51315. public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type
  51316. {
  51317. $args = $methodCall->getArgs();
  51318. $patternArg = $args[0] ?? null;
  51319. $flagsArg = $args[5] ?? null;
  51320. if (
  51321. $patternArg === null
  51322. ) {
  51323. return null;
  51324. }
  51325. $flagsType = null;
  51326. if ($flagsArg !== null) {
  51327. $flagsType = $scope->getType($flagsArg->value);
  51328. }
  51329. $matchesType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createYes(), $scope);
  51330. if ($matchesType === null) {
  51331. return null;
  51332. }
  51333. return new ClosureType(
  51334. [
  51335. new NativeParameterReflection($parameter->getName(), $parameter->isOptional(), $matchesType, $parameter->passedByReference(), $parameter->isVariadic(), $parameter->getDefaultValue()),
  51336. ],
  51337. new StringType()
  51338. );
  51339. }
  51340. }
  51341. <?php declare(strict_types=1);
  51342. namespace Composer\Pcre\PHPStan;
  51343. use Composer\Pcre\Preg;
  51344. use Composer\Pcre\Regex;
  51345. use PhpParser\Node;
  51346. use PhpParser\Node\Expr\StaticCall;
  51347. use PhpParser\Node\Name\FullyQualified;
  51348. use PHPStan\Analyser\Scope;
  51349. use PHPStan\Analyser\SpecifiedTypes;
  51350. use PHPStan\Rules\Rule;
  51351. use PHPStan\Rules\RuleErrorBuilder;
  51352. use PHPStan\TrinaryLogic;
  51353. use PHPStan\Type\ObjectType;
  51354. use PHPStan\Type\Type;
  51355. use PHPStan\Type\TypeCombinator;
  51356. use PHPStan\Type\Php\RegexArrayShapeMatcher;
  51357. use function sprintf;
  51358. final class UnsafeStrictGroupsCallRule implements Rule
  51359. {
  51360. private $regexShapeMatcher;
  51361. public function __construct(RegexArrayShapeMatcher $regexShapeMatcher)
  51362. {
  51363. $this->regexShapeMatcher = $regexShapeMatcher;
  51364. }
  51365. public function getNodeType(): string
  51366. {
  51367. return StaticCall::class;
  51368. }
  51369. public function processNode(Node $node, Scope $scope): array
  51370. {
  51371. if (!$node->class instanceof FullyQualified) {
  51372. return [];
  51373. }
  51374. $isRegex = $node->class->toString() === Regex::class;
  51375. $isPreg = $node->class->toString() === Preg::class;
  51376. if (!$isRegex && !$isPreg) {
  51377. return [];
  51378. }
  51379. if (!$node->name instanceof Node\Identifier || !in_array($node->name->name, ['matchStrictGroups', 'isMatchStrictGroups', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], true)) {
  51380. return [];
  51381. }
  51382. $args = $node->getArgs();
  51383. if (!isset($args[0])) {
  51384. return [];
  51385. }
  51386. $patternArg = $args[0] ?? null;
  51387. if ($isPreg) {
  51388. if (!isset($args[2])) {
  51389. return [];
  51390. }
  51391. $flagsArg = $args[3] ?? null;
  51392. } else {
  51393. $flagsArg = $args[2] ?? null;
  51394. }
  51395. if ($patternArg === null) {
  51396. return [];
  51397. }
  51398. $flagsType = PregMatchFlags::getType($flagsArg, $scope);
  51399. if ($flagsType === null) {
  51400. return [];
  51401. }
  51402. $matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createYes(), $scope);
  51403. if ($matchedType === null) {
  51404. return [
  51405. RuleErrorBuilder::message(sprintf('The %s call is potentially unsafe as $matches\' type could not be inferred.', $node->name->name))
  51406. ->identifier('composerPcre.maybeUnsafeStrictGroups')
  51407. ->build(),
  51408. ];
  51409. }
  51410. if (count($matchedType->getConstantArrays()) === 1) {
  51411. $matchedType = $matchedType->getConstantArrays()[0];
  51412. $nullableGroups = [];
  51413. foreach ($matchedType->getValueTypes() as $index => $type) {
  51414. if (TypeCombinator::containsNull($type)) {
  51415. $nullableGroups[] = $matchedType->getKeyTypes()[$index]->getValue();
  51416. }
  51417. }
  51418. if (\count($nullableGroups) > 0) {
  51419. return [
  51420. RuleErrorBuilder::message(sprintf(
  51421. 'The %s call is unsafe as match group%s "%s" %s optional and may be null.',
  51422. $node->name->name,
  51423. \count($nullableGroups) > 1 ? 's' : '',
  51424. implode('", "', $nullableGroups),
  51425. \count($nullableGroups) > 1 ? 'are' : 'is'
  51426. ))->identifier('composerPcre.unsafeStrictGroups')->build(),
  51427. ];
  51428. }
  51429. }
  51430. return [];
  51431. }
  51432. }
  51433. <?php
  51434. namespace Composer\Pcre;
  51435. class PcreException extends \RuntimeException
  51436. {
  51437. public static function fromFunction($function, $pattern)
  51438. {
  51439. $code = preg_last_error();
  51440. if (is_array($pattern)) {
  51441. $pattern = implode(', ', $pattern);
  51442. }
  51443. return new PcreException($function.'(): failed executing "'.$pattern.'": '.self::pcreLastErrorMessage($code), $code);
  51444. }
  51445. private static function pcreLastErrorMessage($code)
  51446. {
  51447. if (function_exists('preg_last_error_msg')) {
  51448. return preg_last_error_msg();
  51449. }
  51450. if (PHP_VERSION_ID < 70201 && $code === 0) {
  51451. return 'UNDEFINED_ERROR';
  51452. }
  51453. $constants = get_defined_constants(true);
  51454. if (!isset($constants['pcre']) || !is_array($constants['pcre'])) {
  51455. return 'UNDEFINED_ERROR';
  51456. }
  51457. foreach ($constants['pcre'] as $const => $val) {
  51458. if ($val === $code && substr($const, -6) === '_ERROR') {
  51459. return $const;
  51460. }
  51461. }
  51462. return 'UNDEFINED_ERROR';
  51463. }
  51464. }
  51465. <?php
  51466. namespace Composer\Pcre;
  51467. class Preg
  51468. {
  51469. public const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.';
  51470. public const INVALID_TYPE_MSG = '$subject must be a string, %s given.';
  51471. public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
  51472. {
  51473. self::checkOffsetCapture($flags, 'matchWithOffsets');
  51474. $result = self::pregMatch($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset);
  51475. if ($result === false) {
  51476. throw PcreException::fromFunction('preg_match', $pattern);
  51477. }
  51478. return $result;
  51479. }
  51480. public static function matchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
  51481. {
  51482. $result = self::match($pattern, $subject, $matchesInternal, $flags, $offset);
  51483. $matches = self::enforceNonNullMatches($pattern, $matchesInternal, 'match');
  51484. return $result;
  51485. }
  51486. public static function matchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int
  51487. {
  51488. $result = self::pregMatch($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
  51489. if ($result === false) {
  51490. throw PcreException::fromFunction('preg_match', $pattern);
  51491. }
  51492. return $result;
  51493. }
  51494. public static function matchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
  51495. {
  51496. self::checkOffsetCapture($flags, 'matchAllWithOffsets');
  51497. self::checkSetOrder($flags);
  51498. $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset);
  51499. if (!is_int($result)) {
  51500. throw PcreException::fromFunction('preg_match_all', $pattern);
  51501. }
  51502. return $result;
  51503. }
  51504. public static function matchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int
  51505. {
  51506. $result = self::matchAll($pattern, $subject, $matchesInternal, $flags, $offset);
  51507. $matches = self::enforceNonNullMatchAll($pattern, $matchesInternal, 'matchAll');
  51508. return $result;
  51509. }
  51510. public static function matchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int
  51511. {
  51512. self::checkSetOrder($flags);
  51513. $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset);
  51514. if (!is_int($result)) {
  51515. throw PcreException::fromFunction('preg_match_all', $pattern);
  51516. }
  51517. return $result;
  51518. }
  51519. public static function replace($pattern, $replacement, $subject, int $limit = -1, ?int &$count = null): string
  51520. {
  51521. if (!is_scalar($subject)) {
  51522. if (is_array($subject)) {
  51523. throw new \InvalidArgumentException(static::ARRAY_MSG);
  51524. }
  51525. throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
  51526. }
  51527. $result = preg_replace($pattern, $replacement, $subject, $limit, $count);
  51528. if ($result === null) {
  51529. throw PcreException::fromFunction('preg_replace', $pattern);
  51530. }
  51531. return $result;
  51532. }
  51533. public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string
  51534. {
  51535. if (!is_scalar($subject)) {
  51536. if (is_array($subject)) {
  51537. throw new \InvalidArgumentException(static::ARRAY_MSG);
  51538. }
  51539. throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
  51540. }
  51541. if (PHP_VERSION_ID >= 70400) {
  51542. $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags);
  51543. } else {
  51544. $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count);
  51545. }
  51546. if ($result === null) {
  51547. throw PcreException::fromFunction('preg_replace_callback', $pattern);
  51548. }
  51549. return $result;
  51550. }
  51551. public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string
  51552. {
  51553. if (!is_scalar($subject)) {
  51554. if (is_array($subject)) {
  51555. throw new \InvalidArgumentException(static::ARRAY_MSG);
  51556. }
  51557. throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject)));
  51558. }
  51559. if (PHP_VERSION_ID >= 70400) {
  51560. $result = preg_replace_callback_array($pattern, $subject, $limit, $count, $flags);
  51561. } else {
  51562. $result = preg_replace_callback_array($pattern, $subject, $limit, $count);
  51563. }
  51564. if ($result === null) {
  51565. $pattern = array_keys($pattern);
  51566. throw PcreException::fromFunction('preg_replace_callback_array', $pattern);
  51567. }
  51568. return $result;
  51569. }
  51570. public static function split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
  51571. {
  51572. if (($flags & PREG_SPLIT_OFFSET_CAPTURE) !== 0) {
  51573. throw new \InvalidArgumentException('PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead');
  51574. }
  51575. $result = preg_split($pattern, $subject, $limit, $flags);
  51576. if ($result === false) {
  51577. throw PcreException::fromFunction('preg_split', $pattern);
  51578. }
  51579. return $result;
  51580. }
  51581. public static function splitWithOffsets(string $pattern, string $subject, int $limit = -1, int $flags = 0): array
  51582. {
  51583. $result = preg_split($pattern, $subject, $limit, $flags | PREG_SPLIT_OFFSET_CAPTURE);
  51584. if ($result === false) {
  51585. throw PcreException::fromFunction('preg_split', $pattern);
  51586. }
  51587. return $result;
  51588. }
  51589. public static function grep(string $pattern, array $array, int $flags = 0): array
  51590. {
  51591. $result = preg_grep($pattern, $array, $flags);
  51592. if ($result === false) {
  51593. throw PcreException::fromFunction('preg_grep', $pattern);
  51594. }
  51595. return $result;
  51596. }
  51597. public static function isMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
  51598. {
  51599. return (bool) static::match($pattern, $subject, $matches, $flags, $offset);
  51600. }
  51601. public static function isMatchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
  51602. {
  51603. return (bool) self::matchStrictGroups($pattern, $subject, $matches, $flags, $offset);
  51604. }
  51605. public static function isMatchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
  51606. {
  51607. return (bool) static::matchAll($pattern, $subject, $matches, $flags, $offset);
  51608. }
  51609. public static function isMatchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool
  51610. {
  51611. return (bool) self::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset);
  51612. }
  51613. public static function isMatchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool
  51614. {
  51615. return (bool) static::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
  51616. }
  51617. public static function isMatchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool
  51618. {
  51619. return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
  51620. }
  51621. private static function checkOffsetCapture(int $flags, string $useFunctionName): void
  51622. {
  51623. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  51624. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use ' . $useFunctionName . '() instead');
  51625. }
  51626. }
  51627. private static function checkSetOrder(int $flags): void
  51628. {
  51629. if (($flags & PREG_SET_ORDER) !== 0) {
  51630. throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the type of $matches');
  51631. }
  51632. }
  51633. private static function enforceNonNullMatches(string $pattern, array $matches, string $variantMethod)
  51634. {
  51635. foreach ($matches as $group => $match) {
  51636. if (null === $match) {
  51637. throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.');
  51638. }
  51639. }
  51640. return $matches;
  51641. }
  51642. private static function enforceNonNullMatchAll(string $pattern, array $matches, string $variantMethod)
  51643. {
  51644. foreach ($matches as $group => $groupMatches) {
  51645. foreach ($groupMatches as $match) {
  51646. if (null === $match) {
  51647. throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.');
  51648. }
  51649. }
  51650. }
  51651. return $matches;
  51652. }
  51653. private static function pregMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0)
  51654. {
  51655. if (PHP_VERSION_ID >= 70400) {
  51656. return preg_match($pattern, $subject, $matches, $flags, $offset);
  51657. }
  51658. $result = preg_match_all($pattern, $subject, $matchesInternal, $flags, $offset);
  51659. if (!is_int($result)) {
  51660. throw PcreException::fromFunction('preg_match', $pattern);
  51661. }
  51662. if ($result === 0) {
  51663. $matches = [];
  51664. } else {
  51665. $matches = array_map(function (array $m) {
  51666. $first = reset($m);
  51667. assert($first !== false);
  51668. return $first;
  51669. }, $matchesInternal);
  51670. $result = min($result, 1);
  51671. }
  51672. return $result;
  51673. }
  51674. }
  51675. <?php
  51676. namespace Composer\Pcre;
  51677. class Regex
  51678. {
  51679. public static function isMatch(string $pattern, string $subject, int $offset = 0): bool
  51680. {
  51681. return (bool) Preg::match($pattern, $subject, $matches, 0, $offset);
  51682. }
  51683. public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchResult
  51684. {
  51685. self::checkOffsetCapture($flags, 'matchWithOffsets');
  51686. $count = Preg::match($pattern, $subject, $matches, $flags, $offset);
  51687. return new MatchResult($count, $matches);
  51688. }
  51689. public static function matchStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchStrictGroupsResult
  51690. {
  51691. $count = Preg::matchStrictGroups($pattern, $subject, $matches, $flags, $offset);
  51692. return new MatchStrictGroupsResult($count, $matches);
  51693. }
  51694. public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchWithOffsetsResult
  51695. {
  51696. $count = Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
  51697. return new MatchWithOffsetsResult($count, $matches);
  51698. }
  51699. public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllResult
  51700. {
  51701. self::checkOffsetCapture($flags, 'matchAllWithOffsets');
  51702. self::checkSetOrder($flags);
  51703. $count = Preg::matchAll($pattern, $subject, $matches, $flags, $offset);
  51704. return new MatchAllResult($count, $matches);
  51705. }
  51706. public static function matchAllStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllStrictGroupsResult
  51707. {
  51708. self::checkOffsetCapture($flags, 'matchAllWithOffsets');
  51709. self::checkSetOrder($flags);
  51710. $count = Preg::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset);
  51711. return new MatchAllStrictGroupsResult($count, $matches);
  51712. }
  51713. public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllWithOffsetsResult
  51714. {
  51715. self::checkSetOrder($flags);
  51716. $count = Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
  51717. return new MatchAllWithOffsetsResult($count, $matches);
  51718. }
  51719. public static function replace($pattern, $replacement, $subject, int $limit = -1): ReplaceResult
  51720. {
  51721. $result = Preg::replace($pattern, $replacement, $subject, $limit, $count);
  51722. return new ReplaceResult($count, $result);
  51723. }
  51724. public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult
  51725. {
  51726. $result = Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags);
  51727. return new ReplaceResult($count, $result);
  51728. }
  51729. public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0): ReplaceResult
  51730. {
  51731. $result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags);
  51732. return new ReplaceResult($count, $result);
  51733. }
  51734. private static function checkOffsetCapture(int $flags, string $useFunctionName): void
  51735. {
  51736. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  51737. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use '.$useFunctionName.'() instead');
  51738. }
  51739. }
  51740. private static function checkSetOrder(int $flags): void
  51741. {
  51742. if (($flags & PREG_SET_ORDER) !== 0) {
  51743. throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type');
  51744. }
  51745. }
  51746. }
  51747. <?php
  51748. namespace Composer\Pcre;
  51749. final class ReplaceResult
  51750. {
  51751. public $result;
  51752. public $count;
  51753. public $matched;
  51754. public function __construct(int $count, string $result)
  51755. {
  51756. $this->count = $count;
  51757. $this->matched = (bool) $count;
  51758. $this->result = $result;
  51759. }
  51760. }
  51761. <?php
  51762. namespace Composer\Pcre;
  51763. class UnexpectedNullMatchException extends PcreException
  51764. {
  51765. public static function fromFunction($function, $pattern)
  51766. {
  51767. throw new \LogicException('fromFunction should not be called on '.self::class.', use '.PcreException::class);
  51768. }
  51769. }
  51770. Copyright (C) 2015 Composer
  51771. Permission is hereby granted, free of charge, to any person obtaining a copy of
  51772. this software and associated documentation files (the "Software"), to deal in
  51773. the Software without restriction, including without limitation the rights to
  51774. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  51775. of the Software, and to permit persons to whom the Software is furnished to do
  51776. so, subject to the following conditions:
  51777. The above copyright notice and this permission notice shall be included in all
  51778. copies or substantial portions of the Software.
  51779. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  51780. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  51781. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  51782. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  51783. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  51784. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  51785. SOFTWARE.
  51786. <?php
  51787. namespace Composer\Semver;
  51788. use Composer\Semver\Constraint\Constraint;
  51789. class Comparator
  51790. {
  51791. public static function greaterThan($version1, $version2)
  51792. {
  51793. return self::compare($version1, '>', $version2);
  51794. }
  51795. public static function greaterThanOrEqualTo($version1, $version2)
  51796. {
  51797. return self::compare($version1, '>=', $version2);
  51798. }
  51799. public static function lessThan($version1, $version2)
  51800. {
  51801. return self::compare($version1, '<', $version2);
  51802. }
  51803. public static function lessThanOrEqualTo($version1, $version2)
  51804. {
  51805. return self::compare($version1, '<=', $version2);
  51806. }
  51807. public static function equalTo($version1, $version2)
  51808. {
  51809. return self::compare($version1, '==', $version2);
  51810. }
  51811. public static function notEqualTo($version1, $version2)
  51812. {
  51813. return self::compare($version1, '!=', $version2);
  51814. }
  51815. public static function compare($version1, $operator, $version2)
  51816. {
  51817. $constraint = new Constraint($operator, $version2);
  51818. return $constraint->matchSpecific(new Constraint('==', $version1), true);
  51819. }
  51820. }
  51821. <?php
  51822. namespace Composer\Semver;
  51823. use Composer\Semver\Constraint\Constraint;
  51824. use Composer\Semver\Constraint\ConstraintInterface;
  51825. class CompilingMatcher
  51826. {
  51827. private static $compiledCheckerCache = array();
  51828. private static $resultCache = array();
  51829. private static $enabled;
  51830. private static $transOpInt = array(
  51831. Constraint::OP_EQ => Constraint::STR_OP_EQ,
  51832. Constraint::OP_LT => Constraint::STR_OP_LT,
  51833. Constraint::OP_LE => Constraint::STR_OP_LE,
  51834. Constraint::OP_GT => Constraint::STR_OP_GT,
  51835. Constraint::OP_GE => Constraint::STR_OP_GE,
  51836. Constraint::OP_NE => Constraint::STR_OP_NE,
  51837. );
  51838. public static function clear()
  51839. {
  51840. self::$resultCache = array();
  51841. self::$compiledCheckerCache = array();
  51842. }
  51843. public static function match(ConstraintInterface $constraint, $operator, $version)
  51844. {
  51845. $resultCacheKey = $operator.$constraint.';'.$version;
  51846. if (isset(self::$resultCache[$resultCacheKey])) {
  51847. return self::$resultCache[$resultCacheKey];
  51848. }
  51849. if (self::$enabled === null) {
  51850. self::$enabled = !\in_array('eval', explode(',', (string) ini_get('disable_functions')), true);
  51851. }
  51852. if (!self::$enabled) {
  51853. return self::$resultCache[$resultCacheKey] = $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
  51854. }
  51855. $cacheKey = $operator.$constraint;
  51856. if (!isset(self::$compiledCheckerCache[$cacheKey])) {
  51857. $code = $constraint->compile($operator);
  51858. self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
  51859. } else {
  51860. $function = self::$compiledCheckerCache[$cacheKey];
  51861. }
  51862. return self::$resultCache[$resultCacheKey] = $function($version, strpos($version, 'dev-') === 0);
  51863. }
  51864. }
  51865. <?php
  51866. namespace Composer\Semver\Constraint;
  51867. class Bound
  51868. {
  51869. private $version;
  51870. private $isInclusive;
  51871. public function __construct($version, $isInclusive)
  51872. {
  51873. $this->version = $version;
  51874. $this->isInclusive = $isInclusive;
  51875. }
  51876. public function getVersion()
  51877. {
  51878. return $this->version;
  51879. }
  51880. public function isInclusive()
  51881. {
  51882. return $this->isInclusive;
  51883. }
  51884. public function isZero()
  51885. {
  51886. return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
  51887. }
  51888. public function isPositiveInfinity()
  51889. {
  51890. return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
  51891. }
  51892. public function compareTo(Bound $other, $operator)
  51893. {
  51894. if (!\in_array($operator, array('<', '>'), true)) {
  51895. throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
  51896. }
  51897. if ($this == $other) {
  51898. return false;
  51899. }
  51900. $compareResult = version_compare($this->getVersion(), $other->getVersion());
  51901. if (0 !== $compareResult) {
  51902. return (('>' === $operator) ? 1 : -1) === $compareResult;
  51903. }
  51904. return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
  51905. }
  51906. public function __toString()
  51907. {
  51908. return sprintf(
  51909. '%s [%s]',
  51910. $this->getVersion(),
  51911. $this->isInclusive() ? 'inclusive' : 'exclusive'
  51912. );
  51913. }
  51914. public static function zero()
  51915. {
  51916. return new Bound('0.0.0.0-dev', true);
  51917. }
  51918. public static function positiveInfinity()
  51919. {
  51920. return new Bound(PHP_INT_MAX.'.0.0.0', false);
  51921. }
  51922. }
  51923. <?php
  51924. namespace Composer\Semver\Constraint;
  51925. class Constraint implements ConstraintInterface
  51926. {
  51927. const OP_EQ = 0;
  51928. const OP_LT = 1;
  51929. const OP_LE = 2;
  51930. const OP_GT = 3;
  51931. const OP_GE = 4;
  51932. const OP_NE = 5;
  51933. const STR_OP_EQ = '==';
  51934. const STR_OP_EQ_ALT = '=';
  51935. const STR_OP_LT = '<';
  51936. const STR_OP_LE = '<=';
  51937. const STR_OP_GT = '>';
  51938. const STR_OP_GE = '>=';
  51939. const STR_OP_NE = '!=';
  51940. const STR_OP_NE_ALT = '<>';
  51941. private static $transOpStr = array(
  51942. '=' => self::OP_EQ,
  51943. '==' => self::OP_EQ,
  51944. '<' => self::OP_LT,
  51945. '<=' => self::OP_LE,
  51946. '>' => self::OP_GT,
  51947. '>=' => self::OP_GE,
  51948. '<>' => self::OP_NE,
  51949. '!=' => self::OP_NE,
  51950. );
  51951. private static $transOpInt = array(
  51952. self::OP_EQ => '==',
  51953. self::OP_LT => '<',
  51954. self::OP_LE => '<=',
  51955. self::OP_GT => '>',
  51956. self::OP_GE => '>=',
  51957. self::OP_NE => '!=',
  51958. );
  51959. protected $operator;
  51960. protected $version;
  51961. protected $prettyString;
  51962. protected $lowerBound;
  51963. protected $upperBound;
  51964. public function __construct($operator, $version)
  51965. {
  51966. if (!isset(self::$transOpStr[$operator])) {
  51967. throw new \InvalidArgumentException(sprintf(
  51968. 'Invalid operator "%s" given, expected one of: %s',
  51969. $operator,
  51970. implode(', ', self::getSupportedOperators())
  51971. ));
  51972. }
  51973. $this->operator = self::$transOpStr[$operator];
  51974. $this->version = $version;
  51975. }
  51976. public function getVersion()
  51977. {
  51978. return $this->version;
  51979. }
  51980. public function getOperator()
  51981. {
  51982. return self::$transOpInt[$this->operator];
  51983. }
  51984. public function matches(ConstraintInterface $provider)
  51985. {
  51986. if ($provider instanceof self) {
  51987. return $this->matchSpecific($provider);
  51988. }
  51989. return $provider->matches($this);
  51990. }
  51991. public function setPrettyString($prettyString)
  51992. {
  51993. $this->prettyString = $prettyString;
  51994. }
  51995. public function getPrettyString()
  51996. {
  51997. if ($this->prettyString) {
  51998. return $this->prettyString;
  51999. }
  52000. return $this->__toString();
  52001. }
  52002. public static function getSupportedOperators()
  52003. {
  52004. return array_keys(self::$transOpStr);
  52005. }
  52006. public static function getOperatorConstant($operator)
  52007. {
  52008. return self::$transOpStr[$operator];
  52009. }
  52010. public function versionCompare($a, $b, $operator, $compareBranches = false)
  52011. {
  52012. if (!isset(self::$transOpStr[$operator])) {
  52013. throw new \InvalidArgumentException(sprintf(
  52014. 'Invalid operator "%s" given, expected one of: %s',
  52015. $operator,
  52016. implode(', ', self::getSupportedOperators())
  52017. ));
  52018. }
  52019. $aIsBranch = strpos($a, 'dev-') === 0;
  52020. $bIsBranch = strpos($b, 'dev-') === 0;
  52021. if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
  52022. return $a !== $b;
  52023. }
  52024. if ($aIsBranch && $bIsBranch) {
  52025. return $operator === '==' && $a === $b;
  52026. }
  52027. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  52028. return false;
  52029. }
  52030. return \version_compare($a, $b, $operator);
  52031. }
  52032. public function compile($otherOperator)
  52033. {
  52034. if (strpos($this->version, 'dev-') === 0) {
  52035. if (self::OP_EQ === $this->operator) {
  52036. if (self::OP_EQ === $otherOperator) {
  52037. return sprintf('$b && $v === %s', \var_export($this->version, true));
  52038. }
  52039. if (self::OP_NE === $otherOperator) {
  52040. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  52041. }
  52042. return 'false';
  52043. }
  52044. if (self::OP_NE === $this->operator) {
  52045. if (self::OP_EQ === $otherOperator) {
  52046. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  52047. }
  52048. if (self::OP_NE === $otherOperator) {
  52049. return 'true';
  52050. }
  52051. return '!$b';
  52052. }
  52053. return 'false';
  52054. }
  52055. if (self::OP_EQ === $this->operator) {
  52056. if (self::OP_EQ === $otherOperator) {
  52057. return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
  52058. }
  52059. if (self::OP_NE === $otherOperator) {
  52060. return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
  52061. }
  52062. return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
  52063. }
  52064. if (self::OP_NE === $this->operator) {
  52065. if (self::OP_EQ === $otherOperator) {
  52066. return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
  52067. }
  52068. if (self::OP_NE === $otherOperator) {
  52069. return 'true';
  52070. }
  52071. return '!$b';
  52072. }
  52073. if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
  52074. if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
  52075. return '!$b';
  52076. }
  52077. } else {
  52078. if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
  52079. return '!$b';
  52080. }
  52081. }
  52082. if (self::OP_NE === $otherOperator) {
  52083. return 'true';
  52084. }
  52085. $codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
  52086. if ($this->operator === self::OP_LE) {
  52087. if ($otherOperator === self::OP_GT) {
  52088. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  52089. }
  52090. } elseif ($this->operator === self::OP_GE) {
  52091. if ($otherOperator === self::OP_LT) {
  52092. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  52093. }
  52094. }
  52095. return sprintf('!$b && %s', $codeComparison);
  52096. }
  52097. public function matchSpecific(Constraint $provider, $compareBranches = false)
  52098. {
  52099. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  52100. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  52101. $isEqualOp = self::OP_EQ === $this->operator;
  52102. $isNonEqualOp = self::OP_NE === $this->operator;
  52103. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  52104. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  52105. if ($isNonEqualOp || $isProviderNonEqualOp) {
  52106. if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
  52107. return false;
  52108. }
  52109. if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
  52110. return false;
  52111. }
  52112. if (!$isEqualOp && !$isProviderEqualOp) {
  52113. return true;
  52114. }
  52115. return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  52116. }
  52117. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  52118. return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
  52119. }
  52120. $version1 = $isEqualOp ? $this->version : $provider->version;
  52121. $version2 = $isEqualOp ? $provider->version : $this->version;
  52122. $operator = $isEqualOp ? $provider->operator : $this->operator;
  52123. if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
  52124. return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
  52125. && self::$transOpInt[$this->operator] !== $noEqualOp
  52126. && \version_compare($provider->version, $this->version, '=='));
  52127. }
  52128. return false;
  52129. }
  52130. public function __toString()
  52131. {
  52132. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  52133. }
  52134. public function getLowerBound()
  52135. {
  52136. $this->extractBounds();
  52137. return $this->lowerBound;
  52138. }
  52139. public function getUpperBound()
  52140. {
  52141. $this->extractBounds();
  52142. return $this->upperBound;
  52143. }
  52144. private function extractBounds()
  52145. {
  52146. if (null !== $this->lowerBound) {
  52147. return;
  52148. }
  52149. if (strpos($this->version, 'dev-') === 0) {
  52150. $this->lowerBound = Bound::zero();
  52151. $this->upperBound = Bound::positiveInfinity();
  52152. return;
  52153. }
  52154. switch ($this->operator) {
  52155. case self::OP_EQ:
  52156. $this->lowerBound = new Bound($this->version, true);
  52157. $this->upperBound = new Bound($this->version, true);
  52158. break;
  52159. case self::OP_LT:
  52160. $this->lowerBound = Bound::zero();
  52161. $this->upperBound = new Bound($this->version, false);
  52162. break;
  52163. case self::OP_LE:
  52164. $this->lowerBound = Bound::zero();
  52165. $this->upperBound = new Bound($this->version, true);
  52166. break;
  52167. case self::OP_GT:
  52168. $this->lowerBound = new Bound($this->version, false);
  52169. $this->upperBound = Bound::positiveInfinity();
  52170. break;
  52171. case self::OP_GE:
  52172. $this->lowerBound = new Bound($this->version, true);
  52173. $this->upperBound = Bound::positiveInfinity();
  52174. break;
  52175. case self::OP_NE:
  52176. $this->lowerBound = Bound::zero();
  52177. $this->upperBound = Bound::positiveInfinity();
  52178. break;
  52179. }
  52180. }
  52181. }
  52182. <?php
  52183. namespace Composer\Semver\Constraint;
  52184. interface ConstraintInterface
  52185. {
  52186. public function matches(ConstraintInterface $provider);
  52187. public function compile($otherOperator);
  52188. public function getUpperBound();
  52189. public function getLowerBound();
  52190. public function getPrettyString();
  52191. public function setPrettyString($prettyString);
  52192. public function __toString();
  52193. }
  52194. <?php
  52195. namespace Composer\Semver\Constraint;
  52196. class MatchAllConstraint implements ConstraintInterface
  52197. {
  52198. protected $prettyString;
  52199. public function matches(ConstraintInterface $provider)
  52200. {
  52201. return true;
  52202. }
  52203. public function compile($otherOperator)
  52204. {
  52205. return 'true';
  52206. }
  52207. public function setPrettyString($prettyString)
  52208. {
  52209. $this->prettyString = $prettyString;
  52210. }
  52211. public function getPrettyString()
  52212. {
  52213. if ($this->prettyString) {
  52214. return $this->prettyString;
  52215. }
  52216. return (string) $this;
  52217. }
  52218. public function __toString()
  52219. {
  52220. return '*';
  52221. }
  52222. public function getUpperBound()
  52223. {
  52224. return Bound::positiveInfinity();
  52225. }
  52226. public function getLowerBound()
  52227. {
  52228. return Bound::zero();
  52229. }
  52230. }
  52231. <?php
  52232. namespace Composer\Semver\Constraint;
  52233. class MatchNoneConstraint implements ConstraintInterface
  52234. {
  52235. protected $prettyString;
  52236. public function matches(ConstraintInterface $provider)
  52237. {
  52238. return false;
  52239. }
  52240. public function compile($otherOperator)
  52241. {
  52242. return 'false';
  52243. }
  52244. public function setPrettyString($prettyString)
  52245. {
  52246. $this->prettyString = $prettyString;
  52247. }
  52248. public function getPrettyString()
  52249. {
  52250. if ($this->prettyString) {
  52251. return $this->prettyString;
  52252. }
  52253. return (string) $this;
  52254. }
  52255. public function __toString()
  52256. {
  52257. return '[]';
  52258. }
  52259. public function getUpperBound()
  52260. {
  52261. return new Bound('0.0.0.0-dev', false);
  52262. }
  52263. public function getLowerBound()
  52264. {
  52265. return new Bound('0.0.0.0-dev', false);
  52266. }
  52267. }
  52268. <?php
  52269. namespace Composer\Semver\Constraint;
  52270. class MultiConstraint implements ConstraintInterface
  52271. {
  52272. protected $constraints;
  52273. protected $prettyString;
  52274. protected $string;
  52275. protected $conjunctive;
  52276. protected $lowerBound;
  52277. protected $upperBound;
  52278. public function __construct(array $constraints, $conjunctive = true)
  52279. {
  52280. if (\count($constraints) < 2) {
  52281. throw new \InvalidArgumentException(
  52282. 'Must provide at least two constraints for a MultiConstraint. Use '.
  52283. 'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
  52284. 'MultiConstraint::create() which optimizes and handles those cases automatically.'
  52285. );
  52286. }
  52287. $this->constraints = $constraints;
  52288. $this->conjunctive = $conjunctive;
  52289. }
  52290. public function getConstraints()
  52291. {
  52292. return $this->constraints;
  52293. }
  52294. public function isConjunctive()
  52295. {
  52296. return $this->conjunctive;
  52297. }
  52298. public function isDisjunctive()
  52299. {
  52300. return !$this->conjunctive;
  52301. }
  52302. public function compile($otherOperator)
  52303. {
  52304. $parts = array();
  52305. foreach ($this->constraints as $constraint) {
  52306. $code = $constraint->compile($otherOperator);
  52307. if ($code === 'true') {
  52308. if (!$this->conjunctive) {
  52309. return 'true';
  52310. }
  52311. } elseif ($code === 'false') {
  52312. if ($this->conjunctive) {
  52313. return 'false';
  52314. }
  52315. } else {
  52316. $parts[] = '('.$code.')';
  52317. }
  52318. }
  52319. if (!$parts) {
  52320. return $this->conjunctive ? 'true' : 'false';
  52321. }
  52322. return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
  52323. }
  52324. public function matches(ConstraintInterface $provider)
  52325. {
  52326. if (false === $this->conjunctive) {
  52327. foreach ($this->constraints as $constraint) {
  52328. if ($provider->matches($constraint)) {
  52329. return true;
  52330. }
  52331. }
  52332. return false;
  52333. }
  52334. if ($provider instanceof MultiConstraint && $provider->isDisjunctive()) {
  52335. return $provider->matches($this);
  52336. }
  52337. foreach ($this->constraints as $constraint) {
  52338. if (!$provider->matches($constraint)) {
  52339. return false;
  52340. }
  52341. }
  52342. return true;
  52343. }
  52344. public function setPrettyString($prettyString)
  52345. {
  52346. $this->prettyString = $prettyString;
  52347. }
  52348. public function getPrettyString()
  52349. {
  52350. if ($this->prettyString) {
  52351. return $this->prettyString;
  52352. }
  52353. return (string) $this;
  52354. }
  52355. public function __toString()
  52356. {
  52357. if ($this->string !== null) {
  52358. return $this->string;
  52359. }
  52360. $constraints = array();
  52361. foreach ($this->constraints as $constraint) {
  52362. $constraints[] = (string) $constraint;
  52363. }
  52364. return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  52365. }
  52366. public function getLowerBound()
  52367. {
  52368. $this->extractBounds();
  52369. if (null === $this->lowerBound) {
  52370. throw new \LogicException('extractBounds should have populated the lowerBound property');
  52371. }
  52372. return $this->lowerBound;
  52373. }
  52374. public function getUpperBound()
  52375. {
  52376. $this->extractBounds();
  52377. if (null === $this->upperBound) {
  52378. throw new \LogicException('extractBounds should have populated the upperBound property');
  52379. }
  52380. return $this->upperBound;
  52381. }
  52382. public static function create(array $constraints, $conjunctive = true)
  52383. {
  52384. if (0 === \count($constraints)) {
  52385. return new MatchAllConstraint();
  52386. }
  52387. if (1 === \count($constraints)) {
  52388. return $constraints[0];
  52389. }
  52390. $optimized = self::optimizeConstraints($constraints, $conjunctive);
  52391. if ($optimized !== null) {
  52392. list($constraints, $conjunctive) = $optimized;
  52393. if (\count($constraints) === 1) {
  52394. return $constraints[0];
  52395. }
  52396. }
  52397. return new self($constraints, $conjunctive);
  52398. }
  52399. private static function optimizeConstraints(array $constraints, $conjunctive)
  52400. {
  52401. if (!$conjunctive) {
  52402. $left = $constraints[0];
  52403. $mergedConstraints = array();
  52404. $optimized = false;
  52405. for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
  52406. $right = $constraints[$i];
  52407. if (
  52408. $left instanceof self
  52409. && $left->conjunctive
  52410. && $right instanceof self
  52411. && $right->conjunctive
  52412. && \count($left->constraints) === 2
  52413. && \count($right->constraints) === 2
  52414. && ($left0 = (string) $left->constraints[0])
  52415. && $left0[0] === '>' && $left0[1] === '='
  52416. && ($left1 = (string) $left->constraints[1])
  52417. && $left1[0] === '<'
  52418. && ($right0 = (string) $right->constraints[0])
  52419. && $right0[0] === '>' && $right0[1] === '='
  52420. && ($right1 = (string) $right->constraints[1])
  52421. && $right1[0] === '<'
  52422. && substr($left1, 2) === substr($right0, 3)
  52423. ) {
  52424. $optimized = true;
  52425. $left = new MultiConstraint(
  52426. array(
  52427. $left->constraints[0],
  52428. $right->constraints[1],
  52429. ),
  52430. true);
  52431. } else {
  52432. $mergedConstraints[] = $left;
  52433. $left = $right;
  52434. }
  52435. }
  52436. if ($optimized) {
  52437. $mergedConstraints[] = $left;
  52438. return array($mergedConstraints, false);
  52439. }
  52440. }
  52441. return null;
  52442. }
  52443. private function extractBounds()
  52444. {
  52445. if (null !== $this->lowerBound) {
  52446. return;
  52447. }
  52448. foreach ($this->constraints as $constraint) {
  52449. if (null === $this->lowerBound || null === $this->upperBound) {
  52450. $this->lowerBound = $constraint->getLowerBound();
  52451. $this->upperBound = $constraint->getUpperBound();
  52452. continue;
  52453. }
  52454. if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
  52455. $this->lowerBound = $constraint->getLowerBound();
  52456. }
  52457. if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
  52458. $this->upperBound = $constraint->getUpperBound();
  52459. }
  52460. }
  52461. }
  52462. }
  52463. <?php
  52464. namespace Composer\Semver;
  52465. use Composer\Semver\Constraint\Constraint;
  52466. class Interval
  52467. {
  52468. private $start;
  52469. private $end;
  52470. public function __construct(Constraint $start, Constraint $end)
  52471. {
  52472. $this->start = $start;
  52473. $this->end = $end;
  52474. }
  52475. public function getStart()
  52476. {
  52477. return $this->start;
  52478. }
  52479. public function getEnd()
  52480. {
  52481. return $this->end;
  52482. }
  52483. public static function fromZero()
  52484. {
  52485. static $zero;
  52486. if (null === $zero) {
  52487. $zero = new Constraint('>=', '0.0.0.0-dev');
  52488. }
  52489. return $zero;
  52490. }
  52491. public static function untilPositiveInfinity()
  52492. {
  52493. static $positiveInfinity;
  52494. if (null === $positiveInfinity) {
  52495. $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
  52496. }
  52497. return $positiveInfinity;
  52498. }
  52499. public static function any()
  52500. {
  52501. return new self(self::fromZero(), self::untilPositiveInfinity());
  52502. }
  52503. public static function anyDev()
  52504. {
  52505. return array('names' => array(), 'exclude' => true);
  52506. }
  52507. public static function noDev()
  52508. {
  52509. return array('names' => array(), 'exclude' => false);
  52510. }
  52511. }
  52512. <?php
  52513. namespace Composer\Semver;
  52514. use Composer\Semver\Constraint\Constraint;
  52515. use Composer\Semver\Constraint\ConstraintInterface;
  52516. use Composer\Semver\Constraint\MatchAllConstraint;
  52517. use Composer\Semver\Constraint\MatchNoneConstraint;
  52518. use Composer\Semver\Constraint\MultiConstraint;
  52519. class Intervals
  52520. {
  52521. private static $intervalsCache = array();
  52522. private static $opSortOrder = array(
  52523. '>=' => -3,
  52524. '<' => -2,
  52525. '>' => 2,
  52526. '<=' => 3,
  52527. );
  52528. public static function clear()
  52529. {
  52530. self::$intervalsCache = array();
  52531. }
  52532. public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
  52533. {
  52534. if ($constraint instanceof MatchAllConstraint) {
  52535. return true;
  52536. }
  52537. if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
  52538. return false;
  52539. }
  52540. $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
  52541. $candidateIntervals = self::get($candidate);
  52542. if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
  52543. return false;
  52544. }
  52545. foreach ($intersectionIntervals['numeric'] as $index => $interval) {
  52546. if (!isset($candidateIntervals['numeric'][$index])) {
  52547. return false;
  52548. }
  52549. if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
  52550. return false;
  52551. }
  52552. if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
  52553. return false;
  52554. }
  52555. }
  52556. if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
  52557. return false;
  52558. }
  52559. if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
  52560. return false;
  52561. }
  52562. foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
  52563. if ($name !== $candidateIntervals['branches']['names'][$index]) {
  52564. return false;
  52565. }
  52566. }
  52567. return true;
  52568. }
  52569. public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
  52570. {
  52571. if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
  52572. return true;
  52573. }
  52574. if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
  52575. return false;
  52576. }
  52577. $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
  52578. return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
  52579. }
  52580. public static function compactConstraint(ConstraintInterface $constraint)
  52581. {
  52582. if (!$constraint instanceof MultiConstraint) {
  52583. return $constraint;
  52584. }
  52585. $intervals = self::generateIntervals($constraint);
  52586. $constraints = array();
  52587. $hasNumericMatchAll = false;
  52588. if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
  52589. $constraints[] = $intervals['numeric'][0]->getStart();
  52590. $hasNumericMatchAll = true;
  52591. } else {
  52592. $unEqualConstraints = array();
  52593. for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
  52594. $interval = $intervals['numeric'][$i];
  52595. if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
  52596. $nextInterval = $intervals['numeric'][$i+1];
  52597. if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
  52598. if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
  52599. $unEqualConstraints[] = $interval->getStart();
  52600. }
  52601. $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
  52602. continue;
  52603. }
  52604. }
  52605. if (\count($unEqualConstraints) > 0) {
  52606. if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  52607. $unEqualConstraints[] = $interval->getEnd();
  52608. }
  52609. if (\count($unEqualConstraints) > 1) {
  52610. $constraints[] = new MultiConstraint($unEqualConstraints, true);
  52611. } else {
  52612. $constraints[] = $unEqualConstraints[0];
  52613. }
  52614. $unEqualConstraints = array();
  52615. continue;
  52616. }
  52617. if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
  52618. $constraints[] = new Constraint('==', $interval->getStart()->getVersion());
  52619. continue;
  52620. }
  52621. if ((string) $interval->getStart() === (string) Interval::fromZero()) {
  52622. $constraints[] = $interval->getEnd();
  52623. } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
  52624. $constraints[] = $interval->getStart();
  52625. } else {
  52626. $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
  52627. }
  52628. }
  52629. }
  52630. $devConstraints = array();
  52631. if (0 === \count($intervals['branches']['names'])) {
  52632. if ($intervals['branches']['exclude']) {
  52633. if ($hasNumericMatchAll) {
  52634. return new MatchAllConstraint;
  52635. }
  52636. }
  52637. } else {
  52638. foreach ($intervals['branches']['names'] as $branchName) {
  52639. if ($intervals['branches']['exclude']) {
  52640. $devConstraints[] = new Constraint('!=', $branchName);
  52641. } else {
  52642. $devConstraints[] = new Constraint('==', $branchName);
  52643. }
  52644. }
  52645. if ($intervals['branches']['exclude']) {
  52646. if (\count($constraints) > 1) {
  52647. return new MultiConstraint(array_merge(
  52648. array(new MultiConstraint($constraints, false)),
  52649. $devConstraints
  52650. ), true);
  52651. }
  52652. if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
  52653. if (\count($devConstraints) > 1) {
  52654. return new MultiConstraint($devConstraints, true);
  52655. }
  52656. return $devConstraints[0];
  52657. }
  52658. return new MultiConstraint(array_merge($constraints, $devConstraints), true);
  52659. }
  52660. $constraints = array_merge($constraints, $devConstraints);
  52661. }
  52662. if (\count($constraints) > 1) {
  52663. return new MultiConstraint($constraints, false);
  52664. }
  52665. if (\count($constraints) === 1) {
  52666. return $constraints[0];
  52667. }
  52668. return new MatchNoneConstraint;
  52669. }
  52670. public static function get(ConstraintInterface $constraint)
  52671. {
  52672. $key = (string) $constraint;
  52673. if (!isset(self::$intervalsCache[$key])) {
  52674. self::$intervalsCache[$key] = self::generateIntervals($constraint);
  52675. }
  52676. return self::$intervalsCache[$key];
  52677. }
  52678. private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
  52679. {
  52680. if ($constraint instanceof MatchAllConstraint) {
  52681. return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
  52682. }
  52683. if ($constraint instanceof MatchNoneConstraint) {
  52684. return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
  52685. }
  52686. if ($constraint instanceof Constraint) {
  52687. return self::generateSingleConstraintIntervals($constraint);
  52688. }
  52689. if (!$constraint instanceof MultiConstraint) {
  52690. throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
  52691. }
  52692. $constraints = $constraint->getConstraints();
  52693. $numericGroups = array();
  52694. $constraintBranches = array();
  52695. foreach ($constraints as $c) {
  52696. $res = self::get($c);
  52697. $numericGroups[] = $res['numeric'];
  52698. $constraintBranches[] = $res['branches'];
  52699. }
  52700. if ($constraint->isDisjunctive()) {
  52701. $branches = Interval::noDev();
  52702. foreach ($constraintBranches as $b) {
  52703. if ($b['exclude']) {
  52704. if ($branches['exclude']) {
  52705. $branches['names'] = array_intersect($branches['names'], $b['names']);
  52706. } else {
  52707. $branches['exclude'] = true;
  52708. $branches['names'] = array_diff($b['names'], $branches['names']);
  52709. }
  52710. } else {
  52711. if ($branches['exclude']) {
  52712. $branches['names'] = array_diff($branches['names'], $b['names']);
  52713. } else {
  52714. $branches['names'] = array_merge($branches['names'], $b['names']);
  52715. }
  52716. }
  52717. }
  52718. } else {
  52719. $branches = Interval::anyDev();
  52720. foreach ($constraintBranches as $b) {
  52721. if ($b['exclude']) {
  52722. if ($branches['exclude']) {
  52723. $branches['names'] = array_merge($branches['names'], $b['names']);
  52724. } else {
  52725. $branches['names'] = array_diff($branches['names'], $b['names']);
  52726. }
  52727. } else {
  52728. if ($branches['exclude']) {
  52729. $branches['names'] = array_diff($b['names'], $branches['names']);
  52730. $branches['exclude'] = false;
  52731. } else {
  52732. $branches['names'] = array_intersect($branches['names'], $b['names']);
  52733. }
  52734. }
  52735. }
  52736. }
  52737. $branches['names'] = array_unique($branches['names']);
  52738. if (\count($numericGroups) === 1) {
  52739. return array('numeric' => $numericGroups[0], 'branches' => $branches);
  52740. }
  52741. $borders = array();
  52742. foreach ($numericGroups as $group) {
  52743. foreach ($group as $interval) {
  52744. $borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
  52745. $borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
  52746. }
  52747. }
  52748. $opSortOrder = self::$opSortOrder;
  52749. usort($borders, function ($a, $b) use ($opSortOrder) {
  52750. $order = version_compare($a['version'], $b['version']);
  52751. if ($order === 0) {
  52752. return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
  52753. }
  52754. return $order;
  52755. });
  52756. $activeIntervals = 0;
  52757. $intervals = array();
  52758. $index = 0;
  52759. $activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
  52760. $start = null;
  52761. foreach ($borders as $border) {
  52762. if ($border['side'] === 'start') {
  52763. $activeIntervals++;
  52764. } else {
  52765. $activeIntervals--;
  52766. }
  52767. if (!$start && $activeIntervals >= $activationThreshold) {
  52768. $start = new Constraint($border['operator'], $border['version']);
  52769. } elseif ($start && $activeIntervals < $activationThreshold) {
  52770. if (
  52771. version_compare($start->getVersion(), $border['version'], '=')
  52772. && (
  52773. ($start->getOperator() === '>' && $border['operator'] === '<=')
  52774. || ($start->getOperator() === '>=' && $border['operator'] === '<')
  52775. )
  52776. ) {
  52777. unset($intervals[$index]);
  52778. } else {
  52779. $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
  52780. $index++;
  52781. if ($stopOnFirstValidInterval) {
  52782. break;
  52783. }
  52784. }
  52785. $start = null;
  52786. }
  52787. }
  52788. return array('numeric' => $intervals, 'branches' => $branches);
  52789. }
  52790. private static function generateSingleConstraintIntervals(Constraint $constraint)
  52791. {
  52792. $op = $constraint->getOperator();
  52793. if (strpos($constraint->getVersion(), 'dev-') === 0) {
  52794. $intervals = array();
  52795. $branches = array('names' => array(), 'exclude' => false);
  52796. if ($op === '!=') {
  52797. $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
  52798. $branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
  52799. } elseif ($op === '==') {
  52800. $branches['names'][] = $constraint->getVersion();
  52801. }
  52802. return array(
  52803. 'numeric' => $intervals,
  52804. 'branches' => $branches,
  52805. );
  52806. }
  52807. if ($op[0] === '>') {
  52808. return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
  52809. }
  52810. if ($op[0] === '<') {
  52811. return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
  52812. }
  52813. if ($op === '!=') {
  52814. return array('numeric' => array(
  52815. new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
  52816. new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
  52817. ), 'branches' => Interval::anyDev());
  52818. }
  52819. return array('numeric' => array(
  52820. new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
  52821. ), 'branches' => Interval::noDev());
  52822. }
  52823. }
  52824. <?php
  52825. namespace Composer\Semver;
  52826. use Composer\Semver\Constraint\Constraint;
  52827. class Semver
  52828. {
  52829. const SORT_ASC = 1;
  52830. const SORT_DESC = -1;
  52831. private static $versionParser;
  52832. public static function satisfies($version, $constraints)
  52833. {
  52834. if (null === self::$versionParser) {
  52835. self::$versionParser = new VersionParser();
  52836. }
  52837. $versionParser = self::$versionParser;
  52838. $provider = new Constraint('==', $versionParser->normalize($version));
  52839. $parsedConstraints = $versionParser->parseConstraints($constraints);
  52840. return $parsedConstraints->matches($provider);
  52841. }
  52842. public static function satisfiedBy(array $versions, $constraints)
  52843. {
  52844. $versions = array_filter($versions, function ($version) use ($constraints) {
  52845. return Semver::satisfies($version, $constraints);
  52846. });
  52847. return array_values($versions);
  52848. }
  52849. public static function sort(array $versions)
  52850. {
  52851. return self::usort($versions, self::SORT_ASC);
  52852. }
  52853. public static function rsort(array $versions)
  52854. {
  52855. return self::usort($versions, self::SORT_DESC);
  52856. }
  52857. private static function usort(array $versions, $direction)
  52858. {
  52859. if (null === self::$versionParser) {
  52860. self::$versionParser = new VersionParser();
  52861. }
  52862. $versionParser = self::$versionParser;
  52863. $normalized = array();
  52864. foreach ($versions as $key => $version) {
  52865. $normalizedVersion = $versionParser->normalize($version);
  52866. $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
  52867. $normalized[] = array($normalizedVersion, $key);
  52868. }
  52869. usort($normalized, function (array $left, array $right) use ($direction) {
  52870. if ($left[0] === $right[0]) {
  52871. return 0;
  52872. }
  52873. if (Comparator::lessThan($left[0], $right[0])) {
  52874. return -$direction;
  52875. }
  52876. return $direction;
  52877. });
  52878. $sorted = array();
  52879. foreach ($normalized as $item) {
  52880. $sorted[] = $versions[$item[1]];
  52881. }
  52882. return $sorted;
  52883. }
  52884. }
  52885. <?php
  52886. namespace Composer\Semver;
  52887. use Composer\Semver\Constraint\ConstraintInterface;
  52888. use Composer\Semver\Constraint\MatchAllConstraint;
  52889. use Composer\Semver\Constraint\MultiConstraint;
  52890. use Composer\Semver\Constraint\Constraint;
  52891. class VersionParser
  52892. {
  52893. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  52894. private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
  52895. public static function parseStability($version)
  52896. {
  52897. $version = (string) preg_replace('{#.+$}', '', (string) $version);
  52898. if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
  52899. return 'dev';
  52900. }
  52901. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  52902. if (!empty($match[3])) {
  52903. return 'dev';
  52904. }
  52905. if (!empty($match[1])) {
  52906. if ('beta' === $match[1] || 'b' === $match[1]) {
  52907. return 'beta';
  52908. }
  52909. if ('alpha' === $match[1] || 'a' === $match[1]) {
  52910. return 'alpha';
  52911. }
  52912. if ('rc' === $match[1]) {
  52913. return 'RC';
  52914. }
  52915. }
  52916. return 'stable';
  52917. }
  52918. public static function normalizeStability($stability)
  52919. {
  52920. $stability = strtolower((string) $stability);
  52921. if (!in_array($stability, array('stable', 'rc', 'beta', 'alpha', 'dev'), true)) {
  52922. throw new \InvalidArgumentException('Invalid stability string "'.$stability.'", expected one of stable, RC, beta, alpha or dev');
  52923. }
  52924. return $stability === 'rc' ? 'RC' : $stability;
  52925. }
  52926. public function normalize($version, $fullVersion = null)
  52927. {
  52928. $version = trim((string) $version);
  52929. $origVersion = $version;
  52930. if (null === $fullVersion) {
  52931. $fullVersion = $version;
  52932. }
  52933. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  52934. $version = $match[1];
  52935. }
  52936. if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
  52937. $version = substr($version, 0, strlen($version) - strlen($match[0]));
  52938. }
  52939. if (\in_array($version, array('master', 'trunk', 'default'), true)) {
  52940. $version = 'dev-' . $version;
  52941. }
  52942. if (stripos($version, 'dev-') === 0) {
  52943. return 'dev-' . substr($version, 4);
  52944. }
  52945. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  52946. $version = $match[1];
  52947. }
  52948. if (preg_match('{^v?(\d{1,5}+)(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  52949. $version = $matches[1]
  52950. . (!empty($matches[2]) ? $matches[2] : '.0')
  52951. . (!empty($matches[3]) ? $matches[3] : '.0')
  52952. . (!empty($matches[4]) ? $matches[4] : '.0');
  52953. $index = 5;
  52954. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3}){0,2})' . self::$modifierRegex . '$}i', $version, $matches)) {
  52955. $version = (string) preg_replace('{\D}', '.', $matches[1]);
  52956. $index = 2;
  52957. }
  52958. if (isset($index)) {
  52959. if (!empty($matches[$index])) {
  52960. if ('stable' === $matches[$index]) {
  52961. return $version;
  52962. }
  52963. $version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
  52964. }
  52965. if (!empty($matches[$index + 2])) {
  52966. $version .= '-dev';
  52967. }
  52968. return $version;
  52969. }
  52970. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  52971. try {
  52972. $normalized = $this->normalizeBranch($match[1]);
  52973. if (strpos($normalized, 'dev-') === false) {
  52974. return $normalized;
  52975. }
  52976. } catch (\Exception $e) {
  52977. }
  52978. }
  52979. $extraMessage = '';
  52980. if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
  52981. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  52982. } elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
  52983. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  52984. }
  52985. throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
  52986. }
  52987. public function parseNumericAliasPrefix($branch)
  52988. {
  52989. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', (string) $branch, $matches)) {
  52990. return $matches['version'] . '.';
  52991. }
  52992. return false;
  52993. }
  52994. public function normalizeBranch($name)
  52995. {
  52996. $name = trim((string) $name);
  52997. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  52998. $version = '';
  52999. for ($i = 1; $i < 5; ++$i) {
  53000. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  53001. }
  53002. return str_replace('x', '9999999', $version) . '-dev';
  53003. }
  53004. return 'dev-' . $name;
  53005. }
  53006. public function normalizeDefaultBranch($name)
  53007. {
  53008. if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
  53009. return '9999999-dev';
  53010. }
  53011. return (string) $name;
  53012. }
  53013. public function parseConstraints($constraints)
  53014. {
  53015. $prettyConstraint = (string) $constraints;
  53016. $orConstraints = preg_split('{\s*\|\|?\s*}', trim((string) $constraints));
  53017. if (false === $orConstraints) {
  53018. throw new \RuntimeException('Failed to preg_split string: '.$constraints);
  53019. }
  53020. $orGroups = array();
  53021. foreach ($orConstraints as $orConstraint) {
  53022. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  53023. if (false === $andConstraints) {
  53024. throw new \RuntimeException('Failed to preg_split string: '.$orConstraint);
  53025. }
  53026. if (\count($andConstraints) > 1) {
  53027. $constraintObjects = array();
  53028. foreach ($andConstraints as $andConstraint) {
  53029. foreach ($this->parseConstraint($andConstraint) as $parsedAndConstraint) {
  53030. $constraintObjects[] = $parsedAndConstraint;
  53031. }
  53032. }
  53033. } else {
  53034. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  53035. }
  53036. if (1 === \count($constraintObjects)) {
  53037. $constraint = $constraintObjects[0];
  53038. } else {
  53039. $constraint = new MultiConstraint($constraintObjects);
  53040. }
  53041. $orGroups[] = $constraint;
  53042. }
  53043. $parsedConstraint = MultiConstraint::create($orGroups, false);
  53044. $parsedConstraint->setPrettyString($prettyConstraint);
  53045. return $parsedConstraint;
  53046. }
  53047. private function parseConstraint($constraint)
  53048. {
  53049. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
  53050. $constraint = $match[1];
  53051. }
  53052. if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
  53053. $constraint = '' !== $match[1] ? $match[1] : '*';
  53054. if ($match[2] !== 'stable') {
  53055. $stabilityModifier = $match[2];
  53056. }
  53057. }
  53058. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
  53059. $constraint = $match[1];
  53060. }
  53061. if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
  53062. if (!empty($match[1]) || !empty($match[2])) {
  53063. return array(new Constraint('>=', '0.0.0.0-dev'));
  53064. }
  53065. return array(new MatchAllConstraint());
  53066. }
  53067. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
  53068. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  53069. if (strpos($constraint, '~>') === 0) {
  53070. throw new \UnexpectedValueException(
  53071. 'Could not parse version constraint ' . $constraint . ': ' .
  53072. 'Invalid operator "~>", you probably meant to use the "~" operator'
  53073. );
  53074. }
  53075. if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
  53076. $position = 4;
  53077. } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  53078. $position = 3;
  53079. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  53080. $position = 2;
  53081. } else {
  53082. $position = 1;
  53083. }
  53084. if (!empty($matches[8])) {
  53085. $position++;
  53086. }
  53087. $stabilitySuffix = '';
  53088. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  53089. $stabilitySuffix .= '-dev';
  53090. }
  53091. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  53092. $lowerBound = new Constraint('>=', $lowVersion);
  53093. $highPosition = max(1, $position - 1);
  53094. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  53095. $upperBound = new Constraint('<', $highVersion);
  53096. return array(
  53097. $lowerBound,
  53098. $upperBound,
  53099. );
  53100. }
  53101. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  53102. if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
  53103. $position = 1;
  53104. } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
  53105. $position = 2;
  53106. } else {
  53107. $position = 3;
  53108. }
  53109. $stabilitySuffix = '';
  53110. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  53111. $stabilitySuffix .= '-dev';
  53112. }
  53113. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  53114. $lowerBound = new Constraint('>=', $lowVersion);
  53115. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  53116. $upperBound = new Constraint('<', $highVersion);
  53117. return array(
  53118. $lowerBound,
  53119. $upperBound,
  53120. );
  53121. }
  53122. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  53123. if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  53124. $position = 3;
  53125. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  53126. $position = 2;
  53127. } else {
  53128. $position = 1;
  53129. }
  53130. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  53131. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  53132. if ($lowVersion === '0.0.0.0-dev') {
  53133. return array(new Constraint('<', $highVersion));
  53134. }
  53135. return array(
  53136. new Constraint('>=', $lowVersion),
  53137. new Constraint('<', $highVersion),
  53138. );
  53139. }
  53140. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  53141. $lowStabilitySuffix = '';
  53142. if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
  53143. $lowStabilitySuffix = '-dev';
  53144. }
  53145. $lowVersion = $this->normalize($matches['from']);
  53146. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  53147. $empty = function ($x) {
  53148. return ($x === 0 || $x === '0') ? false : empty($x);
  53149. };
  53150. if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
  53151. $highVersion = $this->normalize($matches['to']);
  53152. $upperBound = new Constraint('<=', $highVersion);
  53153. } else {
  53154. $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
  53155. $this->normalize($matches['to']);
  53156. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
  53157. $upperBound = new Constraint('<', $highVersion);
  53158. }
  53159. return array(
  53160. $lowerBound,
  53161. $upperBound,
  53162. );
  53163. }
  53164. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  53165. try {
  53166. try {
  53167. $version = $this->normalize($matches[2]);
  53168. } catch (\UnexpectedValueException $e) {
  53169. if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
  53170. $version = $this->normalize('dev-'.substr($matches[2], 0, -4));
  53171. } else {
  53172. throw $e;
  53173. }
  53174. }
  53175. $op = $matches[1] ?: '=';
  53176. if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
  53177. $version .= '-' . $stabilityModifier;
  53178. } elseif ('<' === $op || '>=' === $op) {
  53179. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  53180. if (strpos($matches[2], 'dev-') !== 0) {
  53181. $version .= '-dev';
  53182. }
  53183. }
  53184. }
  53185. return array(new Constraint($matches[1] ?: '=', $version));
  53186. } catch (\Exception $e) {
  53187. }
  53188. }
  53189. $message = 'Could not parse version constraint ' . $constraint;
  53190. if (isset($e)) {
  53191. $message .= ': ' . $e->getMessage();
  53192. }
  53193. throw new \UnexpectedValueException($message);
  53194. }
  53195. private function manipulateVersionString(array $matches, $position, $increment = 0, $pad = '0')
  53196. {
  53197. for ($i = 4; $i > 0; --$i) {
  53198. if ($i > $position) {
  53199. $matches[$i] = $pad;
  53200. } elseif ($i === $position && $increment) {
  53201. $matches[$i] += $increment;
  53202. if ($matches[$i] < 0) {
  53203. $matches[$i] = $pad;
  53204. --$position;
  53205. if ($i === 1) {
  53206. return null;
  53207. }
  53208. }
  53209. }
  53210. }
  53211. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  53212. }
  53213. private function expandStability($stability)
  53214. {
  53215. $stability = strtolower($stability);
  53216. switch ($stability) {
  53217. case 'a':
  53218. return 'alpha';
  53219. case 'b':
  53220. return 'beta';
  53221. case 'p':
  53222. case 'pl':
  53223. return 'patch';
  53224. case 'rc':
  53225. return 'RC';
  53226. default:
  53227. return $stability;
  53228. }
  53229. }
  53230. }
  53231. Copyright (C) 2015 Composer
  53232. Permission is hereby granted, free of charge, to any person obtaining a copy of
  53233. this software and associated documentation files (the "Software"), to deal in
  53234. the Software without restriction, including without limitation the rights to
  53235. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  53236. of the Software, and to permit persons to whom the Software is furnished to do
  53237. so, subject to the following conditions:
  53238. The above copyright notice and this permission notice shall be included in all
  53239. copies or substantial portions of the Software.
  53240. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  53241. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  53242. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  53243. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  53244. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  53245. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  53246. SOFTWARE.
  53247. {
  53248. "389-exception": [
  53249. "389 Directory Server Exception"
  53250. ],
  53251. "Asterisk-exception": [
  53252. "Asterisk exception"
  53253. ],
  53254. "Autoconf-exception-2.0": [
  53255. "Autoconf exception 2.0"
  53256. ],
  53257. "Autoconf-exception-3.0": [
  53258. "Autoconf exception 3.0"
  53259. ],
  53260. "Autoconf-exception-generic": [
  53261. "Autoconf generic exception"
  53262. ],
  53263. "Autoconf-exception-generic-3.0": [
  53264. "Autoconf generic exception for GPL-3.0"
  53265. ],
  53266. "Autoconf-exception-macro": [
  53267. "Autoconf macro exception"
  53268. ],
  53269. "Bison-exception-2.2": [
  53270. "Bison exception 2.2"
  53271. ],
  53272. "Bootloader-exception": [
  53273. "Bootloader Distribution Exception"
  53274. ],
  53275. "Classpath-exception-2.0": [
  53276. "Classpath exception 2.0"
  53277. ],
  53278. "CLISP-exception-2.0": [
  53279. "CLISP exception 2.0"
  53280. ],
  53281. "cryptsetup-OpenSSL-exception": [
  53282. "cryptsetup OpenSSL exception"
  53283. ],
  53284. "DigiRule-FOSS-exception": [
  53285. "DigiRule FOSS License Exception"
  53286. ],
  53287. "eCos-exception-2.0": [
  53288. "eCos exception 2.0"
  53289. ],
  53290. "Fawkes-Runtime-exception": [
  53291. "Fawkes Runtime Exception"
  53292. ],
  53293. "FLTK-exception": [
  53294. "FLTK exception"
  53295. ],
  53296. "Font-exception-2.0": [
  53297. "Font exception 2.0"
  53298. ],
  53299. "freertos-exception-2.0": [
  53300. "FreeRTOS Exception 2.0"
  53301. ],
  53302. "GCC-exception-2.0": [
  53303. "GCC Runtime Library exception 2.0"
  53304. ],
  53305. "GCC-exception-2.0-note": [
  53306. "GCC Runtime Library exception 2.0 - note variant"
  53307. ],
  53308. "GCC-exception-3.1": [
  53309. "GCC Runtime Library exception 3.1"
  53310. ],
  53311. "GNAT-exception": [
  53312. "GNAT exception"
  53313. ],
  53314. "GNU-compiler-exception": [
  53315. "GNU Compiler Exception"
  53316. ],
  53317. "gnu-javamail-exception": [
  53318. "GNU JavaMail exception"
  53319. ],
  53320. "GPL-3.0-interface-exception": [
  53321. "GPL-3.0 Interface Exception"
  53322. ],
  53323. "GPL-3.0-linking-exception": [
  53324. "GPL-3.0 Linking Exception"
  53325. ],
  53326. "GPL-3.0-linking-source-exception": [
  53327. "GPL-3.0 Linking Exception (with Corresponding Source)"
  53328. ],
  53329. "GPL-CC-1.0": [
  53330. "GPL Cooperation Commitment 1.0"
  53331. ],
  53332. "GStreamer-exception-2005": [
  53333. "GStreamer Exception (2005)"
  53334. ],
  53335. "GStreamer-exception-2008": [
  53336. "GStreamer Exception (2008)"
  53337. ],
  53338. "i2p-gpl-java-exception": [
  53339. "i2p GPL+Java Exception"
  53340. ],
  53341. "KiCad-libraries-exception": [
  53342. "KiCad Libraries Exception"
  53343. ],
  53344. "LGPL-3.0-linking-exception": [
  53345. "LGPL-3.0 Linking Exception"
  53346. ],
  53347. "libpri-OpenH323-exception": [
  53348. "libpri OpenH323 exception"
  53349. ],
  53350. "Libtool-exception": [
  53351. "Libtool Exception"
  53352. ],
  53353. "Linux-syscall-note": [
  53354. "Linux Syscall Note"
  53355. ],
  53356. "LLGPL": [
  53357. "LLGPL Preamble"
  53358. ],
  53359. "LLVM-exception": [
  53360. "LLVM Exception"
  53361. ],
  53362. "LZMA-exception": [
  53363. "LZMA exception"
  53364. ],
  53365. "mif-exception": [
  53366. "Macros and Inline Functions Exception"
  53367. ],
  53368. "Nokia-Qt-exception-1.1": [
  53369. "Nokia Qt LGPL exception 1.1"
  53370. ],
  53371. "OCaml-LGPL-linking-exception": [
  53372. "OCaml LGPL Linking Exception"
  53373. ],
  53374. "OCCT-exception-1.0": [
  53375. "Open CASCADE Exception 1.0"
  53376. ],
  53377. "OpenJDK-assembly-exception-1.0": [
  53378. "OpenJDK Assembly exception 1.0"
  53379. ],
  53380. "openvpn-openssl-exception": [
  53381. "OpenVPN OpenSSL Exception"
  53382. ],
  53383. "PS-or-PDF-font-exception-20170817": [
  53384. "PS/PDF font exception (2017-08-17)"
  53385. ],
  53386. "QPL-1.0-INRIA-2004-exception": [
  53387. "INRIA QPL 1.0 2004 variant exception"
  53388. ],
  53389. "Qt-GPL-exception-1.0": [
  53390. "Qt GPL exception 1.0"
  53391. ],
  53392. "Qt-LGPL-exception-1.1": [
  53393. "Qt LGPL exception 1.1"
  53394. ],
  53395. "Qwt-exception-1.0": [
  53396. "Qwt exception 1.0"
  53397. ],
  53398. "SANE-exception": [
  53399. "SANE Exception"
  53400. ],
  53401. "SHL-2.0": [
  53402. "Solderpad Hardware License v2.0"
  53403. ],
  53404. "SHL-2.1": [
  53405. "Solderpad Hardware License v2.1"
  53406. ],
  53407. "stunnel-exception": [
  53408. "stunnel Exception"
  53409. ],
  53410. "SWI-exception": [
  53411. "SWI exception"
  53412. ],
  53413. "Swift-exception": [
  53414. "Swift Exception"
  53415. ],
  53416. "Texinfo-exception": [
  53417. "Texinfo exception"
  53418. ],
  53419. "u-boot-exception-2.0": [
  53420. "U-Boot exception 2.0"
  53421. ],
  53422. "UBDL-exception": [
  53423. "Unmodified Binary Distribution exception"
  53424. ],
  53425. "Universal-FOSS-exception-1.0": [
  53426. "Universal FOSS Exception, Version 1.0"
  53427. ],
  53428. "vsftpd-openssl-exception": [
  53429. "vsftpd OpenSSL exception"
  53430. ],
  53431. "WxWindows-exception-3.1": [
  53432. "WxWindows Library Exception 3.1"
  53433. ],
  53434. "x11vnc-openssl-exception": [
  53435. "x11vnc OpenSSL Exception"
  53436. ]
  53437. }{
  53438. "0BSD": [
  53439. "BSD Zero Clause License",
  53440. true,
  53441. false
  53442. ],
  53443. "AAL": [
  53444. "Attribution Assurance License",
  53445. true,
  53446. false
  53447. ],
  53448. "Abstyles": [
  53449. "Abstyles License",
  53450. false,
  53451. false
  53452. ],
  53453. "AdaCore-doc": [
  53454. "AdaCore Doc License",
  53455. false,
  53456. false
  53457. ],
  53458. "Adobe-2006": [
  53459. "Adobe Systems Incorporated Source Code License Agreement",
  53460. false,
  53461. false
  53462. ],
  53463. "Adobe-Display-PostScript": [
  53464. "Adobe Display PostScript License",
  53465. false,
  53466. false
  53467. ],
  53468. "Adobe-Glyph": [
  53469. "Adobe Glyph List License",
  53470. false,
  53471. false
  53472. ],
  53473. "Adobe-Utopia": [
  53474. "Adobe Utopia Font License",
  53475. false,
  53476. false
  53477. ],
  53478. "ADSL": [
  53479. "Amazon Digital Services License",
  53480. false,
  53481. false
  53482. ],
  53483. "AFL-1.1": [
  53484. "Academic Free License v1.1",
  53485. true,
  53486. false
  53487. ],
  53488. "AFL-1.2": [
  53489. "Academic Free License v1.2",
  53490. true,
  53491. false
  53492. ],
  53493. "AFL-2.0": [
  53494. "Academic Free License v2.0",
  53495. true,
  53496. false
  53497. ],
  53498. "AFL-2.1": [
  53499. "Academic Free License v2.1",
  53500. true,
  53501. false
  53502. ],
  53503. "AFL-3.0": [
  53504. "Academic Free License v3.0",
  53505. true,
  53506. false
  53507. ],
  53508. "Afmparse": [
  53509. "Afmparse License",
  53510. false,
  53511. false
  53512. ],
  53513. "AGPL-1.0": [
  53514. "Affero General Public License v1.0",
  53515. false,
  53516. true
  53517. ],
  53518. "AGPL-1.0-only": [
  53519. "Affero General Public License v1.0 only",
  53520. false,
  53521. false
  53522. ],
  53523. "AGPL-1.0-or-later": [
  53524. "Affero General Public License v1.0 or later",
  53525. false,
  53526. false
  53527. ],
  53528. "AGPL-3.0": [
  53529. "GNU Affero General Public License v3.0",
  53530. true,
  53531. true
  53532. ],
  53533. "AGPL-3.0-only": [
  53534. "GNU Affero General Public License v3.0 only",
  53535. true,
  53536. false
  53537. ],
  53538. "AGPL-3.0-or-later": [
  53539. "GNU Affero General Public License v3.0 or later",
  53540. true,
  53541. false
  53542. ],
  53543. "Aladdin": [
  53544. "Aladdin Free Public License",
  53545. false,
  53546. false
  53547. ],
  53548. "AMDPLPA": [
  53549. "AMD's plpa_map.c License",
  53550. false,
  53551. false
  53552. ],
  53553. "AML": [
  53554. "Apple MIT License",
  53555. false,
  53556. false
  53557. ],
  53558. "AML-glslang": [
  53559. "AML glslang variant License",
  53560. false,
  53561. false
  53562. ],
  53563. "AMPAS": [
  53564. "Academy of Motion Picture Arts and Sciences BSD",
  53565. false,
  53566. false
  53567. ],
  53568. "ANTLR-PD": [
  53569. "ANTLR Software Rights Notice",
  53570. false,
  53571. false
  53572. ],
  53573. "ANTLR-PD-fallback": [
  53574. "ANTLR Software Rights Notice with license fallback",
  53575. false,
  53576. false
  53577. ],
  53578. "Apache-1.0": [
  53579. "Apache License 1.0",
  53580. false,
  53581. false
  53582. ],
  53583. "Apache-1.1": [
  53584. "Apache License 1.1",
  53585. true,
  53586. false
  53587. ],
  53588. "Apache-2.0": [
  53589. "Apache License 2.0",
  53590. true,
  53591. false
  53592. ],
  53593. "APAFML": [
  53594. "Adobe Postscript AFM License",
  53595. false,
  53596. false
  53597. ],
  53598. "APL-1.0": [
  53599. "Adaptive Public License 1.0",
  53600. true,
  53601. false
  53602. ],
  53603. "App-s2p": [
  53604. "App::s2p License",
  53605. false,
  53606. false
  53607. ],
  53608. "APSL-1.0": [
  53609. "Apple Public Source License 1.0",
  53610. true,
  53611. false
  53612. ],
  53613. "APSL-1.1": [
  53614. "Apple Public Source License 1.1",
  53615. true,
  53616. false
  53617. ],
  53618. "APSL-1.2": [
  53619. "Apple Public Source License 1.2",
  53620. true,
  53621. false
  53622. ],
  53623. "APSL-2.0": [
  53624. "Apple Public Source License 2.0",
  53625. true,
  53626. false
  53627. ],
  53628. "Arphic-1999": [
  53629. "Arphic Public License",
  53630. false,
  53631. false
  53632. ],
  53633. "Artistic-1.0": [
  53634. "Artistic License 1.0",
  53635. true,
  53636. false
  53637. ],
  53638. "Artistic-1.0-cl8": [
  53639. "Artistic License 1.0 w/clause 8",
  53640. true,
  53641. false
  53642. ],
  53643. "Artistic-1.0-Perl": [
  53644. "Artistic License 1.0 (Perl)",
  53645. true,
  53646. false
  53647. ],
  53648. "Artistic-2.0": [
  53649. "Artistic License 2.0",
  53650. true,
  53651. false
  53652. ],
  53653. "ASWF-Digital-Assets-1.0": [
  53654. "ASWF Digital Assets License version 1.0",
  53655. false,
  53656. false
  53657. ],
  53658. "ASWF-Digital-Assets-1.1": [
  53659. "ASWF Digital Assets License 1.1",
  53660. false,
  53661. false
  53662. ],
  53663. "Baekmuk": [
  53664. "Baekmuk License",
  53665. false,
  53666. false
  53667. ],
  53668. "Bahyph": [
  53669. "Bahyph License",
  53670. false,
  53671. false
  53672. ],
  53673. "Barr": [
  53674. "Barr License",
  53675. false,
  53676. false
  53677. ],
  53678. "Beerware": [
  53679. "Beerware License",
  53680. false,
  53681. false
  53682. ],
  53683. "Bitstream-Charter": [
  53684. "Bitstream Charter Font License",
  53685. false,
  53686. false
  53687. ],
  53688. "Bitstream-Vera": [
  53689. "Bitstream Vera Font License",
  53690. false,
  53691. false
  53692. ],
  53693. "BitTorrent-1.0": [
  53694. "BitTorrent Open Source License v1.0",
  53695. false,
  53696. false
  53697. ],
  53698. "BitTorrent-1.1": [
  53699. "BitTorrent Open Source License v1.1",
  53700. false,
  53701. false
  53702. ],
  53703. "blessing": [
  53704. "SQLite Blessing",
  53705. false,
  53706. false
  53707. ],
  53708. "BlueOak-1.0.0": [
  53709. "Blue Oak Model License 1.0.0",
  53710. false,
  53711. false
  53712. ],
  53713. "Boehm-GC": [
  53714. "Boehm-Demers-Weiser GC License",
  53715. false,
  53716. false
  53717. ],
  53718. "Borceux": [
  53719. "Borceux license",
  53720. false,
  53721. false
  53722. ],
  53723. "Brian-Gladman-3-Clause": [
  53724. "Brian Gladman 3-Clause License",
  53725. false,
  53726. false
  53727. ],
  53728. "BSD-1-Clause": [
  53729. "BSD 1-Clause License",
  53730. true,
  53731. false
  53732. ],
  53733. "BSD-2-Clause": [
  53734. "BSD 2-Clause \"Simplified\" License",
  53735. true,
  53736. false
  53737. ],
  53738. "BSD-2-Clause-FreeBSD": [
  53739. "BSD 2-Clause FreeBSD License",
  53740. false,
  53741. true
  53742. ],
  53743. "BSD-2-Clause-NetBSD": [
  53744. "BSD 2-Clause NetBSD License",
  53745. false,
  53746. true
  53747. ],
  53748. "BSD-2-Clause-Patent": [
  53749. "BSD-2-Clause Plus Patent License",
  53750. true,
  53751. false
  53752. ],
  53753. "BSD-2-Clause-Views": [
  53754. "BSD 2-Clause with views sentence",
  53755. false,
  53756. false
  53757. ],
  53758. "BSD-3-Clause": [
  53759. "BSD 3-Clause \"New\" or \"Revised\" License",
  53760. true,
  53761. false
  53762. ],
  53763. "BSD-3-Clause-Attribution": [
  53764. "BSD with attribution",
  53765. false,
  53766. false
  53767. ],
  53768. "BSD-3-Clause-Clear": [
  53769. "BSD 3-Clause Clear License",
  53770. false,
  53771. false
  53772. ],
  53773. "BSD-3-Clause-flex": [
  53774. "BSD 3-Clause Flex variant",
  53775. false,
  53776. false
  53777. ],
  53778. "BSD-3-Clause-HP": [
  53779. "Hewlett-Packard BSD variant license",
  53780. false,
  53781. false
  53782. ],
  53783. "BSD-3-Clause-LBNL": [
  53784. "Lawrence Berkeley National Labs BSD variant license",
  53785. true,
  53786. false
  53787. ],
  53788. "BSD-3-Clause-Modification": [
  53789. "BSD 3-Clause Modification",
  53790. false,
  53791. false
  53792. ],
  53793. "BSD-3-Clause-No-Military-License": [
  53794. "BSD 3-Clause No Military License",
  53795. false,
  53796. false
  53797. ],
  53798. "BSD-3-Clause-No-Nuclear-License": [
  53799. "BSD 3-Clause No Nuclear License",
  53800. false,
  53801. false
  53802. ],
  53803. "BSD-3-Clause-No-Nuclear-License-2014": [
  53804. "BSD 3-Clause No Nuclear License 2014",
  53805. false,
  53806. false
  53807. ],
  53808. "BSD-3-Clause-No-Nuclear-Warranty": [
  53809. "BSD 3-Clause No Nuclear Warranty",
  53810. false,
  53811. false
  53812. ],
  53813. "BSD-3-Clause-Open-MPI": [
  53814. "BSD 3-Clause Open MPI variant",
  53815. false,
  53816. false
  53817. ],
  53818. "BSD-3-Clause-Sun": [
  53819. "BSD 3-Clause Sun Microsystems",
  53820. false,
  53821. false
  53822. ],
  53823. "BSD-4-Clause": [
  53824. "BSD 4-Clause \"Original\" or \"Old\" License",
  53825. false,
  53826. false
  53827. ],
  53828. "BSD-4-Clause-Shortened": [
  53829. "BSD 4 Clause Shortened",
  53830. false,
  53831. false
  53832. ],
  53833. "BSD-4-Clause-UC": [
  53834. "BSD-4-Clause (University of California-Specific)",
  53835. false,
  53836. false
  53837. ],
  53838. "BSD-4.3RENO": [
  53839. "BSD 4.3 RENO License",
  53840. false,
  53841. false
  53842. ],
  53843. "BSD-4.3TAHOE": [
  53844. "BSD 4.3 TAHOE License",
  53845. false,
  53846. false
  53847. ],
  53848. "BSD-Advertising-Acknowledgement": [
  53849. "BSD Advertising Acknowledgement License",
  53850. false,
  53851. false
  53852. ],
  53853. "BSD-Attribution-HPND-disclaimer": [
  53854. "BSD with Attribution and HPND disclaimer",
  53855. false,
  53856. false
  53857. ],
  53858. "BSD-Inferno-Nettverk": [
  53859. "BSD-Inferno-Nettverk",
  53860. false,
  53861. false
  53862. ],
  53863. "BSD-Protection": [
  53864. "BSD Protection License",
  53865. false,
  53866. false
  53867. ],
  53868. "BSD-Source-Code": [
  53869. "BSD Source Code Attribution",
  53870. false,
  53871. false
  53872. ],
  53873. "BSD-Systemics": [
  53874. "Systemics BSD variant license",
  53875. false,
  53876. false
  53877. ],
  53878. "BSL-1.0": [
  53879. "Boost Software License 1.0",
  53880. true,
  53881. false
  53882. ],
  53883. "BUSL-1.1": [
  53884. "Business Source License 1.1",
  53885. false,
  53886. false
  53887. ],
  53888. "bzip2-1.0.5": [
  53889. "bzip2 and libbzip2 License v1.0.5",
  53890. false,
  53891. true
  53892. ],
  53893. "bzip2-1.0.6": [
  53894. "bzip2 and libbzip2 License v1.0.6",
  53895. false,
  53896. false
  53897. ],
  53898. "C-UDA-1.0": [
  53899. "Computational Use of Data Agreement v1.0",
  53900. false,
  53901. false
  53902. ],
  53903. "CAL-1.0": [
  53904. "Cryptographic Autonomy License 1.0",
  53905. true,
  53906. false
  53907. ],
  53908. "CAL-1.0-Combined-Work-Exception": [
  53909. "Cryptographic Autonomy License 1.0 (Combined Work Exception)",
  53910. true,
  53911. false
  53912. ],
  53913. "Caldera": [
  53914. "Caldera License",
  53915. false,
  53916. false
  53917. ],
  53918. "CATOSL-1.1": [
  53919. "Computer Associates Trusted Open Source License 1.1",
  53920. true,
  53921. false
  53922. ],
  53923. "CC-BY-1.0": [
  53924. "Creative Commons Attribution 1.0 Generic",
  53925. false,
  53926. false
  53927. ],
  53928. "CC-BY-2.0": [
  53929. "Creative Commons Attribution 2.0 Generic",
  53930. false,
  53931. false
  53932. ],
  53933. "CC-BY-2.5": [
  53934. "Creative Commons Attribution 2.5 Generic",
  53935. false,
  53936. false
  53937. ],
  53938. "CC-BY-2.5-AU": [
  53939. "Creative Commons Attribution 2.5 Australia",
  53940. false,
  53941. false
  53942. ],
  53943. "CC-BY-3.0": [
  53944. "Creative Commons Attribution 3.0 Unported",
  53945. false,
  53946. false
  53947. ],
  53948. "CC-BY-3.0-AT": [
  53949. "Creative Commons Attribution 3.0 Austria",
  53950. false,
  53951. false
  53952. ],
  53953. "CC-BY-3.0-DE": [
  53954. "Creative Commons Attribution 3.0 Germany",
  53955. false,
  53956. false
  53957. ],
  53958. "CC-BY-3.0-IGO": [
  53959. "Creative Commons Attribution 3.0 IGO",
  53960. false,
  53961. false
  53962. ],
  53963. "CC-BY-3.0-NL": [
  53964. "Creative Commons Attribution 3.0 Netherlands",
  53965. false,
  53966. false
  53967. ],
  53968. "CC-BY-3.0-US": [
  53969. "Creative Commons Attribution 3.0 United States",
  53970. false,
  53971. false
  53972. ],
  53973. "CC-BY-4.0": [
  53974. "Creative Commons Attribution 4.0 International",
  53975. false,
  53976. false
  53977. ],
  53978. "CC-BY-NC-1.0": [
  53979. "Creative Commons Attribution Non Commercial 1.0 Generic",
  53980. false,
  53981. false
  53982. ],
  53983. "CC-BY-NC-2.0": [
  53984. "Creative Commons Attribution Non Commercial 2.0 Generic",
  53985. false,
  53986. false
  53987. ],
  53988. "CC-BY-NC-2.5": [
  53989. "Creative Commons Attribution Non Commercial 2.5 Generic",
  53990. false,
  53991. false
  53992. ],
  53993. "CC-BY-NC-3.0": [
  53994. "Creative Commons Attribution Non Commercial 3.0 Unported",
  53995. false,
  53996. false
  53997. ],
  53998. "CC-BY-NC-3.0-DE": [
  53999. "Creative Commons Attribution Non Commercial 3.0 Germany",
  54000. false,
  54001. false
  54002. ],
  54003. "CC-BY-NC-4.0": [
  54004. "Creative Commons Attribution Non Commercial 4.0 International",
  54005. false,
  54006. false
  54007. ],
  54008. "CC-BY-NC-ND-1.0": [
  54009. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  54010. false,
  54011. false
  54012. ],
  54013. "CC-BY-NC-ND-2.0": [
  54014. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  54015. false,
  54016. false
  54017. ],
  54018. "CC-BY-NC-ND-2.5": [
  54019. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  54020. false,
  54021. false
  54022. ],
  54023. "CC-BY-NC-ND-3.0": [
  54024. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  54025. false,
  54026. false
  54027. ],
  54028. "CC-BY-NC-ND-3.0-DE": [
  54029. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany",
  54030. false,
  54031. false
  54032. ],
  54033. "CC-BY-NC-ND-3.0-IGO": [
  54034. "Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO",
  54035. false,
  54036. false
  54037. ],
  54038. "CC-BY-NC-ND-4.0": [
  54039. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  54040. false,
  54041. false
  54042. ],
  54043. "CC-BY-NC-SA-1.0": [
  54044. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  54045. false,
  54046. false
  54047. ],
  54048. "CC-BY-NC-SA-2.0": [
  54049. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  54050. false,
  54051. false
  54052. ],
  54053. "CC-BY-NC-SA-2.0-DE": [
  54054. "Creative Commons Attribution Non Commercial Share Alike 2.0 Germany",
  54055. false,
  54056. false
  54057. ],
  54058. "CC-BY-NC-SA-2.0-FR": [
  54059. "Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France",
  54060. false,
  54061. false
  54062. ],
  54063. "CC-BY-NC-SA-2.0-UK": [
  54064. "Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales",
  54065. false,
  54066. false
  54067. ],
  54068. "CC-BY-NC-SA-2.5": [
  54069. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  54070. false,
  54071. false
  54072. ],
  54073. "CC-BY-NC-SA-3.0": [
  54074. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  54075. false,
  54076. false
  54077. ],
  54078. "CC-BY-NC-SA-3.0-DE": [
  54079. "Creative Commons Attribution Non Commercial Share Alike 3.0 Germany",
  54080. false,
  54081. false
  54082. ],
  54083. "CC-BY-NC-SA-3.0-IGO": [
  54084. "Creative Commons Attribution Non Commercial Share Alike 3.0 IGO",
  54085. false,
  54086. false
  54087. ],
  54088. "CC-BY-NC-SA-4.0": [
  54089. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  54090. false,
  54091. false
  54092. ],
  54093. "CC-BY-ND-1.0": [
  54094. "Creative Commons Attribution No Derivatives 1.0 Generic",
  54095. false,
  54096. false
  54097. ],
  54098. "CC-BY-ND-2.0": [
  54099. "Creative Commons Attribution No Derivatives 2.0 Generic",
  54100. false,
  54101. false
  54102. ],
  54103. "CC-BY-ND-2.5": [
  54104. "Creative Commons Attribution No Derivatives 2.5 Generic",
  54105. false,
  54106. false
  54107. ],
  54108. "CC-BY-ND-3.0": [
  54109. "Creative Commons Attribution No Derivatives 3.0 Unported",
  54110. false,
  54111. false
  54112. ],
  54113. "CC-BY-ND-3.0-DE": [
  54114. "Creative Commons Attribution No Derivatives 3.0 Germany",
  54115. false,
  54116. false
  54117. ],
  54118. "CC-BY-ND-4.0": [
  54119. "Creative Commons Attribution No Derivatives 4.0 International",
  54120. false,
  54121. false
  54122. ],
  54123. "CC-BY-SA-1.0": [
  54124. "Creative Commons Attribution Share Alike 1.0 Generic",
  54125. false,
  54126. false
  54127. ],
  54128. "CC-BY-SA-2.0": [
  54129. "Creative Commons Attribution Share Alike 2.0 Generic",
  54130. false,
  54131. false
  54132. ],
  54133. "CC-BY-SA-2.0-UK": [
  54134. "Creative Commons Attribution Share Alike 2.0 England and Wales",
  54135. false,
  54136. false
  54137. ],
  54138. "CC-BY-SA-2.1-JP": [
  54139. "Creative Commons Attribution Share Alike 2.1 Japan",
  54140. false,
  54141. false
  54142. ],
  54143. "CC-BY-SA-2.5": [
  54144. "Creative Commons Attribution Share Alike 2.5 Generic",
  54145. false,
  54146. false
  54147. ],
  54148. "CC-BY-SA-3.0": [
  54149. "Creative Commons Attribution Share Alike 3.0 Unported",
  54150. false,
  54151. false
  54152. ],
  54153. "CC-BY-SA-3.0-AT": [
  54154. "Creative Commons Attribution Share Alike 3.0 Austria",
  54155. false,
  54156. false
  54157. ],
  54158. "CC-BY-SA-3.0-DE": [
  54159. "Creative Commons Attribution Share Alike 3.0 Germany",
  54160. false,
  54161. false
  54162. ],
  54163. "CC-BY-SA-3.0-IGO": [
  54164. "Creative Commons Attribution-ShareAlike 3.0 IGO",
  54165. false,
  54166. false
  54167. ],
  54168. "CC-BY-SA-4.0": [
  54169. "Creative Commons Attribution Share Alike 4.0 International",
  54170. false,
  54171. false
  54172. ],
  54173. "CC-PDDC": [
  54174. "Creative Commons Public Domain Dedication and Certification",
  54175. false,
  54176. false
  54177. ],
  54178. "CC0-1.0": [
  54179. "Creative Commons Zero v1.0 Universal",
  54180. false,
  54181. false
  54182. ],
  54183. "CDDL-1.0": [
  54184. "Common Development and Distribution License 1.0",
  54185. true,
  54186. false
  54187. ],
  54188. "CDDL-1.1": [
  54189. "Common Development and Distribution License 1.1",
  54190. false,
  54191. false
  54192. ],
  54193. "CDL-1.0": [
  54194. "Common Documentation License 1.0",
  54195. false,
  54196. false
  54197. ],
  54198. "CDLA-Permissive-1.0": [
  54199. "Community Data License Agreement Permissive 1.0",
  54200. false,
  54201. false
  54202. ],
  54203. "CDLA-Permissive-2.0": [
  54204. "Community Data License Agreement Permissive 2.0",
  54205. false,
  54206. false
  54207. ],
  54208. "CDLA-Sharing-1.0": [
  54209. "Community Data License Agreement Sharing 1.0",
  54210. false,
  54211. false
  54212. ],
  54213. "CECILL-1.0": [
  54214. "CeCILL Free Software License Agreement v1.0",
  54215. false,
  54216. false
  54217. ],
  54218. "CECILL-1.1": [
  54219. "CeCILL Free Software License Agreement v1.1",
  54220. false,
  54221. false
  54222. ],
  54223. "CECILL-2.0": [
  54224. "CeCILL Free Software License Agreement v2.0",
  54225. false,
  54226. false
  54227. ],
  54228. "CECILL-2.1": [
  54229. "CeCILL Free Software License Agreement v2.1",
  54230. true,
  54231. false
  54232. ],
  54233. "CECILL-B": [
  54234. "CeCILL-B Free Software License Agreement",
  54235. false,
  54236. false
  54237. ],
  54238. "CECILL-C": [
  54239. "CeCILL-C Free Software License Agreement",
  54240. false,
  54241. false
  54242. ],
  54243. "CERN-OHL-1.1": [
  54244. "CERN Open Hardware Licence v1.1",
  54245. false,
  54246. false
  54247. ],
  54248. "CERN-OHL-1.2": [
  54249. "CERN Open Hardware Licence v1.2",
  54250. false,
  54251. false
  54252. ],
  54253. "CERN-OHL-P-2.0": [
  54254. "CERN Open Hardware Licence Version 2 - Permissive",
  54255. true,
  54256. false
  54257. ],
  54258. "CERN-OHL-S-2.0": [
  54259. "CERN Open Hardware Licence Version 2 - Strongly Reciprocal",
  54260. true,
  54261. false
  54262. ],
  54263. "CERN-OHL-W-2.0": [
  54264. "CERN Open Hardware Licence Version 2 - Weakly Reciprocal",
  54265. true,
  54266. false
  54267. ],
  54268. "CFITSIO": [
  54269. "CFITSIO License",
  54270. false,
  54271. false
  54272. ],
  54273. "check-cvs": [
  54274. "check-cvs License",
  54275. false,
  54276. false
  54277. ],
  54278. "checkmk": [
  54279. "Checkmk License",
  54280. false,
  54281. false
  54282. ],
  54283. "ClArtistic": [
  54284. "Clarified Artistic License",
  54285. false,
  54286. false
  54287. ],
  54288. "Clips": [
  54289. "Clips License",
  54290. false,
  54291. false
  54292. ],
  54293. "CMU-Mach": [
  54294. "CMU Mach License",
  54295. false,
  54296. false
  54297. ],
  54298. "CNRI-Jython": [
  54299. "CNRI Jython License",
  54300. false,
  54301. false
  54302. ],
  54303. "CNRI-Python": [
  54304. "CNRI Python License",
  54305. true,
  54306. false
  54307. ],
  54308. "CNRI-Python-GPL-Compatible": [
  54309. "CNRI Python Open Source GPL Compatible License Agreement",
  54310. false,
  54311. false
  54312. ],
  54313. "COIL-1.0": [
  54314. "Copyfree Open Innovation License",
  54315. false,
  54316. false
  54317. ],
  54318. "Community-Spec-1.0": [
  54319. "Community Specification License 1.0",
  54320. false,
  54321. false
  54322. ],
  54323. "Condor-1.1": [
  54324. "Condor Public License v1.1",
  54325. false,
  54326. false
  54327. ],
  54328. "copyleft-next-0.3.0": [
  54329. "copyleft-next 0.3.0",
  54330. false,
  54331. false
  54332. ],
  54333. "copyleft-next-0.3.1": [
  54334. "copyleft-next 0.3.1",
  54335. false,
  54336. false
  54337. ],
  54338. "Cornell-Lossless-JPEG": [
  54339. "Cornell Lossless JPEG License",
  54340. false,
  54341. false
  54342. ],
  54343. "CPAL-1.0": [
  54344. "Common Public Attribution License 1.0",
  54345. true,
  54346. false
  54347. ],
  54348. "CPL-1.0": [
  54349. "Common Public License 1.0",
  54350. true,
  54351. false
  54352. ],
  54353. "CPOL-1.02": [
  54354. "Code Project Open License 1.02",
  54355. false,
  54356. false
  54357. ],
  54358. "Cronyx": [
  54359. "Cronyx License",
  54360. false,
  54361. false
  54362. ],
  54363. "Crossword": [
  54364. "Crossword License",
  54365. false,
  54366. false
  54367. ],
  54368. "CrystalStacker": [
  54369. "CrystalStacker License",
  54370. false,
  54371. false
  54372. ],
  54373. "CUA-OPL-1.0": [
  54374. "CUA Office Public License v1.0",
  54375. true,
  54376. false
  54377. ],
  54378. "Cube": [
  54379. "Cube License",
  54380. false,
  54381. false
  54382. ],
  54383. "curl": [
  54384. "curl License",
  54385. false,
  54386. false
  54387. ],
  54388. "D-FSL-1.0": [
  54389. "Deutsche Freie Software Lizenz",
  54390. false,
  54391. false
  54392. ],
  54393. "DEC-3-Clause": [
  54394. "DEC 3-Clause License",
  54395. false,
  54396. false
  54397. ],
  54398. "diffmark": [
  54399. "diffmark license",
  54400. false,
  54401. false
  54402. ],
  54403. "DL-DE-BY-2.0": [
  54404. "Data licence Germany \u2013 attribution \u2013 version 2.0",
  54405. false,
  54406. false
  54407. ],
  54408. "DL-DE-ZERO-2.0": [
  54409. "Data licence Germany \u2013 zero \u2013 version 2.0",
  54410. false,
  54411. false
  54412. ],
  54413. "DOC": [
  54414. "DOC License",
  54415. false,
  54416. false
  54417. ],
  54418. "Dotseqn": [
  54419. "Dotseqn License",
  54420. false,
  54421. false
  54422. ],
  54423. "DRL-1.0": [
  54424. "Detection Rule License 1.0",
  54425. false,
  54426. false
  54427. ],
  54428. "DRL-1.1": [
  54429. "Detection Rule License 1.1",
  54430. false,
  54431. false
  54432. ],
  54433. "DSDP": [
  54434. "DSDP License",
  54435. false,
  54436. false
  54437. ],
  54438. "dtoa": [
  54439. "David M. Gay dtoa License",
  54440. false,
  54441. false
  54442. ],
  54443. "dvipdfm": [
  54444. "dvipdfm License",
  54445. false,
  54446. false
  54447. ],
  54448. "ECL-1.0": [
  54449. "Educational Community License v1.0",
  54450. true,
  54451. false
  54452. ],
  54453. "ECL-2.0": [
  54454. "Educational Community License v2.0",
  54455. true,
  54456. false
  54457. ],
  54458. "eCos-2.0": [
  54459. "eCos license version 2.0",
  54460. false,
  54461. true
  54462. ],
  54463. "EFL-1.0": [
  54464. "Eiffel Forum License v1.0",
  54465. true,
  54466. false
  54467. ],
  54468. "EFL-2.0": [
  54469. "Eiffel Forum License v2.0",
  54470. true,
  54471. false
  54472. ],
  54473. "eGenix": [
  54474. "eGenix.com Public License 1.1.0",
  54475. false,
  54476. false
  54477. ],
  54478. "Elastic-2.0": [
  54479. "Elastic License 2.0",
  54480. false,
  54481. false
  54482. ],
  54483. "Entessa": [
  54484. "Entessa Public License v1.0",
  54485. true,
  54486. false
  54487. ],
  54488. "EPICS": [
  54489. "EPICS Open License",
  54490. false,
  54491. false
  54492. ],
  54493. "EPL-1.0": [
  54494. "Eclipse Public License 1.0",
  54495. true,
  54496. false
  54497. ],
  54498. "EPL-2.0": [
  54499. "Eclipse Public License 2.0",
  54500. true,
  54501. false
  54502. ],
  54503. "ErlPL-1.1": [
  54504. "Erlang Public License v1.1",
  54505. false,
  54506. false
  54507. ],
  54508. "etalab-2.0": [
  54509. "Etalab Open License 2.0",
  54510. false,
  54511. false
  54512. ],
  54513. "EUDatagrid": [
  54514. "EU DataGrid Software License",
  54515. true,
  54516. false
  54517. ],
  54518. "EUPL-1.0": [
  54519. "European Union Public License 1.0",
  54520. false,
  54521. false
  54522. ],
  54523. "EUPL-1.1": [
  54524. "European Union Public License 1.1",
  54525. true,
  54526. false
  54527. ],
  54528. "EUPL-1.2": [
  54529. "European Union Public License 1.2",
  54530. true,
  54531. false
  54532. ],
  54533. "Eurosym": [
  54534. "Eurosym License",
  54535. false,
  54536. false
  54537. ],
  54538. "Fair": [
  54539. "Fair License",
  54540. true,
  54541. false
  54542. ],
  54543. "FBM": [
  54544. "Fuzzy Bitmap License",
  54545. false,
  54546. false
  54547. ],
  54548. "FDK-AAC": [
  54549. "Fraunhofer FDK AAC Codec Library",
  54550. false,
  54551. false
  54552. ],
  54553. "Ferguson-Twofish": [
  54554. "Ferguson Twofish License",
  54555. false,
  54556. false
  54557. ],
  54558. "Frameworx-1.0": [
  54559. "Frameworx Open License 1.0",
  54560. true,
  54561. false
  54562. ],
  54563. "FreeBSD-DOC": [
  54564. "FreeBSD Documentation License",
  54565. false,
  54566. false
  54567. ],
  54568. "FreeImage": [
  54569. "FreeImage Public License v1.0",
  54570. false,
  54571. false
  54572. ],
  54573. "FSFAP": [
  54574. "FSF All Permissive License",
  54575. false,
  54576. false
  54577. ],
  54578. "FSFUL": [
  54579. "FSF Unlimited License",
  54580. false,
  54581. false
  54582. ],
  54583. "FSFULLR": [
  54584. "FSF Unlimited License (with License Retention)",
  54585. false,
  54586. false
  54587. ],
  54588. "FSFULLRWD": [
  54589. "FSF Unlimited License (With License Retention and Warranty Disclaimer)",
  54590. false,
  54591. false
  54592. ],
  54593. "FTL": [
  54594. "Freetype Project License",
  54595. false,
  54596. false
  54597. ],
  54598. "Furuseth": [
  54599. "Furuseth License",
  54600. false,
  54601. false
  54602. ],
  54603. "fwlw": [
  54604. "fwlw License",
  54605. false,
  54606. false
  54607. ],
  54608. "GCR-docs": [
  54609. "Gnome GCR Documentation License",
  54610. false,
  54611. false
  54612. ],
  54613. "GD": [
  54614. "GD License",
  54615. false,
  54616. false
  54617. ],
  54618. "GFDL-1.1": [
  54619. "GNU Free Documentation License v1.1",
  54620. false,
  54621. true
  54622. ],
  54623. "GFDL-1.1-invariants-only": [
  54624. "GNU Free Documentation License v1.1 only - invariants",
  54625. false,
  54626. false
  54627. ],
  54628. "GFDL-1.1-invariants-or-later": [
  54629. "GNU Free Documentation License v1.1 or later - invariants",
  54630. false,
  54631. false
  54632. ],
  54633. "GFDL-1.1-no-invariants-only": [
  54634. "GNU Free Documentation License v1.1 only - no invariants",
  54635. false,
  54636. false
  54637. ],
  54638. "GFDL-1.1-no-invariants-or-later": [
  54639. "GNU Free Documentation License v1.1 or later - no invariants",
  54640. false,
  54641. false
  54642. ],
  54643. "GFDL-1.1-only": [
  54644. "GNU Free Documentation License v1.1 only",
  54645. false,
  54646. false
  54647. ],
  54648. "GFDL-1.1-or-later": [
  54649. "GNU Free Documentation License v1.1 or later",
  54650. false,
  54651. false
  54652. ],
  54653. "GFDL-1.2": [
  54654. "GNU Free Documentation License v1.2",
  54655. false,
  54656. true
  54657. ],
  54658. "GFDL-1.2-invariants-only": [
  54659. "GNU Free Documentation License v1.2 only - invariants",
  54660. false,
  54661. false
  54662. ],
  54663. "GFDL-1.2-invariants-or-later": [
  54664. "GNU Free Documentation License v1.2 or later - invariants",
  54665. false,
  54666. false
  54667. ],
  54668. "GFDL-1.2-no-invariants-only": [
  54669. "GNU Free Documentation License v1.2 only - no invariants",
  54670. false,
  54671. false
  54672. ],
  54673. "GFDL-1.2-no-invariants-or-later": [
  54674. "GNU Free Documentation License v1.2 or later - no invariants",
  54675. false,
  54676. false
  54677. ],
  54678. "GFDL-1.2-only": [
  54679. "GNU Free Documentation License v1.2 only",
  54680. false,
  54681. false
  54682. ],
  54683. "GFDL-1.2-or-later": [
  54684. "GNU Free Documentation License v1.2 or later",
  54685. false,
  54686. false
  54687. ],
  54688. "GFDL-1.3": [
  54689. "GNU Free Documentation License v1.3",
  54690. false,
  54691. true
  54692. ],
  54693. "GFDL-1.3-invariants-only": [
  54694. "GNU Free Documentation License v1.3 only - invariants",
  54695. false,
  54696. false
  54697. ],
  54698. "GFDL-1.3-invariants-or-later": [
  54699. "GNU Free Documentation License v1.3 or later - invariants",
  54700. false,
  54701. false
  54702. ],
  54703. "GFDL-1.3-no-invariants-only": [
  54704. "GNU Free Documentation License v1.3 only - no invariants",
  54705. false,
  54706. false
  54707. ],
  54708. "GFDL-1.3-no-invariants-or-later": [
  54709. "GNU Free Documentation License v1.3 or later - no invariants",
  54710. false,
  54711. false
  54712. ],
  54713. "GFDL-1.3-only": [
  54714. "GNU Free Documentation License v1.3 only",
  54715. false,
  54716. false
  54717. ],
  54718. "GFDL-1.3-or-later": [
  54719. "GNU Free Documentation License v1.3 or later",
  54720. false,
  54721. false
  54722. ],
  54723. "Giftware": [
  54724. "Giftware License",
  54725. false,
  54726. false
  54727. ],
  54728. "GL2PS": [
  54729. "GL2PS License",
  54730. false,
  54731. false
  54732. ],
  54733. "Glide": [
  54734. "3dfx Glide License",
  54735. false,
  54736. false
  54737. ],
  54738. "Glulxe": [
  54739. "Glulxe License",
  54740. false,
  54741. false
  54742. ],
  54743. "GLWTPL": [
  54744. "Good Luck With That Public License",
  54745. false,
  54746. false
  54747. ],
  54748. "gnuplot": [
  54749. "gnuplot License",
  54750. false,
  54751. false
  54752. ],
  54753. "GPL-1.0": [
  54754. "GNU General Public License v1.0 only",
  54755. false,
  54756. true
  54757. ],
  54758. "GPL-1.0+": [
  54759. "GNU General Public License v1.0 or later",
  54760. false,
  54761. true
  54762. ],
  54763. "GPL-1.0-only": [
  54764. "GNU General Public License v1.0 only",
  54765. false,
  54766. false
  54767. ],
  54768. "GPL-1.0-or-later": [
  54769. "GNU General Public License v1.0 or later",
  54770. false,
  54771. false
  54772. ],
  54773. "GPL-2.0": [
  54774. "GNU General Public License v2.0 only",
  54775. true,
  54776. true
  54777. ],
  54778. "GPL-2.0+": [
  54779. "GNU General Public License v2.0 or later",
  54780. true,
  54781. true
  54782. ],
  54783. "GPL-2.0-only": [
  54784. "GNU General Public License v2.0 only",
  54785. true,
  54786. false
  54787. ],
  54788. "GPL-2.0-or-later": [
  54789. "GNU General Public License v2.0 or later",
  54790. true,
  54791. false
  54792. ],
  54793. "GPL-2.0-with-autoconf-exception": [
  54794. "GNU General Public License v2.0 w/Autoconf exception",
  54795. false,
  54796. true
  54797. ],
  54798. "GPL-2.0-with-bison-exception": [
  54799. "GNU General Public License v2.0 w/Bison exception",
  54800. false,
  54801. true
  54802. ],
  54803. "GPL-2.0-with-classpath-exception": [
  54804. "GNU General Public License v2.0 w/Classpath exception",
  54805. false,
  54806. true
  54807. ],
  54808. "GPL-2.0-with-font-exception": [
  54809. "GNU General Public License v2.0 w/Font exception",
  54810. false,
  54811. true
  54812. ],
  54813. "GPL-2.0-with-GCC-exception": [
  54814. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  54815. false,
  54816. true
  54817. ],
  54818. "GPL-3.0": [
  54819. "GNU General Public License v3.0 only",
  54820. true,
  54821. true
  54822. ],
  54823. "GPL-3.0+": [
  54824. "GNU General Public License v3.0 or later",
  54825. true,
  54826. true
  54827. ],
  54828. "GPL-3.0-only": [
  54829. "GNU General Public License v3.0 only",
  54830. true,
  54831. false
  54832. ],
  54833. "GPL-3.0-or-later": [
  54834. "GNU General Public License v3.0 or later",
  54835. true,
  54836. false
  54837. ],
  54838. "GPL-3.0-with-autoconf-exception": [
  54839. "GNU General Public License v3.0 w/Autoconf exception",
  54840. false,
  54841. true
  54842. ],
  54843. "GPL-3.0-with-GCC-exception": [
  54844. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  54845. true,
  54846. true
  54847. ],
  54848. "Graphics-Gems": [
  54849. "Graphics Gems License",
  54850. false,
  54851. false
  54852. ],
  54853. "gSOAP-1.3b": [
  54854. "gSOAP Public License v1.3b",
  54855. false,
  54856. false
  54857. ],
  54858. "HaskellReport": [
  54859. "Haskell Language Report License",
  54860. false,
  54861. false
  54862. ],
  54863. "hdparm": [
  54864. "hdparm License",
  54865. false,
  54866. false
  54867. ],
  54868. "Hippocratic-2.1": [
  54869. "Hippocratic License 2.1",
  54870. false,
  54871. false
  54872. ],
  54873. "HP-1986": [
  54874. "Hewlett-Packard 1986 License",
  54875. false,
  54876. false
  54877. ],
  54878. "HP-1989": [
  54879. "Hewlett-Packard 1989 License",
  54880. false,
  54881. false
  54882. ],
  54883. "HPND": [
  54884. "Historical Permission Notice and Disclaimer",
  54885. true,
  54886. false
  54887. ],
  54888. "HPND-DEC": [
  54889. "Historical Permission Notice and Disclaimer - DEC variant",
  54890. false,
  54891. false
  54892. ],
  54893. "HPND-doc": [
  54894. "Historical Permission Notice and Disclaimer - documentation variant",
  54895. false,
  54896. false
  54897. ],
  54898. "HPND-doc-sell": [
  54899. "Historical Permission Notice and Disclaimer - documentation sell variant",
  54900. false,
  54901. false
  54902. ],
  54903. "HPND-export-US": [
  54904. "HPND with US Government export control warning",
  54905. false,
  54906. false
  54907. ],
  54908. "HPND-export-US-modify": [
  54909. "HPND with US Government export control warning and modification rqmt",
  54910. false,
  54911. false
  54912. ],
  54913. "HPND-Markus-Kuhn": [
  54914. "Historical Permission Notice and Disclaimer - Markus Kuhn variant",
  54915. false,
  54916. false
  54917. ],
  54918. "HPND-Pbmplus": [
  54919. "Historical Permission Notice and Disclaimer - Pbmplus variant",
  54920. false,
  54921. false
  54922. ],
  54923. "HPND-sell-MIT-disclaimer-xserver": [
  54924. "Historical Permission Notice and Disclaimer - sell xserver variant with MIT disclaimer",
  54925. false,
  54926. false
  54927. ],
  54928. "HPND-sell-regexpr": [
  54929. "Historical Permission Notice and Disclaimer - sell regexpr variant",
  54930. false,
  54931. false
  54932. ],
  54933. "HPND-sell-variant": [
  54934. "Historical Permission Notice and Disclaimer - sell variant",
  54935. false,
  54936. false
  54937. ],
  54938. "HPND-sell-variant-MIT-disclaimer": [
  54939. "HPND sell variant with MIT disclaimer",
  54940. false,
  54941. false
  54942. ],
  54943. "HPND-UC": [
  54944. "Historical Permission Notice and Disclaimer - University of California variant",
  54945. false,
  54946. false
  54947. ],
  54948. "HTMLTIDY": [
  54949. "HTML Tidy License",
  54950. false,
  54951. false
  54952. ],
  54953. "IBM-pibs": [
  54954. "IBM PowerPC Initialization and Boot Software",
  54955. false,
  54956. false
  54957. ],
  54958. "ICU": [
  54959. "ICU License",
  54960. true,
  54961. false
  54962. ],
  54963. "IEC-Code-Components-EULA": [
  54964. "IEC Code Components End-user licence agreement",
  54965. false,
  54966. false
  54967. ],
  54968. "IJG": [
  54969. "Independent JPEG Group License",
  54970. false,
  54971. false
  54972. ],
  54973. "IJG-short": [
  54974. "Independent JPEG Group License - short",
  54975. false,
  54976. false
  54977. ],
  54978. "ImageMagick": [
  54979. "ImageMagick License",
  54980. false,
  54981. false
  54982. ],
  54983. "iMatix": [
  54984. "iMatix Standard Function Library Agreement",
  54985. false,
  54986. false
  54987. ],
  54988. "Imlib2": [
  54989. "Imlib2 License",
  54990. false,
  54991. false
  54992. ],
  54993. "Info-ZIP": [
  54994. "Info-ZIP License",
  54995. false,
  54996. false
  54997. ],
  54998. "Inner-Net-2.0": [
  54999. "Inner Net License v2.0",
  55000. false,
  55001. false
  55002. ],
  55003. "Intel": [
  55004. "Intel Open Source License",
  55005. true,
  55006. false
  55007. ],
  55008. "Intel-ACPI": [
  55009. "Intel ACPI Software License Agreement",
  55010. false,
  55011. false
  55012. ],
  55013. "Interbase-1.0": [
  55014. "Interbase Public License v1.0",
  55015. false,
  55016. false
  55017. ],
  55018. "IPA": [
  55019. "IPA Font License",
  55020. true,
  55021. false
  55022. ],
  55023. "IPL-1.0": [
  55024. "IBM Public License v1.0",
  55025. true,
  55026. false
  55027. ],
  55028. "ISC": [
  55029. "ISC License",
  55030. true,
  55031. false
  55032. ],
  55033. "Jam": [
  55034. "Jam License",
  55035. true,
  55036. false
  55037. ],
  55038. "JasPer-2.0": [
  55039. "JasPer License",
  55040. false,
  55041. false
  55042. ],
  55043. "JPL-image": [
  55044. "JPL Image Use Policy",
  55045. false,
  55046. false
  55047. ],
  55048. "JPNIC": [
  55049. "Japan Network Information Center License",
  55050. false,
  55051. false
  55052. ],
  55053. "JSON": [
  55054. "JSON License",
  55055. false,
  55056. false
  55057. ],
  55058. "Kastrup": [
  55059. "Kastrup License",
  55060. false,
  55061. false
  55062. ],
  55063. "Kazlib": [
  55064. "Kazlib License",
  55065. false,
  55066. false
  55067. ],
  55068. "Knuth-CTAN": [
  55069. "Knuth CTAN License",
  55070. false,
  55071. false
  55072. ],
  55073. "LAL-1.2": [
  55074. "Licence Art Libre 1.2",
  55075. false,
  55076. false
  55077. ],
  55078. "LAL-1.3": [
  55079. "Licence Art Libre 1.3",
  55080. false,
  55081. false
  55082. ],
  55083. "Latex2e": [
  55084. "Latex2e License",
  55085. false,
  55086. false
  55087. ],
  55088. "Latex2e-translated-notice": [
  55089. "Latex2e with translated notice permission",
  55090. false,
  55091. false
  55092. ],
  55093. "Leptonica": [
  55094. "Leptonica License",
  55095. false,
  55096. false
  55097. ],
  55098. "LGPL-2.0": [
  55099. "GNU Library General Public License v2 only",
  55100. true,
  55101. true
  55102. ],
  55103. "LGPL-2.0+": [
  55104. "GNU Library General Public License v2 or later",
  55105. true,
  55106. true
  55107. ],
  55108. "LGPL-2.0-only": [
  55109. "GNU Library General Public License v2 only",
  55110. true,
  55111. false
  55112. ],
  55113. "LGPL-2.0-or-later": [
  55114. "GNU Library General Public License v2 or later",
  55115. true,
  55116. false
  55117. ],
  55118. "LGPL-2.1": [
  55119. "GNU Lesser General Public License v2.1 only",
  55120. true,
  55121. true
  55122. ],
  55123. "LGPL-2.1+": [
  55124. "GNU Lesser General Public License v2.1 or later",
  55125. true,
  55126. true
  55127. ],
  55128. "LGPL-2.1-only": [
  55129. "GNU Lesser General Public License v2.1 only",
  55130. true,
  55131. false
  55132. ],
  55133. "LGPL-2.1-or-later": [
  55134. "GNU Lesser General Public License v2.1 or later",
  55135. true,
  55136. false
  55137. ],
  55138. "LGPL-3.0": [
  55139. "GNU Lesser General Public License v3.0 only",
  55140. true,
  55141. true
  55142. ],
  55143. "LGPL-3.0+": [
  55144. "GNU Lesser General Public License v3.0 or later",
  55145. true,
  55146. true
  55147. ],
  55148. "LGPL-3.0-only": [
  55149. "GNU Lesser General Public License v3.0 only",
  55150. true,
  55151. false
  55152. ],
  55153. "LGPL-3.0-or-later": [
  55154. "GNU Lesser General Public License v3.0 or later",
  55155. true,
  55156. false
  55157. ],
  55158. "LGPLLR": [
  55159. "Lesser General Public License For Linguistic Resources",
  55160. false,
  55161. false
  55162. ],
  55163. "Libpng": [
  55164. "libpng License",
  55165. false,
  55166. false
  55167. ],
  55168. "libpng-2.0": [
  55169. "PNG Reference Library version 2",
  55170. false,
  55171. false
  55172. ],
  55173. "libselinux-1.0": [
  55174. "libselinux public domain notice",
  55175. false,
  55176. false
  55177. ],
  55178. "libtiff": [
  55179. "libtiff License",
  55180. false,
  55181. false
  55182. ],
  55183. "libutil-David-Nugent": [
  55184. "libutil David Nugent License",
  55185. false,
  55186. false
  55187. ],
  55188. "LiLiQ-P-1.1": [
  55189. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  55190. true,
  55191. false
  55192. ],
  55193. "LiLiQ-R-1.1": [
  55194. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  55195. true,
  55196. false
  55197. ],
  55198. "LiLiQ-Rplus-1.1": [
  55199. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  55200. true,
  55201. false
  55202. ],
  55203. "Linux-man-pages-1-para": [
  55204. "Linux man-pages - 1 paragraph",
  55205. false,
  55206. false
  55207. ],
  55208. "Linux-man-pages-copyleft": [
  55209. "Linux man-pages Copyleft",
  55210. false,
  55211. false
  55212. ],
  55213. "Linux-man-pages-copyleft-2-para": [
  55214. "Linux man-pages Copyleft - 2 paragraphs",
  55215. false,
  55216. false
  55217. ],
  55218. "Linux-man-pages-copyleft-var": [
  55219. "Linux man-pages Copyleft Variant",
  55220. false,
  55221. false
  55222. ],
  55223. "Linux-OpenIB": [
  55224. "Linux Kernel Variant of OpenIB.org license",
  55225. false,
  55226. false
  55227. ],
  55228. "LOOP": [
  55229. "Common Lisp LOOP License",
  55230. false,
  55231. false
  55232. ],
  55233. "LPL-1.0": [
  55234. "Lucent Public License Version 1.0",
  55235. true,
  55236. false
  55237. ],
  55238. "LPL-1.02": [
  55239. "Lucent Public License v1.02",
  55240. true,
  55241. false
  55242. ],
  55243. "LPPL-1.0": [
  55244. "LaTeX Project Public License v1.0",
  55245. false,
  55246. false
  55247. ],
  55248. "LPPL-1.1": [
  55249. "LaTeX Project Public License v1.1",
  55250. false,
  55251. false
  55252. ],
  55253. "LPPL-1.2": [
  55254. "LaTeX Project Public License v1.2",
  55255. false,
  55256. false
  55257. ],
  55258. "LPPL-1.3a": [
  55259. "LaTeX Project Public License v1.3a",
  55260. false,
  55261. false
  55262. ],
  55263. "LPPL-1.3c": [
  55264. "LaTeX Project Public License v1.3c",
  55265. true,
  55266. false
  55267. ],
  55268. "lsof": [
  55269. "lsof License",
  55270. false,
  55271. false
  55272. ],
  55273. "Lucida-Bitmap-Fonts": [
  55274. "Lucida Bitmap Fonts License",
  55275. false,
  55276. false
  55277. ],
  55278. "LZMA-SDK-9.11-to-9.20": [
  55279. "LZMA SDK License (versions 9.11 to 9.20)",
  55280. false,
  55281. false
  55282. ],
  55283. "LZMA-SDK-9.22": [
  55284. "LZMA SDK License (versions 9.22 and beyond)",
  55285. false,
  55286. false
  55287. ],
  55288. "magaz": [
  55289. "magaz License",
  55290. false,
  55291. false
  55292. ],
  55293. "MakeIndex": [
  55294. "MakeIndex License",
  55295. false,
  55296. false
  55297. ],
  55298. "Martin-Birgmeier": [
  55299. "Martin Birgmeier License",
  55300. false,
  55301. false
  55302. ],
  55303. "McPhee-slideshow": [
  55304. "McPhee Slideshow License",
  55305. false,
  55306. false
  55307. ],
  55308. "metamail": [
  55309. "metamail License",
  55310. false,
  55311. false
  55312. ],
  55313. "Minpack": [
  55314. "Minpack License",
  55315. false,
  55316. false
  55317. ],
  55318. "MirOS": [
  55319. "The MirOS Licence",
  55320. true,
  55321. false
  55322. ],
  55323. "MIT": [
  55324. "MIT License",
  55325. true,
  55326. false
  55327. ],
  55328. "MIT-0": [
  55329. "MIT No Attribution",
  55330. true,
  55331. false
  55332. ],
  55333. "MIT-advertising": [
  55334. "Enlightenment License (e16)",
  55335. false,
  55336. false
  55337. ],
  55338. "MIT-CMU": [
  55339. "CMU License",
  55340. false,
  55341. false
  55342. ],
  55343. "MIT-enna": [
  55344. "enna License",
  55345. false,
  55346. false
  55347. ],
  55348. "MIT-feh": [
  55349. "feh License",
  55350. false,
  55351. false
  55352. ],
  55353. "MIT-Festival": [
  55354. "MIT Festival Variant",
  55355. false,
  55356. false
  55357. ],
  55358. "MIT-Modern-Variant": [
  55359. "MIT License Modern Variant",
  55360. true,
  55361. false
  55362. ],
  55363. "MIT-open-group": [
  55364. "MIT Open Group variant",
  55365. false,
  55366. false
  55367. ],
  55368. "MIT-testregex": [
  55369. "MIT testregex Variant",
  55370. false,
  55371. false
  55372. ],
  55373. "MIT-Wu": [
  55374. "MIT Tom Wu Variant",
  55375. false,
  55376. false
  55377. ],
  55378. "MITNFA": [
  55379. "MIT +no-false-attribs license",
  55380. false,
  55381. false
  55382. ],
  55383. "MMIXware": [
  55384. "MMIXware License",
  55385. false,
  55386. false
  55387. ],
  55388. "Motosoto": [
  55389. "Motosoto License",
  55390. true,
  55391. false
  55392. ],
  55393. "MPEG-SSG": [
  55394. "MPEG Software Simulation",
  55395. false,
  55396. false
  55397. ],
  55398. "mpi-permissive": [
  55399. "mpi Permissive License",
  55400. false,
  55401. false
  55402. ],
  55403. "mpich2": [
  55404. "mpich2 License",
  55405. false,
  55406. false
  55407. ],
  55408. "MPL-1.0": [
  55409. "Mozilla Public License 1.0",
  55410. true,
  55411. false
  55412. ],
  55413. "MPL-1.1": [
  55414. "Mozilla Public License 1.1",
  55415. true,
  55416. false
  55417. ],
  55418. "MPL-2.0": [
  55419. "Mozilla Public License 2.0",
  55420. true,
  55421. false
  55422. ],
  55423. "MPL-2.0-no-copyleft-exception": [
  55424. "Mozilla Public License 2.0 (no copyleft exception)",
  55425. true,
  55426. false
  55427. ],
  55428. "mplus": [
  55429. "mplus Font License",
  55430. false,
  55431. false
  55432. ],
  55433. "MS-LPL": [
  55434. "Microsoft Limited Public License",
  55435. false,
  55436. false
  55437. ],
  55438. "MS-PL": [
  55439. "Microsoft Public License",
  55440. true,
  55441. false
  55442. ],
  55443. "MS-RL": [
  55444. "Microsoft Reciprocal License",
  55445. true,
  55446. false
  55447. ],
  55448. "MTLL": [
  55449. "Matrix Template Library License",
  55450. false,
  55451. false
  55452. ],
  55453. "MulanPSL-1.0": [
  55454. "Mulan Permissive Software License, Version 1",
  55455. false,
  55456. false
  55457. ],
  55458. "MulanPSL-2.0": [
  55459. "Mulan Permissive Software License, Version 2",
  55460. true,
  55461. false
  55462. ],
  55463. "Multics": [
  55464. "Multics License",
  55465. true,
  55466. false
  55467. ],
  55468. "Mup": [
  55469. "Mup License",
  55470. false,
  55471. false
  55472. ],
  55473. "NAIST-2003": [
  55474. "Nara Institute of Science and Technology License (2003)",
  55475. false,
  55476. false
  55477. ],
  55478. "NASA-1.3": [
  55479. "NASA Open Source Agreement 1.3",
  55480. true,
  55481. false
  55482. ],
  55483. "Naumen": [
  55484. "Naumen Public License",
  55485. true,
  55486. false
  55487. ],
  55488. "NBPL-1.0": [
  55489. "Net Boolean Public License v1",
  55490. false,
  55491. false
  55492. ],
  55493. "NCGL-UK-2.0": [
  55494. "Non-Commercial Government Licence",
  55495. false,
  55496. false
  55497. ],
  55498. "NCSA": [
  55499. "University of Illinois/NCSA Open Source License",
  55500. true,
  55501. false
  55502. ],
  55503. "Net-SNMP": [
  55504. "Net-SNMP License",
  55505. false,
  55506. false
  55507. ],
  55508. "NetCDF": [
  55509. "NetCDF license",
  55510. false,
  55511. false
  55512. ],
  55513. "Newsletr": [
  55514. "Newsletr License",
  55515. false,
  55516. false
  55517. ],
  55518. "NGPL": [
  55519. "Nethack General Public License",
  55520. true,
  55521. false
  55522. ],
  55523. "NICTA-1.0": [
  55524. "NICTA Public Software License, Version 1.0",
  55525. false,
  55526. false
  55527. ],
  55528. "NIST-PD": [
  55529. "NIST Public Domain Notice",
  55530. false,
  55531. false
  55532. ],
  55533. "NIST-PD-fallback": [
  55534. "NIST Public Domain Notice with license fallback",
  55535. false,
  55536. false
  55537. ],
  55538. "NIST-Software": [
  55539. "NIST Software License",
  55540. false,
  55541. false
  55542. ],
  55543. "NLOD-1.0": [
  55544. "Norwegian Licence for Open Government Data (NLOD) 1.0",
  55545. false,
  55546. false
  55547. ],
  55548. "NLOD-2.0": [
  55549. "Norwegian Licence for Open Government Data (NLOD) 2.0",
  55550. false,
  55551. false
  55552. ],
  55553. "NLPL": [
  55554. "No Limit Public License",
  55555. false,
  55556. false
  55557. ],
  55558. "Nokia": [
  55559. "Nokia Open Source License",
  55560. true,
  55561. false
  55562. ],
  55563. "NOSL": [
  55564. "Netizen Open Source License",
  55565. false,
  55566. false
  55567. ],
  55568. "Noweb": [
  55569. "Noweb License",
  55570. false,
  55571. false
  55572. ],
  55573. "NPL-1.0": [
  55574. "Netscape Public License v1.0",
  55575. false,
  55576. false
  55577. ],
  55578. "NPL-1.1": [
  55579. "Netscape Public License v1.1",
  55580. false,
  55581. false
  55582. ],
  55583. "NPOSL-3.0": [
  55584. "Non-Profit Open Software License 3.0",
  55585. true,
  55586. false
  55587. ],
  55588. "NRL": [
  55589. "NRL License",
  55590. false,
  55591. false
  55592. ],
  55593. "NTP": [
  55594. "NTP License",
  55595. true,
  55596. false
  55597. ],
  55598. "NTP-0": [
  55599. "NTP No Attribution",
  55600. false,
  55601. false
  55602. ],
  55603. "Nunit": [
  55604. "Nunit License",
  55605. false,
  55606. true
  55607. ],
  55608. "O-UDA-1.0": [
  55609. "Open Use of Data Agreement v1.0",
  55610. false,
  55611. false
  55612. ],
  55613. "OCCT-PL": [
  55614. "Open CASCADE Technology Public License",
  55615. false,
  55616. false
  55617. ],
  55618. "OCLC-2.0": [
  55619. "OCLC Research Public License 2.0",
  55620. true,
  55621. false
  55622. ],
  55623. "ODbL-1.0": [
  55624. "Open Data Commons Open Database License v1.0",
  55625. false,
  55626. false
  55627. ],
  55628. "ODC-By-1.0": [
  55629. "Open Data Commons Attribution License v1.0",
  55630. false,
  55631. false
  55632. ],
  55633. "OFFIS": [
  55634. "OFFIS License",
  55635. false,
  55636. false
  55637. ],
  55638. "OFL-1.0": [
  55639. "SIL Open Font License 1.0",
  55640. false,
  55641. false
  55642. ],
  55643. "OFL-1.0-no-RFN": [
  55644. "SIL Open Font License 1.0 with no Reserved Font Name",
  55645. false,
  55646. false
  55647. ],
  55648. "OFL-1.0-RFN": [
  55649. "SIL Open Font License 1.0 with Reserved Font Name",
  55650. false,
  55651. false
  55652. ],
  55653. "OFL-1.1": [
  55654. "SIL Open Font License 1.1",
  55655. true,
  55656. false
  55657. ],
  55658. "OFL-1.1-no-RFN": [
  55659. "SIL Open Font License 1.1 with no Reserved Font Name",
  55660. true,
  55661. false
  55662. ],
  55663. "OFL-1.1-RFN": [
  55664. "SIL Open Font License 1.1 with Reserved Font Name",
  55665. true,
  55666. false
  55667. ],
  55668. "OGC-1.0": [
  55669. "OGC Software License, Version 1.0",
  55670. false,
  55671. false
  55672. ],
  55673. "OGDL-Taiwan-1.0": [
  55674. "Taiwan Open Government Data License, version 1.0",
  55675. false,
  55676. false
  55677. ],
  55678. "OGL-Canada-2.0": [
  55679. "Open Government Licence - Canada",
  55680. false,
  55681. false
  55682. ],
  55683. "OGL-UK-1.0": [
  55684. "Open Government Licence v1.0",
  55685. false,
  55686. false
  55687. ],
  55688. "OGL-UK-2.0": [
  55689. "Open Government Licence v2.0",
  55690. false,
  55691. false
  55692. ],
  55693. "OGL-UK-3.0": [
  55694. "Open Government Licence v3.0",
  55695. false,
  55696. false
  55697. ],
  55698. "OGTSL": [
  55699. "Open Group Test Suite License",
  55700. true,
  55701. false
  55702. ],
  55703. "OLDAP-1.1": [
  55704. "Open LDAP Public License v1.1",
  55705. false,
  55706. false
  55707. ],
  55708. "OLDAP-1.2": [
  55709. "Open LDAP Public License v1.2",
  55710. false,
  55711. false
  55712. ],
  55713. "OLDAP-1.3": [
  55714. "Open LDAP Public License v1.3",
  55715. false,
  55716. false
  55717. ],
  55718. "OLDAP-1.4": [
  55719. "Open LDAP Public License v1.4",
  55720. false,
  55721. false
  55722. ],
  55723. "OLDAP-2.0": [
  55724. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  55725. false,
  55726. false
  55727. ],
  55728. "OLDAP-2.0.1": [
  55729. "Open LDAP Public License v2.0.1",
  55730. false,
  55731. false
  55732. ],
  55733. "OLDAP-2.1": [
  55734. "Open LDAP Public License v2.1",
  55735. false,
  55736. false
  55737. ],
  55738. "OLDAP-2.2": [
  55739. "Open LDAP Public License v2.2",
  55740. false,
  55741. false
  55742. ],
  55743. "OLDAP-2.2.1": [
  55744. "Open LDAP Public License v2.2.1",
  55745. false,
  55746. false
  55747. ],
  55748. "OLDAP-2.2.2": [
  55749. "Open LDAP Public License 2.2.2",
  55750. false,
  55751. false
  55752. ],
  55753. "OLDAP-2.3": [
  55754. "Open LDAP Public License v2.3",
  55755. false,
  55756. false
  55757. ],
  55758. "OLDAP-2.4": [
  55759. "Open LDAP Public License v2.4",
  55760. false,
  55761. false
  55762. ],
  55763. "OLDAP-2.5": [
  55764. "Open LDAP Public License v2.5",
  55765. false,
  55766. false
  55767. ],
  55768. "OLDAP-2.6": [
  55769. "Open LDAP Public License v2.6",
  55770. false,
  55771. false
  55772. ],
  55773. "OLDAP-2.7": [
  55774. "Open LDAP Public License v2.7",
  55775. false,
  55776. false
  55777. ],
  55778. "OLDAP-2.8": [
  55779. "Open LDAP Public License v2.8",
  55780. true,
  55781. false
  55782. ],
  55783. "OLFL-1.3": [
  55784. "Open Logistics Foundation License Version 1.3",
  55785. true,
  55786. false
  55787. ],
  55788. "OML": [
  55789. "Open Market License",
  55790. false,
  55791. false
  55792. ],
  55793. "OpenPBS-2.3": [
  55794. "OpenPBS v2.3 Software License",
  55795. false,
  55796. false
  55797. ],
  55798. "OpenSSL": [
  55799. "OpenSSL License",
  55800. false,
  55801. false
  55802. ],
  55803. "OPL-1.0": [
  55804. "Open Public License v1.0",
  55805. false,
  55806. false
  55807. ],
  55808. "OPL-UK-3.0": [
  55809. "United Kingdom Open Parliament Licence v3.0",
  55810. false,
  55811. false
  55812. ],
  55813. "OPUBL-1.0": [
  55814. "Open Publication License v1.0",
  55815. false,
  55816. false
  55817. ],
  55818. "OSET-PL-2.1": [
  55819. "OSET Public License version 2.1",
  55820. true,
  55821. false
  55822. ],
  55823. "OSL-1.0": [
  55824. "Open Software License 1.0",
  55825. true,
  55826. false
  55827. ],
  55828. "OSL-1.1": [
  55829. "Open Software License 1.1",
  55830. false,
  55831. false
  55832. ],
  55833. "OSL-2.0": [
  55834. "Open Software License 2.0",
  55835. true,
  55836. false
  55837. ],
  55838. "OSL-2.1": [
  55839. "Open Software License 2.1",
  55840. true,
  55841. false
  55842. ],
  55843. "OSL-3.0": [
  55844. "Open Software License 3.0",
  55845. true,
  55846. false
  55847. ],
  55848. "PADL": [
  55849. "PADL License",
  55850. false,
  55851. false
  55852. ],
  55853. "Parity-6.0.0": [
  55854. "The Parity Public License 6.0.0",
  55855. false,
  55856. false
  55857. ],
  55858. "Parity-7.0.0": [
  55859. "The Parity Public License 7.0.0",
  55860. false,
  55861. false
  55862. ],
  55863. "PDDL-1.0": [
  55864. "Open Data Commons Public Domain Dedication & License 1.0",
  55865. false,
  55866. false
  55867. ],
  55868. "PHP-3.0": [
  55869. "PHP License v3.0",
  55870. true,
  55871. false
  55872. ],
  55873. "PHP-3.01": [
  55874. "PHP License v3.01",
  55875. true,
  55876. false
  55877. ],
  55878. "Pixar": [
  55879. "Pixar License",
  55880. false,
  55881. false
  55882. ],
  55883. "Plexus": [
  55884. "Plexus Classworlds License",
  55885. false,
  55886. false
  55887. ],
  55888. "pnmstitch": [
  55889. "pnmstitch License",
  55890. false,
  55891. false
  55892. ],
  55893. "PolyForm-Noncommercial-1.0.0": [
  55894. "PolyForm Noncommercial License 1.0.0",
  55895. false,
  55896. false
  55897. ],
  55898. "PolyForm-Small-Business-1.0.0": [
  55899. "PolyForm Small Business License 1.0.0",
  55900. false,
  55901. false
  55902. ],
  55903. "PostgreSQL": [
  55904. "PostgreSQL License",
  55905. true,
  55906. false
  55907. ],
  55908. "PSF-2.0": [
  55909. "Python Software Foundation License 2.0",
  55910. false,
  55911. false
  55912. ],
  55913. "psfrag": [
  55914. "psfrag License",
  55915. false,
  55916. false
  55917. ],
  55918. "psutils": [
  55919. "psutils License",
  55920. false,
  55921. false
  55922. ],
  55923. "Python-2.0": [
  55924. "Python License 2.0",
  55925. true,
  55926. false
  55927. ],
  55928. "Python-2.0.1": [
  55929. "Python License 2.0.1",
  55930. false,
  55931. false
  55932. ],
  55933. "python-ldap": [
  55934. "Python ldap License",
  55935. false,
  55936. false
  55937. ],
  55938. "Qhull": [
  55939. "Qhull License",
  55940. false,
  55941. false
  55942. ],
  55943. "QPL-1.0": [
  55944. "Q Public License 1.0",
  55945. true,
  55946. false
  55947. ],
  55948. "QPL-1.0-INRIA-2004": [
  55949. "Q Public License 1.0 - INRIA 2004 variant",
  55950. false,
  55951. false
  55952. ],
  55953. "Rdisc": [
  55954. "Rdisc License",
  55955. false,
  55956. false
  55957. ],
  55958. "RHeCos-1.1": [
  55959. "Red Hat eCos Public License v1.1",
  55960. false,
  55961. false
  55962. ],
  55963. "RPL-1.1": [
  55964. "Reciprocal Public License 1.1",
  55965. true,
  55966. false
  55967. ],
  55968. "RPL-1.5": [
  55969. "Reciprocal Public License 1.5",
  55970. true,
  55971. false
  55972. ],
  55973. "RPSL-1.0": [
  55974. "RealNetworks Public Source License v1.0",
  55975. true,
  55976. false
  55977. ],
  55978. "RSA-MD": [
  55979. "RSA Message-Digest License",
  55980. false,
  55981. false
  55982. ],
  55983. "RSCPL": [
  55984. "Ricoh Source Code Public License",
  55985. true,
  55986. false
  55987. ],
  55988. "Ruby": [
  55989. "Ruby License",
  55990. false,
  55991. false
  55992. ],
  55993. "SAX-PD": [
  55994. "Sax Public Domain Notice",
  55995. false,
  55996. false
  55997. ],
  55998. "Saxpath": [
  55999. "Saxpath License",
  56000. false,
  56001. false
  56002. ],
  56003. "SCEA": [
  56004. "SCEA Shared Source License",
  56005. false,
  56006. false
  56007. ],
  56008. "SchemeReport": [
  56009. "Scheme Language Report License",
  56010. false,
  56011. false
  56012. ],
  56013. "Sendmail": [
  56014. "Sendmail License",
  56015. false,
  56016. false
  56017. ],
  56018. "Sendmail-8.23": [
  56019. "Sendmail License 8.23",
  56020. false,
  56021. false
  56022. ],
  56023. "SGI-B-1.0": [
  56024. "SGI Free Software License B v1.0",
  56025. false,
  56026. false
  56027. ],
  56028. "SGI-B-1.1": [
  56029. "SGI Free Software License B v1.1",
  56030. false,
  56031. false
  56032. ],
  56033. "SGI-B-2.0": [
  56034. "SGI Free Software License B v2.0",
  56035. false,
  56036. false
  56037. ],
  56038. "SGI-OpenGL": [
  56039. "SGI OpenGL License",
  56040. false,
  56041. false
  56042. ],
  56043. "SGP4": [
  56044. "SGP4 Permission Notice",
  56045. false,
  56046. false
  56047. ],
  56048. "SHL-0.5": [
  56049. "Solderpad Hardware License v0.5",
  56050. false,
  56051. false
  56052. ],
  56053. "SHL-0.51": [
  56054. "Solderpad Hardware License, Version 0.51",
  56055. false,
  56056. false
  56057. ],
  56058. "SimPL-2.0": [
  56059. "Simple Public License 2.0",
  56060. true,
  56061. false
  56062. ],
  56063. "SISSL": [
  56064. "Sun Industry Standards Source License v1.1",
  56065. true,
  56066. false
  56067. ],
  56068. "SISSL-1.2": [
  56069. "Sun Industry Standards Source License v1.2",
  56070. false,
  56071. false
  56072. ],
  56073. "SL": [
  56074. "SL License",
  56075. false,
  56076. false
  56077. ],
  56078. "Sleepycat": [
  56079. "Sleepycat License",
  56080. true,
  56081. false
  56082. ],
  56083. "SMLNJ": [
  56084. "Standard ML of New Jersey License",
  56085. false,
  56086. false
  56087. ],
  56088. "SMPPL": [
  56089. "Secure Messaging Protocol Public License",
  56090. false,
  56091. false
  56092. ],
  56093. "SNIA": [
  56094. "SNIA Public License 1.1",
  56095. false,
  56096. false
  56097. ],
  56098. "snprintf": [
  56099. "snprintf License",
  56100. false,
  56101. false
  56102. ],
  56103. "Soundex": [
  56104. "Soundex License",
  56105. false,
  56106. false
  56107. ],
  56108. "Spencer-86": [
  56109. "Spencer License 86",
  56110. false,
  56111. false
  56112. ],
  56113. "Spencer-94": [
  56114. "Spencer License 94",
  56115. false,
  56116. false
  56117. ],
  56118. "Spencer-99": [
  56119. "Spencer License 99",
  56120. false,
  56121. false
  56122. ],
  56123. "SPL-1.0": [
  56124. "Sun Public License v1.0",
  56125. true,
  56126. false
  56127. ],
  56128. "ssh-keyscan": [
  56129. "ssh-keyscan License",
  56130. false,
  56131. false
  56132. ],
  56133. "SSH-OpenSSH": [
  56134. "SSH OpenSSH license",
  56135. false,
  56136. false
  56137. ],
  56138. "SSH-short": [
  56139. "SSH short notice",
  56140. false,
  56141. false
  56142. ],
  56143. "SSPL-1.0": [
  56144. "Server Side Public License, v 1",
  56145. false,
  56146. false
  56147. ],
  56148. "StandardML-NJ": [
  56149. "Standard ML of New Jersey License",
  56150. false,
  56151. true
  56152. ],
  56153. "SugarCRM-1.1.3": [
  56154. "SugarCRM Public License v1.1.3",
  56155. false,
  56156. false
  56157. ],
  56158. "SunPro": [
  56159. "SunPro License",
  56160. false,
  56161. false
  56162. ],
  56163. "SWL": [
  56164. "Scheme Widget Library (SWL) Software License Agreement",
  56165. false,
  56166. false
  56167. ],
  56168. "swrule": [
  56169. "swrule License",
  56170. false,
  56171. false
  56172. ],
  56173. "Symlinks": [
  56174. "Symlinks License",
  56175. false,
  56176. false
  56177. ],
  56178. "TAPR-OHL-1.0": [
  56179. "TAPR Open Hardware License v1.0",
  56180. false,
  56181. false
  56182. ],
  56183. "TCL": [
  56184. "TCL/TK License",
  56185. false,
  56186. false
  56187. ],
  56188. "TCP-wrappers": [
  56189. "TCP Wrappers License",
  56190. false,
  56191. false
  56192. ],
  56193. "TermReadKey": [
  56194. "TermReadKey License",
  56195. false,
  56196. false
  56197. ],
  56198. "TMate": [
  56199. "TMate Open Source License",
  56200. false,
  56201. false
  56202. ],
  56203. "TORQUE-1.1": [
  56204. "TORQUE v2.5+ Software License v1.1",
  56205. false,
  56206. false
  56207. ],
  56208. "TOSL": [
  56209. "Trusster Open Source License",
  56210. false,
  56211. false
  56212. ],
  56213. "TPDL": [
  56214. "Time::ParseDate License",
  56215. false,
  56216. false
  56217. ],
  56218. "TPL-1.0": [
  56219. "THOR Public License 1.0",
  56220. false,
  56221. false
  56222. ],
  56223. "TTWL": [
  56224. "Text-Tabs+Wrap License",
  56225. false,
  56226. false
  56227. ],
  56228. "TTYP0": [
  56229. "TTYP0 License",
  56230. false,
  56231. false
  56232. ],
  56233. "TU-Berlin-1.0": [
  56234. "Technische Universitaet Berlin License 1.0",
  56235. false,
  56236. false
  56237. ],
  56238. "TU-Berlin-2.0": [
  56239. "Technische Universitaet Berlin License 2.0",
  56240. false,
  56241. false
  56242. ],
  56243. "UCAR": [
  56244. "UCAR License",
  56245. false,
  56246. false
  56247. ],
  56248. "UCL-1.0": [
  56249. "Upstream Compatibility License v1.0",
  56250. true,
  56251. false
  56252. ],
  56253. "ulem": [
  56254. "ulem License",
  56255. false,
  56256. false
  56257. ],
  56258. "Unicode-DFS-2015": [
  56259. "Unicode License Agreement - Data Files and Software (2015)",
  56260. false,
  56261. false
  56262. ],
  56263. "Unicode-DFS-2016": [
  56264. "Unicode License Agreement - Data Files and Software (2016)",
  56265. true,
  56266. false
  56267. ],
  56268. "Unicode-TOU": [
  56269. "Unicode Terms of Use",
  56270. false,
  56271. false
  56272. ],
  56273. "UnixCrypt": [
  56274. "UnixCrypt License",
  56275. false,
  56276. false
  56277. ],
  56278. "Unlicense": [
  56279. "The Unlicense",
  56280. true,
  56281. false
  56282. ],
  56283. "UPL-1.0": [
  56284. "Universal Permissive License v1.0",
  56285. true,
  56286. false
  56287. ],
  56288. "URT-RLE": [
  56289. "Utah Raster Toolkit Run Length Encoded License",
  56290. false,
  56291. false
  56292. ],
  56293. "Vim": [
  56294. "Vim License",
  56295. false,
  56296. false
  56297. ],
  56298. "VOSTROM": [
  56299. "VOSTROM Public License for Open Source",
  56300. false,
  56301. false
  56302. ],
  56303. "VSL-1.0": [
  56304. "Vovida Software License v1.0",
  56305. true,
  56306. false
  56307. ],
  56308. "W3C": [
  56309. "W3C Software Notice and License (2002-12-31)",
  56310. true,
  56311. false
  56312. ],
  56313. "W3C-19980720": [
  56314. "W3C Software Notice and License (1998-07-20)",
  56315. false,
  56316. false
  56317. ],
  56318. "W3C-20150513": [
  56319. "W3C Software Notice and Document License (2015-05-13)",
  56320. false,
  56321. false
  56322. ],
  56323. "w3m": [
  56324. "w3m License",
  56325. false,
  56326. false
  56327. ],
  56328. "Watcom-1.0": [
  56329. "Sybase Open Watcom Public License 1.0",
  56330. true,
  56331. false
  56332. ],
  56333. "Widget-Workshop": [
  56334. "Widget Workshop License",
  56335. false,
  56336. false
  56337. ],
  56338. "Wsuipa": [
  56339. "Wsuipa License",
  56340. false,
  56341. false
  56342. ],
  56343. "WTFPL": [
  56344. "Do What The F*ck You Want To Public License",
  56345. false,
  56346. false
  56347. ],
  56348. "wxWindows": [
  56349. "wxWindows Library License",
  56350. true,
  56351. true
  56352. ],
  56353. "X11": [
  56354. "X11 License",
  56355. false,
  56356. false
  56357. ],
  56358. "X11-distribute-modifications-variant": [
  56359. "X11 License Distribution Modification Variant",
  56360. false,
  56361. false
  56362. ],
  56363. "Xdebug-1.03": [
  56364. "Xdebug License v 1.03",
  56365. false,
  56366. false
  56367. ],
  56368. "Xerox": [
  56369. "Xerox License",
  56370. false,
  56371. false
  56372. ],
  56373. "Xfig": [
  56374. "Xfig License",
  56375. false,
  56376. false
  56377. ],
  56378. "XFree86-1.1": [
  56379. "XFree86 License 1.1",
  56380. false,
  56381. false
  56382. ],
  56383. "xinetd": [
  56384. "xinetd License",
  56385. false,
  56386. false
  56387. ],
  56388. "xlock": [
  56389. "xlock License",
  56390. false,
  56391. false
  56392. ],
  56393. "Xnet": [
  56394. "X.Net License",
  56395. true,
  56396. false
  56397. ],
  56398. "xpp": [
  56399. "XPP License",
  56400. false,
  56401. false
  56402. ],
  56403. "XSkat": [
  56404. "XSkat License",
  56405. false,
  56406. false
  56407. ],
  56408. "YPL-1.0": [
  56409. "Yahoo! Public License v1.0",
  56410. false,
  56411. false
  56412. ],
  56413. "YPL-1.1": [
  56414. "Yahoo! Public License v1.1",
  56415. false,
  56416. false
  56417. ],
  56418. "Zed": [
  56419. "Zed License",
  56420. false,
  56421. false
  56422. ],
  56423. "Zeeff": [
  56424. "Zeeff License",
  56425. false,
  56426. false
  56427. ],
  56428. "Zend-2.0": [
  56429. "Zend License v2.0",
  56430. false,
  56431. false
  56432. ],
  56433. "Zimbra-1.3": [
  56434. "Zimbra Public License v1.3",
  56435. false,
  56436. false
  56437. ],
  56438. "Zimbra-1.4": [
  56439. "Zimbra Public License v1.4",
  56440. false,
  56441. false
  56442. ],
  56443. "Zlib": [
  56444. "zlib License",
  56445. true,
  56446. false
  56447. ],
  56448. "zlib-acknowledgement": [
  56449. "zlib/libpng License with Acknowledgement",
  56450. false,
  56451. false
  56452. ],
  56453. "ZPL-1.1": [
  56454. "Zope Public License 1.1",
  56455. false,
  56456. false
  56457. ],
  56458. "ZPL-2.0": [
  56459. "Zope Public License 2.0",
  56460. true,
  56461. false
  56462. ],
  56463. "ZPL-2.1": [
  56464. "Zope Public License 2.1",
  56465. true,
  56466. false
  56467. ]
  56468. }<?php
  56469. namespace Composer\Spdx;
  56470. class SpdxLicenses
  56471. {
  56472. const LICENSES_FILE = 'spdx-licenses.json';
  56473. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  56474. private $licenses;
  56475. private $licensesExpression;
  56476. private $exceptions;
  56477. private $exceptionsExpression;
  56478. public function __construct()
  56479. {
  56480. $this->loadLicenses();
  56481. $this->loadExceptions();
  56482. }
  56483. public function getLicenseByIdentifier($identifier)
  56484. {
  56485. $key = strtolower($identifier);
  56486. if (!isset($this->licenses[$key])) {
  56487. return null;
  56488. }
  56489. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  56490. return array(
  56491. $name,
  56492. $isOsiApproved,
  56493. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  56494. $isDeprecatedLicenseId,
  56495. );
  56496. }
  56497. public function getLicenses()
  56498. {
  56499. return $this->licenses;
  56500. }
  56501. public function getExceptionByIdentifier($identifier)
  56502. {
  56503. $key = strtolower($identifier);
  56504. if (!isset($this->exceptions[$key])) {
  56505. return null;
  56506. }
  56507. list($identifier, $name) = $this->exceptions[$key];
  56508. return array(
  56509. $name,
  56510. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  56511. );
  56512. }
  56513. public function getIdentifierByName($name)
  56514. {
  56515. foreach ($this->licenses as $licenseData) {
  56516. if ($licenseData[1] === $name) {
  56517. return $licenseData[0];
  56518. }
  56519. }
  56520. foreach ($this->exceptions as $licenseData) {
  56521. if ($licenseData[1] === $name) {
  56522. return $licenseData[0];
  56523. }
  56524. }
  56525. return null;
  56526. }
  56527. public function isOsiApprovedByIdentifier($identifier)
  56528. {
  56529. return $this->licenses[strtolower($identifier)][2];
  56530. }
  56531. public function isDeprecatedByIdentifier($identifier)
  56532. {
  56533. return $this->licenses[strtolower($identifier)][3];
  56534. }
  56535. public function validate($license)
  56536. {
  56537. if (is_array($license)) {
  56538. $count = count($license);
  56539. if ($count !== count(array_filter($license, 'is_string'))) {
  56540. throw new \InvalidArgumentException('Array of strings expected.');
  56541. }
  56542. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  56543. }
  56544. if (!is_string($license)) {
  56545. throw new \InvalidArgumentException(sprintf(
  56546. 'Array or String expected, %s given.',
  56547. gettype($license)
  56548. ));
  56549. }
  56550. return $this->isValidLicenseString($license);
  56551. }
  56552. public static function getResourcesDir()
  56553. {
  56554. return dirname(__DIR__) . '/res';
  56555. }
  56556. private function loadLicenses()
  56557. {
  56558. if (null !== $this->licenses) {
  56559. return;
  56560. }
  56561. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  56562. if (false === $json) {
  56563. throw new \RuntimeException('Missing license file in ' . self::getResourcesDir() . '/' . self::LICENSES_FILE);
  56564. }
  56565. $this->licenses = array();
  56566. foreach (json_decode($json, true) as $identifier => $license) {
  56567. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  56568. }
  56569. }
  56570. private function loadExceptions()
  56571. {
  56572. if (null !== $this->exceptions) {
  56573. return;
  56574. }
  56575. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  56576. if (false === $json) {
  56577. throw new \RuntimeException('Missing exceptions file in ' . self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  56578. }
  56579. $this->exceptions = array();
  56580. foreach (json_decode($json, true) as $identifier => $exception) {
  56581. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  56582. }
  56583. }
  56584. private function getLicensesExpression()
  56585. {
  56586. if (null === $this->licensesExpression) {
  56587. $licenses = array_map('preg_quote', array_keys($this->licenses));
  56588. rsort($licenses);
  56589. $licenses = implode('|', $licenses);
  56590. $this->licensesExpression = $licenses;
  56591. }
  56592. return $this->licensesExpression;
  56593. }
  56594. private function getExceptionsExpression()
  56595. {
  56596. if (null === $this->exceptionsExpression) {
  56597. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  56598. rsort($exceptions);
  56599. $exceptions = implode('|', $exceptions);
  56600. $this->exceptionsExpression = $exceptions;
  56601. }
  56602. return $this->exceptionsExpression;
  56603. }
  56604. private function isValidLicenseString($license)
  56605. {
  56606. if (isset($this->licenses[strtolower($license)])) {
  56607. return true;
  56608. }
  56609. $licenses = $this->getLicensesExpression();
  56610. $exceptions = $this->getExceptionsExpression();
  56611. $regex = <<<REGEX
  56612. {
  56613. (?(DEFINE)
  56614. # idstring: 1*( ALPHA / DIGIT / - / . )
  56615. (?<idstring>[\pL\pN.-]{1,})
  56616. # license-id: taken from list
  56617. (?<licenseid>{$licenses})
  56618. # license-exception-id: taken from list
  56619. (?<licenseexceptionid>{$exceptions})
  56620. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  56621. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  56622. # simple-expresssion: license-id / license-id+ / license-ref
  56623. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  56624. # compound-expression: 1*(
  56625. # simple-expression /
  56626. # simple-expression WITH license-exception-id /
  56627. # compound-expression AND compound-expression /
  56628. # compound-expression OR compound-expression
  56629. # ) / ( compound-expression ) )
  56630. (?<compound_head>
  56631. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  56632. | \( \s* (?&compound_expression) \s* \)
  56633. )
  56634. (?<compound_expression>
  56635. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  56636. )
  56637. # license-expression: 1*1(simple-expression / compound-expression)
  56638. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  56639. ) # end of define
  56640. ^(NONE | NOASSERTION | (?&license_expression))$
  56641. }xi
  56642. REGEX;
  56643. $match = preg_match($regex, $license);
  56644. if (0 === $match) {
  56645. return false;
  56646. }
  56647. if (false === $match) {
  56648. throw new \RuntimeException('Regex failed to compile/run.');
  56649. }
  56650. return true;
  56651. }
  56652. }
  56653. MIT License
  56654. Copyright (c) 2017 Composer
  56655. Permission is hereby granted, free of charge, to any person obtaining a copy
  56656. of this software and associated documentation files (the "Software"), to deal
  56657. in the Software without restriction, including without limitation the rights
  56658. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56659. copies of the Software, and to permit persons to whom the Software is
  56660. furnished to do so, subject to the following conditions:
  56661. The above copyright notice and this permission notice shall be included in all
  56662. copies or substantial portions of the Software.
  56663. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56664. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  56665. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56666. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56667. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56668. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  56669. SOFTWARE.
  56670. <?php
  56671. declare(strict_types=1);
  56672. namespace Composer\XdebugHandler;
  56673. class PhpConfig
  56674. {
  56675. public function useOriginal(): array
  56676. {
  56677. $this->getDataAndReset();
  56678. return [];
  56679. }
  56680. public function useStandard(): array
  56681. {
  56682. $data = $this->getDataAndReset();
  56683. if ($data !== null) {
  56684. return ['-n', '-c', $data['tmpIni']];
  56685. }
  56686. return [];
  56687. }
  56688. public function usePersistent(): array
  56689. {
  56690. $data = $this->getDataAndReset();
  56691. if ($data !== null) {
  56692. $this->updateEnv('PHPRC', $data['tmpIni']);
  56693. $this->updateEnv('PHP_INI_SCAN_DIR', '');
  56694. }
  56695. return [];
  56696. }
  56697. private function getDataAndReset(): ?array
  56698. {
  56699. $data = XdebugHandler::getRestartSettings();
  56700. if ($data !== null) {
  56701. $this->updateEnv('PHPRC', $data['phprc']);
  56702. $this->updateEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  56703. }
  56704. return $data;
  56705. }
  56706. private function updateEnv(string $name, $value): void
  56707. {
  56708. Process::setEnv($name, false !== $value ? $value : null);
  56709. }
  56710. }
  56711. <?php
  56712. declare(strict_types=1);
  56713. namespace Composer\XdebugHandler;
  56714. use Composer\Pcre\Preg;
  56715. class Process
  56716. {
  56717. public static function escape(string $arg, bool $meta = true, bool $module = false): string
  56718. {
  56719. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  56720. return "'".str_replace("'", "'\\''", $arg)."'";
  56721. }
  56722. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  56723. $arg = Preg::replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  56724. $dquotes = (bool) $dquotes;
  56725. if ($meta) {
  56726. $meta = $dquotes || Preg::isMatch('/%[^%]+%/', $arg);
  56727. if (!$meta) {
  56728. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  56729. } elseif ($module && !$dquotes && $quote) {
  56730. $meta = false;
  56731. }
  56732. }
  56733. if ($quote) {
  56734. $arg = '"'.(Preg::replace('/(\\\\*)$/', '$1$1', $arg)).'"';
  56735. }
  56736. if ($meta) {
  56737. $arg = Preg::replace('/(["^&|<>()%])/', '^$1', $arg);
  56738. }
  56739. return $arg;
  56740. }
  56741. public static function escapeShellCommand(array $args): string
  56742. {
  56743. $command = '';
  56744. $module = array_shift($args);
  56745. if ($module !== null) {
  56746. $command = self::escape($module, true, true);
  56747. foreach ($args as $arg) {
  56748. $command .= ' '.self::escape($arg);
  56749. }
  56750. }
  56751. return $command;
  56752. }
  56753. public static function setEnv(string $name, ?string $value = null): bool
  56754. {
  56755. $unset = null === $value;
  56756. if (!putenv($unset ? $name : $name.'='.$value)) {
  56757. return false;
  56758. }
  56759. if ($unset) {
  56760. unset($_SERVER[$name]);
  56761. } else {
  56762. $_SERVER[$name] = $value;
  56763. }
  56764. if (false !== stripos((string) ini_get('variables_order'), 'E')) {
  56765. if ($unset) {
  56766. unset($_ENV[$name]);
  56767. } else {
  56768. $_ENV[$name] = $value;
  56769. }
  56770. }
  56771. return true;
  56772. }
  56773. }
  56774. <?php
  56775. declare(strict_types=1);
  56776. namespace Composer\XdebugHandler;
  56777. use Psr\Log\LoggerInterface;
  56778. use Psr\Log\LogLevel;
  56779. class Status
  56780. {
  56781. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  56782. const CHECK = 'Check';
  56783. const ERROR = 'Error';
  56784. const INFO = 'Info';
  56785. const NORESTART = 'NoRestart';
  56786. const RESTART = 'Restart';
  56787. const RESTARTING = 'Restarting';
  56788. const RESTARTED = 'Restarted';
  56789. private $debug;
  56790. private $envAllowXdebug;
  56791. private $loaded;
  56792. private $logger;
  56793. private $modeOff;
  56794. private $time;
  56795. public function __construct(string $envAllowXdebug, bool $debug)
  56796. {
  56797. $start = getenv(self::ENV_RESTART);
  56798. Process::setEnv(self::ENV_RESTART);
  56799. $this->time = is_numeric($start) ? round((microtime(true) - $start) * 1000) : 0;
  56800. $this->envAllowXdebug = $envAllowXdebug;
  56801. $this->debug = $debug && defined('STDERR');
  56802. $this->modeOff = false;
  56803. }
  56804. public function setLogger(LoggerInterface $logger): void
  56805. {
  56806. $this->logger = $logger;
  56807. }
  56808. public function report(string $op, ?string $data): void
  56809. {
  56810. if ($this->logger !== null || $this->debug) {
  56811. $param = (string) $data;
  56812. switch($op) {
  56813. case self::CHECK:
  56814. $this->reportCheck($param);
  56815. break;
  56816. case self::ERROR:
  56817. $this->reportError($param);
  56818. break;
  56819. case self::INFO:
  56820. $this->reportInfo($param);
  56821. break;
  56822. case self::NORESTART:
  56823. $this->reportNoRestart();
  56824. break;
  56825. case self::RESTART:
  56826. $this->reportRestart();
  56827. break;
  56828. case self::RESTARTED:
  56829. $this->reportRestarted();
  56830. break;
  56831. case self::RESTARTING:
  56832. $this->reportRestarting($param);
  56833. break;
  56834. default:
  56835. throw new \InvalidArgumentException('Unknown op handler: '.$op);
  56836. }
  56837. }
  56838. }
  56839. private function output(string $text, ?string $level = null): void
  56840. {
  56841. if ($this->logger !== null) {
  56842. $this->logger->log($level !== null ? $level: LogLevel::DEBUG, $text);
  56843. }
  56844. if ($this->debug) {
  56845. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  56846. }
  56847. }
  56848. private function reportCheck(string $loaded): void
  56849. {
  56850. list($version, $mode) = explode('|', $loaded);
  56851. if ($version !== '') {
  56852. $this->loaded = '('.$version.')'.($mode !== '' ? ' xdebug.mode='.$mode : '');
  56853. }
  56854. $this->modeOff = $mode === 'off';
  56855. $this->output('Checking '.$this->envAllowXdebug);
  56856. }
  56857. private function reportError(string $error): void
  56858. {
  56859. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  56860. }
  56861. private function reportInfo(string $info): void
  56862. {
  56863. $this->output($info);
  56864. }
  56865. private function reportNoRestart(): void
  56866. {
  56867. $this->output($this->getLoadedMessage());
  56868. if ($this->loaded !== null) {
  56869. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  56870. if (!((bool) getenv($this->envAllowXdebug))) {
  56871. $text .= ' Allowed by '.($this->modeOff ? 'xdebug.mode' : 'application');
  56872. }
  56873. $this->output($text);
  56874. }
  56875. }
  56876. private function reportRestart(): void
  56877. {
  56878. $this->output($this->getLoadedMessage());
  56879. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  56880. }
  56881. private function reportRestarted(): void
  56882. {
  56883. $loaded = $this->getLoadedMessage();
  56884. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  56885. $level = $this->loaded !== null ? LogLevel::WARNING : null;
  56886. $this->output($text, $level);
  56887. }
  56888. private function reportRestarting(string $command): void
  56889. {
  56890. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  56891. $this->output($text);
  56892. $text = 'Running: '.$command;
  56893. $this->output($text);
  56894. }
  56895. private function getEnvAllow(): string
  56896. {
  56897. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  56898. }
  56899. private function getLoadedMessage(): string
  56900. {
  56901. $loaded = $this->loaded !== null ? sprintf('loaded %s', $this->loaded) : 'not loaded';
  56902. return 'The Xdebug extension is '.$loaded;
  56903. }
  56904. }
  56905. <?php
  56906. declare(strict_types=1);
  56907. namespace Composer\XdebugHandler;
  56908. use Composer\Pcre\Preg;
  56909. use Psr\Log\LoggerInterface;
  56910. class XdebugHandler
  56911. {
  56912. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  56913. const SUFFIX_INIS = '_ORIGINAL_INIS';
  56914. const RESTART_ID = 'internal';
  56915. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  56916. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  56917. protected $tmpIni;
  56918. private static $inRestart;
  56919. private static $name;
  56920. private static $skipped;
  56921. private static $xdebugActive;
  56922. private static $xdebugMode;
  56923. private static $xdebugVersion;
  56924. private $cli;
  56925. private $debug;
  56926. private $envAllowXdebug;
  56927. private $envOriginalInis;
  56928. private $persistent;
  56929. private $script;
  56930. private $statusWriter;
  56931. public function __construct(string $envPrefix)
  56932. {
  56933. if ($envPrefix === '') {
  56934. throw new \RuntimeException('Invalid constructor parameter');
  56935. }
  56936. self::$name = strtoupper($envPrefix);
  56937. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  56938. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  56939. self::setXdebugDetails();
  56940. self::$inRestart = false;
  56941. if ($this->cli = PHP_SAPI === 'cli') {
  56942. $this->debug = (string) getenv(self::DEBUG);
  56943. }
  56944. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  56945. }
  56946. public function setLogger(LoggerInterface $logger): self
  56947. {
  56948. $this->statusWriter->setLogger($logger);
  56949. return $this;
  56950. }
  56951. public function setMainScript(string $script): self
  56952. {
  56953. $this->script = $script;
  56954. return $this;
  56955. }
  56956. public function setPersistent(): self
  56957. {
  56958. $this->persistent = true;
  56959. return $this;
  56960. }
  56961. public function check(): void
  56962. {
  56963. $this->notify(Status::CHECK, self::$xdebugVersion.'|'.self::$xdebugMode);
  56964. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  56965. if (!((bool) $envArgs[0]) && $this->requiresRestart(self::$xdebugActive)) {
  56966. $this->notify(Status::RESTART);
  56967. $command = $this->prepareRestart();
  56968. if ($command !== null) {
  56969. $this->restart($command);
  56970. }
  56971. return;
  56972. }
  56973. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  56974. $this->notify(Status::RESTARTED);
  56975. Process::setEnv($this->envAllowXdebug);
  56976. self::$inRestart = true;
  56977. if (self::$xdebugVersion === null) {
  56978. self::$skipped = $envArgs[1];
  56979. }
  56980. $this->tryEnableSignals();
  56981. $this->setEnvRestartSettings($envArgs);
  56982. return;
  56983. }
  56984. $this->notify(Status::NORESTART);
  56985. $settings = self::getRestartSettings();
  56986. if ($settings !== null) {
  56987. $this->syncSettings($settings);
  56988. }
  56989. }
  56990. public static function getAllIniFiles(): array
  56991. {
  56992. if (self::$name !== null) {
  56993. $env = getenv(self::$name.self::SUFFIX_INIS);
  56994. if (false !== $env) {
  56995. return explode(PATH_SEPARATOR, $env);
  56996. }
  56997. }
  56998. $paths = [(string) php_ini_loaded_file()];
  56999. $scanned = php_ini_scanned_files();
  57000. if ($scanned !== false) {
  57001. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  57002. }
  57003. return $paths;
  57004. }
  57005. public static function getRestartSettings(): ?array
  57006. {
  57007. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  57008. if (count($envArgs) !== 6
  57009. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  57010. return null;
  57011. }
  57012. return [
  57013. 'tmpIni' => $envArgs[0],
  57014. 'scannedInis' => (bool) $envArgs[1],
  57015. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  57016. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  57017. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  57018. 'skipped' => $envArgs[5],
  57019. ];
  57020. }
  57021. public static function getSkippedVersion(): string
  57022. {
  57023. return (string) self::$skipped;
  57024. }
  57025. public static function isXdebugActive(): bool
  57026. {
  57027. self::setXdebugDetails();
  57028. return self::$xdebugActive;
  57029. }
  57030. protected function requiresRestart(bool $default): bool
  57031. {
  57032. return $default;
  57033. }
  57034. protected function restart(array $command): void
  57035. {
  57036. $this->doRestart($command);
  57037. }
  57038. private function doRestart(array $command): void
  57039. {
  57040. if (PHP_VERSION_ID >= 70400) {
  57041. $cmd = $command;
  57042. $displayCmd = sprintf('[%s]', implode(', ', $cmd));
  57043. } else {
  57044. $cmd = Process::escapeShellCommand($command);
  57045. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  57046. $cmd = '"'.$cmd.'"';
  57047. }
  57048. $displayCmd = $cmd;
  57049. }
  57050. $this->tryEnableSignals();
  57051. $this->notify(Status::RESTARTING, $displayCmd);
  57052. $process = proc_open($cmd, [], $pipes);
  57053. if (is_resource($process)) {
  57054. $exitCode = proc_close($process);
  57055. }
  57056. if (!isset($exitCode)) {
  57057. $this->notify(Status::ERROR, 'Unable to restart process');
  57058. $exitCode = -1;
  57059. } else {
  57060. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  57061. }
  57062. if ($this->debug === '2') {
  57063. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  57064. } else {
  57065. @unlink((string) $this->tmpIni);
  57066. }
  57067. exit($exitCode);
  57068. }
  57069. private function prepareRestart(): ?array
  57070. {
  57071. if (!$this->cli) {
  57072. $this->notify(Status::ERROR, 'Unsupported SAPI: '.PHP_SAPI);
  57073. return null;
  57074. }
  57075. if (($argv = $this->checkServerArgv()) === null) {
  57076. $this->notify(Status::ERROR, '$_SERVER[argv] is not as expected');
  57077. return null;
  57078. }
  57079. if (!$this->checkConfiguration($info)) {
  57080. $this->notify(Status::ERROR, $info);
  57081. return null;
  57082. }
  57083. $mainScript = (string) $this->script;
  57084. if (!$this->checkMainScript($mainScript, $argv)) {
  57085. $this->notify(Status::ERROR, 'Unable to access main script: '.$mainScript);
  57086. return null;
  57087. }
  57088. $tmpDir = sys_get_temp_dir();
  57089. $iniError = 'Unable to create temp ini file at: '.$tmpDir;
  57090. if (($tmpfile = @tempnam($tmpDir, '')) === false) {
  57091. $this->notify(Status::ERROR, $iniError);
  57092. return null;
  57093. }
  57094. $error = null;
  57095. $iniFiles = self::getAllIniFiles();
  57096. $scannedInis = count($iniFiles) > 1;
  57097. if (!$this->writeTmpIni($tmpfile, $iniFiles, $error)) {
  57098. $this->notify(Status::ERROR, $error ?? $iniError);
  57099. @unlink($tmpfile);
  57100. return null;
  57101. }
  57102. if (!$this->setEnvironment($scannedInis, $iniFiles, $tmpfile)) {
  57103. $this->notify(Status::ERROR, 'Unable to set environment variables');
  57104. @unlink($tmpfile);
  57105. return null;
  57106. }
  57107. $this->tmpIni = $tmpfile;
  57108. return $this->getCommand($argv, $tmpfile, $mainScript);
  57109. }
  57110. private function writeTmpIni(string $tmpFile, array $iniFiles, ?string &$error): bool
  57111. {
  57112. if ($iniFiles[0] === '') {
  57113. array_shift($iniFiles);
  57114. }
  57115. $content = '';
  57116. $sectionRegex = '/^\s*\[(?:PATH|HOST)\s*=/mi';
  57117. $xdebugRegex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  57118. foreach ($iniFiles as $file) {
  57119. if (($data = @file_get_contents($file)) === false) {
  57120. $error = 'Unable to read ini: '.$file;
  57121. return false;
  57122. }
  57123. if (Preg::isMatchWithOffsets($sectionRegex, $data, $matches)) {
  57124. $data = substr($data, 0, $matches[0][1]);
  57125. }
  57126. $content .= Preg::replace($xdebugRegex, ';$1', $data).PHP_EOL;
  57127. }
  57128. $config = parse_ini_string($content);
  57129. $loaded = ini_get_all(null, false);
  57130. if (false === $config || false === $loaded) {
  57131. $error = 'Unable to parse ini data';
  57132. return false;
  57133. }
  57134. $content .= $this->mergeLoadedConfig($loaded, $config);
  57135. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  57136. return (bool) @file_put_contents($tmpFile, $content);
  57137. }
  57138. private function getCommand(array $argv, string $tmpIni, string $mainScript): array
  57139. {
  57140. $php = [PHP_BINARY];
  57141. $args = array_slice($argv, 1);
  57142. if (!$this->persistent) {
  57143. array_push($php, '-n', '-c', $tmpIni);
  57144. }
  57145. return array_merge($php, [$mainScript], $args);
  57146. }
  57147. private function setEnvironment(bool $scannedInis, array $iniFiles, string $tmpIni): bool
  57148. {
  57149. $scanDir = getenv('PHP_INI_SCAN_DIR');
  57150. $phprc = getenv('PHPRC');
  57151. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  57152. return false;
  57153. }
  57154. if ($this->persistent) {
  57155. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$tmpIni)) {
  57156. return false;
  57157. }
  57158. }
  57159. $envArgs = [
  57160. self::RESTART_ID,
  57161. self::$xdebugVersion,
  57162. (int) $scannedInis,
  57163. false === $scanDir ? '*' : $scanDir,
  57164. false === $phprc ? '*' : $phprc,
  57165. ];
  57166. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  57167. }
  57168. private function notify(string $op, ?string $data = null): void
  57169. {
  57170. $this->statusWriter->report($op, $data);
  57171. }
  57172. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig): string
  57173. {
  57174. $content = '';
  57175. foreach ($loadedConfig as $name => $value) {
  57176. if (!is_string($value)
  57177. || strpos($name, 'xdebug') === 0
  57178. || $name === 'apc.mmap_file_mask') {
  57179. continue;
  57180. }
  57181. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  57182. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  57183. }
  57184. }
  57185. return $content;
  57186. }
  57187. private function checkMainScript(string &$mainScript, array $argv): bool
  57188. {
  57189. if ($mainScript !== '') {
  57190. return file_exists($mainScript) || '--' === $mainScript;
  57191. }
  57192. if (file_exists($mainScript = $argv[0])) {
  57193. return true;
  57194. }
  57195. $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  57196. $main = end($trace);
  57197. if ($main !== false && isset($main['file'])) {
  57198. return file_exists($mainScript = $main['file']);
  57199. }
  57200. return false;
  57201. }
  57202. private function setEnvRestartSettings(array $envArgs): void
  57203. {
  57204. $settings = [
  57205. php_ini_loaded_file(),
  57206. $envArgs[2],
  57207. $envArgs[3],
  57208. $envArgs[4],
  57209. getenv($this->envOriginalInis),
  57210. self::$skipped,
  57211. ];
  57212. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  57213. }
  57214. private function syncSettings(array $settings): void
  57215. {
  57216. if (false === getenv($this->envOriginalInis)) {
  57217. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  57218. }
  57219. self::$skipped = $settings['skipped'];
  57220. $this->notify(Status::INFO, 'Process called with existing restart settings');
  57221. }
  57222. private function checkConfiguration(?string &$info): bool
  57223. {
  57224. if (!function_exists('proc_open')) {
  57225. $info = 'proc_open function is disabled';
  57226. return false;
  57227. }
  57228. if (!file_exists(PHP_BINARY)) {
  57229. $info = 'PHP_BINARY is not available';
  57230. return false;
  57231. }
  57232. if (extension_loaded('uopz') && !((bool) ini_get('uopz.disable'))) {
  57233. if (function_exists('uopz_allow_exit')) {
  57234. @uopz_allow_exit(true);
  57235. } else {
  57236. $info = 'uopz extension is not compatible';
  57237. return false;
  57238. }
  57239. }
  57240. if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 70400) {
  57241. $workingDir = getcwd();
  57242. if ($workingDir === false) {
  57243. $info = 'unable to determine working directory';
  57244. return false;
  57245. }
  57246. if (0 === strpos($workingDir, '\\\\')) {
  57247. $info = 'cmd.exe does not support UNC paths: '.$workingDir;
  57248. return false;
  57249. }
  57250. }
  57251. return true;
  57252. }
  57253. private function tryEnableSignals(): void
  57254. {
  57255. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  57256. pcntl_async_signals(true);
  57257. $message = 'Async signals enabled';
  57258. if (!self::$inRestart) {
  57259. pcntl_signal(SIGINT, SIG_IGN);
  57260. } elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
  57261. pcntl_signal(SIGINT, SIG_DFL);
  57262. }
  57263. }
  57264. if (!self::$inRestart && function_exists('sapi_windows_set_ctrl_handler')) {
  57265. sapi_windows_set_ctrl_handler(function ($evt) {});
  57266. }
  57267. }
  57268. private function checkServerArgv(): ?array
  57269. {
  57270. $result = [];
  57271. if (isset($_SERVER['argv']) && is_array($_SERVER['argv'])) {
  57272. foreach ($_SERVER['argv'] as $value) {
  57273. if (!is_string($value)) {
  57274. return null;
  57275. }
  57276. $result[] = $value;
  57277. }
  57278. }
  57279. return count($result) > 0 ? $result : null;
  57280. }
  57281. private static function setXdebugDetails(): void
  57282. {
  57283. if (self::$xdebugActive !== null) {
  57284. return;
  57285. }
  57286. self::$xdebugActive = false;
  57287. if (!extension_loaded('xdebug')) {
  57288. return;
  57289. }
  57290. $version = phpversion('xdebug');
  57291. self::$xdebugVersion = $version !== false ? $version : 'unknown';
  57292. if (version_compare(self::$xdebugVersion, '3.1', '>=')) {
  57293. $modes = xdebug_info('mode');
  57294. self::$xdebugMode = count($modes) === 0 ? 'off' : implode(',', $modes);
  57295. self::$xdebugActive = self::$xdebugMode !== 'off';
  57296. return;
  57297. }
  57298. $iniMode = ini_get('xdebug.mode');
  57299. if ($iniMode === false) {
  57300. self::$xdebugActive = true;
  57301. return;
  57302. }
  57303. $envMode = (string) getenv('XDEBUG_MODE');
  57304. if ($envMode !== '') {
  57305. self::$xdebugMode = $envMode;
  57306. } else {
  57307. self::$xdebugMode = $iniMode !== '' ? $iniMode : 'off';
  57308. }
  57309. if (Preg::isMatch('/^,+$/', str_replace(' ', '', self::$xdebugMode))) {
  57310. self::$xdebugMode = 'off';
  57311. }
  57312. self::$xdebugActive = self::$xdebugMode !== 'off';
  57313. }
  57314. }
  57315. MIT License
  57316. Copyright (c) 2016
  57317. Permission is hereby granted, free of charge, to any person obtaining a copy
  57318. of this software and associated documentation files (the "Software"), to deal
  57319. in the Software without restriction, including without limitation the rights
  57320. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  57321. copies of the Software, and to permit persons to whom the Software is
  57322. furnished to do so, subject to the following conditions:
  57323. The above copyright notice and this permission notice shall be included in all
  57324. copies or substantial portions of the Software.
  57325. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  57326. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  57327. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  57328. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  57329. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  57330. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  57331. SOFTWARE.
  57332. <?php
  57333. declare(strict_types=1);
  57334. namespace JsonSchema;
  57335. use JsonSchema\Exception\InvalidArgumentException;
  57336. class ConstraintError extends Enum
  57337. {
  57338. public const ADDITIONAL_ITEMS = 'additionalItems';
  57339. public const ADDITIONAL_PROPERTIES = 'additionalProp';
  57340. public const ALL_OF = 'allOf';
  57341. public const ANY_OF = 'anyOf';
  57342. public const DEPENDENCIES = 'dependencies';
  57343. public const DISALLOW = 'disallow';
  57344. public const DIVISIBLE_BY = 'divisibleBy';
  57345. public const ENUM = 'enum';
  57346. public const CONSTANT = 'const';
  57347. public const EXCLUSIVE_MINIMUM = 'exclusiveMinimum';
  57348. public const EXCLUSIVE_MAXIMUM = 'exclusiveMaximum';
  57349. public const FORMAT_COLOR = 'colorFormat';
  57350. public const FORMAT_DATE = 'dateFormat';
  57351. public const FORMAT_DATE_TIME = 'dateTimeFormat';
  57352. public const FORMAT_DATE_UTC = 'dateUtcFormat';
  57353. public const FORMAT_EMAIL = 'emailFormat';
  57354. public const FORMAT_HOSTNAME = 'styleHostName';
  57355. public const FORMAT_IP = 'ipFormat';
  57356. public const FORMAT_PHONE = 'phoneFormat';
  57357. public const FORMAT_REGEX= 'regexFormat';
  57358. public const FORMAT_STYLE = 'styleFormat';
  57359. public const FORMAT_TIME = 'timeFormat';
  57360. public const FORMAT_URL = 'urlFormat';
  57361. public const FORMAT_URL_REF = 'urlRefFormat';
  57362. public const INVALID_SCHEMA = 'invalidSchema';
  57363. public const LENGTH_MAX = 'maxLength';
  57364. public const LENGTH_MIN = 'minLength';
  57365. public const MAXIMUM = 'maximum';
  57366. public const MIN_ITEMS = 'minItems';
  57367. public const MINIMUM = 'minimum';
  57368. public const MISSING_ERROR = 'missingError';
  57369. public const MISSING_MAXIMUM = 'missingMaximum';
  57370. public const MISSING_MINIMUM = 'missingMinimum';
  57371. public const MAX_ITEMS = 'maxItems';
  57372. public const MULTIPLE_OF = 'multipleOf';
  57373. public const NOT = 'not';
  57374. public const ONE_OF = 'oneOf';
  57375. public const REQUIRED = 'required';
  57376. public const REQUIRES = 'requires';
  57377. public const PATTERN = 'pattern';
  57378. public const PREGEX_INVALID = 'pregrex';
  57379. public const PROPERTIES_MIN = 'minProperties';
  57380. public const PROPERTIES_MAX = 'maxProperties';
  57381. public const TYPE = 'type';
  57382. public const UNIQUE_ITEMS = 'uniqueItems';
  57383. public function getMessage()
  57384. {
  57385. $name = $this->getValue();
  57386. static $messages = [
  57387. self::ADDITIONAL_ITEMS => 'The item %s[%s] is not defined and the definition does not allow additional items',
  57388. self::ADDITIONAL_PROPERTIES => 'The property %s is not defined and the definition does not allow additional properties',
  57389. self::ALL_OF => 'Failed to match all schemas',
  57390. self::ANY_OF => 'Failed to match at least one schema',
  57391. self::DEPENDENCIES => '%s depends on %s, which is missing',
  57392. self::DISALLOW => 'Disallowed value was matched',
  57393. self::DIVISIBLE_BY => 'Is not divisible by %d',
  57394. self::ENUM => 'Does not have a value in the enumeration %s',
  57395. self::CONSTANT => 'Does not have a value equal to %s',
  57396. self::EXCLUSIVE_MINIMUM => 'Must have a minimum value greater than %d',
  57397. self::EXCLUSIVE_MAXIMUM => 'Must have a maximum value less than %d',
  57398. self::FORMAT_COLOR => 'Invalid color',
  57399. self::FORMAT_DATE => 'Invalid date %s, expected format YYYY-MM-DD',
  57400. self::FORMAT_DATE_TIME => 'Invalid date-time %s, expected format YYYY-MM-DDThh:mm:ssZ or YYYY-MM-DDThh:mm:ss+hh:mm',
  57401. self::FORMAT_DATE_UTC => 'Invalid time %s, expected integer of milliseconds since Epoch',
  57402. self::FORMAT_EMAIL => 'Invalid email',
  57403. self::FORMAT_HOSTNAME => 'Invalid hostname',
  57404. self::FORMAT_IP => 'Invalid IP address',
  57405. self::FORMAT_PHONE => 'Invalid phone number',
  57406. self::FORMAT_REGEX=> 'Invalid regex format %s',
  57407. self::FORMAT_STYLE => 'Invalid style',
  57408. self::FORMAT_TIME => 'Invalid time %s, expected format hh:mm:ss',
  57409. self::FORMAT_URL => 'Invalid URL format',
  57410. self::FORMAT_URL_REF => 'Invalid URL reference format',
  57411. self::LENGTH_MAX => 'Must be at most %d characters long',
  57412. self::INVALID_SCHEMA => 'Schema is not valid',
  57413. self::LENGTH_MIN => 'Must be at least %d characters long',
  57414. self::MAX_ITEMS => 'There must be a maximum of %d items in the array, %d found',
  57415. self::MAXIMUM => 'Must have a maximum value less than or equal to %d',
  57416. self::MIN_ITEMS => 'There must be a minimum of %d items in the array, %d found',
  57417. self::MINIMUM => 'Must have a minimum value greater than or equal to %d',
  57418. self::MISSING_MAXIMUM => 'Use of exclusiveMaximum requires presence of maximum',
  57419. self::MISSING_MINIMUM => 'Use of exclusiveMinimum requires presence of minimum',
  57420. self::MULTIPLE_OF => 'Must be a multiple of %s',
  57421. self::NOT => 'Matched a schema which it should not',
  57422. self::ONE_OF => 'Failed to match exactly one schema',
  57423. self::REQUIRED => 'The property %s is required',
  57424. self::REQUIRES => 'The presence of the property %s requires that %s also be present',
  57425. self::PATTERN => 'Does not match the regex pattern %s',
  57426. self::PREGEX_INVALID => 'The pattern %s is invalid',
  57427. self::PROPERTIES_MIN => 'Must contain a minimum of %d properties',
  57428. self::PROPERTIES_MAX => 'Must contain no more than %d properties',
  57429. self::TYPE => '%s value found, but %s is required',
  57430. self::UNIQUE_ITEMS => 'There are no duplicates allowed in the array'
  57431. ];
  57432. if (!isset($messages[$name])) {
  57433. throw new InvalidArgumentException('Missing error message for ' . $name);
  57434. }
  57435. return $messages[$name];
  57436. }
  57437. }
  57438. <?php
  57439. declare(strict_types=1);
  57440. namespace JsonSchema\Constraints;
  57441. use JsonSchema\ConstraintError;
  57442. use JsonSchema\Entity\JsonPointer;
  57443. use JsonSchema\Exception\InvalidArgumentException;
  57444. use JsonSchema\Exception\ValidationException;
  57445. use JsonSchema\Validator;
  57446. class BaseConstraint
  57447. {
  57448. protected $errors = [];
  57449. protected $errorMask = Validator::ERROR_NONE;
  57450. protected $factory;
  57451. public function __construct(?Factory $factory = null)
  57452. {
  57453. $this->factory = $factory ?: new Factory();
  57454. }
  57455. public function addError(ConstraintError $constraint, ?JsonPointer $path = null, array $more = []): void
  57456. {
  57457. $message = $constraint->getMessage();
  57458. $name = $constraint->getValue();
  57459. $error = [
  57460. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  57461. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  57462. 'message' => ucfirst(vsprintf($message, array_map(function ($val) {
  57463. if (is_scalar($val)) {
  57464. return is_bool($val) ? var_export($val, true) : $val;
  57465. }
  57466. return json_encode($val);
  57467. }, array_values($more)))),
  57468. 'constraint' => [
  57469. 'name' => $name,
  57470. 'params' => $more
  57471. ],
  57472. 'context' => $this->factory->getErrorContext(),
  57473. ];
  57474. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  57475. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  57476. }
  57477. $this->errors[] = $error;
  57478. $this->errorMask |= $error['context'];
  57479. }
  57480. public function addErrors(array $errors): void
  57481. {
  57482. if ($errors) {
  57483. $this->errors = array_merge($this->errors, $errors);
  57484. $errorMask = &$this->errorMask;
  57485. array_walk($errors, function ($error) use (&$errorMask) {
  57486. if (isset($error['context'])) {
  57487. $errorMask |= $error['context'];
  57488. }
  57489. });
  57490. }
  57491. }
  57492. public function getErrors(int $errorContext = Validator::ERROR_ALL): array
  57493. {
  57494. if ($errorContext === Validator::ERROR_ALL) {
  57495. return $this->errors;
  57496. }
  57497. return array_filter($this->errors, function ($error) use ($errorContext) {
  57498. if ($errorContext & $error['context']) {
  57499. return true;
  57500. }
  57501. });
  57502. }
  57503. public function numErrors(int $errorContext = Validator::ERROR_ALL): int
  57504. {
  57505. if ($errorContext === Validator::ERROR_ALL) {
  57506. return count($this->errors);
  57507. }
  57508. return count($this->getErrors($errorContext));
  57509. }
  57510. public function isValid(): bool
  57511. {
  57512. return !$this->getErrors();
  57513. }
  57514. public function reset(): void
  57515. {
  57516. $this->errors = [];
  57517. $this->errorMask = Validator::ERROR_NONE;
  57518. }
  57519. public function getErrorMask(): int
  57520. {
  57521. return $this->errorMask;
  57522. }
  57523. public static function arrayToObjectRecursive(array $array): object
  57524. {
  57525. $json = json_encode($array);
  57526. if (json_last_error() !== \JSON_ERROR_NONE) {
  57527. $message = 'Unable to encode schema array as JSON';
  57528. if (function_exists('json_last_error_msg')) {
  57529. $message .= ': ' . json_last_error_msg();
  57530. }
  57531. throw new InvalidArgumentException($message);
  57532. }
  57533. return (object) json_decode($json);
  57534. }
  57535. public static function jsonPatternToPhpRegex(string $pattern): string
  57536. {
  57537. return '~' . str_replace('~', '\\~', $pattern) . '~u';
  57538. }
  57539. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer): string
  57540. {
  57541. $result = array_map(
  57542. function ($path) {
  57543. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  57544. },
  57545. $pointer->getPropertyPaths()
  57546. );
  57547. return trim(implode('', $result), '.');
  57548. }
  57549. }
  57550. <?php
  57551. declare(strict_types=1);
  57552. namespace JsonSchema\Constraints;
  57553. use JsonSchema\ConstraintError;
  57554. use JsonSchema\Entity\JsonPointer;
  57555. class CollectionConstraint extends Constraint
  57556. {
  57557. public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
  57558. {
  57559. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  57560. $this->addError(ConstraintError::MIN_ITEMS(), $path, ['minItems' => $schema->minItems, 'found' => count($value)]);
  57561. }
  57562. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  57563. $this->addError(ConstraintError::MAX_ITEMS(), $path, ['maxItems' => $schema->maxItems, 'found' => count($value)]);
  57564. }
  57565. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  57566. $unique = $value;
  57567. if (is_array($value) && count($value)) {
  57568. $unique = array_map(function ($e) {
  57569. return var_export($e, true);
  57570. }, $value);
  57571. }
  57572. if (count(array_unique($unique)) != count($value)) {
  57573. $this->addError(ConstraintError::UNIQUE_ITEMS(), $path);
  57574. }
  57575. }
  57576. $this->validateItems($value, $schema, $path, $i);
  57577. }
  57578. protected function validateItems(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
  57579. {
  57580. if (\is_null($schema) || !isset($schema->items)) {
  57581. return;
  57582. }
  57583. if ($schema->items === true) {
  57584. return;
  57585. }
  57586. if (is_object($schema->items)) {
  57587. foreach ($value as $k => &$v) {
  57588. $initErrors = $this->getErrors();
  57589. $this->checkUndefined($v, $schema->items, $path, $k);
  57590. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  57591. $secondErrors = $this->getErrors();
  57592. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  57593. }
  57594. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  57595. $this->errors = $secondErrors;
  57596. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  57597. $this->errors = $initErrors;
  57598. }
  57599. }
  57600. unset($v);
  57601. } else {
  57602. foreach ($value as $k => &$v) {
  57603. if (array_key_exists($k, $schema->items)) {
  57604. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  57605. } else {
  57606. if (property_exists($schema, 'additionalItems')) {
  57607. if ($schema->additionalItems !== false) {
  57608. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  57609. } else {
  57610. $this->addError(
  57611. ConstraintError::ADDITIONAL_ITEMS(),
  57612. $path,
  57613. [
  57614. 'item' => $i,
  57615. 'property' => $k,
  57616. 'additionalItems' => $schema->additionalItems
  57617. ]
  57618. );
  57619. }
  57620. } else {
  57621. $this->checkUndefined($v, new \stdClass(), $path, $k);
  57622. }
  57623. }
  57624. }
  57625. unset($v);
  57626. if (count($value) > 0) {
  57627. for ($k = count($value); $k < count($schema->items); $k++) {
  57628. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  57629. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  57630. }
  57631. }
  57632. }
  57633. }
  57634. }
  57635. <?php
  57636. declare(strict_types=1);
  57637. namespace JsonSchema\Constraints;
  57638. use JsonSchema\ConstraintError;
  57639. use JsonSchema\Entity\JsonPointer;
  57640. use JsonSchema\Tool\DeepComparer;
  57641. class ConstConstraint extends Constraint
  57642. {
  57643. public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
  57644. {
  57645. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  57646. return;
  57647. }
  57648. $const = $schema->const;
  57649. $type = gettype($element);
  57650. $constType = gettype($const);
  57651. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type === 'array' && $constType === 'object') {
  57652. if (DeepComparer::isEqual((object) $element, $const)) {
  57653. return;
  57654. }
  57655. }
  57656. if (DeepComparer::isEqual($element, $const)) {
  57657. return;
  57658. }
  57659. $this->addError(ConstraintError::CONSTANT(), $path, ['const' => $schema->const]);
  57660. }
  57661. }
  57662. <?php
  57663. declare(strict_types=1);
  57664. namespace JsonSchema\Constraints;
  57665. use JsonSchema\Entity\JsonPointer;
  57666. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  57667. {
  57668. protected $inlineSchemaProperty = '$schema';
  57669. public const CHECK_MODE_NONE = 0x00000000;
  57670. public const CHECK_MODE_NORMAL = 0x00000001;
  57671. public const CHECK_MODE_TYPE_CAST = 0x00000002;
  57672. public const CHECK_MODE_COERCE_TYPES = 0x00000004;
  57673. public const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  57674. public const CHECK_MODE_EXCEPTIONS = 0x00000010;
  57675. public const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  57676. public const CHECK_MODE_EARLY_COERCE = 0x00000040;
  57677. public const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  57678. public const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  57679. protected function incrementPath(?JsonPointer $path, $i): JsonPointer
  57680. {
  57681. $path = $path ?? new JsonPointer('');
  57682. if ($i === null || $i === '') {
  57683. return $path;
  57684. }
  57685. $path = $path->withPropertyPaths(
  57686. array_merge(
  57687. $path->getPropertyPaths(),
  57688. [$i]
  57689. )
  57690. );
  57691. return $path;
  57692. }
  57693. protected function checkArray(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
  57694. {
  57695. $validator = $this->factory->createInstanceFor('collection');
  57696. $validator->check($value, $schema, $path, $i);
  57697. $this->addErrors($validator->getErrors());
  57698. }
  57699. protected function checkObject(&$value, $schema = null, ?JsonPointer $path = null, $properties = null,
  57700. $additionalProperties = null, $patternProperties = null, $appliedDefaults = []): void
  57701. {
  57702. $validator = $this->factory->createInstanceFor('object');
  57703. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  57704. $this->addErrors($validator->getErrors());
  57705. }
  57706. protected function checkType(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void
  57707. {
  57708. $validator = $this->factory->createInstanceFor('type');
  57709. $validator->check($value, $schema, $path, $i);
  57710. $this->addErrors($validator->getErrors());
  57711. }
  57712. protected function checkUndefined(&$value, $schema = null, ?JsonPointer $path = null, $i = null, $fromDefault = false): void
  57713. {
  57714. $validator = $this->factory->createInstanceFor('undefined');
  57715. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  57716. $this->addErrors($validator->getErrors());
  57717. }
  57718. protected function checkString($value, $schema = null, ?JsonPointer $path = null, $i = null): void
  57719. {
  57720. $validator = $this->factory->createInstanceFor('string');
  57721. $validator->check($value, $schema, $path, $i);
  57722. $this->addErrors($validator->getErrors());
  57723. }
  57724. protected function checkNumber($value, $schema = null, ?JsonPointer $path = null, $i = null): void
  57725. {
  57726. $validator = $this->factory->createInstanceFor('number');
  57727. $validator->check($value, $schema, $path, $i);
  57728. $this->addErrors($validator->getErrors());
  57729. }
  57730. protected function checkEnum($value, $schema = null, ?JsonPointer $path = null, $i = null): void
  57731. {
  57732. $validator = $this->factory->createInstanceFor('enum');
  57733. $validator->check($value, $schema, $path, $i);
  57734. $this->addErrors($validator->getErrors());
  57735. }
  57736. protected function checkConst($value, $schema = null, ?JsonPointer $path = null, $i = null): void
  57737. {
  57738. $validator = $this->factory->createInstanceFor('const');
  57739. $validator->check($value, $schema, $path, $i);
  57740. $this->addErrors($validator->getErrors());
  57741. }
  57742. protected function checkFormat($value, $schema = null, ?JsonPointer $path = null, $i = null): void
  57743. {
  57744. $validator = $this->factory->createInstanceFor('format');
  57745. $validator->check($value, $schema, $path, $i);
  57746. $this->addErrors($validator->getErrors());
  57747. }
  57748. protected function getTypeCheck(): TypeCheck\TypeCheckInterface
  57749. {
  57750. return $this->factory->getTypeCheck();
  57751. }
  57752. }
  57753. <?php
  57754. declare(strict_types=1);
  57755. namespace JsonSchema\Constraints;
  57756. use JsonSchema\ConstraintError;
  57757. use JsonSchema\Entity\JsonPointer;
  57758. interface ConstraintInterface
  57759. {
  57760. public function getErrors(): array;
  57761. public function addErrors(array $errors): void;
  57762. public function addError(ConstraintError $constraint, ?JsonPointer $path = null, array $more = []): void;
  57763. public function isValid(): bool;
  57764. public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = null): void;
  57765. }
  57766. <?php
  57767. declare(strict_types=1);
  57768. namespace JsonSchema\Constraints;
  57769. use JsonSchema\ConstraintError;
  57770. use JsonSchema\Entity\JsonPointer;
  57771. use JsonSchema\Tool\DeepComparer;
  57772. class EnumConstraint extends Constraint
  57773. {
  57774. public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
  57775. {
  57776. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  57777. return;
  57778. }
  57779. $type = gettype($element);
  57780. foreach ($schema->enum as $enum) {
  57781. $enumType = gettype($enum);
  57782. if ($enumType === 'object'
  57783. && $type === 'array'
  57784. && $this->factory->getConfig(self::CHECK_MODE_TYPE_CAST)
  57785. && DeepComparer::isEqual((object) $element, $enum)
  57786. ) {
  57787. return;
  57788. }
  57789. if (($type === $enumType) && DeepComparer::isEqual($element, $enum)) {
  57790. return;
  57791. }
  57792. if (is_numeric($element) && is_numeric($enum) && DeepComparer::isEqual((float) $element, (float) $enum)) {
  57793. return;
  57794. }
  57795. }
  57796. $this->addError(ConstraintError::ENUM(), $path, ['enum' => $schema->enum]);
  57797. }
  57798. }
  57799. <?php
  57800. declare(strict_types=1);
  57801. namespace JsonSchema\Constraints;
  57802. use JsonSchema\Exception\InvalidArgumentException;
  57803. use JsonSchema\SchemaStorage;
  57804. use JsonSchema\SchemaStorageInterface;
  57805. use JsonSchema\Uri\UriRetriever;
  57806. use JsonSchema\UriRetrieverInterface;
  57807. use JsonSchema\Validator;
  57808. class Factory
  57809. {
  57810. protected $schemaStorage;
  57811. protected $uriRetriever;
  57812. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  57813. private $typeCheck = [];
  57814. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  57815. protected $constraintMap = [
  57816. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  57817. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  57818. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  57819. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  57820. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  57821. 'string' => 'JsonSchema\Constraints\StringConstraint',
  57822. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  57823. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  57824. 'const' => 'JsonSchema\Constraints\ConstConstraint',
  57825. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  57826. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  57827. 'validator' => 'JsonSchema\Validator'
  57828. ];
  57829. private $instanceCache = [];
  57830. public function __construct(
  57831. ?SchemaStorageInterface $schemaStorage = null,
  57832. ?UriRetrieverInterface $uriRetriever = null,
  57833. int $checkMode = Constraint::CHECK_MODE_NORMAL
  57834. ) {
  57835. $this->setConfig($checkMode);
  57836. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  57837. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  57838. }
  57839. public function setConfig(int $checkMode = Constraint::CHECK_MODE_NORMAL): void
  57840. {
  57841. $this->checkMode = $checkMode;
  57842. }
  57843. public function addConfig(int $options): void
  57844. {
  57845. $this->checkMode |= $options;
  57846. }
  57847. public function removeConfig(int $options): void
  57848. {
  57849. $this->checkMode &= ~$options;
  57850. }
  57851. public function getConfig(?int $options = null): int
  57852. {
  57853. if ($options === null) {
  57854. return $this->checkMode;
  57855. }
  57856. return $this->checkMode & $options;
  57857. }
  57858. public function getUriRetriever(): UriRetrieverInterface
  57859. {
  57860. return $this->uriRetriever;
  57861. }
  57862. public function getSchemaStorage(): SchemaStorageInterface
  57863. {
  57864. return $this->schemaStorage;
  57865. }
  57866. public function getTypeCheck(): TypeCheck\TypeCheckInterface
  57867. {
  57868. if (!isset($this->typeCheck[$this->checkMode])) {
  57869. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  57870. ? new TypeCheck\LooseTypeCheck()
  57871. : new TypeCheck\StrictTypeCheck();
  57872. }
  57873. return $this->typeCheck[$this->checkMode];
  57874. }
  57875. public function setConstraintClass(string $name, string $class): Factory
  57876. {
  57877. if (!class_exists($class)) {
  57878. throw new InvalidArgumentException('Unknown constraint ' . $name);
  57879. }
  57880. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  57881. throw new InvalidArgumentException('Invalid class ' . $name);
  57882. }
  57883. $this->constraintMap[$name] = $class;
  57884. return $this;
  57885. }
  57886. public function createInstanceFor($constraintName)
  57887. {
  57888. if (!isset($this->constraintMap[$constraintName])) {
  57889. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  57890. }
  57891. if (!isset($this->instanceCache[$constraintName])) {
  57892. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  57893. }
  57894. return clone $this->instanceCache[$constraintName];
  57895. }
  57896. public function getErrorContext(): int
  57897. {
  57898. return $this->errorContext;
  57899. }
  57900. public function setErrorContext(int $errorContext): void
  57901. {
  57902. $this->errorContext = $errorContext;
  57903. }
  57904. }
  57905. <?php
  57906. declare(strict_types=1);
  57907. namespace JsonSchema\Constraints;
  57908. use JsonSchema\ConstraintError;
  57909. use JsonSchema\Entity\JsonPointer;
  57910. use JsonSchema\Rfc3339;
  57911. use JsonSchema\Tool\Validator\RelativeReferenceValidator;
  57912. use JsonSchema\Tool\Validator\UriValidator;
  57913. class FormatConstraint extends Constraint
  57914. {
  57915. public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
  57916. {
  57917. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  57918. return;
  57919. }
  57920. switch ($schema->format) {
  57921. case 'date':
  57922. if (is_string($element) && !$date = $this->validateDateTime($element, 'Y-m-d')) {
  57923. $this->addError(ConstraintError::FORMAT_DATE(), $path, [
  57924. 'date' => $element,
  57925. 'format' => $schema->format
  57926. ]
  57927. );
  57928. }
  57929. break;
  57930. case 'time':
  57931. if (is_string($element) && !$this->validateDateTime($element, 'H:i:s')) {
  57932. $this->addError(ConstraintError::FORMAT_TIME(), $path, [
  57933. 'time' => json_encode($element),
  57934. 'format' => $schema->format,
  57935. ]
  57936. );
  57937. }
  57938. break;
  57939. case 'date-time':
  57940. if (is_string($element) && null === Rfc3339::createFromString($element)) {
  57941. $this->addError(ConstraintError::FORMAT_DATE_TIME(), $path, [
  57942. 'dateTime' => json_encode($element),
  57943. 'format' => $schema->format
  57944. ]
  57945. );
  57946. }
  57947. break;
  57948. case 'utc-millisec':
  57949. if (!$this->validateDateTime($element, 'U')) {
  57950. $this->addError(ConstraintError::FORMAT_DATE_UTC(), $path, [
  57951. 'value' => $element,
  57952. 'format' => $schema->format]);
  57953. }
  57954. break;
  57955. case 'regex':
  57956. if (!$this->validateRegex($element)) {
  57957. $this->addError(ConstraintError::FORMAT_REGEX(), $path, [
  57958. 'value' => $element,
  57959. 'format' => $schema->format
  57960. ]
  57961. );
  57962. }
  57963. break;
  57964. case 'color':
  57965. if (!$this->validateColor($element)) {
  57966. $this->addError(ConstraintError::FORMAT_COLOR(), $path, ['format' => $schema->format]);
  57967. }
  57968. break;
  57969. case 'style':
  57970. if (!$this->validateStyle($element)) {
  57971. $this->addError(ConstraintError::FORMAT_STYLE(), $path, ['format' => $schema->format]);
  57972. }
  57973. break;
  57974. case 'phone':
  57975. if (!$this->validatePhone($element)) {
  57976. $this->addError(ConstraintError::FORMAT_PHONE(), $path, ['format' => $schema->format]);
  57977. }
  57978. break;
  57979. case 'uri':
  57980. if (is_string($element) && !UriValidator::isValid($element)) {
  57981. $this->addError(ConstraintError::FORMAT_URL(), $path, ['format' => $schema->format]);
  57982. }
  57983. break;
  57984. case 'uriref':
  57985. case 'uri-reference':
  57986. if (is_string($element) && !(UriValidator::isValid($element) || RelativeReferenceValidator::isValid($element))) {
  57987. $this->addError(ConstraintError::FORMAT_URL(), $path, ['format' => $schema->format]);
  57988. }
  57989. break;
  57990. case 'email':
  57991. if (is_string($element) && null === filter_var($element, FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE | FILTER_FLAG_EMAIL_UNICODE)) {
  57992. $this->addError(ConstraintError::FORMAT_EMAIL(), $path, ['format' => $schema->format]);
  57993. }
  57994. break;
  57995. case 'ip-address':
  57996. case 'ipv4':
  57997. if (is_string($element) && null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  57998. $this->addError(ConstraintError::FORMAT_IP(), $path, ['format' => $schema->format]);
  57999. }
  58000. break;
  58001. case 'ipv6':
  58002. if (is_string($element) && null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  58003. $this->addError(ConstraintError::FORMAT_IP(), $path, ['format' => $schema->format]);
  58004. }
  58005. break;
  58006. case 'host-name':
  58007. case 'hostname':
  58008. if (!$this->validateHostname($element)) {
  58009. $this->addError(ConstraintError::FORMAT_HOSTNAME(), $path, ['format' => $schema->format]);
  58010. }
  58011. break;
  58012. default:
  58013. break;
  58014. }
  58015. }
  58016. protected function validateDateTime($datetime, $format)
  58017. {
  58018. $dt = \DateTime::createFromFormat($format, (string) $datetime);
  58019. if (!$dt) {
  58020. return false;
  58021. }
  58022. if ($datetime === $dt->format($format)) {
  58023. return true;
  58024. }
  58025. return false;
  58026. }
  58027. protected function validateRegex($regex)
  58028. {
  58029. if (!is_string($regex)) {
  58030. return true;
  58031. }
  58032. return false !== @preg_match(self::jsonPatternToPhpRegex($regex), '');
  58033. }
  58034. protected function validateColor($color)
  58035. {
  58036. if (!is_string($color)) {
  58037. return true;
  58038. }
  58039. if (in_array(strtolower($color), ['aqua', 'black', 'blue', 'fuchsia',
  58040. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  58041. 'red', 'silver', 'teal', 'white', 'yellow'])) {
  58042. return true;
  58043. }
  58044. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  58045. }
  58046. protected function validateStyle($style)
  58047. {
  58048. $properties = explode(';', rtrim($style, ';'));
  58049. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  58050. return empty($invalidEntries);
  58051. }
  58052. protected function validatePhone($phone)
  58053. {
  58054. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  58055. }
  58056. protected function validateHostname($host)
  58057. {
  58058. if (!is_string($host)) {
  58059. return true;
  58060. }
  58061. $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';
  58062. return preg_match($hostnameRegex, $host);
  58063. }
  58064. }
  58065. <?php
  58066. declare(strict_types=1);
  58067. namespace JsonSchema\Constraints;
  58068. use JsonSchema\ConstraintError;
  58069. use JsonSchema\Entity\JsonPointer;
  58070. class NumberConstraint extends Constraint
  58071. {
  58072. public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
  58073. {
  58074. if (isset($schema->exclusiveMinimum)) {
  58075. if (isset($schema->minimum)) {
  58076. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  58077. $this->addError(ConstraintError::EXCLUSIVE_MINIMUM(), $path, ['minimum' => $schema->minimum]);
  58078. } elseif ($element < $schema->minimum) {
  58079. $this->addError(ConstraintError::MINIMUM(), $path, ['minimum' => $schema->minimum]);
  58080. }
  58081. } else {
  58082. $this->addError(ConstraintError::MISSING_MINIMUM(), $path);
  58083. }
  58084. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  58085. $this->addError(ConstraintError::MINIMUM(), $path, ['minimum' => $schema->minimum]);
  58086. }
  58087. if (isset($schema->exclusiveMaximum)) {
  58088. if (isset($schema->maximum)) {
  58089. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  58090. $this->addError(ConstraintError::EXCLUSIVE_MAXIMUM(), $path, ['maximum' => $schema->maximum]);
  58091. } elseif ($element > $schema->maximum) {
  58092. $this->addError(ConstraintError::MAXIMUM(), $path, ['maximum' => $schema->maximum]);
  58093. }
  58094. } else {
  58095. $this->addError(ConstraintError::MISSING_MAXIMUM(), $path);
  58096. }
  58097. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  58098. $this->addError(ConstraintError::MAXIMUM(), $path, ['maximum' => $schema->maximum]);
  58099. }
  58100. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  58101. $this->addError(ConstraintError::DIVISIBLE_BY(), $path, ['divisibleBy' => $schema->divisibleBy]);
  58102. }
  58103. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  58104. $this->addError(ConstraintError::MULTIPLE_OF(), $path, ['multipleOf' => $schema->multipleOf]);
  58105. }
  58106. $this->checkFormat($element, $schema, $path, $i);
  58107. }
  58108. private function fmod($number1, $number2)
  58109. {
  58110. $modulus = ($number1 - round($number1 / $number2) * $number2);
  58111. $precision = 0.0000000001;
  58112. if (-$precision < $modulus && $modulus < $precision) {
  58113. return 0.0;
  58114. }
  58115. return $modulus;
  58116. }
  58117. }
  58118. <?php
  58119. declare(strict_types=1);
  58120. namespace JsonSchema\Constraints;
  58121. use JsonSchema\ConstraintError;
  58122. use JsonSchema\Entity\JsonPointer;
  58123. class ObjectConstraint extends Constraint
  58124. {
  58125. protected $appliedDefaults = [];
  58126. public function check(&$element, $schema = null, ?JsonPointer $path = null, $properties = null,
  58127. $additionalProp = null, $patternProperties = null, $appliedDefaults = []): void
  58128. {
  58129. if ($element instanceof UndefinedConstraint) {
  58130. return;
  58131. }
  58132. $this->appliedDefaults = $appliedDefaults;
  58133. $matches = [];
  58134. if ($patternProperties) {
  58135. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  58136. }
  58137. if ($properties) {
  58138. $this->validateProperties($element, $properties, $path);
  58139. }
  58140. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  58141. }
  58142. public function validatePatternProperties($element, ?JsonPointer $path, $patternProperties)
  58143. {
  58144. $matches = [];
  58145. foreach ($patternProperties as $pregex => $schema) {
  58146. $fullRegex = self::jsonPatternToPhpRegex($pregex);
  58147. if (@preg_match($fullRegex, '') === false) {
  58148. $this->addError(ConstraintError::PREGEX_INVALID(), $path, ['pregex' => $pregex]);
  58149. continue;
  58150. }
  58151. foreach ($element as $i => $value) {
  58152. if (preg_match($fullRegex, $i)) {
  58153. $matches[] = $i;
  58154. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  58155. }
  58156. }
  58157. }
  58158. return $matches;
  58159. }
  58160. public function validateElement($element, $matches, $schema = null, ?JsonPointer $path = null,
  58161. $properties = null, $additionalProp = null)
  58162. {
  58163. $this->validateMinMaxConstraint($element, $schema, $path);
  58164. foreach ($element as $i => $value) {
  58165. $definition = $this->getProperty($properties, $i);
  58166. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  58167. $this->addError(ConstraintError::ADDITIONAL_PROPERTIES(), $path, ['property' => $i]);
  58168. }
  58169. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  58170. if ($additionalProp === true) {
  58171. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  58172. } else {
  58173. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  58174. }
  58175. }
  58176. $require = $this->getProperty($definition, 'requires');
  58177. if ($require && !$this->getProperty($element, $require)) {
  58178. $this->addError(ConstraintError::REQUIRES(), $path, [
  58179. 'property' => $i,
  58180. 'requiredProperty' => $require
  58181. ]);
  58182. }
  58183. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  58184. if (is_object($property)) {
  58185. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  58186. }
  58187. }
  58188. }
  58189. public function validateProperties(&$element, $properties = null, ?JsonPointer $path = null)
  58190. {
  58191. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  58192. foreach ($properties as $i => $value) {
  58193. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  58194. $definition = $this->getProperty($properties, $i);
  58195. if (is_object($definition)) {
  58196. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  58197. }
  58198. }
  58199. }
  58200. protected function &getProperty(&$element, $property, $fallback = null)
  58201. {
  58202. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  58203. return $element[$property];
  58204. } elseif (is_object($element) && property_exists($element, (string) $property)) {
  58205. return $element->$property;
  58206. }
  58207. return $fallback;
  58208. }
  58209. protected function validateMinMaxConstraint($element, $objectDefinition, ?JsonPointer $path = null)
  58210. {
  58211. if (!$this->getTypeCheck()::isObject($element)) {
  58212. return;
  58213. }
  58214. if (isset($objectDefinition->minProperties) && is_int($objectDefinition->minProperties)) {
  58215. if ($this->getTypeCheck()->propertyCount($element) < max(0, $objectDefinition->minProperties)) {
  58216. $this->addError(ConstraintError::PROPERTIES_MIN(), $path, ['minProperties' => $objectDefinition->minProperties]);
  58217. }
  58218. }
  58219. if (isset($objectDefinition->maxProperties) && is_int($objectDefinition->maxProperties)) {
  58220. if ($this->getTypeCheck()->propertyCount($element) > max(0, $objectDefinition->maxProperties)) {
  58221. $this->addError(ConstraintError::PROPERTIES_MAX(), $path, ['maxProperties' => $objectDefinition->maxProperties]);
  58222. }
  58223. }
  58224. }
  58225. }
  58226. <?php
  58227. declare(strict_types=1);
  58228. namespace JsonSchema\Constraints;
  58229. use JsonSchema\ConstraintError;
  58230. use JsonSchema\Entity\JsonPointer;
  58231. use JsonSchema\Exception\InvalidArgumentException;
  58232. use JsonSchema\Exception\InvalidSchemaException;
  58233. use JsonSchema\Exception\RuntimeException;
  58234. use JsonSchema\Validator;
  58235. class SchemaConstraint extends Constraint
  58236. {
  58237. private const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  58238. public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
  58239. {
  58240. if ($schema !== null) {
  58241. $validationSchema = $schema;
  58242. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  58243. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  58244. } else {
  58245. throw new InvalidArgumentException('no schema found to verify against');
  58246. }
  58247. if (is_array($validationSchema)) {
  58248. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  58249. }
  58250. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  58251. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  58252. throw new RuntimeException('Cannot validate the schema of a non-object');
  58253. }
  58254. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  58255. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  58256. } else {
  58257. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  58258. }
  58259. $schemaStorage = $this->factory->getSchemaStorage();
  58260. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  58261. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  58262. }
  58263. $initialErrorCount = $this->numErrors();
  58264. $initialConfig = $this->factory->getConfig();
  58265. $initialContext = $this->factory->getErrorContext();
  58266. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  58267. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  58268. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  58269. try {
  58270. $this->check($validationSchema, $schemaSpec);
  58271. } catch (\Exception $e) {
  58272. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  58273. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  58274. }
  58275. }
  58276. if ($this->numErrors() > $initialErrorCount) {
  58277. $this->addError(ConstraintError::INVALID_SCHEMA(), $path);
  58278. }
  58279. $this->factory->setConfig($initialConfig);
  58280. $this->factory->setErrorContext($initialContext);
  58281. }
  58282. $this->checkUndefined($element, $validationSchema, $path, $i);
  58283. }
  58284. }
  58285. <?php
  58286. declare(strict_types=1);
  58287. namespace JsonSchema\Constraints;
  58288. use JsonSchema\ConstraintError;
  58289. use JsonSchema\Entity\JsonPointer;
  58290. class StringConstraint extends Constraint
  58291. {
  58292. public function check(&$element, $schema = null, ?JsonPointer $path = null, $i = null): void
  58293. {
  58294. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  58295. $this->addError(ConstraintError::LENGTH_MAX(), $path, [
  58296. 'maxLength' => $schema->maxLength,
  58297. ]);
  58298. }
  58299. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  58300. $this->addError(ConstraintError::LENGTH_MIN(), $path, [
  58301. 'minLength' => $schema->minLength,
  58302. ]);
  58303. }
  58304. if (isset($schema->pattern) && !preg_match(self::jsonPatternToPhpRegex($schema->pattern), $element)) {
  58305. $this->addError(ConstraintError::PATTERN(), $path, [
  58306. 'pattern' => $schema->pattern,
  58307. ]);
  58308. }
  58309. $this->checkFormat($element, $schema, $path, $i);
  58310. }
  58311. private function strlen($string)
  58312. {
  58313. if (extension_loaded('mbstring')) {
  58314. return mb_strlen($string, mb_detect_encoding($string));
  58315. }
  58316. return strlen($string);
  58317. }
  58318. }
  58319. <?php
  58320. declare(strict_types=1);
  58321. namespace JsonSchema\Constraints\TypeCheck;
  58322. class LooseTypeCheck implements TypeCheckInterface
  58323. {
  58324. public static function isObject($value)
  58325. {
  58326. return
  58327. is_object($value) ||
  58328. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  58329. }
  58330. public static function isArray($value)
  58331. {
  58332. return
  58333. is_array($value) &&
  58334. (count($value) == 0 || !self::isAssociativeArray($value));
  58335. }
  58336. public static function propertyGet($value, $property)
  58337. {
  58338. if (is_object($value)) {
  58339. return $value->{$property};
  58340. }
  58341. return $value[$property];
  58342. }
  58343. public static function propertySet(&$value, $property, $data)
  58344. {
  58345. if (is_object($value)) {
  58346. $value->{$property} = $data;
  58347. } else {
  58348. $value[$property] = $data;
  58349. }
  58350. }
  58351. public static function propertyExists($value, $property)
  58352. {
  58353. if (is_object($value)) {
  58354. return property_exists($value, $property);
  58355. }
  58356. return is_array($value) && array_key_exists($property, $value);
  58357. }
  58358. public static function propertyCount($value)
  58359. {
  58360. if (is_object($value)) {
  58361. return count(get_object_vars($value));
  58362. }
  58363. return count($value);
  58364. }
  58365. private static function isAssociativeArray($arr)
  58366. {
  58367. return array_keys($arr) !== range(0, count($arr) - 1);
  58368. }
  58369. }
  58370. <?php
  58371. declare(strict_types=1);
  58372. namespace JsonSchema\Constraints\TypeCheck;
  58373. class StrictTypeCheck implements TypeCheckInterface
  58374. {
  58375. public static function isObject($value)
  58376. {
  58377. return is_object($value);
  58378. }
  58379. public static function isArray($value)
  58380. {
  58381. return is_array($value);
  58382. }
  58383. public static function propertyGet($value, $property)
  58384. {
  58385. return $value->{$property};
  58386. }
  58387. public static function propertySet(&$value, $property, $data)
  58388. {
  58389. $value->{$property} = $data;
  58390. }
  58391. public static function propertyExists($value, $property)
  58392. {
  58393. return property_exists($value, $property);
  58394. }
  58395. public static function propertyCount($value)
  58396. {
  58397. if (!is_object($value)) {
  58398. return 0;
  58399. }
  58400. return count(get_object_vars($value));
  58401. }
  58402. }
  58403. <?php
  58404. declare(strict_types=1);
  58405. namespace JsonSchema\Constraints\TypeCheck;
  58406. interface TypeCheckInterface
  58407. {
  58408. public static function isObject($value);
  58409. public static function isArray($value);
  58410. public static function propertyGet($value, $property);
  58411. public static function propertySet(&$value, $property, $data);
  58412. public static function propertyExists($value, $property);
  58413. public static function propertyCount($value);
  58414. }
  58415. <?php
  58416. declare(strict_types=1);
  58417. namespace JsonSchema\Constraints;
  58418. use JsonSchema\ConstraintError;
  58419. use JsonSchema\Entity\JsonPointer;
  58420. use JsonSchema\Exception\InvalidArgumentException;
  58421. use UnexpectedValueException as StandardUnexpectedValueException;
  58422. class TypeConstraint extends Constraint
  58423. {
  58424. public static $wording = [
  58425. 'integer' => 'an integer',
  58426. 'number' => 'a number',
  58427. 'boolean' => 'a boolean',
  58428. 'object' => 'an object',
  58429. 'array' => 'an array',
  58430. 'string' => 'a string',
  58431. 'null' => 'a null',
  58432. 'any' => null,
  58433. 0 => null,
  58434. ];
  58435. public function check(&$value = null, $schema = null, ?JsonPointer $path = null, $i = null): void
  58436. {
  58437. $type = isset($schema->type) ? $schema->type : null;
  58438. $isValid = false;
  58439. $coerce = $this->factory->getConfig(self::CHECK_MODE_COERCE_TYPES);
  58440. $earlyCoerce = $this->factory->getConfig(self::CHECK_MODE_EARLY_COERCE);
  58441. $wording = [];
  58442. if (is_array($type)) {
  58443. $this->validateTypesArray($value, $type, $wording, $isValid, $path, $coerce && $earlyCoerce);
  58444. if (!$isValid && $coerce && !$earlyCoerce) {
  58445. $this->validateTypesArray($value, $type, $wording, $isValid, $path, true);
  58446. }
  58447. } elseif (is_object($type)) {
  58448. $this->checkUndefined($value, $type, $path);
  58449. return;
  58450. } else {
  58451. $isValid = $this->validateType($value, $type, $coerce && $earlyCoerce);
  58452. if (!$isValid && $coerce && !$earlyCoerce) {
  58453. $isValid = $this->validateType($value, $type, true);
  58454. }
  58455. }
  58456. if ($isValid === false) {
  58457. if (!is_array($type)) {
  58458. $this->validateTypeNameWording($type);
  58459. $wording[] = self::$wording[$type];
  58460. }
  58461. $this->addError(ConstraintError::TYPE(), $path, [
  58462. 'found' => gettype($value),
  58463. 'expected' => $this->implodeWith($wording, ', ', 'or')
  58464. ]);
  58465. }
  58466. }
  58467. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path, $coerce = false)
  58468. {
  58469. foreach ($type as $tp) {
  58470. if ($isValid) {
  58471. return;
  58472. }
  58473. if (is_object($tp)) {
  58474. if (!$isValid) {
  58475. $validator = $this->factory->createInstanceFor('type');
  58476. $subSchema = new \stdClass();
  58477. $subSchema->type = $tp;
  58478. $validator->check($value, $subSchema, $path, null);
  58479. $error = $validator->getErrors();
  58480. $isValid = !(bool) $error;
  58481. $validTypesWording[] = self::$wording['object'];
  58482. }
  58483. } else {
  58484. $this->validateTypeNameWording($tp);
  58485. $validTypesWording[] = self::$wording[$tp];
  58486. if (!$isValid) {
  58487. $isValid = $this->validateType($value, $tp, $coerce);
  58488. }
  58489. }
  58490. }
  58491. }
  58492. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  58493. {
  58494. if ($listEnd === false || !isset($elements[1])) {
  58495. return implode($delimiter, $elements);
  58496. }
  58497. $lastElement = array_slice($elements, -1);
  58498. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  58499. $implodedElements = array_merge([$firsElements], $lastElement);
  58500. return join(" $listEnd ", $implodedElements);
  58501. }
  58502. protected function validateTypeNameWording($type)
  58503. {
  58504. if (!array_key_exists($type, self::$wording)) {
  58505. throw new StandardUnexpectedValueException(
  58506. sprintf(
  58507. 'No wording for %s available, expected wordings are: [%s]',
  58508. var_export($type, true),
  58509. implode(', ', array_filter(self::$wording)))
  58510. );
  58511. }
  58512. }
  58513. protected function validateType(&$value, $type, $coerce = false)
  58514. {
  58515. if (!$type) {
  58516. return true;
  58517. }
  58518. if ('any' === $type) {
  58519. return true;
  58520. }
  58521. if ('object' === $type) {
  58522. return $this->getTypeCheck()->isObject($value);
  58523. }
  58524. if ('array' === $type) {
  58525. if ($coerce) {
  58526. $value = $this->toArray($value);
  58527. }
  58528. return $this->getTypeCheck()->isArray($value);
  58529. }
  58530. if ('integer' === $type) {
  58531. if ($coerce) {
  58532. $value = $this->toInteger($value);
  58533. }
  58534. return is_int($value);
  58535. }
  58536. if ('number' === $type) {
  58537. if ($coerce) {
  58538. $value = $this->toNumber($value);
  58539. }
  58540. return is_numeric($value) && !is_string($value);
  58541. }
  58542. if ('boolean' === $type) {
  58543. if ($coerce) {
  58544. $value = $this->toBoolean($value);
  58545. }
  58546. return is_bool($value);
  58547. }
  58548. if ('string' === $type) {
  58549. if ($coerce) {
  58550. $value = $this->toString($value);
  58551. }
  58552. return is_string($value);
  58553. }
  58554. if ('null' === $type) {
  58555. if ($coerce) {
  58556. $value = $this->toNull($value);
  58557. }
  58558. return is_null($value);
  58559. }
  58560. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  58561. }
  58562. protected function toBoolean($value)
  58563. {
  58564. if ($value === 1 || $value === 'true') {
  58565. return true;
  58566. }
  58567. if (is_null($value) || $value === 0 || $value === 'false') {
  58568. return false;
  58569. }
  58570. if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
  58571. return $this->toBoolean(reset($value));
  58572. }
  58573. return $value;
  58574. }
  58575. protected function toNumber($value)
  58576. {
  58577. if (is_numeric($value)) {
  58578. return $value + 0;
  58579. }
  58580. if (is_bool($value) || is_null($value)) {
  58581. return (int) $value;
  58582. }
  58583. if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
  58584. return $this->toNumber(reset($value));
  58585. }
  58586. return $value;
  58587. }
  58588. protected function toInteger($value)
  58589. {
  58590. $numberValue = $this->toNumber($value);
  58591. if (is_numeric($numberValue) && (int) $numberValue == $numberValue) {
  58592. return (int) $numberValue;
  58593. }
  58594. return $value;
  58595. }
  58596. protected function toArray($value)
  58597. {
  58598. if (is_scalar($value) || is_null($value)) {
  58599. return [$value];
  58600. }
  58601. return $value;
  58602. }
  58603. protected function toString($value)
  58604. {
  58605. if (is_numeric($value)) {
  58606. return "$value";
  58607. }
  58608. if ($value === true) {
  58609. return 'true';
  58610. }
  58611. if ($value === false) {
  58612. return 'false';
  58613. }
  58614. if (is_null($value)) {
  58615. return '';
  58616. }
  58617. if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
  58618. return $this->toString(reset($value));
  58619. }
  58620. return $value;
  58621. }
  58622. protected function toNull($value)
  58623. {
  58624. if ($value === 0 || $value === false || $value === '') {
  58625. return null;
  58626. }
  58627. if ($this->getTypeCheck()->isArray($value) && count($value) === 1) {
  58628. return $this->toNull(reset($value));
  58629. }
  58630. return $value;
  58631. }
  58632. }
  58633. <?php
  58634. declare(strict_types=1);
  58635. namespace JsonSchema\Constraints;
  58636. use JsonSchema\ConstraintError;
  58637. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  58638. use JsonSchema\Entity\JsonPointer;
  58639. use JsonSchema\Exception\ValidationException;
  58640. use JsonSchema\Tool\DeepCopy;
  58641. use JsonSchema\Uri\UriResolver;
  58642. #[\AllowDynamicProperties]
  58643. class UndefinedConstraint extends Constraint
  58644. {
  58645. protected $appliedDefaults = [];
  58646. public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = null, $fromDefault = false): void
  58647. {
  58648. if (is_null($schema) || !is_object($schema)) {
  58649. return;
  58650. }
  58651. $path = $this->incrementPath($path, $i);
  58652. if ($fromDefault) {
  58653. $path->setFromDefault();
  58654. }
  58655. $this->validateCommonProperties($value, $schema, $path, $i);
  58656. $this->validateOfProperties($value, $schema, $path, '');
  58657. $this->validateTypes($value, $schema, $path, $i);
  58658. }
  58659. public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
  58660. {
  58661. if ($this->getTypeCheck()->isArray($value)) {
  58662. $this->checkArray($value, $schema, $path, $i);
  58663. }
  58664. if (LooseTypeCheck::isObject($value)) {
  58665. $this->checkObject(
  58666. $value,
  58667. $schema,
  58668. $path,
  58669. isset($schema->properties) ? $schema->properties : null,
  58670. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  58671. isset($schema->patternProperties) ? $schema->patternProperties : null,
  58672. $this->appliedDefaults
  58673. );
  58674. }
  58675. if (is_string($value)) {
  58676. $this->checkString($value, $schema, $path, $i);
  58677. }
  58678. if (is_numeric($value)) {
  58679. $this->checkNumber($value, $schema, $path, $i);
  58680. }
  58681. if (isset($schema->enum)) {
  58682. $this->checkEnum($value, $schema, $path, $i);
  58683. }
  58684. if (isset($schema->const)) {
  58685. $this->checkConst($value, $schema, $path, $i);
  58686. }
  58687. }
  58688. protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
  58689. {
  58690. if (isset($schema->extends)) {
  58691. if (is_string($schema->extends)) {
  58692. $schema->extends = $this->validateUri($schema, $schema->extends);
  58693. }
  58694. if (is_array($schema->extends)) {
  58695. foreach ($schema->extends as $extends) {
  58696. $this->checkUndefined($value, $extends, $path, $i);
  58697. }
  58698. } else {
  58699. $this->checkUndefined($value, $schema->extends, $path, $i);
  58700. }
  58701. }
  58702. if (!$path->fromDefault()) {
  58703. $this->applyDefaultValues($value, $schema, $path);
  58704. }
  58705. if ($this->getTypeCheck()->isObject($value)) {
  58706. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  58707. foreach ($schema->required as $required) {
  58708. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  58709. $this->addError(
  58710. ConstraintError::REQUIRED(),
  58711. $this->incrementPath($path, $required), [
  58712. 'property' => $required
  58713. ]
  58714. );
  58715. }
  58716. }
  58717. } elseif (isset($schema->required) && !is_array($schema->required)) {
  58718. if ($schema->required && $value instanceof self) {
  58719. $propertyPaths = $path->getPropertyPaths();
  58720. $propertyName = end($propertyPaths);
  58721. $this->addError(ConstraintError::REQUIRED(), $path, ['property' => $propertyName]);
  58722. }
  58723. } else {
  58724. if ($value instanceof self) {
  58725. return;
  58726. }
  58727. }
  58728. }
  58729. if (!($value instanceof self)) {
  58730. $this->checkType($value, $schema, $path, $i);
  58731. }
  58732. if (isset($schema->disallow)) {
  58733. $initErrors = $this->getErrors();
  58734. $typeSchema = new \stdClass();
  58735. $typeSchema->type = $schema->disallow;
  58736. $this->checkType($value, $typeSchema, $path);
  58737. if (count($this->getErrors()) == count($initErrors)) {
  58738. $this->addError(ConstraintError::DISALLOW(), $path);
  58739. } else {
  58740. $this->errors = $initErrors;
  58741. }
  58742. }
  58743. if (isset($schema->not)) {
  58744. $initErrors = $this->getErrors();
  58745. $this->checkUndefined($value, $schema->not, $path, $i);
  58746. if (count($this->getErrors()) == count($initErrors)) {
  58747. $this->addError(ConstraintError::NOT(), $path);
  58748. } else {
  58749. $this->errors = $initErrors;
  58750. }
  58751. }
  58752. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  58753. $this->validateDependencies($value, $schema->dependencies, $path);
  58754. }
  58755. }
  58756. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  58757. {
  58758. if (!$requiredOnly) {
  58759. return true;
  58760. }
  58761. if (
  58762. $name !== null
  58763. && isset($parentSchema->required)
  58764. && is_array($parentSchema->required)
  58765. && in_array($name, $parentSchema->required)
  58766. ) {
  58767. return true;
  58768. }
  58769. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  58770. return true;
  58771. }
  58772. return false;
  58773. }
  58774. protected function applyDefaultValues(&$value, $schema, $path): void
  58775. {
  58776. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  58777. return;
  58778. }
  58779. $requiredOnly = (bool) $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  58780. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  58781. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  58782. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  58783. if (
  58784. !LooseTypeCheck::propertyExists($value, $currentProperty)
  58785. && property_exists($propertyDefinition, 'default')
  58786. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  58787. ) {
  58788. if (is_object($propertyDefinition->default)) {
  58789. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  58790. } else {
  58791. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  58792. }
  58793. $this->appliedDefaults[] = $currentProperty;
  58794. }
  58795. }
  58796. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  58797. $items = [];
  58798. if (LooseTypeCheck::isArray($schema->items)) {
  58799. $items = $schema->items;
  58800. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  58801. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  58802. }
  58803. foreach ($items as $currentItem => $itemDefinition) {
  58804. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  58805. if (
  58806. !array_key_exists($currentItem, $value)
  58807. && property_exists($itemDefinition, 'default')
  58808. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  58809. if (is_object($itemDefinition->default)) {
  58810. $value[$currentItem] = clone $itemDefinition->default;
  58811. } else {
  58812. $value[$currentItem] = $itemDefinition->default;
  58813. }
  58814. }
  58815. $path->setFromDefault();
  58816. }
  58817. } elseif (
  58818. $value instanceof self
  58819. && property_exists($schema, 'default')
  58820. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  58821. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  58822. $path->setFromDefault();
  58823. }
  58824. }
  58825. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  58826. {
  58827. if ($value instanceof self) {
  58828. return;
  58829. }
  58830. if (isset($schema->allOf)) {
  58831. $isValid = true;
  58832. foreach ($schema->allOf as $allOf) {
  58833. $initErrors = $this->getErrors();
  58834. $this->checkUndefined($value, $allOf, $path, $i);
  58835. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  58836. }
  58837. if (!$isValid) {
  58838. $this->addError(ConstraintError::ALL_OF(), $path);
  58839. }
  58840. }
  58841. if (isset($schema->anyOf)) {
  58842. $isValid = false;
  58843. $startErrors = $this->getErrors();
  58844. $coerceOrDefaults = $this->factory->getConfig(self::CHECK_MODE_COERCE_TYPES | self::CHECK_MODE_APPLY_DEFAULTS);
  58845. foreach ($schema->anyOf as $anyOf) {
  58846. $initErrors = $this->getErrors();
  58847. try {
  58848. $anyOfValue = $coerceOrDefaults ? DeepCopy::copyOf($value) : $value;
  58849. $this->checkUndefined($anyOfValue, $anyOf, $path, $i);
  58850. if ($isValid = (count($this->getErrors()) === count($initErrors))) {
  58851. $value = $anyOfValue;
  58852. break;
  58853. }
  58854. } catch (ValidationException $e) {
  58855. $isValid = false;
  58856. }
  58857. }
  58858. if (!$isValid) {
  58859. $this->addError(ConstraintError::ANY_OF(), $path);
  58860. } else {
  58861. $this->errors = $startErrors;
  58862. }
  58863. }
  58864. if (isset($schema->oneOf)) {
  58865. $allErrors = [];
  58866. $matchedSchemas = [];
  58867. $startErrors = $this->getErrors();
  58868. $coerceOrDefaults = $this->factory->getConfig(self::CHECK_MODE_COERCE_TYPES | self::CHECK_MODE_APPLY_DEFAULTS);
  58869. foreach ($schema->oneOf as $oneOf) {
  58870. try {
  58871. $this->errors = [];
  58872. $oneOfValue = $coerceOrDefaults ? DeepCopy::copyOf($value) : $value;
  58873. $this->checkUndefined($oneOfValue, $oneOf, $path, $i);
  58874. if (count($this->getErrors()) === 0) {
  58875. $matchedSchemas[] = ['schema' => $oneOf, 'value' => $oneOfValue];
  58876. }
  58877. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  58878. } catch (ValidationException $e) {
  58879. }
  58880. }
  58881. if (count($matchedSchemas) !== 1) {
  58882. $this->addErrors(array_merge($allErrors, $startErrors));
  58883. $this->addError(ConstraintError::ONE_OF(), $path);
  58884. } else {
  58885. $this->errors = $startErrors;
  58886. $value = $matchedSchemas[0]['value'];
  58887. }
  58888. }
  58889. }
  58890. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  58891. {
  58892. foreach ($dependencies as $key => $dependency) {
  58893. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  58894. if (is_string($dependency)) {
  58895. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  58896. $this->addError(ConstraintError::DEPENDENCIES(), $path, [
  58897. 'key' => $key,
  58898. 'dependency' => $dependency
  58899. ]);
  58900. }
  58901. } elseif (is_array($dependency)) {
  58902. foreach ($dependency as $d) {
  58903. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  58904. $this->addError(ConstraintError::DEPENDENCIES(), $path, [
  58905. 'key' => $key,
  58906. 'dependency' => $dependency
  58907. ]);
  58908. }
  58909. }
  58910. } elseif (is_object($dependency)) {
  58911. $this->checkUndefined($value, $dependency, $path, $i);
  58912. }
  58913. }
  58914. }
  58915. }
  58916. protected function validateUri($schema, $schemaUri = null)
  58917. {
  58918. $resolver = new UriResolver();
  58919. $retriever = $this->factory->getUriRetriever();
  58920. $jsonSchema = null;
  58921. if ($resolver->isValid($schemaUri)) {
  58922. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  58923. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  58924. }
  58925. return $jsonSchema;
  58926. }
  58927. }
  58928. <?php
  58929. declare(strict_types=1);
  58930. namespace JsonSchema\Entity;
  58931. use JsonSchema\Exception\InvalidArgumentException;
  58932. class JsonPointer
  58933. {
  58934. private $filename;
  58935. private $propertyPaths = [];
  58936. private $fromDefault = false;
  58937. public function __construct($value)
  58938. {
  58939. if (!is_string($value)) {
  58940. throw new InvalidArgumentException('Ref value must be a string');
  58941. }
  58942. $splitRef = explode('#', $value, 2);
  58943. $this->filename = $splitRef[0];
  58944. if (array_key_exists(1, $splitRef)) {
  58945. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  58946. }
  58947. }
  58948. private function decodePropertyPaths($propertyPathString)
  58949. {
  58950. $paths = [];
  58951. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  58952. $path = $this->decodePath($path);
  58953. if (is_string($path) && '' !== $path) {
  58954. $paths[] = $path;
  58955. }
  58956. }
  58957. return $paths;
  58958. }
  58959. private function encodePropertyPaths()
  58960. {
  58961. return array_map(
  58962. [$this, 'encodePath'],
  58963. $this->getPropertyPaths()
  58964. );
  58965. }
  58966. private function decodePath($path)
  58967. {
  58968. return strtr($path, ['~1' => '/', '~0' => '~', '%25' => '%']);
  58969. }
  58970. private function encodePath($path)
  58971. {
  58972. return strtr($path, ['/' => '~1', '~' => '~0', '%' => '%25']);
  58973. }
  58974. public function getFilename()
  58975. {
  58976. return $this->filename;
  58977. }
  58978. public function getPropertyPaths()
  58979. {
  58980. return $this->propertyPaths;
  58981. }
  58982. public function withPropertyPaths(array $propertyPaths)
  58983. {
  58984. $new = clone $this;
  58985. $new->propertyPaths = array_map(function ($p): string { return (string) $p; }, $propertyPaths);
  58986. return $new;
  58987. }
  58988. public function getPropertyPathAsString()
  58989. {
  58990. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  58991. }
  58992. public function __toString()
  58993. {
  58994. return $this->getFilename() . $this->getPropertyPathAsString();
  58995. }
  58996. public function setFromDefault()
  58997. {
  58998. $this->fromDefault = true;
  58999. }
  59000. public function fromDefault()
  59001. {
  59002. return $this->fromDefault;
  59003. }
  59004. }
  59005. <?php
  59006. declare(strict_types=1);
  59007. namespace JsonSchema;
  59008. abstract class Enum extends \MabeEnum\Enum
  59009. {
  59010. }
  59011. <?php
  59012. declare(strict_types=1);
  59013. namespace JsonSchema\Exception;
  59014. interface ExceptionInterface
  59015. {
  59016. }
  59017. <?php
  59018. declare(strict_types=1);
  59019. namespace JsonSchema\Exception;
  59020. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  59021. {
  59022. }
  59023. <?php
  59024. declare(strict_types=1);
  59025. namespace JsonSchema\Exception;
  59026. class InvalidConfigException extends RuntimeException
  59027. {
  59028. }
  59029. <?php
  59030. declare(strict_types=1);
  59031. namespace JsonSchema\Exception;
  59032. class InvalidSchemaException extends RuntimeException
  59033. {
  59034. }
  59035. <?php
  59036. declare(strict_types=1);
  59037. namespace JsonSchema\Exception;
  59038. class InvalidSchemaMediaTypeException extends RuntimeException
  59039. {
  59040. }
  59041. <?php
  59042. declare(strict_types=1);
  59043. namespace JsonSchema\Exception;
  59044. class InvalidSourceUriException extends InvalidArgumentException
  59045. {
  59046. }
  59047. <?php
  59048. declare(strict_types=1);
  59049. namespace JsonSchema\Exception;
  59050. class JsonDecodingException extends RuntimeException
  59051. {
  59052. public function __construct($code = JSON_ERROR_NONE, ?\Exception $previous = null)
  59053. {
  59054. switch ($code) {
  59055. case JSON_ERROR_DEPTH:
  59056. $message = 'The maximum stack depth has been exceeded';
  59057. break;
  59058. case JSON_ERROR_STATE_MISMATCH:
  59059. $message = 'Invalid or malformed JSON';
  59060. break;
  59061. case JSON_ERROR_CTRL_CHAR:
  59062. $message = 'Control character error, possibly incorrectly encoded';
  59063. break;
  59064. case JSON_ERROR_UTF8:
  59065. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  59066. break;
  59067. case JSON_ERROR_SYNTAX:
  59068. $message = 'JSON syntax is malformed';
  59069. break;
  59070. default:
  59071. $message = 'Syntax error';
  59072. }
  59073. parent::__construct($message, $code, $previous);
  59074. }
  59075. }
  59076. <?php
  59077. declare(strict_types=1);
  59078. namespace JsonSchema\Exception;
  59079. class ResourceNotFoundException extends RuntimeException
  59080. {
  59081. }
  59082. <?php
  59083. declare(strict_types=1);
  59084. namespace JsonSchema\Exception;
  59085. class RuntimeException extends \RuntimeException implements ExceptionInterface
  59086. {
  59087. }
  59088. <?php
  59089. declare(strict_types=1);
  59090. namespace JsonSchema\Exception;
  59091. class UnresolvableJsonPointerException extends InvalidArgumentException
  59092. {
  59093. }
  59094. <?php
  59095. declare(strict_types=1);
  59096. namespace JsonSchema\Exception;
  59097. class UriResolverException extends RuntimeException
  59098. {
  59099. }
  59100. <?php
  59101. declare(strict_types=1);
  59102. namespace JsonSchema\Exception;
  59103. class ValidationException extends RuntimeException
  59104. {
  59105. }
  59106. <?php
  59107. declare(strict_types=1);
  59108. namespace JsonSchema\Iterator;
  59109. class ObjectIterator implements \Iterator, \Countable
  59110. {
  59111. private $object;
  59112. private $position = 0;
  59113. private $data = [];
  59114. private $initialized = false;
  59115. public function __construct($object)
  59116. {
  59117. $this->object = $object;
  59118. }
  59119. #[\ReturnTypeWillChange]
  59120. public function current()
  59121. {
  59122. $this->initialize();
  59123. return $this->data[$this->position];
  59124. }
  59125. public function next(): void
  59126. {
  59127. $this->initialize();
  59128. $this->position++;
  59129. }
  59130. public function key(): int
  59131. {
  59132. $this->initialize();
  59133. return $this->position;
  59134. }
  59135. public function valid(): bool
  59136. {
  59137. $this->initialize();
  59138. return isset($this->data[$this->position]);
  59139. }
  59140. public function rewind(): void
  59141. {
  59142. $this->initialize();
  59143. $this->position = 0;
  59144. }
  59145. public function count(): int
  59146. {
  59147. $this->initialize();
  59148. return count($this->data);
  59149. }
  59150. private function initialize()
  59151. {
  59152. if (!$this->initialized) {
  59153. $this->data = $this->buildDataFromObject($this->object);
  59154. $this->initialized = true;
  59155. }
  59156. }
  59157. private function buildDataFromObject($object)
  59158. {
  59159. $result = [];
  59160. $stack = new \SplStack();
  59161. $stack->push($object);
  59162. while (!$stack->isEmpty()) {
  59163. $current = $stack->pop();
  59164. if (is_object($current)) {
  59165. array_push($result, $current);
  59166. }
  59167. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  59168. if (is_object($propertyValue) || is_array($propertyValue)) {
  59169. $stack->push($propertyValue);
  59170. }
  59171. }
  59172. }
  59173. return $result;
  59174. }
  59175. private function getDataFromItem($item)
  59176. {
  59177. if (!is_object($item) && !is_array($item)) {
  59178. return [];
  59179. }
  59180. return is_object($item) ? get_object_vars($item) : $item;
  59181. }
  59182. }
  59183. <?php
  59184. declare(strict_types=1);
  59185. namespace JsonSchema;
  59186. class Rfc3339
  59187. {
  59188. private const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  59189. public static function createFromString($string)
  59190. {
  59191. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  59192. return null;
  59193. }
  59194. $dateAndTime = $matches[1];
  59195. $microseconds = $matches[2] ?: '.000000';
  59196. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  59197. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  59198. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  59199. return $dateTime ?: null;
  59200. }
  59201. }
  59202. <?php
  59203. declare(strict_types=1);
  59204. namespace JsonSchema;
  59205. use JsonSchema\Constraints\BaseConstraint;
  59206. use JsonSchema\Entity\JsonPointer;
  59207. use JsonSchema\Exception\UnresolvableJsonPointerException;
  59208. use JsonSchema\Uri\UriResolver;
  59209. use JsonSchema\Uri\UriRetriever;
  59210. class SchemaStorage implements SchemaStorageInterface
  59211. {
  59212. public const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  59213. protected $uriRetriever;
  59214. protected $uriResolver;
  59215. protected $schemas = [];
  59216. public function __construct(
  59217. ?UriRetrieverInterface $uriRetriever = null,
  59218. ?UriResolverInterface $uriResolver = null
  59219. ) {
  59220. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  59221. $this->uriResolver = $uriResolver ?: new UriResolver();
  59222. }
  59223. public function getUriRetriever()
  59224. {
  59225. return $this->uriRetriever;
  59226. }
  59227. public function getUriResolver()
  59228. {
  59229. return $this->uriResolver;
  59230. }
  59231. public function addSchema($id, $schema = null)
  59232. {
  59233. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  59234. $schema = $this->uriRetriever->retrieve($id);
  59235. }
  59236. if (is_array($schema)) {
  59237. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  59238. }
  59239. if (is_object($schema) && property_exists($schema, 'id')) {
  59240. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  59241. $schema->properties->id->format = 'uri-reference';
  59242. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  59243. $schema->properties->id->format = 'uri-reference';
  59244. $schema->properties->{'$ref'}->format = 'uri-reference';
  59245. }
  59246. }
  59247. $this->expandRefs($schema, $id);
  59248. $this->schemas[$id] = $schema;
  59249. }
  59250. private function expandRefs(&$schema, $base = null)
  59251. {
  59252. if (!is_object($schema)) {
  59253. if (is_array($schema)) {
  59254. foreach ($schema as &$member) {
  59255. $this->expandRefs($member, $base);
  59256. }
  59257. }
  59258. return;
  59259. }
  59260. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  59261. $base = $this->uriResolver->resolve($schema->id, $base);
  59262. }
  59263. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  59264. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  59265. $schema->{'$ref'} = (string) $refPointer;
  59266. }
  59267. foreach ($schema as &$member) {
  59268. $this->expandRefs($member, $base);
  59269. }
  59270. }
  59271. public function getSchema($id)
  59272. {
  59273. if (!array_key_exists($id, $this->schemas)) {
  59274. $this->addSchema($id);
  59275. }
  59276. return $this->schemas[$id];
  59277. }
  59278. public function resolveRef($ref, $resolveStack = [])
  59279. {
  59280. $jsonPointer = new JsonPointer($ref);
  59281. $fileName = $jsonPointer->getFilename();
  59282. if (!strlen($fileName)) {
  59283. throw new UnresolvableJsonPointerException(sprintf(
  59284. "Could not resolve fragment '%s': no file is defined",
  59285. $jsonPointer->getPropertyPathAsString()
  59286. ));
  59287. }
  59288. $refSchema = $this->getSchema($fileName);
  59289. foreach ($jsonPointer->getPropertyPaths() as $path) {
  59290. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  59291. $refSchema = $this->resolveRefSchema($refSchema->{$path}, $resolveStack);
  59292. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  59293. $refSchema = $this->resolveRefSchema($refSchema[$path], $resolveStack);
  59294. } else {
  59295. throw new UnresolvableJsonPointerException(sprintf(
  59296. 'File: %s is found, but could not resolve fragment: %s',
  59297. $jsonPointer->getFilename(),
  59298. $jsonPointer->getPropertyPathAsString()
  59299. ));
  59300. }
  59301. }
  59302. return $refSchema;
  59303. }
  59304. public function resolveRefSchema($refSchema, $resolveStack = [])
  59305. {
  59306. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  59307. if (in_array($refSchema, $resolveStack, true)) {
  59308. throw new UnresolvableJsonPointerException(sprintf(
  59309. 'Dereferencing a pointer to %s results in an infinite loop',
  59310. $refSchema->{'$ref'}
  59311. ));
  59312. }
  59313. $resolveStack[] = $refSchema;
  59314. return $this->resolveRef($refSchema->{'$ref'}, $resolveStack);
  59315. }
  59316. return $refSchema;
  59317. }
  59318. }
  59319. <?php
  59320. declare(strict_types=1);
  59321. namespace JsonSchema;
  59322. interface SchemaStorageInterface
  59323. {
  59324. public function addSchema($id, $schema = null);
  59325. public function getSchema($id);
  59326. public function resolveRef($ref);
  59327. public function resolveRefSchema($refSchema);
  59328. }
  59329. <?php
  59330. declare(strict_types=1);
  59331. namespace JsonSchema\Tool;
  59332. class DeepComparer
  59333. {
  59334. public static function isEqual($left, $right): bool
  59335. {
  59336. if ($left === null && $right === null) {
  59337. return true;
  59338. }
  59339. $isLeftScalar = is_scalar($left);
  59340. $isLeftNumber = is_int($left) || is_float($left);
  59341. $isRightScalar = is_scalar($right);
  59342. $isRightNumber = is_int($right) || is_float($right);
  59343. if ($isLeftScalar && $isRightScalar) {
  59344. if ($isLeftNumber && $isRightNumber && (float) $left === (float) $right) {
  59345. return true;
  59346. }
  59347. return $left === $right;
  59348. }
  59349. if ($isLeftScalar !== $isRightScalar) {
  59350. return false;
  59351. }
  59352. if (is_array($left) && is_array($right)) {
  59353. return self::isArrayEqual($left, $right);
  59354. }
  59355. if ($left instanceof \stdClass && $right instanceof \stdClass) {
  59356. return self::isArrayEqual((array) $left, (array) $right);
  59357. }
  59358. return false;
  59359. }
  59360. private static function isArrayEqual(array $left, array $right): bool
  59361. {
  59362. if (count($left) !== count($right)) {
  59363. return false;
  59364. }
  59365. foreach ($left as $key => $value) {
  59366. if (!array_key_exists($key, $right)) {
  59367. return false;
  59368. }
  59369. if (!self::isEqual($value, $right[$key])) {
  59370. return false;
  59371. }
  59372. }
  59373. return true;
  59374. }
  59375. }
  59376. <?php
  59377. declare(strict_types=1);
  59378. namespace JsonSchema\Tool;
  59379. use JsonSchema\Exception\JsonDecodingException;
  59380. use JsonSchema\Exception\RuntimeException;
  59381. class DeepCopy
  59382. {
  59383. public static function copyOf($input)
  59384. {
  59385. $json = json_encode($input);
  59386. if (JSON_ERROR_NONE < $error = json_last_error()) {
  59387. throw new JsonDecodingException($error);
  59388. }
  59389. if ($json === false) {
  59390. throw new RuntimeException('Failed to encode input to JSON: ' . json_last_error_msg());
  59391. }
  59392. return json_decode($json, self::isAssociativeArray($input));
  59393. }
  59394. private static function isAssociativeArray($input): bool
  59395. {
  59396. return is_array($input) && array_keys($input) !== range(0, count($input) - 1);
  59397. }
  59398. }
  59399. <?php
  59400. declare(strict_types=1);
  59401. namespace JsonSchema\Tool\Validator;
  59402. class RelativeReferenceValidator
  59403. {
  59404. public static function isValid(string $ref): bool
  59405. {
  59406. $pattern = '/^(([^\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/';
  59407. if (preg_match($pattern, $ref) !== 1) {
  59408. return false;
  59409. }
  59410. if (preg_match('/^(http|https):\/\//', $ref)) {
  59411. return false;
  59412. }
  59413. if (preg_match('/^:\/\//', $ref)) {
  59414. return false;
  59415. }
  59416. if (preg_match('/^:\//', $ref)) {
  59417. return false;
  59418. }
  59419. if (preg_match('/^\/\/$/', $ref)) {
  59420. return false;
  59421. }
  59422. if (preg_match('/^\/\/\/[^\/]/', $ref)) {
  59423. return false;
  59424. }
  59425. if (preg_match('/\s/', $ref)) {
  59426. return false;
  59427. }
  59428. if (preg_match('/^\?#|^#$/', $ref)) {
  59429. return false;
  59430. }
  59431. if ($ref === '#' || $ref === '?') {
  59432. return false;
  59433. }
  59434. return true;
  59435. }
  59436. }
  59437. <?php
  59438. declare(strict_types=1);
  59439. namespace JsonSchema\Tool\Validator;
  59440. class UriValidator
  59441. {
  59442. public static function isValid(string $uri): bool
  59443. {
  59444. $hierarchicalPattern = '/^
  59445. ([a-z][a-z0-9+\-.]*):\/\/ # Scheme (http, https, ftp, etc.)
  59446. (?:([^:@\/?#]+)(?::([^@\/?#]*))?@)? # Optional userinfo (user:pass@)
  59447. ([a-z0-9.-]+|\[[a-f0-9:.]+\]) # Hostname or IPv6 in brackets
  59448. (?::(\d{1,5}))? # Optional port
  59449. (\/[a-zA-Z0-9._~!$&\'()*+,;=:@\/%-]*)* # Path (valid characters only)
  59450. (\?([^#]*))? # Optional query
  59451. (\#(.*))? # Optional fragment
  59452. $/ix';
  59453. $nonHierarchicalPattern = '/^
  59454. (mailto|data|urn): # Only allow known non-hierarchical schemes
  59455. (.+) # Must contain at least one character after scheme
  59456. $/ix';
  59457. $emailPattern = '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/';
  59458. if (preg_match($hierarchicalPattern, $uri, $matches) === 1) {
  59459. if (!empty($matches[4]) && preg_match('/\.\./', $matches[4])) {
  59460. return false;
  59461. }
  59462. if (!empty($matches[5]) && ($matches[5] < 1 || $matches[5] > 65535)) {
  59463. return false;
  59464. }
  59465. if (!empty($matches[6]) && preg_match('/[<>{}|\\\^`]/', $matches[6])) {
  59466. return false;
  59467. }
  59468. return true;
  59469. }
  59470. if (preg_match($nonHierarchicalPattern, $uri, $matches) === 1) {
  59471. $scheme = strtolower($matches[1]);
  59472. if ($scheme === 'mailto') {
  59473. return preg_match($emailPattern, $matches[2]) === 1;
  59474. }
  59475. return true;
  59476. }
  59477. return false;
  59478. }
  59479. }
  59480. <?php
  59481. declare(strict_types=1);
  59482. namespace JsonSchema\Uri\Retrievers;
  59483. abstract class AbstractRetriever implements UriRetrieverInterface
  59484. {
  59485. protected $contentType;
  59486. public function getContentType()
  59487. {
  59488. return $this->contentType;
  59489. }
  59490. }
  59491. <?php
  59492. declare(strict_types=1);
  59493. namespace JsonSchema\Uri\Retrievers;
  59494. use JsonSchema\Exception\RuntimeException;
  59495. use JsonSchema\Validator;
  59496. class Curl extends AbstractRetriever
  59497. {
  59498. protected $messageBody;
  59499. public function __construct()
  59500. {
  59501. if (!function_exists('curl_init')) {
  59502. throw new RuntimeException('cURL not installed');
  59503. }
  59504. }
  59505. public function retrieve($uri)
  59506. {
  59507. $ch = curl_init();
  59508. curl_setopt($ch, CURLOPT_URL, $uri);
  59509. curl_setopt($ch, CURLOPT_HEADER, true);
  59510. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  59511. curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept: ' . Validator::SCHEMA_MEDIA_TYPE]);
  59512. $response = curl_exec($ch);
  59513. if (false === $response) {
  59514. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  59515. }
  59516. $this->fetchMessageBody($response);
  59517. $this->fetchContentType($response);
  59518. curl_close($ch);
  59519. return $this->messageBody;
  59520. }
  59521. private function fetchMessageBody($response)
  59522. {
  59523. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  59524. $this->messageBody = $match[1];
  59525. }
  59526. protected function fetchContentType($response)
  59527. {
  59528. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  59529. $this->contentType = trim($match[1]);
  59530. return true;
  59531. }
  59532. return false;
  59533. }
  59534. }
  59535. <?php
  59536. declare(strict_types=1);
  59537. namespace JsonSchema\Uri\Retrievers;
  59538. use JsonSchema\Exception\ResourceNotFoundException;
  59539. class FileGetContents extends AbstractRetriever
  59540. {
  59541. protected $messageBody;
  59542. public function retrieve($uri)
  59543. {
  59544. $errorMessage = null;
  59545. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  59546. $errorMessage = $errstr;
  59547. });
  59548. $response = file_get_contents($uri);
  59549. restore_error_handler();
  59550. if ($errorMessage) {
  59551. throw new ResourceNotFoundException($errorMessage);
  59552. }
  59553. if (false === $response) {
  59554. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  59555. }
  59556. if ($response == ''
  59557. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  59558. ) {
  59559. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  59560. }
  59561. $this->messageBody = $response;
  59562. if (!empty($http_response_header)) {
  59563. $this->fetchContentType($http_response_header);
  59564. } else {
  59565. $this->contentType = null;
  59566. }
  59567. return $this->messageBody;
  59568. }
  59569. private function fetchContentType(array $headers)
  59570. {
  59571. foreach (array_reverse($headers) as $header) {
  59572. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  59573. return true;
  59574. }
  59575. }
  59576. return false;
  59577. }
  59578. protected static function getContentTypeMatchInHeader($header)
  59579. {
  59580. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  59581. return trim($match[1]);
  59582. }
  59583. return null;
  59584. }
  59585. }
  59586. <?php
  59587. declare(strict_types=1);
  59588. namespace JsonSchema\Uri\Retrievers;
  59589. use JsonSchema\Validator;
  59590. class PredefinedArray extends AbstractRetriever
  59591. {
  59592. private $schemas;
  59593. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  59594. {
  59595. $this->schemas = $schemas;
  59596. $this->contentType = $contentType;
  59597. }
  59598. public function retrieve($uri)
  59599. {
  59600. if (!array_key_exists($uri, $this->schemas)) {
  59601. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  59602. 'The JSON schema "%s" was not found.',
  59603. $uri
  59604. ));
  59605. }
  59606. return $this->schemas[$uri];
  59607. }
  59608. }
  59609. <?php
  59610. declare(strict_types=1);
  59611. namespace JsonSchema\Uri\Retrievers;
  59612. interface UriRetrieverInterface
  59613. {
  59614. public function retrieve($uri);
  59615. public function getContentType();
  59616. }
  59617. <?php
  59618. declare(strict_types=1);
  59619. namespace JsonSchema\Uri;
  59620. use JsonSchema\Exception\UriResolverException;
  59621. use JsonSchema\UriResolverInterface;
  59622. class UriResolver implements UriResolverInterface
  59623. {
  59624. public function parse($uri)
  59625. {
  59626. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', (string) $uri, $match);
  59627. $components = [];
  59628. if (5 < count($match)) {
  59629. $components = [
  59630. 'scheme' => $match[2],
  59631. 'authority' => $match[4],
  59632. 'path' => $match[5]
  59633. ];
  59634. }
  59635. if (7 < count($match)) {
  59636. $components['query'] = $match[7];
  59637. }
  59638. if (9 < count($match)) {
  59639. $components['fragment'] = $match[9];
  59640. }
  59641. return $components;
  59642. }
  59643. public function generate(array $components)
  59644. {
  59645. $uri = $components['scheme'] . '://'
  59646. . $components['authority']
  59647. . $components['path'];
  59648. if (array_key_exists('query', $components) && strlen($components['query'])) {
  59649. $uri .= '?' . $components['query'];
  59650. }
  59651. if (array_key_exists('fragment', $components)) {
  59652. $uri .= '#' . $components['fragment'];
  59653. }
  59654. return $uri;
  59655. }
  59656. public function resolve($uri, $baseUri = null)
  59657. {
  59658. if (
  59659. !is_null($baseUri) &&
  59660. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  59661. !preg_match('|^[^/]+://|u', $baseUri)
  59662. ) {
  59663. if (is_file($baseUri)) {
  59664. $baseUri = 'file://' . realpath($baseUri);
  59665. } elseif (is_dir($baseUri)) {
  59666. $baseUri = 'file://' . realpath($baseUri) . '/';
  59667. } else {
  59668. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  59669. }
  59670. }
  59671. if ($uri == '') {
  59672. return $baseUri;
  59673. }
  59674. $components = $this->parse($uri);
  59675. $path = $components['path'];
  59676. if (!empty($components['scheme'])) {
  59677. return $uri;
  59678. }
  59679. $baseComponents = $this->parse($baseUri);
  59680. $basePath = $baseComponents['path'];
  59681. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  59682. if (isset($components['fragment'])) {
  59683. $baseComponents['fragment'] = $components['fragment'];
  59684. }
  59685. return $this->generate($baseComponents);
  59686. }
  59687. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  59688. {
  59689. $relativePath = self::normalizePath($relativePath);
  59690. if (!$relativePath) {
  59691. return $basePath;
  59692. }
  59693. if ($relativePath[0] === '/') {
  59694. return $relativePath;
  59695. }
  59696. if (!$basePath) {
  59697. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  59698. }
  59699. $dirname = $basePath[strlen($basePath) - 1] === '/' ? $basePath : dirname($basePath);
  59700. $combined = rtrim($dirname, '/') . '/' . ltrim($relativePath, '/');
  59701. $combinedSegments = explode('/', $combined);
  59702. $collapsedSegments = [];
  59703. while ($combinedSegments) {
  59704. $segment = array_shift($combinedSegments);
  59705. if ($segment === '..') {
  59706. if (count($collapsedSegments) <= 1) {
  59707. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  59708. }
  59709. array_pop($collapsedSegments);
  59710. } else {
  59711. $collapsedSegments[] = $segment;
  59712. }
  59713. }
  59714. return implode('/', $collapsedSegments);
  59715. }
  59716. private static function normalizePath($path)
  59717. {
  59718. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  59719. $path = preg_replace('|//|', '/', $path);
  59720. return $path;
  59721. }
  59722. public function isValid($uri)
  59723. {
  59724. $components = $this->parse($uri);
  59725. return !empty($components);
  59726. }
  59727. }
  59728. <?php
  59729. declare(strict_types=1);
  59730. namespace JsonSchema\Uri;
  59731. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  59732. use JsonSchema\Exception\JsonDecodingException;
  59733. use JsonSchema\Exception\ResourceNotFoundException;
  59734. use JsonSchema\Uri\Retrievers\FileGetContents;
  59735. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  59736. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  59737. use JsonSchema\Validator;
  59738. class UriRetriever implements BaseUriRetrieverInterface
  59739. {
  59740. protected $translationMap = [
  59741. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  59742. ];
  59743. protected $allowedInvalidContentTypeEndpoints = [
  59744. 'http://json-schema.org/',
  59745. 'https://json-schema.org/'
  59746. ];
  59747. protected $uriRetriever = null;
  59748. private $schemaCache = [];
  59749. public function addInvalidContentTypeEndpoint($endpoint)
  59750. {
  59751. $this->allowedInvalidContentTypeEndpoints[] = $endpoint;
  59752. }
  59753. public function confirmMediaType($uriRetriever, $uri)
  59754. {
  59755. $contentType = $uriRetriever->getContentType();
  59756. if (is_null($contentType)) {
  59757. return;
  59758. }
  59759. if (in_array($contentType, [Validator::SCHEMA_MEDIA_TYPE, 'application/json'])) {
  59760. return;
  59761. }
  59762. foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
  59763. if (!\is_null($uri) && strpos($uri, $endpoint) === 0) {
  59764. return true;
  59765. }
  59766. }
  59767. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  59768. }
  59769. public function getUriRetriever()
  59770. {
  59771. if (is_null($this->uriRetriever)) {
  59772. $this->setUriRetriever(new FileGetContents());
  59773. }
  59774. return $this->uriRetriever;
  59775. }
  59776. public function resolvePointer($jsonSchema, $uri)
  59777. {
  59778. $resolver = new UriResolver();
  59779. $parsed = $resolver->parse($uri);
  59780. if (empty($parsed['fragment'])) {
  59781. return $jsonSchema;
  59782. }
  59783. $path = explode('/', $parsed['fragment']);
  59784. while ($path) {
  59785. $pathElement = array_shift($path);
  59786. if (!empty($pathElement)) {
  59787. $pathElement = str_replace('~1', '/', $pathElement);
  59788. $pathElement = str_replace('~0', '~', $pathElement);
  59789. if (!empty($jsonSchema->$pathElement)) {
  59790. $jsonSchema = $jsonSchema->$pathElement;
  59791. } else {
  59792. throw new ResourceNotFoundException(
  59793. 'Fragment "' . $parsed['fragment'] . '" not found'
  59794. . ' in ' . $uri
  59795. );
  59796. }
  59797. if (!is_object($jsonSchema)) {
  59798. throw new ResourceNotFoundException(
  59799. 'Fragment part "' . $pathElement . '" is no object '
  59800. . ' in ' . $uri
  59801. );
  59802. }
  59803. }
  59804. }
  59805. return $jsonSchema;
  59806. }
  59807. public function retrieve($uri, $baseUri = null, $translate = true)
  59808. {
  59809. $resolver = new UriResolver();
  59810. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  59811. $arParts = $resolver->parse($resolvedUri);
  59812. if (isset($arParts['fragment'])) {
  59813. unset($arParts['fragment']);
  59814. $fetchUri = $resolver->generate($arParts);
  59815. }
  59816. if ($translate) {
  59817. $fetchUri = $this->translate($fetchUri);
  59818. }
  59819. $jsonSchema = $this->loadSchema($fetchUri);
  59820. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  59821. if ($jsonSchema instanceof \stdClass) {
  59822. $jsonSchema->id = $resolvedUri;
  59823. }
  59824. return $jsonSchema;
  59825. }
  59826. protected function loadSchema($fetchUri)
  59827. {
  59828. if (isset($this->schemaCache[$fetchUri])) {
  59829. return $this->schemaCache[$fetchUri];
  59830. }
  59831. $uriRetriever = $this->getUriRetriever();
  59832. $contents = $this->uriRetriever->retrieve($fetchUri);
  59833. $this->confirmMediaType($uriRetriever, $fetchUri);
  59834. $jsonSchema = json_decode($contents);
  59835. if (JSON_ERROR_NONE < $error = json_last_error()) {
  59836. throw new JsonDecodingException($error);
  59837. }
  59838. $this->schemaCache[$fetchUri] = $jsonSchema;
  59839. return $jsonSchema;
  59840. }
  59841. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  59842. {
  59843. $this->uriRetriever = $uriRetriever;
  59844. return $this;
  59845. }
  59846. public function parse($uri)
  59847. {
  59848. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  59849. $components = [];
  59850. if (5 < count($match)) {
  59851. $components = [
  59852. 'scheme' => $match[2],
  59853. 'authority' => $match[4],
  59854. 'path' => $match[5]
  59855. ];
  59856. }
  59857. if (7 < count($match)) {
  59858. $components['query'] = $match[7];
  59859. }
  59860. if (9 < count($match)) {
  59861. $components['fragment'] = $match[9];
  59862. }
  59863. return $components;
  59864. }
  59865. public function generate(array $components)
  59866. {
  59867. $uri = $components['scheme'] . '://'
  59868. . $components['authority']
  59869. . $components['path'];
  59870. if (array_key_exists('query', $components)) {
  59871. $uri .= $components['query'];
  59872. }
  59873. if (array_key_exists('fragment', $components)) {
  59874. $uri .= $components['fragment'];
  59875. }
  59876. return $uri;
  59877. }
  59878. public function resolve($uri, $baseUri = null)
  59879. {
  59880. $components = $this->parse($uri);
  59881. $path = $components['path'];
  59882. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  59883. return $uri;
  59884. }
  59885. $baseComponents = $this->parse($baseUri);
  59886. $basePath = $baseComponents['path'];
  59887. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  59888. return $this->generate($baseComponents);
  59889. }
  59890. public function isValid($uri)
  59891. {
  59892. $components = $this->parse($uri);
  59893. return !empty($components);
  59894. }
  59895. public function setTranslation($from, $to)
  59896. {
  59897. $this->translationMap[$from] = $to;
  59898. }
  59899. public function translate($uri)
  59900. {
  59901. foreach ($this->translationMap as $from => $to) {
  59902. $uri = preg_replace($from, $to, $uri);
  59903. }
  59904. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  59905. return $uri;
  59906. }
  59907. }
  59908. <?php
  59909. declare(strict_types=1);
  59910. namespace JsonSchema;
  59911. interface UriResolverInterface
  59912. {
  59913. public function resolve($uri, $baseUri = null);
  59914. }
  59915. <?php
  59916. declare(strict_types=1);
  59917. namespace JsonSchema;
  59918. interface UriRetrieverInterface
  59919. {
  59920. public function retrieve($uri, $baseUri = null);
  59921. }
  59922. <?php
  59923. declare(strict_types=1);
  59924. namespace JsonSchema;
  59925. use JsonSchema\Constraints\BaseConstraint;
  59926. use JsonSchema\Constraints\Constraint;
  59927. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  59928. class Validator extends BaseConstraint
  59929. {
  59930. public const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  59931. public const ERROR_NONE = 0;
  59932. public const ERROR_ALL = -1;
  59933. public const ERROR_DOCUMENT_VALIDATION = 1;
  59934. public const ERROR_SCHEMA_VALIDATION = 2;
  59935. public function validate(&$value, $schema = null, ?int $checkMode = null): int
  59936. {
  59937. $this->reset();
  59938. $initialCheckMode = $this->factory->getConfig();
  59939. if ($checkMode !== null) {
  59940. $this->factory->setConfig($checkMode);
  59941. }
  59942. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  59943. if (LooseTypeCheck::propertyExists($schema, 'id')) {
  59944. $schemaURI = LooseTypeCheck::propertyGet($schema, 'id');
  59945. }
  59946. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  59947. $validator = $this->factory->createInstanceFor('schema');
  59948. $validator->check(
  59949. $value,
  59950. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  59951. );
  59952. $this->factory->setConfig($initialCheckMode);
  59953. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  59954. return $validator->getErrorMask();
  59955. }
  59956. public function check($value, $schema): int
  59957. {
  59958. return $this->validate($value, $schema);
  59959. }
  59960. public function coerce(&$value, $schema): int
  59961. {
  59962. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  59963. }
  59964. }
  59965. Copyright (c) 2020, Marc Bennewitz
  59966. All rights reserved.
  59967. Redistribution and use in source and binary forms, with or without modification,
  59968. are permitted provided that the following conditions are met:
  59969. * Redistributions of source code must retain the above copyright notice,
  59970. this list of conditions and the following disclaimer.
  59971. * Redistributions in binary form must reproduce the above copyright notice,
  59972. this list of conditions and the following disclaimer in the documentation
  59973. and/or other materials provided with the distribution.
  59974. * Neither the name of the organisation nor the names of its contributors
  59975. may be used to endorse or promote products derived from this software
  59976. without specific prior written permission.
  59977. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  59978. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  59979. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  59980. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  59981. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  59982. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  59983. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  59984. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  59985. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  59986. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  59987. <?php
  59988. declare(strict_types=1);
  59989. namespace MabeEnum;
  59990. use ReflectionClass;
  59991. use InvalidArgumentException;
  59992. use LogicException;
  59993. abstract class Enum implements \Stringable
  59994. {
  59995. private $value;
  59996. private $ordinal;
  59997. private static $constants = [];
  59998. private static $names = [];
  59999. private static $instances = [];
  60000. final private function __construct($value, $ordinal = null)
  60001. {
  60002. $this->value = $value;
  60003. $this->ordinal = $ordinal;
  60004. }
  60005. public function __toString(): string
  60006. {
  60007. return $this->getName();
  60008. }
  60009. final public function __clone()
  60010. {
  60011. throw new LogicException('Enums are not cloneable');
  60012. }
  60013. final public function __sleep()
  60014. {
  60015. throw new LogicException('Serialization is not supported by default in this pseudo-enum implementation');
  60016. }
  60017. final public function __wakeup()
  60018. {
  60019. throw new LogicException('Serialization is not supported by default in this pseudo-enum implementation');
  60020. }
  60021. final public function getValue()
  60022. {
  60023. return $this->value;
  60024. }
  60025. final public function getName()
  60026. {
  60027. return self::$names[static::class][$this->ordinal ?? $this->getOrdinal()];
  60028. }
  60029. final public function getOrdinal()
  60030. {
  60031. if ($this->ordinal === null) {
  60032. $ordinal = 0;
  60033. $value = $this->value;
  60034. $constants = self::$constants[static::class] ?? static::getConstants();
  60035. foreach ($constants as $constValue) {
  60036. if ($value === $constValue) {
  60037. break;
  60038. }
  60039. ++$ordinal;
  60040. }
  60041. $this->ordinal = $ordinal;
  60042. }
  60043. return $this->ordinal;
  60044. }
  60045. final public function is($enumerator)
  60046. {
  60047. return $this === $enumerator || $this->value === $enumerator
  60048. || ($enumerator instanceof static
  60049. && \get_class($enumerator) === static::class
  60050. && $enumerator->value === $this->value
  60051. );
  60052. }
  60053. final public static function get($enumerator)
  60054. {
  60055. if ($enumerator instanceof static) {
  60056. if (\get_class($enumerator) !== static::class) {
  60057. throw new InvalidArgumentException(sprintf(
  60058. 'Invalid value of type %s for enumeration %s',
  60059. \get_class($enumerator),
  60060. static::class
  60061. ));
  60062. }
  60063. return $enumerator;
  60064. }
  60065. return static::byValue($enumerator);
  60066. }
  60067. final public static function byValue($value)
  60068. {
  60069. $constants = self::$constants[static::class] ?? static::getConstants();
  60070. $name = \array_search($value, $constants, true);
  60071. if ($name === false) {
  60072. throw new InvalidArgumentException(sprintf(
  60073. 'Unknown value %s for enumeration %s',
  60074. \is_scalar($value)
  60075. ? \var_export($value, true)
  60076. : 'of type ' . (\is_object($value) ? \get_class($value) : \gettype($value)),
  60077. static::class
  60078. ));
  60079. }
  60080. $instance = self::$instances[static::class][$name]
  60081. ?? self::$instances[static::class][$name] = new static($constants[$name]);
  60082. return $instance;
  60083. }
  60084. final public static function byName(string $name)
  60085. {
  60086. if (isset(self::$instances[static::class][$name])) {
  60087. $instance = self::$instances[static::class][$name];
  60088. return $instance;
  60089. }
  60090. $const = static::class . "::{$name}";
  60091. if (!\defined($const)) {
  60092. throw new InvalidArgumentException("{$const} not defined");
  60093. }
  60094. assert(
  60095. self::noAmbiguousValues(static::getConstants()),
  60096. 'Ambiguous enumerator values detected for ' . static::class
  60097. );
  60098. $value = \constant($const);
  60099. return self::$instances[static::class][$name] = new static($value);
  60100. }
  60101. final public static function byOrdinal(int $ordinal)
  60102. {
  60103. $constants = self::$constants[static::class] ?? static::getConstants();
  60104. if (!isset(self::$names[static::class][$ordinal])) {
  60105. throw new InvalidArgumentException(\sprintf(
  60106. 'Invalid ordinal number %s, must between 0 and %s',
  60107. $ordinal,
  60108. \count(self::$names[static::class]) - 1
  60109. ));
  60110. }
  60111. $name = self::$names[static::class][$ordinal];
  60112. $instance = self::$instances[static::class][$name]
  60113. ?? self::$instances[static::class][$name] = new static($constants[$name], $ordinal);
  60114. return $instance;
  60115. }
  60116. final public static function getEnumerators()
  60117. {
  60118. if (!isset(self::$names[static::class])) {
  60119. static::getConstants();
  60120. }
  60121. $byNameFn = [static::class, 'byName'];
  60122. return \array_map($byNameFn, self::$names[static::class]);
  60123. }
  60124. final public static function getValues()
  60125. {
  60126. return \array_values(self::$constants[static::class] ?? static::getConstants());
  60127. }
  60128. final public static function getNames()
  60129. {
  60130. if (!isset(self::$names[static::class])) {
  60131. static::getConstants();
  60132. }
  60133. return self::$names[static::class];
  60134. }
  60135. final public static function getOrdinals()
  60136. {
  60137. $count = \count(self::$constants[static::class] ?? static::getConstants());
  60138. return $count ? \range(0, $count - 1) : [];
  60139. }
  60140. final public static function getConstants()
  60141. {
  60142. if (isset(self::$constants[static::class])) {
  60143. return self::$constants[static::class];
  60144. }
  60145. $reflection = new ReflectionClass(static::class);
  60146. $constants = [];
  60147. do {
  60148. $scopeConstants = [];
  60149. foreach ($reflection->getReflectionConstants() as $reflConstant) {
  60150. if ($reflConstant->isPublic()) {
  60151. $scopeConstants[ $reflConstant->getName() ] = $reflConstant->getValue();
  60152. }
  60153. }
  60154. $constants = $scopeConstants + $constants;
  60155. } while (($reflection = $reflection->getParentClass()) && $reflection->name !== __CLASS__);
  60156. assert(
  60157. self::noAmbiguousValues($constants),
  60158. 'Ambiguous enumerator values detected for ' . static::class
  60159. );
  60160. self::$names[static::class] = \array_keys($constants);
  60161. return self::$constants[static::class] = $constants;
  60162. }
  60163. private static function noAmbiguousValues($constants)
  60164. {
  60165. foreach ($constants as $value) {
  60166. $names = \array_keys($constants, $value, true);
  60167. if (\count($names) > 1) {
  60168. return false;
  60169. }
  60170. }
  60171. return true;
  60172. }
  60173. final public static function has($enumerator)
  60174. {
  60175. if ($enumerator instanceof static) {
  60176. return \get_class($enumerator) === static::class;
  60177. }
  60178. return static::hasValue($enumerator);
  60179. }
  60180. final public static function hasValue($value)
  60181. {
  60182. return \in_array($value, self::$constants[static::class] ?? static::getConstants(), true);
  60183. }
  60184. final public static function hasName(string $name)
  60185. {
  60186. return \defined("static::{$name}");
  60187. }
  60188. final public static function __callStatic(string $method, array $args)
  60189. {
  60190. return static::byName($method);
  60191. }
  60192. }
  60193. <?php
  60194. declare(strict_types=1);
  60195. namespace MabeEnum;
  60196. use ArrayAccess;
  60197. use Countable;
  60198. use InvalidArgumentException;
  60199. use Iterator;
  60200. use IteratorAggregate;
  60201. use UnexpectedValueException;
  60202. class EnumMap implements ArrayAccess, Countable, IteratorAggregate
  60203. {
  60204. private $enumeration;
  60205. private $map = [];
  60206. public function __construct(string $enumeration, ?iterable $map = null)
  60207. {
  60208. if (!\is_subclass_of($enumeration, Enum::class)) {
  60209. throw new InvalidArgumentException(\sprintf(
  60210. '%s can handle subclasses of %s only',
  60211. __CLASS__,
  60212. Enum::class
  60213. ));
  60214. }
  60215. $this->enumeration = $enumeration;
  60216. if ($map) {
  60217. $this->addIterable($map);
  60218. }
  60219. }
  60220. public function __debugInfo(): array {
  60221. $dbg = (array)$this;
  60222. $dbg["\0" . self::class . "\0__pairs"] = array_map(function ($k, $v) {
  60223. return [$k, $v];
  60224. }, $this->getKeys(), $this->getValues());
  60225. return $dbg;
  60226. }
  60227. public function add($enumerator, $value): void
  60228. {
  60229. $ord = ($this->enumeration)::get($enumerator)->getOrdinal();
  60230. $this->map[$ord] = $value;
  60231. }
  60232. public function addIterable(iterable $map): void
  60233. {
  60234. $innerMap = $this->map;
  60235. foreach ($map as $enumerator => $value) {
  60236. $ord = ($this->enumeration)::get($enumerator)->getOrdinal();
  60237. $innerMap[$ord] = $value;
  60238. }
  60239. $this->map = $innerMap;
  60240. }
  60241. public function remove($enumerator): void
  60242. {
  60243. $ord = ($this->enumeration)::get($enumerator)->getOrdinal();
  60244. unset($this->map[$ord]);
  60245. }
  60246. public function removeIterable(iterable $enumerators): void
  60247. {
  60248. $map = $this->map;
  60249. foreach ($enumerators as $enumerator) {
  60250. $ord = ($this->enumeration)::get($enumerator)->getOrdinal();
  60251. unset($map[$ord]);
  60252. }
  60253. $this->map = $map;
  60254. }
  60255. public function with($enumerator, $value): self
  60256. {
  60257. $clone = clone $this;
  60258. $clone->add($enumerator, $value);
  60259. return $clone;
  60260. }
  60261. public function withIterable(iterable $map): self
  60262. {
  60263. $clone = clone $this;
  60264. $clone->addIterable($map);
  60265. return $clone;
  60266. }
  60267. public function without($enumerator): self
  60268. {
  60269. $clone = clone $this;
  60270. $clone->remove($enumerator);
  60271. return $clone;
  60272. }
  60273. public function withoutIterable(iterable $enumerators): self
  60274. {
  60275. $clone = clone $this;
  60276. $clone->removeIterable($enumerators);
  60277. return $clone;
  60278. }
  60279. public function getEnumeration(): string
  60280. {
  60281. return $this->enumeration;
  60282. }
  60283. public function get($enumerator)
  60284. {
  60285. $enumerator = ($this->enumeration)::get($enumerator);
  60286. $ord = $enumerator->getOrdinal();
  60287. if (!\array_key_exists($ord, $this->map)) {
  60288. throw new UnexpectedValueException(sprintf(
  60289. 'Enumerator %s could not be found',
  60290. \var_export($enumerator->getValue(), true)
  60291. ));
  60292. }
  60293. return $this->map[$ord];
  60294. }
  60295. public function getKeys(): array
  60296. {
  60297. $byOrdinalFn = [$this->enumeration, 'byOrdinal'];
  60298. return \array_map($byOrdinalFn, \array_keys($this->map));
  60299. }
  60300. public function getValues(): array
  60301. {
  60302. return \array_values($this->map);
  60303. }
  60304. public function search($value, bool $strict = false)
  60305. {
  60306. $ord = \array_search($value, $this->map, $strict);
  60307. if ($ord !== false) {
  60308. return ($this->enumeration)::byOrdinal($ord);
  60309. }
  60310. return null;
  60311. }
  60312. public function has($enumerator): bool
  60313. {
  60314. try {
  60315. $ord = ($this->enumeration)::get($enumerator)->getOrdinal();
  60316. return \array_key_exists($ord, $this->map);
  60317. } catch (InvalidArgumentException $e) {
  60318. return false;
  60319. }
  60320. }
  60321. public function contains($enumerator): bool
  60322. {
  60323. return $this->has($enumerator);
  60324. }
  60325. public function offsetExists($enumerator): bool
  60326. {
  60327. try {
  60328. return isset($this->map[($this->enumeration)::get($enumerator)->getOrdinal()]);
  60329. } catch (InvalidArgumentException $e) {
  60330. return false;
  60331. }
  60332. }
  60333. #[\ReturnTypeWillChange]
  60334. public function offsetGet($enumerator)
  60335. {
  60336. try {
  60337. return $this->get($enumerator);
  60338. } catch (UnexpectedValueException $e) {
  60339. return null;
  60340. }
  60341. }
  60342. public function offsetSet($enumerator, $value = null): void
  60343. {
  60344. $this->add($enumerator, $value);
  60345. }
  60346. public function offsetUnset($enumerator): void
  60347. {
  60348. $this->remove($enumerator);
  60349. }
  60350. public function getIterator(): Iterator
  60351. {
  60352. $map = $this->map;
  60353. foreach ($map as $ordinal => $value) {
  60354. yield ($this->enumeration)::byOrdinal($ordinal) => $value;
  60355. }
  60356. }
  60357. public function count(): int
  60358. {
  60359. return \count($this->map);
  60360. }
  60361. public function isEmpty(): bool
  60362. {
  60363. return empty($this->map);
  60364. }
  60365. }
  60366. <?php
  60367. declare(strict_types=1);
  60368. namespace MabeEnum;
  60369. use RuntimeException;
  60370. use LogicException;
  60371. trait EnumSerializableTrait
  60372. {
  60373. abstract public function getValue();
  60374. public function __serialize(): array
  60375. {
  60376. return ['value' => $this->getValue()];
  60377. }
  60378. public function __unserialize(array $data): void
  60379. {
  60380. if (!\array_key_exists('value', $data)) {
  60381. throw new RuntimeException('Missing array key "value"');
  60382. }
  60383. $value = $data['value'];
  60384. $constants = self::getConstants();
  60385. $name = \array_search($value, $constants, true);
  60386. if ($name === false) {
  60387. $message = \is_scalar($value)
  60388. ? 'Unknown value ' . \var_export($value, true)
  60389. : 'Invalid value of type ' . (\is_object($value) ? \get_class($value) : \gettype($value));
  60390. throw new RuntimeException($message);
  60391. }
  60392. $class = static::class;
  60393. $enumerator = $this;
  60394. $closure = function () use ($class, $name, $value, $enumerator) {
  60395. if ($value !== null && $this->value !== null) {
  60396. throw new LogicException('Do not call this directly - please use unserialize($enum) instead');
  60397. }
  60398. $this->value = $value;
  60399. if (!isset(self::$instances[$class][$name])) {
  60400. self::$instances[$class][$name] = $enumerator;
  60401. }
  60402. };
  60403. $closure->bindTo($this, Enum::class)();
  60404. }
  60405. public function serialize(): string
  60406. {
  60407. return \serialize($this->getValue());
  60408. }
  60409. public function unserialize($serialized): void
  60410. {
  60411. $this->__unserialize(['value' => \unserialize($serialized)]);
  60412. }
  60413. }
  60414. <?php
  60415. declare(strict_types=1);
  60416. namespace MabeEnum;
  60417. use Countable;
  60418. use InvalidArgumentException;
  60419. use Iterator;
  60420. use IteratorAggregate;
  60421. class EnumSet implements IteratorAggregate, Countable
  60422. {
  60423. private $enumeration;
  60424. private $enumerationCount;
  60425. private $bitset = 0;
  60426. private $emptyBitset = 0;
  60427. private $fnDoGetIterator = 'doGetIteratorInt';
  60428. private $fnDoCount = 'doCountInt';
  60429. private $fnDoGetOrdinals = 'doGetOrdinalsInt';
  60430. private $fnDoGetBit = 'doGetBitInt';
  60431. private $fnDoSetBit = 'doSetBitInt';
  60432. private $fnDoUnsetBit = 'doUnsetBitInt';
  60433. private $fnDoGetBinaryBitsetLe = 'doGetBinaryBitsetLeInt';
  60434. private $fnDoSetBinaryBitsetLe = 'doSetBinaryBitsetLeInt';
  60435. public function __construct(string $enumeration, ?iterable $enumerators = null)
  60436. {
  60437. if (!\is_subclass_of($enumeration, Enum::class)) {
  60438. throw new InvalidArgumentException(\sprintf(
  60439. '%s can handle subclasses of %s only',
  60440. __METHOD__,
  60441. Enum::class
  60442. ));
  60443. }
  60444. $this->enumeration = $enumeration;
  60445. $this->enumerationCount = \count($enumeration::getConstants());
  60446. if ($this->enumerationCount > \PHP_INT_SIZE * 8) {
  60447. $this->bitset = $this->emptyBitset = \str_repeat("\0", (int)\ceil($this->enumerationCount / 8));
  60448. $this->fnDoGetIterator = 'doGetIteratorBin';
  60449. $this->fnDoCount = 'doCountBin';
  60450. $this->fnDoGetOrdinals = 'doGetOrdinalsBin';
  60451. $this->fnDoGetBit = 'doGetBitBin';
  60452. $this->fnDoSetBit = 'doSetBitBin';
  60453. $this->fnDoUnsetBit = 'doUnsetBitBin';
  60454. $this->fnDoGetBinaryBitsetLe = 'doGetBinaryBitsetLeBin';
  60455. $this->fnDoSetBinaryBitsetLe = 'doSetBinaryBitsetLeBin';
  60456. }
  60457. if ($enumerators !== null) {
  60458. foreach ($enumerators as $enumerator) {
  60459. $this->{$this->fnDoSetBit}($enumeration::get($enumerator)->getOrdinal());
  60460. }
  60461. }
  60462. }
  60463. public function __debugInfo() {
  60464. $dbg = (array)$this;
  60465. $dbg["\0" . self::class . "\0__enumerators"] = $this->getValues();
  60466. return $dbg;
  60467. }
  60468. public function getEnumeration(): string
  60469. {
  60470. return $this->enumeration;
  60471. }
  60472. public function add($enumerator): void
  60473. {
  60474. $this->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal());
  60475. }
  60476. public function addIterable(iterable $enumerators): void
  60477. {
  60478. $bitset = $this->bitset;
  60479. try {
  60480. foreach ($enumerators as $enumerator) {
  60481. $this->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal());
  60482. }
  60483. } catch (\Throwable $e) {
  60484. $this->bitset = $bitset;
  60485. throw $e;
  60486. }
  60487. }
  60488. public function remove($enumerator): void
  60489. {
  60490. $this->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal());
  60491. }
  60492. public function attach($enumerator): void
  60493. {
  60494. $this->add($enumerator);
  60495. }
  60496. public function detach($enumerator): void
  60497. {
  60498. $this->remove($enumerator);
  60499. }
  60500. public function removeIterable(iterable $enumerators): void
  60501. {
  60502. $bitset = $this->bitset;
  60503. try {
  60504. foreach ($enumerators as $enumerator) {
  60505. $this->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal());
  60506. }
  60507. } catch (\Throwable $e) {
  60508. $this->bitset = $bitset;
  60509. throw $e;
  60510. }
  60511. }
  60512. public function setUnion(EnumSet $other): void
  60513. {
  60514. if ($this->enumeration !== $other->enumeration) {
  60515. throw new InvalidArgumentException(\sprintf(
  60516. 'Other should be of the same enumeration as this %s',
  60517. $this->enumeration
  60518. ));
  60519. }
  60520. $this->bitset = $this->bitset | $other->bitset;
  60521. }
  60522. public function setIntersect(EnumSet $other): void
  60523. {
  60524. if ($this->enumeration !== $other->enumeration) {
  60525. throw new InvalidArgumentException(\sprintf(
  60526. 'Other should be of the same enumeration as this %s',
  60527. $this->enumeration
  60528. ));
  60529. }
  60530. $this->bitset = $this->bitset & $other->bitset;
  60531. }
  60532. public function setDiff(EnumSet $other): void
  60533. {
  60534. if ($this->enumeration !== $other->enumeration) {
  60535. throw new InvalidArgumentException(\sprintf(
  60536. 'Other should be of the same enumeration as this %s',
  60537. $this->enumeration
  60538. ));
  60539. }
  60540. $this->bitset = $this->bitset & ~$other->bitset;
  60541. }
  60542. public function setSymDiff(EnumSet $other): void
  60543. {
  60544. if ($this->enumeration !== $other->enumeration) {
  60545. throw new InvalidArgumentException(\sprintf(
  60546. 'Other should be of the same enumeration as this %s',
  60547. $this->enumeration
  60548. ));
  60549. }
  60550. $this->bitset = $this->bitset ^ $other->bitset;
  60551. }
  60552. public function setBinaryBitsetLe(string $bitset): void
  60553. {
  60554. $this->{$this->fnDoSetBinaryBitsetLe}($bitset);
  60555. }
  60556. private function doSetBinaryBitsetLeBin($bitset): void
  60557. {
  60558. $thisBitset = $this->bitset;
  60559. $size = \strlen($thisBitset);
  60560. $sizeIn = \strlen($bitset);
  60561. if ($sizeIn < $size) {
  60562. $bitset .= \str_repeat("\0", $size - $sizeIn);
  60563. } elseif ($sizeIn > $size) {
  60564. if (\ltrim(\substr($bitset, $size), "\0") !== '') {
  60565. throw new InvalidArgumentException('out-of-range bits detected');
  60566. }
  60567. $bitset = \substr($bitset, 0, $size);
  60568. }
  60569. $lastByteMaxOrd = $this->enumerationCount % 8;
  60570. if ($lastByteMaxOrd !== 0) {
  60571. $lastByte = $bitset[-1];
  60572. $lastByteExpected = \chr((1 << $lastByteMaxOrd) - 1) & $lastByte;
  60573. if ($lastByte !== $lastByteExpected) {
  60574. throw new InvalidArgumentException('out-of-range bits detected');
  60575. }
  60576. $this->bitset = \substr($bitset, 0, -1) . $lastByteExpected;
  60577. }
  60578. $this->bitset = $bitset;
  60579. }
  60580. private function doSetBinaryBitsetLeInt($bitset): void
  60581. {
  60582. $len = \strlen($bitset);
  60583. $int = 0;
  60584. for ($i = 0; $i < $len; ++$i) {
  60585. $ord = \ord($bitset[$i]);
  60586. if ($ord && $i > \PHP_INT_SIZE - 1) {
  60587. throw new InvalidArgumentException('out-of-range bits detected');
  60588. }
  60589. $int |= $ord << (8 * $i);
  60590. }
  60591. if ($int & (~0 << $this->enumerationCount)) {
  60592. throw new InvalidArgumentException('out-of-range bits detected');
  60593. }
  60594. $this->bitset = $int;
  60595. }
  60596. public function setBinaryBitsetBe(string $bitset): void
  60597. {
  60598. $this->{$this->fnDoSetBinaryBitsetLe}(\strrev($bitset));
  60599. }
  60600. public function setBit(int $ordinal, bool $bit): void
  60601. {
  60602. if ($ordinal < 0 || $ordinal > $this->enumerationCount) {
  60603. throw new InvalidArgumentException("Ordinal number must be between 0 and {$this->enumerationCount}");
  60604. }
  60605. if ($bit) {
  60606. $this->{$this->fnDoSetBit}($ordinal);
  60607. } else {
  60608. $this->{$this->fnDoUnsetBit}($ordinal);
  60609. }
  60610. }
  60611. private function doSetBitBin($ordinal): void
  60612. {
  60613. $thisBitset = $this->bitset;
  60614. $byte = (int) ($ordinal / 8);
  60615. $thisBitset[$byte] = $thisBitset[$byte] | \chr(1 << ($ordinal % 8));
  60616. $this->bitset = $thisBitset;
  60617. }
  60618. private function doSetBitInt($ordinal): void
  60619. {
  60620. $thisBitset = $this->bitset;
  60621. $this->bitset = $thisBitset | (1 << $ordinal);
  60622. }
  60623. private function doUnsetBitBin($ordinal): void
  60624. {
  60625. $thisBitset = $this->bitset;
  60626. $byte = (int) ($ordinal / 8);
  60627. $thisBitset[$byte] = $thisBitset[$byte] & \chr(~(1 << ($ordinal % 8)));
  60628. $this->bitset = $thisBitset;
  60629. }
  60630. private function doUnsetBitInt($ordinal): void
  60631. {
  60632. $thisBitset = $this->bitset;
  60633. $this->bitset = $thisBitset & ~(1 << $ordinal);
  60634. }
  60635. public function with($enumerator): self
  60636. {
  60637. $clone = clone $this;
  60638. $clone->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal());
  60639. return $clone;
  60640. }
  60641. public function withIterable(iterable $enumerators): self
  60642. {
  60643. $clone = clone $this;
  60644. foreach ($enumerators as $enumerator) {
  60645. $clone->{$this->fnDoSetBit}(($this->enumeration)::get($enumerator)->getOrdinal());
  60646. }
  60647. return $clone;
  60648. }
  60649. public function without($enumerator): self
  60650. {
  60651. $clone = clone $this;
  60652. $clone->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal());
  60653. return $clone;
  60654. }
  60655. public function withoutIterable(iterable $enumerators): self
  60656. {
  60657. $clone = clone $this;
  60658. foreach ($enumerators as $enumerator) {
  60659. $clone->{$this->fnDoUnsetBit}(($this->enumeration)::get($enumerator)->getOrdinal());
  60660. }
  60661. return $clone;
  60662. }
  60663. public function withUnion(EnumSet $other): self
  60664. {
  60665. $clone = clone $this;
  60666. $clone->setUnion($other);
  60667. return $clone;
  60668. }
  60669. public function union(EnumSet $other): self
  60670. {
  60671. return $this->withUnion($other);
  60672. }
  60673. public function withIntersect(EnumSet $other): self
  60674. {
  60675. $clone = clone $this;
  60676. $clone->setIntersect($other);
  60677. return $clone;
  60678. }
  60679. public function intersect(EnumSet $other): self
  60680. {
  60681. return $this->withIntersect($other);
  60682. }
  60683. public function withDiff(EnumSet $other): self
  60684. {
  60685. $clone = clone $this;
  60686. $clone->setDiff($other);
  60687. return $clone;
  60688. }
  60689. public function diff(EnumSet $other): self
  60690. {
  60691. return $this->withDiff($other);
  60692. }
  60693. public function withSymDiff(EnumSet $other): self
  60694. {
  60695. $clone = clone $this;
  60696. $clone->setSymDiff($other);
  60697. return $clone;
  60698. }
  60699. public function symDiff(EnumSet $other): self
  60700. {
  60701. return $this->withSymDiff($other);
  60702. }
  60703. public function withBinaryBitsetLe(string $bitset): self
  60704. {
  60705. $clone = clone $this;
  60706. $clone->{$this->fnDoSetBinaryBitsetLe}($bitset);
  60707. return $clone;
  60708. }
  60709. public function withBinaryBitsetBe(string $bitset): self
  60710. {
  60711. $clone = $this;
  60712. $clone->{$this->fnDoSetBinaryBitsetLe}(\strrev($bitset));
  60713. return $clone;
  60714. }
  60715. public function withBit(int $ordinal, bool $bit): self
  60716. {
  60717. $clone = clone $this;
  60718. $clone->setBit($ordinal, $bit);
  60719. return $clone;
  60720. }
  60721. public function has($enumerator): bool
  60722. {
  60723. return $this->{$this->fnDoGetBit}(($this->enumeration)::get($enumerator)->getOrdinal());
  60724. }
  60725. public function contains($enumerator): bool
  60726. {
  60727. return $this->has($enumerator);
  60728. }
  60729. public function getIterator(): Iterator
  60730. {
  60731. return $this->{$this->fnDoGetIterator}();
  60732. }
  60733. private function doGetIteratorBin()
  60734. {
  60735. $bitset = $this->bitset;
  60736. $byteLen = \strlen($bitset);
  60737. for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) {
  60738. if ($bitset[$bytePos] === "\0") {
  60739. continue;
  60740. }
  60741. $ord = \ord($bitset[$bytePos]);
  60742. for ($bitPos = 0; $bitPos < 8; ++$bitPos) {
  60743. if ($ord & (1 << $bitPos)) {
  60744. $ordinal = $bytePos * 8 + $bitPos;
  60745. yield $ordinal => ($this->enumeration)::byOrdinal($ordinal);
  60746. }
  60747. }
  60748. }
  60749. }
  60750. private function doGetIteratorInt()
  60751. {
  60752. $bitset = $this->bitset;
  60753. $count = $this->enumerationCount;
  60754. for ($ordinal = 0; $ordinal < $count; ++$ordinal) {
  60755. if ($bitset & (1 << $ordinal)) {
  60756. yield $ordinal => ($this->enumeration)::byOrdinal($ordinal);
  60757. }
  60758. }
  60759. }
  60760. public function count(): int
  60761. {
  60762. return $this->{$this->fnDoCount}();
  60763. }
  60764. private function doCountBin()
  60765. {
  60766. $bitset = $this->bitset;
  60767. $count = 0;
  60768. $byteLen = \strlen($bitset);
  60769. for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) {
  60770. if ($bitset[$bytePos] === "\0") {
  60771. continue;
  60772. }
  60773. $ord = \ord($bitset[$bytePos]);
  60774. if ($ord & 0b00000001) ++$count;
  60775. if ($ord & 0b00000010) ++$count;
  60776. if ($ord & 0b00000100) ++$count;
  60777. if ($ord & 0b00001000) ++$count;
  60778. if ($ord & 0b00010000) ++$count;
  60779. if ($ord & 0b00100000) ++$count;
  60780. if ($ord & 0b01000000) ++$count;
  60781. if ($ord & 0b10000000) ++$count;
  60782. }
  60783. return $count;
  60784. }
  60785. private function doCountInt()
  60786. {
  60787. $bitset = $this->bitset;
  60788. $count = 0;
  60789. if ($bitset < 0) {
  60790. $count = 1;
  60791. $bitset = $bitset & \PHP_INT_MAX;
  60792. }
  60793. $phpIntBitSize = \PHP_INT_SIZE * 8;
  60794. for ($bitPos = 0; $bitPos < $phpIntBitSize; $bitPos += 8) {
  60795. $bitChk = 0xff << $bitPos;
  60796. $byte = $bitset & $bitChk;
  60797. if ($byte) {
  60798. $byte = $byte >> $bitPos;
  60799. if ($byte & 0b00000001) ++$count;
  60800. if ($byte & 0b00000010) ++$count;
  60801. if ($byte & 0b00000100) ++$count;
  60802. if ($byte & 0b00001000) ++$count;
  60803. if ($byte & 0b00010000) ++$count;
  60804. if ($byte & 0b00100000) ++$count;
  60805. if ($byte & 0b01000000) ++$count;
  60806. if ($byte & 0b10000000) ++$count;
  60807. }
  60808. if ($bitset <= $bitChk) {
  60809. break;
  60810. }
  60811. }
  60812. return $count;
  60813. }
  60814. public function isEqual(EnumSet $other): bool
  60815. {
  60816. return $this->enumeration === $other->enumeration
  60817. && $this->bitset === $other->bitset;
  60818. }
  60819. public function isSubset(EnumSet $other): bool
  60820. {
  60821. return $this->enumeration === $other->enumeration
  60822. && ($this->bitset & $other->bitset) === $this->bitset;
  60823. }
  60824. public function isSuperset(EnumSet $other): bool
  60825. {
  60826. return $this->enumeration === $other->enumeration
  60827. && ($this->bitset | $other->bitset) === $this->bitset;
  60828. }
  60829. public function isEmpty(): bool
  60830. {
  60831. return $this->bitset === $this->emptyBitset;
  60832. }
  60833. public function getOrdinals(): array
  60834. {
  60835. return $this->{$this->fnDoGetOrdinals}();
  60836. }
  60837. private function doGetOrdinalsBin()
  60838. {
  60839. $bitset = $this->bitset;
  60840. $ordinals = [];
  60841. $byteLen = \strlen($bitset);
  60842. for ($bytePos = 0; $bytePos < $byteLen; ++$bytePos) {
  60843. if ($bitset[$bytePos] === "\0") {
  60844. continue;
  60845. }
  60846. $ord = \ord($bitset[$bytePos]);
  60847. for ($bitPos = 0; $bitPos < 8; ++$bitPos) {
  60848. if ($ord & (1 << $bitPos)) {
  60849. $ordinals[] = $bytePos * 8 + $bitPos;
  60850. }
  60851. }
  60852. }
  60853. return $ordinals;
  60854. }
  60855. private function doGetOrdinalsInt()
  60856. {
  60857. $bitset = $this->bitset;
  60858. $ordinals = [];
  60859. $count = $this->enumerationCount;
  60860. for ($ordinal = 0; $ordinal < $count; ++$ordinal) {
  60861. if ($bitset & (1 << $ordinal)) {
  60862. $ordinals[] = $ordinal;
  60863. }
  60864. }
  60865. return $ordinals;
  60866. }
  60867. public function getValues(): array
  60868. {
  60869. $enumeration = $this->enumeration;
  60870. $values = [];
  60871. foreach ($this->getOrdinals() as $ord) {
  60872. $values[] = $enumeration::byOrdinal($ord)->getValue();
  60873. }
  60874. return $values;
  60875. }
  60876. public function getNames(): array
  60877. {
  60878. $enumeration = $this->enumeration;
  60879. $names = [];
  60880. foreach ($this->getOrdinals() as $ord) {
  60881. $names[] = $enumeration::byOrdinal($ord)->getName();
  60882. }
  60883. return $names;
  60884. }
  60885. public function getEnumerators(): array
  60886. {
  60887. $enumeration = $this->enumeration;
  60888. $enumerators = [];
  60889. foreach ($this->getOrdinals() as $ord) {
  60890. $enumerators[] = $enumeration::byOrdinal($ord);
  60891. }
  60892. return $enumerators;
  60893. }
  60894. public function getBinaryBitsetLe(): string
  60895. {
  60896. return $this->{$this->fnDoGetBinaryBitsetLe}();
  60897. }
  60898. private function doGetBinaryBitsetLeBin()
  60899. {
  60900. $bitset = $this->bitset;
  60901. return $bitset;
  60902. }
  60903. private function doGetBinaryBitsetLeInt()
  60904. {
  60905. $bin = \pack(\PHP_INT_SIZE === 8 ? 'P' : 'V', $this->bitset);
  60906. return \substr($bin, 0, (int)\ceil($this->enumerationCount / 8));
  60907. }
  60908. public function getBinaryBitsetBe(): string
  60909. {
  60910. return \strrev($this->getBinaryBitsetLe());
  60911. }
  60912. public function getBit(int $ordinal): bool
  60913. {
  60914. if ($ordinal < 0 || $ordinal > $this->enumerationCount) {
  60915. throw new InvalidArgumentException("Ordinal number must be between 0 and {$this->enumerationCount}");
  60916. }
  60917. return $this->{$this->fnDoGetBit}($ordinal);
  60918. }
  60919. private function doGetBitBin($ordinal)
  60920. {
  60921. $bitset = $this->bitset;
  60922. return (\ord($bitset[(int) ($ordinal / 8)]) & 1 << ($ordinal % 8)) !== 0;
  60923. }
  60924. private function doGetBitInt($ordinal)
  60925. {
  60926. $bitset = $this->bitset;
  60927. return (bool)($bitset & (1 << $ordinal));
  60928. }
  60929. }
  60930. <?php
  60931. if (\PHP_VERSION_ID < 80000) {
  60932. interface Stringable
  60933. {
  60934. public function __toString();
  60935. }
  60936. }
  60937. The MIT License (MIT)
  60938. Copyright (c) 2013-2016 container-interop
  60939. Copyright (c) 2016 PHP Framework Interoperability Group
  60940. Permission is hereby granted, free of charge, to any person obtaining a copy of
  60941. this software and associated documentation files (the "Software"), to deal in
  60942. the Software without restriction, including without limitation the rights to
  60943. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  60944. the Software, and to permit persons to whom the Software is furnished to do so,
  60945. subject to the following conditions:
  60946. The above copyright notice and this permission notice shall be included in all
  60947. copies or substantial portions of the Software.
  60948. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  60949. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  60950. FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  60951. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  60952. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  60953. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  60954. <?php
  60955. namespace Psr\Container;
  60956. interface ContainerExceptionInterface
  60957. {
  60958. }
  60959. <?php
  60960. declare(strict_types=1);
  60961. namespace Psr\Container;
  60962. interface ContainerInterface
  60963. {
  60964. public function get(string $id);
  60965. public function has(string $id);
  60966. }
  60967. <?php
  60968. namespace Psr\Container;
  60969. interface NotFoundExceptionInterface extends ContainerExceptionInterface
  60970. {
  60971. }
  60972. Copyright (c) 2012 PHP Framework Interoperability Group
  60973. Permission is hereby granted, free of charge, to any person obtaining a copy
  60974. of this software and associated documentation files (the "Software"), to deal
  60975. in the Software without restriction, including without limitation the rights
  60976. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  60977. copies of the Software, and to permit persons to whom the Software is
  60978. furnished to do so, subject to the following conditions:
  60979. The above copyright notice and this permission notice shall be included in
  60980. all copies or substantial portions of the Software.
  60981. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  60982. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  60983. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  60984. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  60985. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  60986. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  60987. THE SOFTWARE.
  60988. <?php
  60989. namespace Psr\Log;
  60990. abstract class AbstractLogger implements LoggerInterface
  60991. {
  60992. public function emergency($message, array $context = array())
  60993. {
  60994. $this->log(LogLevel::EMERGENCY, $message, $context);
  60995. }
  60996. public function alert($message, array $context = array())
  60997. {
  60998. $this->log(LogLevel::ALERT, $message, $context);
  60999. }
  61000. public function critical($message, array $context = array())
  61001. {
  61002. $this->log(LogLevel::CRITICAL, $message, $context);
  61003. }
  61004. public function error($message, array $context = array())
  61005. {
  61006. $this->log(LogLevel::ERROR, $message, $context);
  61007. }
  61008. public function warning($message, array $context = array())
  61009. {
  61010. $this->log(LogLevel::WARNING, $message, $context);
  61011. }
  61012. public function notice($message, array $context = array())
  61013. {
  61014. $this->log(LogLevel::NOTICE, $message, $context);
  61015. }
  61016. public function info($message, array $context = array())
  61017. {
  61018. $this->log(LogLevel::INFO, $message, $context);
  61019. }
  61020. public function debug($message, array $context = array())
  61021. {
  61022. $this->log(LogLevel::DEBUG, $message, $context);
  61023. }
  61024. }
  61025. <?php
  61026. namespace Psr\Log;
  61027. class InvalidArgumentException extends \InvalidArgumentException
  61028. {
  61029. }
  61030. <?php
  61031. namespace Psr\Log;
  61032. class LogLevel
  61033. {
  61034. const EMERGENCY = 'emergency';
  61035. const ALERT = 'alert';
  61036. const CRITICAL = 'critical';
  61037. const ERROR = 'error';
  61038. const WARNING = 'warning';
  61039. const NOTICE = 'notice';
  61040. const INFO = 'info';
  61041. const DEBUG = 'debug';
  61042. }
  61043. <?php
  61044. namespace Psr\Log;
  61045. interface LoggerAwareInterface
  61046. {
  61047. public function setLogger(LoggerInterface $logger);
  61048. }
  61049. <?php
  61050. namespace Psr\Log;
  61051. trait LoggerAwareTrait
  61052. {
  61053. protected $logger;
  61054. public function setLogger(LoggerInterface $logger)
  61055. {
  61056. $this->logger = $logger;
  61057. }
  61058. }
  61059. <?php
  61060. namespace Psr\Log;
  61061. interface LoggerInterface
  61062. {
  61063. public function emergency($message, array $context = array());
  61064. public function alert($message, array $context = array());
  61065. public function critical($message, array $context = array());
  61066. public function error($message, array $context = array());
  61067. public function warning($message, array $context = array());
  61068. public function notice($message, array $context = array());
  61069. public function info($message, array $context = array());
  61070. public function debug($message, array $context = array());
  61071. public function log($level, $message, array $context = array());
  61072. }
  61073. <?php
  61074. namespace Psr\Log;
  61075. trait LoggerTrait
  61076. {
  61077. public function emergency($message, array $context = array())
  61078. {
  61079. $this->log(LogLevel::EMERGENCY, $message, $context);
  61080. }
  61081. public function alert($message, array $context = array())
  61082. {
  61083. $this->log(LogLevel::ALERT, $message, $context);
  61084. }
  61085. public function critical($message, array $context = array())
  61086. {
  61087. $this->log(LogLevel::CRITICAL, $message, $context);
  61088. }
  61089. public function error($message, array $context = array())
  61090. {
  61091. $this->log(LogLevel::ERROR, $message, $context);
  61092. }
  61093. public function warning($message, array $context = array())
  61094. {
  61095. $this->log(LogLevel::WARNING, $message, $context);
  61096. }
  61097. public function notice($message, array $context = array())
  61098. {
  61099. $this->log(LogLevel::NOTICE, $message, $context);
  61100. }
  61101. public function info($message, array $context = array())
  61102. {
  61103. $this->log(LogLevel::INFO, $message, $context);
  61104. }
  61105. public function debug($message, array $context = array())
  61106. {
  61107. $this->log(LogLevel::DEBUG, $message, $context);
  61108. }
  61109. abstract public function log($level, $message, array $context = array());
  61110. }
  61111. <?php
  61112. namespace Psr\Log;
  61113. class NullLogger extends AbstractLogger
  61114. {
  61115. public function log($level, $message, array $context = array())
  61116. {
  61117. }
  61118. }
  61119. <?php
  61120. namespace Psr\Log\Test;
  61121. class DummyTest
  61122. {
  61123. public function __toString()
  61124. {
  61125. return 'DummyTest';
  61126. }
  61127. }
  61128. <?php
  61129. namespace Psr\Log\Test;
  61130. use Psr\Log\LoggerInterface;
  61131. use Psr\Log\LogLevel;
  61132. use PHPUnit\Framework\TestCase;
  61133. abstract class LoggerInterfaceTest extends TestCase
  61134. {
  61135. abstract public function getLogger();
  61136. abstract public function getLogs();
  61137. public function testImplements()
  61138. {
  61139. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  61140. }
  61141. public function testLogsAtAllLevels($level, $message)
  61142. {
  61143. $logger = $this->getLogger();
  61144. $logger->{$level}($message, array('user' => 'Bob'));
  61145. $logger->log($level, $message, array('user' => 'Bob'));
  61146. $expected = array(
  61147. $level.' message of level '.$level.' with context: Bob',
  61148. $level.' message of level '.$level.' with context: Bob',
  61149. );
  61150. $this->assertEquals($expected, $this->getLogs());
  61151. }
  61152. public function provideLevelsAndMessages()
  61153. {
  61154. return array(
  61155. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  61156. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  61157. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  61158. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  61159. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  61160. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  61161. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  61162. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  61163. );
  61164. }
  61165. public function testThrowsOnInvalidLevel()
  61166. {
  61167. $logger = $this->getLogger();
  61168. $logger->log('invalid level', 'Foo');
  61169. }
  61170. public function testContextReplacement()
  61171. {
  61172. $logger = $this->getLogger();
  61173. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  61174. $expected = array('info {Message {nothing} Bob Bar a}');
  61175. $this->assertEquals($expected, $this->getLogs());
  61176. }
  61177. public function testObjectCastToString()
  61178. {
  61179. if (method_exists($this, 'createPartialMock')) {
  61180. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  61181. } else {
  61182. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  61183. }
  61184. $dummy->expects($this->once())
  61185. ->method('__toString')
  61186. ->will($this->returnValue('DUMMY'));
  61187. $this->getLogger()->warning($dummy);
  61188. $expected = array('warning DUMMY');
  61189. $this->assertEquals($expected, $this->getLogs());
  61190. }
  61191. public function testContextCanContainAnything()
  61192. {
  61193. $closed = fopen('php://memory', 'r');
  61194. fclose($closed);
  61195. $context = array(
  61196. 'bool' => true,
  61197. 'null' => null,
  61198. 'string' => 'Foo',
  61199. 'int' => 0,
  61200. 'float' => 0.5,
  61201. 'nested' => array('with object' => new DummyTest),
  61202. 'object' => new \DateTime,
  61203. 'resource' => fopen('php://memory', 'r'),
  61204. 'closed' => $closed,
  61205. );
  61206. $this->getLogger()->warning('Crazy context data', $context);
  61207. $expected = array('warning Crazy context data');
  61208. $this->assertEquals($expected, $this->getLogs());
  61209. }
  61210. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  61211. {
  61212. $logger = $this->getLogger();
  61213. $logger->warning('Random message', array('exception' => 'oops'));
  61214. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  61215. $expected = array(
  61216. 'warning Random message',
  61217. 'critical Uncaught Exception!'
  61218. );
  61219. $this->assertEquals($expected, $this->getLogs());
  61220. }
  61221. }
  61222. <?php
  61223. namespace Psr\Log\Test;
  61224. use Psr\Log\AbstractLogger;
  61225. class TestLogger extends AbstractLogger
  61226. {
  61227. public $records = [];
  61228. public $recordsByLevel = [];
  61229. public function log($level, $message, array $context = [])
  61230. {
  61231. $record = [
  61232. 'level' => $level,
  61233. 'message' => $message,
  61234. 'context' => $context,
  61235. ];
  61236. $this->recordsByLevel[$record['level']][] = $record;
  61237. $this->records[] = $record;
  61238. }
  61239. public function hasRecords($level)
  61240. {
  61241. return isset($this->recordsByLevel[$level]);
  61242. }
  61243. public function hasRecord($record, $level)
  61244. {
  61245. if (is_string($record)) {
  61246. $record = ['message' => $record];
  61247. }
  61248. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  61249. if ($rec['message'] !== $record['message']) {
  61250. return false;
  61251. }
  61252. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  61253. return false;
  61254. }
  61255. return true;
  61256. }, $level);
  61257. }
  61258. public function hasRecordThatContains($message, $level)
  61259. {
  61260. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  61261. return strpos($rec['message'], $message) !== false;
  61262. }, $level);
  61263. }
  61264. public function hasRecordThatMatches($regex, $level)
  61265. {
  61266. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  61267. return preg_match($regex, $rec['message']) > 0;
  61268. }, $level);
  61269. }
  61270. public function hasRecordThatPasses(callable $predicate, $level)
  61271. {
  61272. if (!isset($this->recordsByLevel[$level])) {
  61273. return false;
  61274. }
  61275. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  61276. if (call_user_func($predicate, $rec, $i)) {
  61277. return true;
  61278. }
  61279. }
  61280. return false;
  61281. }
  61282. public function __call($method, $args)
  61283. {
  61284. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  61285. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  61286. $level = strtolower($matches[2]);
  61287. if (method_exists($this, $genericMethod)) {
  61288. $args[] = $level;
  61289. return call_user_func_array([$this, $genericMethod], $args);
  61290. }
  61291. }
  61292. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  61293. }
  61294. public function reset()
  61295. {
  61296. $this->records = [];
  61297. $this->recordsByLevel = [];
  61298. }
  61299. }
  61300. The MIT License (MIT)
  61301. Copyright (c) 2012 Jan Sorgalla, Christian Lück, Cees-Jan Kiewiet, Chris Boden
  61302. Permission is hereby granted, free of charge, to any person
  61303. obtaining a copy of this software and associated documentation
  61304. files (the "Software"), to deal in the Software without
  61305. restriction, including without limitation the rights to use,
  61306. copy, modify, merge, publish, distribute, sublicense, and/or sell
  61307. copies of the Software, and to permit persons to whom the
  61308. Software is furnished to do so, subject to the following
  61309. conditions:
  61310. The above copyright notice and this permission notice shall be
  61311. included in all copies or substantial portions of the Software.
  61312. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  61313. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  61314. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  61315. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  61316. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  61317. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  61318. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  61319. OTHER DEALINGS IN THE SOFTWARE.
  61320. <?php
  61321. namespace React\Promise;
  61322. final class Deferred
  61323. {
  61324. private $promise;
  61325. private $resolveCallback;
  61326. private $rejectCallback;
  61327. public function __construct(?callable $canceller = null)
  61328. {
  61329. $this->promise = new Promise(function ($resolve, $reject): void {
  61330. $this->resolveCallback = $resolve;
  61331. $this->rejectCallback = $reject;
  61332. }, $canceller);
  61333. }
  61334. public function promise(): PromiseInterface
  61335. {
  61336. return $this->promise;
  61337. }
  61338. public function resolve($value): void
  61339. {
  61340. ($this->resolveCallback)($value);
  61341. }
  61342. public function reject(\Throwable $reason): void
  61343. {
  61344. ($this->rejectCallback)($reason);
  61345. }
  61346. }
  61347. <?php
  61348. namespace React\Promise\Exception;
  61349. class CompositeException extends \Exception
  61350. {
  61351. private $throwables;
  61352. public function __construct(array $throwables, string $message = '', int $code = 0, ?\Throwable $previous = null)
  61353. {
  61354. parent::__construct($message, $code, $previous);
  61355. $this->throwables = $throwables;
  61356. }
  61357. public function getThrowables(): array
  61358. {
  61359. return $this->throwables;
  61360. }
  61361. }
  61362. <?php
  61363. namespace React\Promise\Exception;
  61364. class LengthException extends \LengthException
  61365. {
  61366. }
  61367. <?php
  61368. namespace React\Promise\Internal;
  61369. final class CancellationQueue
  61370. {
  61371. private $started = false;
  61372. private $queue = [];
  61373. public function __invoke(): void
  61374. {
  61375. if ($this->started) {
  61376. return;
  61377. }
  61378. $this->started = true;
  61379. $this->drain();
  61380. }
  61381. public function enqueue($cancellable): void
  61382. {
  61383. if (!\is_object($cancellable) || !\method_exists($cancellable, 'then') || !\method_exists($cancellable, 'cancel')) {
  61384. return;
  61385. }
  61386. $length = \array_push($this->queue, $cancellable);
  61387. if ($this->started && 1 === $length) {
  61388. $this->drain();
  61389. }
  61390. }
  61391. private function drain(): void
  61392. {
  61393. for ($i = \key($this->queue); isset($this->queue[$i]); $i++) {
  61394. $cancellable = $this->queue[$i];
  61395. assert(\method_exists($cancellable, 'cancel'));
  61396. $exception = null;
  61397. try {
  61398. $cancellable->cancel();
  61399. } catch (\Throwable $exception) {
  61400. }
  61401. unset($this->queue[$i]);
  61402. if ($exception) {
  61403. throw $exception;
  61404. }
  61405. }
  61406. $this->queue = [];
  61407. }
  61408. }
  61409. <?php
  61410. namespace React\Promise\Internal;
  61411. use React\Promise\PromiseInterface;
  61412. use function React\Promise\resolve;
  61413. final class FulfilledPromise implements PromiseInterface
  61414. {
  61415. private $value;
  61416. public function __construct($value = null)
  61417. {
  61418. if ($value instanceof PromiseInterface) {
  61419. throw new \InvalidArgumentException('You cannot create React\Promise\FulfilledPromise with a promise. Use React\Promise\resolve($promiseOrValue) instead.');
  61420. }
  61421. $this->value = $value;
  61422. }
  61423. public function then(?callable $onFulfilled = null, ?callable $onRejected = null): PromiseInterface
  61424. {
  61425. if (null === $onFulfilled) {
  61426. return $this;
  61427. }
  61428. try {
  61429. $result = $onFulfilled($this->value);
  61430. return resolve($result);
  61431. } catch (\Throwable $exception) {
  61432. return new RejectedPromise($exception);
  61433. }
  61434. }
  61435. public function catch(callable $onRejected): PromiseInterface
  61436. {
  61437. return $this;
  61438. }
  61439. public function finally(callable $onFulfilledOrRejected): PromiseInterface
  61440. {
  61441. return $this->then(function ($value) use ($onFulfilledOrRejected): PromiseInterface {
  61442. return resolve($onFulfilledOrRejected())->then(function () use ($value) {
  61443. return $value;
  61444. });
  61445. });
  61446. }
  61447. public function cancel(): void
  61448. {
  61449. }
  61450. public function otherwise(callable $onRejected): PromiseInterface
  61451. {
  61452. return $this->catch($onRejected);
  61453. }
  61454. public function always(callable $onFulfilledOrRejected): PromiseInterface
  61455. {
  61456. return $this->finally($onFulfilledOrRejected);
  61457. }
  61458. }
  61459. <?php
  61460. namespace React\Promise\Internal;
  61461. use React\Promise\PromiseInterface;
  61462. use function React\Promise\_checkTypehint;
  61463. use function React\Promise\resolve;
  61464. use function React\Promise\set_rejection_handler;
  61465. final class RejectedPromise implements PromiseInterface
  61466. {
  61467. private $reason;
  61468. private $handled = false;
  61469. public function __construct(\Throwable $reason)
  61470. {
  61471. $this->reason = $reason;
  61472. }
  61473. public function __destruct()
  61474. {
  61475. if ($this->handled) {
  61476. return;
  61477. }
  61478. $handler = set_rejection_handler(null);
  61479. if ($handler === null) {
  61480. $message = 'Unhandled promise rejection with ' . $this->reason;
  61481. \error_log($message);
  61482. return;
  61483. }
  61484. try {
  61485. $handler($this->reason);
  61486. } catch (\Throwable $e) {
  61487. \preg_match('/^([^:\s]++)(.*+)$/sm', (string) $e, $match);
  61488. \assert(isset($match[1], $match[2]));
  61489. $message = 'Fatal error: Uncaught ' . $match[1] . ' from unhandled promise rejection handler' . $match[2];
  61490. \error_log($message);
  61491. exit(255);
  61492. }
  61493. }
  61494. public function then(?callable $onFulfilled = null, ?callable $onRejected = null): PromiseInterface
  61495. {
  61496. if (null === $onRejected) {
  61497. return $this;
  61498. }
  61499. $this->handled = true;
  61500. try {
  61501. return resolve($onRejected($this->reason));
  61502. } catch (\Throwable $exception) {
  61503. return new RejectedPromise($exception);
  61504. }
  61505. }
  61506. public function catch(callable $onRejected): PromiseInterface
  61507. {
  61508. if (!_checkTypehint($onRejected, $this->reason)) {
  61509. return $this;
  61510. }
  61511. return $this->then(null, $onRejected);
  61512. }
  61513. public function finally(callable $onFulfilledOrRejected): PromiseInterface
  61514. {
  61515. return $this->then(null, function (\Throwable $reason) use ($onFulfilledOrRejected): PromiseInterface {
  61516. return resolve($onFulfilledOrRejected())->then(function () use ($reason): PromiseInterface {
  61517. return new RejectedPromise($reason);
  61518. });
  61519. });
  61520. }
  61521. public function cancel(): void
  61522. {
  61523. $this->handled = true;
  61524. }
  61525. public function otherwise(callable $onRejected): PromiseInterface
  61526. {
  61527. return $this->catch($onRejected);
  61528. }
  61529. public function always(callable $onFulfilledOrRejected): PromiseInterface
  61530. {
  61531. return $this->finally($onFulfilledOrRejected);
  61532. }
  61533. }
  61534. <?php
  61535. namespace React\Promise;
  61536. use React\Promise\Internal\RejectedPromise;
  61537. final class Promise implements PromiseInterface
  61538. {
  61539. private $canceller;
  61540. private $result;
  61541. private $handlers = [];
  61542. private $requiredCancelRequests = 0;
  61543. private $cancelled = false;
  61544. public function __construct(callable $resolver, ?callable $canceller = null)
  61545. {
  61546. $this->canceller = $canceller;
  61547. $cb = $resolver;
  61548. $resolver = $canceller = null;
  61549. $this->call($cb);
  61550. }
  61551. public function then(?callable $onFulfilled = null, ?callable $onRejected = null): PromiseInterface
  61552. {
  61553. if (null !== $this->result) {
  61554. return $this->result->then($onFulfilled, $onRejected);
  61555. }
  61556. if (null === $this->canceller) {
  61557. return new static($this->resolver($onFulfilled, $onRejected));
  61558. }
  61559. $parent = $this;
  61560. ++$parent->requiredCancelRequests;
  61561. return new static(
  61562. $this->resolver($onFulfilled, $onRejected),
  61563. static function () use (&$parent): void {
  61564. assert($parent instanceof self);
  61565. --$parent->requiredCancelRequests;
  61566. if ($parent->requiredCancelRequests <= 0) {
  61567. $parent->cancel();
  61568. }
  61569. $parent = null;
  61570. }
  61571. );
  61572. }
  61573. public function catch(callable $onRejected): PromiseInterface
  61574. {
  61575. return $this->then(null, static function (\Throwable $reason) use ($onRejected) {
  61576. if (!_checkTypehint($onRejected, $reason)) {
  61577. return new RejectedPromise($reason);
  61578. }
  61579. return $onRejected($reason);
  61580. });
  61581. }
  61582. public function finally(callable $onFulfilledOrRejected): PromiseInterface
  61583. {
  61584. return $this->then(static function ($value) use ($onFulfilledOrRejected): PromiseInterface {
  61585. return resolve($onFulfilledOrRejected())->then(function () use ($value) {
  61586. return $value;
  61587. });
  61588. }, static function (\Throwable $reason) use ($onFulfilledOrRejected): PromiseInterface {
  61589. return resolve($onFulfilledOrRejected())->then(function () use ($reason): RejectedPromise {
  61590. return new RejectedPromise($reason);
  61591. });
  61592. });
  61593. }
  61594. public function cancel(): void
  61595. {
  61596. $this->cancelled = true;
  61597. $canceller = $this->canceller;
  61598. $this->canceller = null;
  61599. $parentCanceller = null;
  61600. if (null !== $this->result) {
  61601. if ($this->result instanceof RejectedPromise) {
  61602. $this->result->cancel();
  61603. }
  61604. $root = $this->unwrap($this->result);
  61605. if (!$root instanceof self || null !== $root->result) {
  61606. return;
  61607. }
  61608. $root->requiredCancelRequests--;
  61609. if ($root->requiredCancelRequests <= 0) {
  61610. $parentCanceller = [$root, 'cancel'];
  61611. }
  61612. }
  61613. if (null !== $canceller) {
  61614. $this->call($canceller);
  61615. }
  61616. if ($parentCanceller) {
  61617. $parentCanceller();
  61618. }
  61619. }
  61620. public function otherwise(callable $onRejected): PromiseInterface
  61621. {
  61622. return $this->catch($onRejected);
  61623. }
  61624. public function always(callable $onFulfilledOrRejected): PromiseInterface
  61625. {
  61626. return $this->finally($onFulfilledOrRejected);
  61627. }
  61628. private function resolver(?callable $onFulfilled = null, ?callable $onRejected = null): callable
  61629. {
  61630. return function (callable $resolve, callable $reject) use ($onFulfilled, $onRejected): void {
  61631. $this->handlers[] = static function (PromiseInterface $promise) use ($onFulfilled, $onRejected, $resolve, $reject): void {
  61632. $promise = $promise->then($onFulfilled, $onRejected);
  61633. if ($promise instanceof self && $promise->result === null) {
  61634. $promise->handlers[] = static function (PromiseInterface $promise) use ($resolve, $reject): void {
  61635. $promise->then($resolve, $reject);
  61636. };
  61637. } else {
  61638. $promise->then($resolve, $reject);
  61639. }
  61640. };
  61641. };
  61642. }
  61643. private function reject(\Throwable $reason): void
  61644. {
  61645. if (null !== $this->result) {
  61646. return;
  61647. }
  61648. $this->settle(reject($reason));
  61649. }
  61650. private function settle(PromiseInterface $result): void
  61651. {
  61652. $result = $this->unwrap($result);
  61653. if ($result === $this) {
  61654. $result = new RejectedPromise(
  61655. new \LogicException('Cannot resolve a promise with itself.')
  61656. );
  61657. }
  61658. if ($result instanceof self) {
  61659. $result->requiredCancelRequests++;
  61660. } else {
  61661. $this->canceller = null;
  61662. }
  61663. $handlers = $this->handlers;
  61664. $this->handlers = [];
  61665. $this->result = $result;
  61666. foreach ($handlers as $handler) {
  61667. $handler($result);
  61668. }
  61669. if ($this->cancelled && $result instanceof RejectedPromise) {
  61670. $result->cancel();
  61671. }
  61672. }
  61673. private function unwrap(PromiseInterface $promise): PromiseInterface
  61674. {
  61675. while ($promise instanceof self && null !== $promise->result) {
  61676. $promise = $promise->result;
  61677. }
  61678. return $promise;
  61679. }
  61680. private function call(callable $cb): void
  61681. {
  61682. $callback = $cb;
  61683. $cb = null;
  61684. if (\is_array($callback)) {
  61685. $ref = new \ReflectionMethod($callback[0], $callback[1]);
  61686. } elseif (\is_object($callback) && !$callback instanceof \Closure) {
  61687. $ref = new \ReflectionMethod($callback, '__invoke');
  61688. } else {
  61689. assert($callback instanceof \Closure || \is_string($callback));
  61690. $ref = new \ReflectionFunction($callback);
  61691. }
  61692. $args = $ref->getNumberOfParameters();
  61693. try {
  61694. if ($args === 0) {
  61695. $callback();
  61696. } else {
  61697. $target =& $this;
  61698. $callback(
  61699. static function ($value) use (&$target): void {
  61700. if ($target !== null) {
  61701. $target->settle(resolve($value));
  61702. $target = null;
  61703. }
  61704. },
  61705. static function (\Throwable $reason) use (&$target): void {
  61706. if ($target !== null) {
  61707. $target->reject($reason);
  61708. $target = null;
  61709. }
  61710. }
  61711. );
  61712. }
  61713. } catch (\Throwable $e) {
  61714. $target = null;
  61715. $this->reject($e);
  61716. }
  61717. }
  61718. }
  61719. <?php
  61720. namespace React\Promise;
  61721. interface PromiseInterface
  61722. {
  61723. public function then(?callable $onFulfilled = null, ?callable $onRejected = null): PromiseInterface;
  61724. public function catch(callable $onRejected): PromiseInterface;
  61725. public function finally(callable $onFulfilledOrRejected): PromiseInterface;
  61726. public function cancel(): void;
  61727. public function otherwise(callable $onRejected): PromiseInterface;
  61728. public function always(callable $onFulfilledOrRejected): PromiseInterface;
  61729. }
  61730. <?php
  61731. namespace React\Promise;
  61732. use React\Promise\Exception\CompositeException;
  61733. use React\Promise\Internal\FulfilledPromise;
  61734. use React\Promise\Internal\RejectedPromise;
  61735. function resolve($promiseOrValue): PromiseInterface
  61736. {
  61737. if ($promiseOrValue instanceof PromiseInterface) {
  61738. return $promiseOrValue;
  61739. }
  61740. if (\is_object($promiseOrValue) && \method_exists($promiseOrValue, 'then')) {
  61741. $canceller = null;
  61742. if (\method_exists($promiseOrValue, 'cancel')) {
  61743. $canceller = [$promiseOrValue, 'cancel'];
  61744. assert(\is_callable($canceller));
  61745. }
  61746. return new Promise(function (callable $resolve, callable $reject) use ($promiseOrValue): void {
  61747. $promiseOrValue->then($resolve, $reject);
  61748. }, $canceller);
  61749. }
  61750. return new FulfilledPromise($promiseOrValue);
  61751. }
  61752. function reject(\Throwable $reason): PromiseInterface
  61753. {
  61754. return new RejectedPromise($reason);
  61755. }
  61756. function all(iterable $promisesOrValues): PromiseInterface
  61757. {
  61758. $cancellationQueue = new Internal\CancellationQueue();
  61759. return new Promise(function (callable $resolve, callable $reject) use ($promisesOrValues, $cancellationQueue): void {
  61760. $toResolve = 0;
  61761. $continue = true;
  61762. $values = [];
  61763. foreach ($promisesOrValues as $i => $promiseOrValue) {
  61764. $cancellationQueue->enqueue($promiseOrValue);
  61765. $values[$i] = null;
  61766. ++$toResolve;
  61767. resolve($promiseOrValue)->then(
  61768. function ($value) use ($i, &$values, &$toResolve, &$continue, $resolve): void {
  61769. $values[$i] = $value;
  61770. if (0 === --$toResolve && !$continue) {
  61771. $resolve($values);
  61772. }
  61773. },
  61774. function (\Throwable $reason) use (&$continue, $reject): void {
  61775. $continue = false;
  61776. $reject($reason);
  61777. }
  61778. );
  61779. if (!$continue && !\is_array($promisesOrValues)) {
  61780. break;
  61781. }
  61782. }
  61783. $continue = false;
  61784. if ($toResolve === 0) {
  61785. $resolve($values);
  61786. }
  61787. }, $cancellationQueue);
  61788. }
  61789. function race(iterable $promisesOrValues): PromiseInterface
  61790. {
  61791. $cancellationQueue = new Internal\CancellationQueue();
  61792. return new Promise(function (callable $resolve, callable $reject) use ($promisesOrValues, $cancellationQueue): void {
  61793. $continue = true;
  61794. foreach ($promisesOrValues as $promiseOrValue) {
  61795. $cancellationQueue->enqueue($promiseOrValue);
  61796. resolve($promiseOrValue)->then($resolve, $reject)->finally(function () use (&$continue): void {
  61797. $continue = false;
  61798. });
  61799. if (!$continue && !\is_array($promisesOrValues)) {
  61800. break;
  61801. }
  61802. }
  61803. }, $cancellationQueue);
  61804. }
  61805. function any(iterable $promisesOrValues): PromiseInterface
  61806. {
  61807. $cancellationQueue = new Internal\CancellationQueue();
  61808. return new Promise(function (callable $resolve, callable $reject) use ($promisesOrValues, $cancellationQueue): void {
  61809. $toReject = 0;
  61810. $continue = true;
  61811. $reasons = [];
  61812. foreach ($promisesOrValues as $i => $promiseOrValue) {
  61813. $cancellationQueue->enqueue($promiseOrValue);
  61814. ++$toReject;
  61815. resolve($promiseOrValue)->then(
  61816. function ($value) use ($resolve, &$continue): void {
  61817. $continue = false;
  61818. $resolve($value);
  61819. },
  61820. function (\Throwable $reason) use ($i, &$reasons, &$toReject, $reject, &$continue): void {
  61821. $reasons[$i] = $reason;
  61822. if (0 === --$toReject && !$continue) {
  61823. $reject(new CompositeException(
  61824. $reasons,
  61825. 'All promises rejected.'
  61826. ));
  61827. }
  61828. }
  61829. );
  61830. if (!$continue && !\is_array($promisesOrValues)) {
  61831. break;
  61832. }
  61833. }
  61834. $continue = false;
  61835. if ($toReject === 0 && !$reasons) {
  61836. $reject(new Exception\LengthException(
  61837. 'Must contain at least 1 item but contains only 0 items.'
  61838. ));
  61839. } elseif ($toReject === 0) {
  61840. $reject(new CompositeException(
  61841. $reasons,
  61842. 'All promises rejected.'
  61843. ));
  61844. }
  61845. }, $cancellationQueue);
  61846. }
  61847. function set_rejection_handler(?callable $callback): ?callable
  61848. {
  61849. static $current = null;
  61850. $previous = $current;
  61851. $current = $callback;
  61852. return $previous;
  61853. }
  61854. function _checkTypehint(callable $callback, \Throwable $reason): bool
  61855. {
  61856. if (\is_array($callback)) {
  61857. $callbackReflection = new \ReflectionMethod($callback[0], $callback[1]);
  61858. } elseif (\is_object($callback) && !$callback instanceof \Closure) {
  61859. $callbackReflection = new \ReflectionMethod($callback, '__invoke');
  61860. } else {
  61861. assert($callback instanceof \Closure || \is_string($callback));
  61862. $callbackReflection = new \ReflectionFunction($callback);
  61863. }
  61864. $parameters = $callbackReflection->getParameters();
  61865. if (!isset($parameters[0])) {
  61866. return true;
  61867. }
  61868. $expectedException = $parameters[0];
  61869. $type = $expectedException->getType();
  61870. $isTypeUnion = true;
  61871. $types = [];
  61872. switch (true) {
  61873. case $type === null:
  61874. break;
  61875. case $type instanceof \ReflectionNamedType:
  61876. $types = [$type];
  61877. break;
  61878. case $type instanceof \ReflectionIntersectionType:
  61879. $isTypeUnion = false;
  61880. case $type instanceof \ReflectionUnionType;
  61881. $types = $type->getTypes();
  61882. break;
  61883. default:
  61884. throw new \LogicException('Unexpected return value of ReflectionParameter::getType');
  61885. }
  61886. if (empty($types)) {
  61887. return true;
  61888. }
  61889. foreach ($types as $type) {
  61890. if ($type instanceof \ReflectionIntersectionType) {
  61891. foreach ($type->getTypes() as $typeToMatch) {
  61892. assert($typeToMatch instanceof \ReflectionNamedType);
  61893. $name = $typeToMatch->getName();
  61894. if (!($matches = (!$typeToMatch->isBuiltin() && $reason instanceof $name))) {
  61895. break;
  61896. }
  61897. }
  61898. assert(isset($matches));
  61899. } else {
  61900. assert($type instanceof \ReflectionNamedType);
  61901. $name = $type->getName();
  61902. $matches = !$type->isBuiltin() && $reason instanceof $name;
  61903. }
  61904. if ($matches) {
  61905. if ($isTypeUnion) {
  61906. return true;
  61907. }
  61908. } else {
  61909. if (!$isTypeUnion) {
  61910. return false;
  61911. }
  61912. }
  61913. }
  61914. return $isTypeUnion ? false : true;
  61915. }
  61916. <?php
  61917. if (!\function_exists('React\Promise\resolve')) {
  61918. require __DIR__.'/functions.php';
  61919. }
  61920. Copyright (c) 2011 Jordi Boggiano
  61921. Permission is hereby granted, free of charge, to any person obtaining a copy
  61922. of this software and associated documentation files (the "Software"), to deal
  61923. in the Software without restriction, including without limitation the rights
  61924. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  61925. copies of the Software, and to permit persons to whom the Software is furnished
  61926. to do so, subject to the following conditions:
  61927. The above copyright notice and this permission notice shall be included in all
  61928. copies or substantial portions of the Software.
  61929. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  61930. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  61931. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  61932. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  61933. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  61934. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  61935. THE SOFTWARE.
  61936. <?php
  61937. namespace Seld\JsonLint;
  61938. class DuplicateKeyException extends ParsingException
  61939. {
  61940. protected $details;
  61941. public function __construct($message, $key, array $details)
  61942. {
  61943. $details['key'] = $key;
  61944. parent::__construct($message, $details);
  61945. }
  61946. public function getKey()
  61947. {
  61948. return $this->details['key'];
  61949. }
  61950. public function getDetails()
  61951. {
  61952. return $this->details;
  61953. }
  61954. }
  61955. <?php
  61956. namespace Seld\JsonLint;
  61957. use stdClass;
  61958. class JsonParser
  61959. {
  61960. const DETECT_KEY_CONFLICTS = 1;
  61961. const ALLOW_DUPLICATE_KEYS = 2;
  61962. const PARSE_TO_ASSOC = 4;
  61963. const ALLOW_COMMENTS = 8;
  61964. const ALLOW_DUPLICATE_KEYS_TO_ARRAY = 16;
  61965. private $lexer;
  61966. private $flags;
  61967. private $stack;
  61968. private $vstack;
  61969. private $lstack;
  61970. private $symbols = array(
  61971. 'error' => 2,
  61972. 'JSONString' => 3,
  61973. 'STRING' => 4,
  61974. 'JSONNumber' => 5,
  61975. 'NUMBER' => 6,
  61976. 'JSONNullLiteral' => 7,
  61977. 'NULL' => 8,
  61978. 'JSONBooleanLiteral' => 9,
  61979. 'TRUE' => 10,
  61980. 'FALSE' => 11,
  61981. 'JSONText' => 12,
  61982. 'JSONValue' => 13,
  61983. 'EOF' => 14,
  61984. 'JSONObject' => 15,
  61985. 'JSONArray' => 16,
  61986. '{' => 17,
  61987. '}' => 18,
  61988. 'JSONMemberList' => 19,
  61989. 'JSONMember' => 20,
  61990. ':' => 21,
  61991. ',' => 22,
  61992. '[' => 23,
  61993. ']' => 24,
  61994. 'JSONElementList' => 25,
  61995. '$accept' => 0,
  61996. '$end' => 1,
  61997. );
  61998. private $terminals_ = array(
  61999. 2 => "error",
  62000. 4 => "STRING",
  62001. 6 => "NUMBER",
  62002. 8 => "NULL",
  62003. 10 => "TRUE",
  62004. 11 => "FALSE",
  62005. 14 => "EOF",
  62006. 17 => "{",
  62007. 18 => "}",
  62008. 21 => ":",
  62009. 22 => ",",
  62010. 23 => "[",
  62011. 24 => "]",
  62012. );
  62013. private $productions_ = array(
  62014. 1 => array(3, 1),
  62015. 2 => array(5, 1),
  62016. 3 => array(7, 1),
  62017. 4 => array(9, 1),
  62018. 5 => array(9, 1),
  62019. 6 => array(12, 2),
  62020. 7 => array(13, 1),
  62021. 8 => array(13, 1),
  62022. 9 => array(13, 1),
  62023. 10 => array(13, 1),
  62024. 11 => array(13, 1),
  62025. 12 => array(13, 1),
  62026. 13 => array(15, 2),
  62027. 14 => array(15, 3),
  62028. 15 => array(20, 3),
  62029. 16 => array(19, 1),
  62030. 17 => array(19, 3),
  62031. 18 => array(16, 2),
  62032. 19 => array(16, 3),
  62033. 20 => array(25, 1),
  62034. 21 => array(25, 3)
  62035. );
  62036. private $table = array(
  62037. 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)),
  62038. 1 => array( 1 => array(3)),
  62039. 2 => array( 14 => array(1,16)),
  62040. 3 => array( 14 => array(2,7), 18 => array(2,7), 22 => array(2,7), 24 => array(2,7)),
  62041. 4 => array( 14 => array(2,8), 18 => array(2,8), 22 => array(2,8), 24 => array(2,8)),
  62042. 5 => array( 14 => array(2,9), 18 => array(2,9), 22 => array(2,9), 24 => array(2,9)),
  62043. 6 => array( 14 => array(2,10), 18 => array(2,10), 22 => array(2,10), 24 => array(2,10)),
  62044. 7 => array( 14 => array(2,11), 18 => array(2,11), 22 => array(2,11), 24 => array(2,11)),
  62045. 8 => array( 14 => array(2,12), 18 => array(2,12), 22 => array(2,12), 24 => array(2,12)),
  62046. 9 => array( 14 => array(2,3), 18 => array(2,3), 22 => array(2,3), 24 => array(2,3)),
  62047. 10 => array( 14 => array(2,4), 18 => array(2,4), 22 => array(2,4), 24 => array(2,4)),
  62048. 11 => array( 14 => array(2,5), 18 => array(2,5), 22 => array(2,5), 24 => array(2,5)),
  62049. 12 => array( 14 => array(2,1), 18 => array(2,1), 21 => array(2,1), 22 => array(2,1), 24 => array(2,1)),
  62050. 13 => array( 14 => array(2,2), 18 => array(2,2), 22 => array(2,2), 24 => array(2,2)),
  62051. 14 => array( 3 => 20, 4 => array(1,12), 18 => array(1,17), 19 => 18, 20 => 19 ),
  62052. 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 ),
  62053. 16 => array( 1 => array(2,6)),
  62054. 17 => array( 14 => array(2,13), 18 => array(2,13), 22 => array(2,13), 24 => array(2,13)),
  62055. 18 => array( 18 => array(1,24), 22 => array(1,25)),
  62056. 19 => array( 18 => array(2,16), 22 => array(2,16)),
  62057. 20 => array( 21 => array(1,26)),
  62058. 21 => array( 14 => array(2,18), 18 => array(2,18), 22 => array(2,18), 24 => array(2,18)),
  62059. 22 => array( 22 => array(1,28), 24 => array(1,27)),
  62060. 23 => array( 22 => array(2,20), 24 => array(2,20)),
  62061. 24 => array( 14 => array(2,14), 18 => array(2,14), 22 => array(2,14), 24 => array(2,14)),
  62062. 25 => array( 3 => 20, 4 => array(1,12), 20 => 29 ),
  62063. 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)),
  62064. 27 => array( 14 => array(2,19), 18 => array(2,19), 22 => array(2,19), 24 => array(2,19)),
  62065. 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)),
  62066. 29 => array( 18 => array(2,17), 22 => array(2,17)),
  62067. 30 => array( 18 => array(2,15), 22 => array(2,15)),
  62068. 31 => array( 22 => array(2,21), 24 => array(2,21)),
  62069. );
  62070. private $defaultActions = array(
  62071. 16 => array(2, 6)
  62072. );
  62073. public function lint($input, $flags = 0)
  62074. {
  62075. try {
  62076. $this->parse($input, $flags);
  62077. } catch (ParsingException $e) {
  62078. return $e;
  62079. }
  62080. return null;
  62081. }
  62082. public function parse($input, $flags = 0)
  62083. {
  62084. if (($flags & self::ALLOW_DUPLICATE_KEYS_TO_ARRAY) && ($flags & self::ALLOW_DUPLICATE_KEYS)) {
  62085. throw new \InvalidArgumentException('Only one of ALLOW_DUPLICATE_KEYS and ALLOW_DUPLICATE_KEYS_TO_ARRAY can be used, you passed in both.');
  62086. }
  62087. $this->failOnBOM($input);
  62088. $this->flags = $flags;
  62089. $this->stack = array(0);
  62090. $this->vstack = array(null);
  62091. $this->lstack = array();
  62092. $yytext = '';
  62093. $yylineno = 0;
  62094. $yyleng = 0;
  62095. $recovering = 0;
  62096. $this->lexer = new Lexer($flags);
  62097. $this->lexer->setInput($input);
  62098. $yyloc = $this->lexer->yylloc;
  62099. $this->lstack[] = $yyloc;
  62100. $symbol = null;
  62101. $preErrorSymbol = null;
  62102. $action = null;
  62103. $a = null;
  62104. $r = null;
  62105. $p = null;
  62106. $len = null;
  62107. $newState = null;
  62108. $expected = null;
  62109. $errStr = null;
  62110. while (true) {
  62111. $state = $this->stack[\count($this->stack)-1];
  62112. if (isset($this->defaultActions[$state])) {
  62113. $action = $this->defaultActions[$state];
  62114. } else {
  62115. if ($symbol === null) {
  62116. $symbol = $this->lexer->lex();
  62117. }
  62118. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  62119. }
  62120. if (!$action || !$action[0]) {
  62121. assert(isset($symbol));
  62122. if (!$recovering) {
  62123. $expected = array();
  62124. foreach ($this->table[$state] as $p => $ignore) {
  62125. if (isset($this->terminals_[$p]) && $p > 2) {
  62126. $expected[] = "'" . $this->terminals_[$p] . "'";
  62127. }
  62128. }
  62129. $message = null;
  62130. if (\in_array("'STRING'", $expected) && \in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  62131. $message = "Invalid string";
  62132. if ("'" === substr($this->lexer->match, 0, 1)) {
  62133. $message .= ", it appears you used single quotes instead of double quotes";
  62134. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u](...)?)}', $this->lexer->getFullUpcomingInput(), $match)) {
  62135. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  62136. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getFullUpcomingInput())) {
  62137. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  62138. }
  62139. }
  62140. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  62141. $errStr .= $this->lexer->showPosition() . "\n";
  62142. if ($message) {
  62143. $errStr .= $message;
  62144. } else {
  62145. $errStr .= (\count($expected) > 1) ? "Expected one of: " : "Expected: ";
  62146. $errStr .= implode(', ', $expected);
  62147. }
  62148. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  62149. $errStr .= " - It appears you have an extra trailing comma";
  62150. }
  62151. $this->parseError($errStr, array(
  62152. 'text' => $this->lexer->match,
  62153. 'token' => isset($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  62154. 'line' => $this->lexer->yylineno,
  62155. 'loc' => $yyloc,
  62156. 'expected' => $expected,
  62157. ));
  62158. }
  62159. if ($recovering == 3) {
  62160. if ($symbol === Lexer::EOF) {
  62161. throw new ParsingException($errStr ?: 'Parsing halted.');
  62162. }
  62163. $yyleng = $this->lexer->yyleng;
  62164. $yytext = $this->lexer->yytext;
  62165. $yylineno = $this->lexer->yylineno;
  62166. $yyloc = $this->lexer->yylloc;
  62167. $symbol = $this->lexer->lex();
  62168. }
  62169. while (true) {
  62170. if (\array_key_exists(Lexer::T_ERROR, $this->table[$state])) {
  62171. break;
  62172. }
  62173. if ($state == 0) {
  62174. throw new ParsingException($errStr ?: 'Parsing halted.');
  62175. }
  62176. $this->popStack(1);
  62177. $state = $this->stack[\count($this->stack)-1];
  62178. }
  62179. $preErrorSymbol = $symbol;
  62180. $symbol = Lexer::T_ERROR;
  62181. $state = $this->stack[\count($this->stack)-1];
  62182. $action = isset($this->table[$state][Lexer::T_ERROR]) ? $this->table[$state][Lexer::T_ERROR] : false;
  62183. if ($action === false) {
  62184. throw new \LogicException('No table value found for '.$state.' => '.Lexer::T_ERROR);
  62185. }
  62186. $recovering = 3;
  62187. }
  62188. if (\is_array($action[0]) && \count($action) > 1) {
  62189. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  62190. }
  62191. switch ($action[0]) {
  62192. case 1:
  62193. assert(isset($symbol));
  62194. $this->stack[] = $symbol;
  62195. $this->vstack[] = $this->lexer->yytext;
  62196. $this->lstack[] = $this->lexer->yylloc;
  62197. $this->stack[] = $action[1];
  62198. $symbol = null;
  62199. if (!$preErrorSymbol) {
  62200. $yyleng = $this->lexer->yyleng;
  62201. $yytext = $this->lexer->yytext;
  62202. $yylineno = $this->lexer->yylineno;
  62203. $yyloc = $this->lexer->yylloc;
  62204. if ($recovering > 0) {
  62205. $recovering--;
  62206. }
  62207. } else {
  62208. $symbol = $preErrorSymbol;
  62209. $preErrorSymbol = null;
  62210. }
  62211. break;
  62212. case 2:
  62213. $len = $this->productions_[$action[1]][1];
  62214. $currentToken = $this->vstack[\count($this->vstack) - $len];
  62215. $position = array(
  62216. 'first_line' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_line'],
  62217. 'last_line' => $this->lstack[\count($this->lstack) - 1]['last_line'],
  62218. 'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
  62219. 'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
  62220. );
  62221. list($newToken, $actionResult) = $this->performAction($currentToken, $yytext, $yyleng, $yylineno, $action[1]);
  62222. if (!$actionResult instanceof Undefined) {
  62223. return $actionResult;
  62224. }
  62225. if ($len) {
  62226. $this->popStack($len);
  62227. }
  62228. $this->stack[] = $this->productions_[$action[1]][0];
  62229. $this->vstack[] = $newToken;
  62230. $this->lstack[] = $position;
  62231. $newState = $this->table[$this->stack[\count($this->stack)-2]][$this->stack[\count($this->stack)-1]];
  62232. $this->stack[] = $newState;
  62233. break;
  62234. case 3:
  62235. return true;
  62236. }
  62237. }
  62238. }
  62239. protected function parseError($str, $hash = null)
  62240. {
  62241. throw new ParsingException($str, $hash ?: array());
  62242. }
  62243. private function performAction($currentToken, $yytext, $yyleng, $yylineno, $yystate)
  62244. {
  62245. $token = $currentToken;
  62246. $len = \count($this->vstack) - 1;
  62247. switch ($yystate) {
  62248. case 1:
  62249. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  62250. $token = $yytext;
  62251. break;
  62252. case 2:
  62253. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  62254. $token = \floatval($yytext);
  62255. } else {
  62256. $token = strpos($yytext, '.') === false ? \intval($yytext) : \floatval($yytext);
  62257. }
  62258. break;
  62259. case 3:
  62260. $token = null;
  62261. break;
  62262. case 4:
  62263. $token = true;
  62264. break;
  62265. case 5:
  62266. $token = false;
  62267. break;
  62268. case 6:
  62269. $token = $this->vstack[$len-1];
  62270. return array($token, $token);
  62271. case 13:
  62272. if ($this->flags & self::PARSE_TO_ASSOC) {
  62273. $token = array();
  62274. } else {
  62275. $token = new stdClass;
  62276. }
  62277. break;
  62278. case 14:
  62279. $token = $this->vstack[$len-1];
  62280. break;
  62281. case 15:
  62282. $token = array($this->vstack[$len-2], $this->vstack[$len]);
  62283. break;
  62284. case 16:
  62285. assert(\is_array($this->vstack[$len]));
  62286. if (PHP_VERSION_ID < 70100) {
  62287. $property = $this->vstack[$len][0] === '' ? '_empty_' : $this->vstack[$len][0];
  62288. } else {
  62289. $property = $this->vstack[$len][0];
  62290. }
  62291. if ($this->flags & self::PARSE_TO_ASSOC) {
  62292. $token = array();
  62293. $token[$property] = $this->vstack[$len][1];
  62294. } else {
  62295. $token = new stdClass;
  62296. $token->$property = $this->vstack[$len][1];
  62297. }
  62298. break;
  62299. case 17:
  62300. assert(\is_array($this->vstack[$len]));
  62301. if ($this->flags & self::PARSE_TO_ASSOC) {
  62302. assert(\is_array($this->vstack[$len-2]));
  62303. $token =& $this->vstack[$len-2];
  62304. $key = $this->vstack[$len][0];
  62305. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($this->vstack[$len-2][$key])) {
  62306. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  62307. $errStr .= $this->lexer->showPosition() . "\n";
  62308. $errStr .= "Duplicate key: ".$this->vstack[$len][0];
  62309. throw new DuplicateKeyException($errStr, $this->vstack[$len][0], array('line' => $yylineno+1));
  62310. }
  62311. if (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($this->vstack[$len-2][$key])) {
  62312. $duplicateCount = 1;
  62313. do {
  62314. $duplicateKey = $key . '.' . $duplicateCount++;
  62315. } while (isset($this->vstack[$len-2][$duplicateKey]));
  62316. $this->vstack[$len-2][$duplicateKey] = $this->vstack[$len][1];
  62317. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS_TO_ARRAY) && isset($this->vstack[$len-2][$key])) {
  62318. if (!isset($this->vstack[$len-2][$key]['__duplicates__']) || !is_array($this->vstack[$len-2][$key]['__duplicates__'])) {
  62319. $this->vstack[$len-2][$key] = array('__duplicates__' => array($this->vstack[$len-2][$key]));
  62320. }
  62321. $this->vstack[$len-2][$key]['__duplicates__'][] = $this->vstack[$len][1];
  62322. } else {
  62323. $this->vstack[$len-2][$key] = $this->vstack[$len][1];
  62324. }
  62325. } else {
  62326. assert($this->vstack[$len-2] instanceof stdClass);
  62327. $token = $this->vstack[$len-2];
  62328. if (PHP_VERSION_ID < 70100) {
  62329. $key = $this->vstack[$len][0] === '' ? '_empty_' : $this->vstack[$len][0];
  62330. } else {
  62331. $key = $this->vstack[$len][0];
  62332. }
  62333. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($this->vstack[$len-2]->$key)) {
  62334. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  62335. $errStr .= $this->lexer->showPosition() . "\n";
  62336. $errStr .= "Duplicate key: ".$this->vstack[$len][0];
  62337. throw new DuplicateKeyException($errStr, $this->vstack[$len][0], array('line' => $yylineno+1));
  62338. }
  62339. if (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($this->vstack[$len-2]->$key)) {
  62340. $duplicateCount = 1;
  62341. do {
  62342. $duplicateKey = $key . '.' . $duplicateCount++;
  62343. } while (isset($this->vstack[$len-2]->$duplicateKey));
  62344. $this->vstack[$len-2]->$duplicateKey = $this->vstack[$len][1];
  62345. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS_TO_ARRAY) && isset($this->vstack[$len-2]->$key)) {
  62346. if (!isset($this->vstack[$len-2]->$key->__duplicates__)) {
  62347. $this->vstack[$len-2]->$key = (object) array('__duplicates__' => array($this->vstack[$len-2]->$key));
  62348. }
  62349. $this->vstack[$len-2]->$key->__duplicates__[] = $this->vstack[$len][1];
  62350. } else {
  62351. $this->vstack[$len-2]->$key = $this->vstack[$len][1];
  62352. }
  62353. }
  62354. break;
  62355. case 18:
  62356. $token = array();
  62357. break;
  62358. case 19:
  62359. $token = $this->vstack[$len-1];
  62360. break;
  62361. case 20:
  62362. $token = array($this->vstack[$len]);
  62363. break;
  62364. case 21:
  62365. assert(\is_array($this->vstack[$len-2]));
  62366. $this->vstack[$len-2][] = $this->vstack[$len];
  62367. $token = $this->vstack[$len-2];
  62368. break;
  62369. }
  62370. return array($token, new Undefined());
  62371. }
  62372. private function stringInterpolation($match)
  62373. {
  62374. switch ($match[0]) {
  62375. case '\\\\':
  62376. return '\\';
  62377. case '\"':
  62378. return '"';
  62379. case '\b':
  62380. return \chr(8);
  62381. case '\f':
  62382. return \chr(12);
  62383. case '\n':
  62384. return "\n";
  62385. case '\r':
  62386. return "\r";
  62387. case '\t':
  62388. return "\t";
  62389. case '\/':
  62390. return "/";
  62391. default:
  62392. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', ENT_QUOTES, 'UTF-8');
  62393. }
  62394. }
  62395. private function popStack($n)
  62396. {
  62397. $this->stack = \array_slice($this->stack, 0, - (2 * $n));
  62398. $this->vstack = \array_slice($this->vstack, 0, - $n);
  62399. $this->lstack = \array_slice($this->lstack, 0, - $n);
  62400. }
  62401. private function failOnBOM($input)
  62402. {
  62403. $bom = "\xEF\xBB\xBF";
  62404. if (substr($input, 0, 3) === $bom) {
  62405. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark");
  62406. }
  62407. }
  62408. }
  62409. <?php
  62410. namespace Seld\JsonLint;
  62411. class Lexer
  62412. {
  62413. const EOF = 1;
  62414. const T_INVALID = -1;
  62415. const T_SKIP_WHITESPACE = 0;
  62416. const T_ERROR = 2;
  62417. const T_BREAK_LINE = 3;
  62418. const T_COMMENT = 30;
  62419. const T_OPEN_COMMENT = 31;
  62420. const T_CLOSE_COMMENT = 32;
  62421. private $rules = array(
  62422. 0 => '/\G\s*\n\r?/',
  62423. 1 => '/\G\s+/',
  62424. 2 => '/\G-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  62425. 3 => '{\G"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  62426. 4 => '/\G\{/',
  62427. 5 => '/\G\}/',
  62428. 6 => '/\G\[/',
  62429. 7 => '/\G\]/',
  62430. 8 => '/\G,/',
  62431. 9 => '/\G:/',
  62432. 10 => '/\Gtrue\b/',
  62433. 11 => '/\Gfalse\b/',
  62434. 12 => '/\Gnull\b/',
  62435. 13 => '/\G$/',
  62436. 14 => '/\G\/\//',
  62437. 15 => '/\G\/\*/',
  62438. 16 => '/\G\*\//',
  62439. 17 => '/\G./',
  62440. );
  62441. private $input;
  62442. private $more;
  62443. private $done;
  62444. private $offset;
  62445. private $flags;
  62446. public $match;
  62447. public $yylineno;
  62448. public $yyleng;
  62449. public $yytext;
  62450. public $yylloc;
  62451. public function __construct($flags = 0)
  62452. {
  62453. $this->flags = $flags;
  62454. }
  62455. public function lex()
  62456. {
  62457. while (true) {
  62458. $symbol = $this->next();
  62459. switch ($symbol) {
  62460. case self::T_SKIP_WHITESPACE:
  62461. case self::T_BREAK_LINE:
  62462. break;
  62463. case self::T_COMMENT:
  62464. case self::T_OPEN_COMMENT:
  62465. if (!($this->flags & JsonParser::ALLOW_COMMENTS)) {
  62466. $this->parseError('Lexical error on line ' . ($this->yylineno+1) . ". Comments are not allowed.\n" . $this->showPosition());
  62467. }
  62468. $this->skipUntil($symbol === self::T_COMMENT ? self::T_BREAK_LINE : self::T_CLOSE_COMMENT);
  62469. if ($this->done) {
  62470. return 14;
  62471. }
  62472. break;
  62473. case self::T_CLOSE_COMMENT:
  62474. $this->parseError('Lexical error on line ' . ($this->yylineno+1) . ". Unexpected token.\n" . $this->showPosition());
  62475. default:
  62476. return $symbol;
  62477. }
  62478. }
  62479. }
  62480. public function setInput($input)
  62481. {
  62482. $this->input = $input;
  62483. $this->more = false;
  62484. $this->done = false;
  62485. $this->offset = 0;
  62486. $this->yylineno = $this->yyleng = 0;
  62487. $this->yytext = $this->match = '';
  62488. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  62489. return $this;
  62490. }
  62491. public function showPosition()
  62492. {
  62493. if ($this->yylineno === 0 && $this->offset === 1 && $this->match !== '{') {
  62494. return $this->match.'...' . "\n^";
  62495. }
  62496. $pre = str_replace("\n", '', $this->getPastInput());
  62497. $c = str_repeat('-', max(0, \strlen($pre) - 1));
  62498. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  62499. }
  62500. public function getPastInput()
  62501. {
  62502. $pastLength = $this->offset - \strlen($this->match);
  62503. return ($pastLength > 20 ? '...' : '') . substr($this->input, max(0, $pastLength - 20), min(20, $pastLength));
  62504. }
  62505. public function getUpcomingInput()
  62506. {
  62507. $next = $this->match;
  62508. if (\strlen($next) < 20) {
  62509. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  62510. }
  62511. return substr($next, 0, 20) . (\strlen($next) > 20 ? '...' : '');
  62512. }
  62513. public function getFullUpcomingInput()
  62514. {
  62515. $next = $this->match;
  62516. if (substr($next, 0, 1) === '"' && substr_count($next, '"') === 1) {
  62517. $len = \strlen($this->input);
  62518. if ($len === $this->offset) {
  62519. $strEnd = $len;
  62520. } else {
  62521. $strEnd = min(strpos($this->input, '"', $this->offset + 1) ?: $len, strpos($this->input, "\n", $this->offset + 1) ?: $len);
  62522. }
  62523. $next .= substr($this->input, $this->offset, $strEnd - $this->offset);
  62524. } elseif (\strlen($next) < 20) {
  62525. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  62526. }
  62527. return $next;
  62528. }
  62529. protected function parseError($str)
  62530. {
  62531. throw new ParsingException($str);
  62532. }
  62533. private function skipUntil($token)
  62534. {
  62535. $symbol = $this->next();
  62536. while ($symbol !== $token && false === $this->done) {
  62537. $symbol = $this->next();
  62538. }
  62539. }
  62540. private function next()
  62541. {
  62542. if ($this->done) {
  62543. return self::EOF;
  62544. }
  62545. if ($this->offset === \strlen($this->input)) {
  62546. $this->done = true;
  62547. }
  62548. $token = null;
  62549. $match = null;
  62550. $col = null;
  62551. $lines = null;
  62552. if (!$this->more) {
  62553. $this->yytext = '';
  62554. $this->match = '';
  62555. }
  62556. $rulesLen = count($this->rules);
  62557. for ($i=0; $i < $rulesLen; $i++) {
  62558. if (preg_match($this->rules[$i], $this->input, $match, 0, $this->offset)) {
  62559. $lines = explode("\n", $match[0]);
  62560. array_shift($lines);
  62561. $lineCount = \count($lines);
  62562. $this->yylineno += $lineCount;
  62563. $this->yylloc = array(
  62564. 'first_line' => $this->yylloc['last_line'],
  62565. 'last_line' => $this->yylineno+1,
  62566. 'first_column' => $this->yylloc['last_column'],
  62567. 'last_column' => $lineCount > 0 ? \strlen($lines[$lineCount - 1]) : $this->yylloc['last_column'] + \strlen($match[0]),
  62568. );
  62569. $this->yytext .= $match[0];
  62570. $this->match .= $match[0];
  62571. $this->yyleng = \strlen($this->yytext);
  62572. $this->more = false;
  62573. $this->offset += \strlen($match[0]);
  62574. return $this->performAction($i);
  62575. }
  62576. }
  62577. if ($this->offset === \strlen($this->input)) {
  62578. return self::EOF;
  62579. }
  62580. $this->parseError(
  62581. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition()
  62582. );
  62583. }
  62584. private function performAction($rule)
  62585. {
  62586. switch ($rule) {
  62587. case 0:
  62588. return self::T_BREAK_LINE;
  62589. case 1:
  62590. return self::T_SKIP_WHITESPACE;
  62591. case 2:
  62592. return 6;
  62593. case 3:
  62594. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  62595. return 4;
  62596. case 4:
  62597. return 17;
  62598. case 5:
  62599. return 18;
  62600. case 6:
  62601. return 23;
  62602. case 7:
  62603. return 24;
  62604. case 8:
  62605. return 22;
  62606. case 9:
  62607. return 21;
  62608. case 10:
  62609. return 10;
  62610. case 11:
  62611. return 11;
  62612. case 12:
  62613. return 8;
  62614. case 13:
  62615. return 14;
  62616. case 14:
  62617. return self::T_COMMENT;
  62618. case 15:
  62619. return self::T_OPEN_COMMENT;
  62620. case 16:
  62621. return self::T_CLOSE_COMMENT;
  62622. case 17:
  62623. return self::T_INVALID;
  62624. default:
  62625. throw new \LogicException('Unsupported rule '.$rule);
  62626. }
  62627. }
  62628. }
  62629. <?php
  62630. namespace Seld\JsonLint;
  62631. class ParsingException extends \Exception
  62632. {
  62633. protected $details;
  62634. public function __construct($message, $details = array())
  62635. {
  62636. $this->details = $details;
  62637. parent::__construct($message);
  62638. }
  62639. public function getDetails()
  62640. {
  62641. return $this->details;
  62642. }
  62643. }
  62644. <?php
  62645. namespace Seld\JsonLint;
  62646. class Undefined
  62647. {
  62648. }
  62649. Copyright (c) 2015 Jordi Boggiano
  62650. Permission is hereby granted, free of charge, to any person obtaining a copy
  62651. of this software and associated documentation files (the "Software"), to deal
  62652. in the Software without restriction, including without limitation the rights
  62653. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  62654. copies of the Software, and to permit persons to whom the Software is furnished
  62655. to do so, subject to the following conditions:
  62656. The above copyright notice and this permission notice shall be included in all
  62657. copies or substantial portions of the Software.
  62658. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  62659. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  62660. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  62661. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  62662. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62663. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  62664. THE SOFTWARE.
  62665. <?php
  62666. namespace Seld\PharUtils;
  62667. class Linter
  62668. {
  62669. public static function lint($path, array $excludedPaths = array())
  62670. {
  62671. $php = defined('PHP_BINARY') ? PHP_BINARY : 'php';
  62672. if ($isWindows = defined('PHP_WINDOWS_VERSION_BUILD')) {
  62673. $tmpFile = @tempnam(sys_get_temp_dir(), '');
  62674. if (!$tmpFile || !is_writable($tmpFile)) {
  62675. throw new \RuntimeException('Unable to create temp file');
  62676. }
  62677. $php = self::escapeWindowsPath($php);
  62678. $tmpFile = self::escapeWindowsPath($tmpFile);
  62679. if (PHP_VERSION_ID >= 80000) {
  62680. $format = '%s -l %s';
  62681. } else {
  62682. $format = '"%s -l %s"';
  62683. }
  62684. $command = sprintf($format, $php, $tmpFile);
  62685. } else {
  62686. $command = "'".$php."' -l";
  62687. }
  62688. $descriptorspec = array(
  62689. 0 => array('pipe', 'r'),
  62690. 1 => array('pipe', 'w'),
  62691. 2 => array('pipe', 'w')
  62692. );
  62693. $baseLen = strlen(realpath($path)) + 7 + 1;
  62694. foreach (new \RecursiveIteratorIterator(new \Phar($path)) as $file) {
  62695. if ($file->isDir()) {
  62696. continue;
  62697. }
  62698. if (substr($file, -4) === '.php') {
  62699. $filename = (string) $file;
  62700. if (in_array(substr($filename, $baseLen), $excludedPaths, true)) {
  62701. continue;
  62702. }
  62703. if ($isWindows) {
  62704. file_put_contents($tmpFile, file_get_contents($filename));
  62705. }
  62706. $process = proc_open($command, $descriptorspec, $pipes);
  62707. if (is_resource($process)) {
  62708. if (!$isWindows) {
  62709. fwrite($pipes[0], file_get_contents($filename));
  62710. }
  62711. fclose($pipes[0]);
  62712. $stdout = stream_get_contents($pipes[1]);
  62713. fclose($pipes[1]);
  62714. $stderr = stream_get_contents($pipes[2]);
  62715. fclose($pipes[2]);
  62716. $exitCode = proc_close($process);
  62717. if ($exitCode !== 0) {
  62718. if ($isWindows) {
  62719. $stderr = str_replace($tmpFile, $filename, $stderr);
  62720. }
  62721. throw new \UnexpectedValueException('Failed linting '.$file.': '.$stderr);
  62722. }
  62723. } else {
  62724. throw new \RuntimeException('Could not start linter process');
  62725. }
  62726. }
  62727. }
  62728. if ($isWindows) {
  62729. @unlink($tmpFile);
  62730. }
  62731. }
  62732. private static function escapeWindowsPath($path)
  62733. {
  62734. if (strpbrk($path, " ()") !== false) {
  62735. $path = '"'.$path.'"';
  62736. }
  62737. return $path;
  62738. }
  62739. }
  62740. <?php
  62741. namespace Seld\PharUtils;
  62742. class Timestamps
  62743. {
  62744. private $contents;
  62745. public function __construct($file)
  62746. {
  62747. $this->contents = file_get_contents($file);
  62748. }
  62749. public function updateTimestamps($timestamp = null)
  62750. {
  62751. if ($timestamp instanceof \DateTime || $timestamp instanceof \DateTimeInterface) {
  62752. $timestamp = $timestamp->getTimestamp();
  62753. } elseif (is_string($timestamp)) {
  62754. $timestamp = strtotime($timestamp);
  62755. } elseif (!is_int($timestamp)) {
  62756. $timestamp = strtotime('1984-12-24T00:00:00Z');
  62757. }
  62758. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  62759. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  62760. }
  62761. $pos = $match[0][1] + strlen($match[0][0]);
  62762. $stubEnd = $pos + $this->readUint($pos, 4);
  62763. $pos += 4;
  62764. $numFiles = $this->readUint($pos, 4);
  62765. $pos += 4;
  62766. $pos += 2;
  62767. $pos += 4;
  62768. $aliasLength = $this->readUint($pos, 4);
  62769. $pos += 4 + $aliasLength;
  62770. $metadataLength = $this->readUint($pos, 4);
  62771. $pos += 4 + $metadataLength;
  62772. while ($pos < $stubEnd) {
  62773. $filenameLength = $this->readUint($pos, 4);
  62774. $pos += 4 + $filenameLength;
  62775. $pos += 4;
  62776. $timeStampBytes = pack('L', $timestamp);
  62777. $this->contents[$pos + 0] = $timeStampBytes[0];
  62778. $this->contents[$pos + 1] = $timeStampBytes[1];
  62779. $this->contents[$pos + 2] = $timeStampBytes[2];
  62780. $this->contents[$pos + 3] = $timeStampBytes[3];
  62781. $pos += 4*4;
  62782. $metadataLength = $this->readUint($pos, 4);
  62783. $pos += 4 + $metadataLength;
  62784. $numFiles--;
  62785. }
  62786. if ($numFiles !== 0) {
  62787. throw new \LogicException('All files were not processed, something must have gone wrong');
  62788. }
  62789. }
  62790. public function save($path, $signatureAlgo)
  62791. {
  62792. $pos = $this->determineSignatureBegin();
  62793. $algos = array(
  62794. \Phar::MD5 => 'md5',
  62795. \Phar::SHA1 => 'sha1',
  62796. \Phar::SHA256 => 'sha256',
  62797. \Phar::SHA512 => 'sha512',
  62798. );
  62799. if (!isset($algos[$signatureAlgo])) {
  62800. throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
  62801. }
  62802. $algo = $algos[$signatureAlgo];
  62803. $signature = hash($algo, substr($this->contents, 0, $pos), true)
  62804. . pack('L', $signatureAlgo)
  62805. . 'GBMB';
  62806. $this->contents = substr($this->contents, 0, $pos) . $signature;
  62807. return file_put_contents($path, $this->contents);
  62808. }
  62809. private function readUint($pos, $bytes)
  62810. {
  62811. $res = unpack('V', substr($this->contents, $pos, $bytes));
  62812. return $res[1];
  62813. }
  62814. private function determineSignatureBegin()
  62815. {
  62816. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  62817. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  62818. }
  62819. $pos = $match[0][1] + strlen($match[0][0]);
  62820. $manifestEnd = $pos + 4 + $this->readUint($pos, 4);
  62821. $pos += 4;
  62822. $numFiles = $this->readUint($pos, 4);
  62823. $pos += 4;
  62824. $pos += 2;
  62825. $pos += 4;
  62826. $aliasLength = $this->readUint($pos, 4);
  62827. $pos += 4 + $aliasLength;
  62828. $metadataLength = $this->readUint($pos, 4);
  62829. $pos += 4 + $metadataLength;
  62830. $compressedSizes = 0;
  62831. while (($numFiles > 0) && ($pos < $manifestEnd - 24)) {
  62832. $filenameLength = $this->readUint($pos, 4);
  62833. $pos += 4 + $filenameLength;
  62834. $pos += 2*4;
  62835. $compressedSizes += $this->readUint($pos, 4);
  62836. $pos += 3*4;
  62837. $metadataLength = $this->readUint($pos, 4);
  62838. $pos += 4 + $metadataLength;
  62839. $numFiles--;
  62840. }
  62841. if ($numFiles !== 0) {
  62842. throw new \LogicException('All files were not processed, something must have gone wrong');
  62843. }
  62844. return $manifestEnd + $compressedSizes;
  62845. }
  62846. }
  62847. Copyright (c) 2015 Jordi Boggiano
  62848. Permission is hereby granted, free of charge, to any person obtaining a copy
  62849. of this software and associated documentation files (the "Software"), to deal
  62850. in the Software without restriction, including without limitation the rights
  62851. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  62852. copies of the Software, and to permit persons to whom the Software is furnished
  62853. to do so, subject to the following conditions:
  62854. The above copyright notice and this permission notice shall be included in all
  62855. copies or substantial portions of the Software.
  62856. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  62857. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  62858. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  62859. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  62860. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62861. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  62862. THE SOFTWARE.
  62863. <?php
  62864. namespace Seld\Signal;
  62865. use Psr\Log\LoggerInterface;
  62866. use Closure;
  62867. use WeakReference;
  62868. final class SignalHandler
  62869. {
  62870. public const SIGHUP = 'SIGHUP';
  62871. public const SIGINT = 'SIGINT';
  62872. public const SIGQUIT = 'SIGQUIT';
  62873. public const SIGILL = 'SIGILL';
  62874. public const SIGTRAP = 'SIGTRAP';
  62875. public const SIGABRT = 'SIGABRT';
  62876. public const SIGIOT = 'SIGIOT';
  62877. public const SIGBUS = 'SIGBUS';
  62878. public const SIGFPE = 'SIGFPE';
  62879. public const SIGKILL = 'SIGKILL';
  62880. public const SIGUSR1 = 'SIGUSR1';
  62881. public const SIGUSR2 = 'SIGUSR2';
  62882. public const SIGSEGV = 'SIGSEGV';
  62883. public const SIGPIPE = 'SIGPIPE';
  62884. public const SIGALRM = 'SIGALRM';
  62885. public const SIGTERM = 'SIGTERM';
  62886. public const SIGSTKFLT = 'SIGSTKFLT';
  62887. public const SIGCLD = 'SIGCLD';
  62888. public const SIGCHLD = 'SIGCHLD';
  62889. public const SIGCONT = 'SIGCONT';
  62890. public const SIGSTOP = 'SIGSTOP';
  62891. public const SIGTSTP = 'SIGTSTP';
  62892. public const SIGTTIN = 'SIGTTIN';
  62893. public const SIGTTOU = 'SIGTTOU';
  62894. public const SIGURG = 'SIGURG';
  62895. public const SIGXCPU = 'SIGXCPU';
  62896. public const SIGXFSZ = 'SIGXFSZ';
  62897. public const SIGVTALRM = 'SIGVTALRM';
  62898. public const SIGPROF = 'SIGPROF';
  62899. public const SIGWINCH = 'SIGWINCH';
  62900. public const SIGPOLL = 'SIGPOLL';
  62901. public const SIGIO = 'SIGIO';
  62902. public const SIGPWR = 'SIGPWR';
  62903. public const SIGSYS = 'SIGSYS';
  62904. public const SIGBABY = 'SIGBABY';
  62905. public const SIGBREAK = 'SIGBREAK';
  62906. private const ALL_SIGNALS = [
  62907. self::SIGHUP, self::SIGINT, self::SIGQUIT, self::SIGILL, self::SIGTRAP, self::SIGABRT, self::SIGIOT, self::SIGBUS,
  62908. self::SIGFPE, self::SIGKILL, self::SIGUSR1, self::SIGUSR2, self::SIGSEGV, self::SIGPIPE, self::SIGALRM, self::SIGTERM,
  62909. self::SIGSTKFLT, self::SIGCLD, self::SIGCHLD, self::SIGCONT, self::SIGSTOP, self::SIGTSTP, self::SIGTTIN, self::SIGTTOU,
  62910. self::SIGURG, self::SIGXCPU, self::SIGXFSZ, self::SIGVTALRM, self::SIGPROF, self::SIGWINCH, self::SIGPOLL, self::SIGIO,
  62911. self::SIGPWR, self::SIGSYS, self::SIGBABY, self::SIGBREAK
  62912. ];
  62913. private $triggered = null;
  62914. private $signals;
  62915. private $loggerOrCallback;
  62916. private static $handlers = [];
  62917. private static $windowsHandler = null;
  62918. private function __construct(array $signals, $loggerOrCallback)
  62919. {
  62920. if (!is_callable($loggerOrCallback) && !$loggerOrCallback instanceof LoggerInterface && $loggerOrCallback !== null) {
  62921. throw new \InvalidArgumentException('$loggerOrCallback must be a '.LoggerInterface::class.' instance, a callable, or null, '.(is_object($loggerOrCallback) ? get_class($loggerOrCallback) : gettype($loggerOrCallback)).' received.');
  62922. }
  62923. $this->signals = $signals;
  62924. $this->loggerOrCallback = $loggerOrCallback;
  62925. }
  62926. private function trigger(string $signalName): void
  62927. {
  62928. $this->triggered = $signalName;
  62929. if ($this->loggerOrCallback instanceof LoggerInterface) {
  62930. $this->loggerOrCallback->info('Received '.$signalName);
  62931. } elseif ($this->loggerOrCallback !== null) {
  62932. ($this->loggerOrCallback)($signalName, $this);
  62933. }
  62934. }
  62935. public function isTriggered(): bool
  62936. {
  62937. return $this->triggered !== null;
  62938. }
  62939. public function exitWithLastSignal(): void
  62940. {
  62941. $signal = $this->triggered ?? 'SIGINT';
  62942. $signal = defined($signal) ? constant($signal) : 2;
  62943. if (function_exists('posix_kill') && function_exists('posix_getpid')) {
  62944. pcntl_signal($signal, SIG_DFL);
  62945. posix_kill(posix_getpid(), $signal);
  62946. }
  62947. exit(128 + $signal);
  62948. }
  62949. public function reset(): void
  62950. {
  62951. $this->triggered = null;
  62952. }
  62953. public function __destruct()
  62954. {
  62955. $this->unregister();
  62956. }
  62957. public static function create(?array $signals = null, $loggerOrCallback = null): self
  62958. {
  62959. if ($signals === null) {
  62960. $signals = [self::SIGINT, self::SIGTERM];
  62961. }
  62962. $signals = array_map(function ($signal) {
  62963. if (is_int($signal)) {
  62964. return self::getSignalName($signal);
  62965. } elseif (!in_array($signal, self::ALL_SIGNALS, true)) {
  62966. throw new \InvalidArgumentException('$signals must be an array of SIG* constants or self::SIG* constants, got '.var_export($signal, true));
  62967. }
  62968. return $signal;
  62969. }, (array) $signals);
  62970. $handler = new self($signals, $loggerOrCallback);
  62971. if (PHP_VERSION_ID >= 80000) {
  62972. array_unshift(self::$handlers, WeakReference::create($handler));
  62973. } else {
  62974. array_unshift(self::$handlers, $handler);
  62975. }
  62976. if (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli' && (in_array(self::SIGINT, $signals, true) || in_array(self::SIGBREAK, $signals, true))) {
  62977. if (null === self::$windowsHandler) {
  62978. self::$windowsHandler = Closure::fromCallable([self::class, 'handleWindowsSignal']);
  62979. sapi_windows_set_ctrl_handler(self::$windowsHandler);
  62980. }
  62981. }
  62982. if (function_exists('pcntl_signal') && function_exists('pcntl_async_signals')) {
  62983. pcntl_async_signals(true);
  62984. self::registerPcntlHandler($signals);
  62985. }
  62986. return $handler;
  62987. }
  62988. public function unregister(): void
  62989. {
  62990. $signals = $this->signals;
  62991. $index = false;
  62992. foreach (self::$handlers as $key => $handler) {
  62993. if (($handler instanceof WeakReference && $handler->get() === $this) || $handler === $this) {
  62994. $index = $key;
  62995. break;
  62996. }
  62997. }
  62998. if ($index === false) {
  62999. return;
  63000. }
  63001. unset(self::$handlers[$index]);
  63002. if (self::$windowsHandler !== null && (in_array(self::SIGINT, $signals, true) || in_array(self::SIGBREAK, $signals, true))) {
  63003. if (self::getHandlerFor(self::SIGINT) === null && self::getHandlerFor(self::SIGBREAK) === null) {
  63004. sapi_windows_set_ctrl_handler(self::$windowsHandler, false);
  63005. self::$windowsHandler = null;
  63006. }
  63007. }
  63008. if (function_exists('pcntl_signal')) {
  63009. foreach ($signals as $signal) {
  63010. if (!defined($signal)) {
  63011. continue;
  63012. }
  63013. if (self::getHandlerFor($signal) !== null) {
  63014. continue;
  63015. }
  63016. pcntl_signal(constant($signal), SIG_DFL);
  63017. }
  63018. }
  63019. }
  63020. public static function unregisterAll(): void
  63021. {
  63022. if (self::$windowsHandler !== null) {
  63023. sapi_windows_set_ctrl_handler(self::$windowsHandler, false);
  63024. self::$windowsHandler = null;
  63025. }
  63026. foreach (self::$handlers as $key => $handler) {
  63027. if ($handler instanceof WeakReference) {
  63028. $handler = $handler->get();
  63029. if ($handler === null) {
  63030. unset(self::$handlers[$key]);
  63031. continue;
  63032. }
  63033. }
  63034. $handler->unregister();
  63035. }
  63036. }
  63037. private static function registerPcntlHandler(array $signals): void
  63038. {
  63039. static $callable;
  63040. if ($callable === null) {
  63041. $callable = Closure::fromCallable([self::class, 'handlePcntlSignal']);
  63042. }
  63043. foreach ($signals as $signal) {
  63044. if (!defined($signal)) {
  63045. continue;
  63046. }
  63047. pcntl_signal(constant($signal), $callable);
  63048. }
  63049. }
  63050. private static function handleWindowsSignal(int $event): void
  63051. {
  63052. if (PHP_WINDOWS_EVENT_CTRL_C === $event) {
  63053. self::callHandlerFor(self::SIGINT);
  63054. } elseif (PHP_WINDOWS_EVENT_CTRL_BREAK === $event) {
  63055. self::callHandlerFor(self::SIGBREAK);
  63056. }
  63057. }
  63058. private static function handlePcntlSignal(int $signal): void
  63059. {
  63060. self::callHandlerFor(self::getSignalName($signal));
  63061. }
  63062. private static function callHandlerFor(string $signal): void
  63063. {
  63064. $handler = self::getHandlerFor($signal);
  63065. if ($handler !== null) {
  63066. $handler->trigger($signal);
  63067. }
  63068. }
  63069. private static function getHandlerFor(string $signal): ?self
  63070. {
  63071. foreach (self::$handlers as $key => $handler) {
  63072. if ($handler instanceof WeakReference) {
  63073. $handler = $handler->get();
  63074. if ($handler === null) {
  63075. unset(self::$handlers[$key]);
  63076. continue;
  63077. }
  63078. }
  63079. if (in_array($signal, $handler->signals, true)) {
  63080. return $handler;
  63081. }
  63082. }
  63083. return null;
  63084. }
  63085. private static function getSignalName(int $signo): string
  63086. {
  63087. static $signals = null;
  63088. if ($signals === null) {
  63089. $signals = [];
  63090. foreach (self::ALL_SIGNALS as $value) {
  63091. if (defined($value)) {
  63092. $signals[constant($value)] = $value;
  63093. }
  63094. }
  63095. }
  63096. if (isset($signals[$signo])) {
  63097. return $signals[$signo];
  63098. }
  63099. throw new \InvalidArgumentException('Unknown signal #'.$signo);
  63100. }
  63101. }
  63102. <?php
  63103. namespace Symfony\Component\Console;
  63104. use Symfony\Component\Console\Command\Command;
  63105. use Symfony\Component\Console\Command\CompleteCommand;
  63106. use Symfony\Component\Console\Command\DumpCompletionCommand;
  63107. use Symfony\Component\Console\Command\HelpCommand;
  63108. use Symfony\Component\Console\Command\LazyCommand;
  63109. use Symfony\Component\Console\Command\ListCommand;
  63110. use Symfony\Component\Console\Command\SignalableCommandInterface;
  63111. use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
  63112. use Symfony\Component\Console\Completion\CompletionInput;
  63113. use Symfony\Component\Console\Completion\CompletionSuggestions;
  63114. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  63115. use Symfony\Component\Console\Event\ConsoleErrorEvent;
  63116. use Symfony\Component\Console\Event\ConsoleSignalEvent;
  63117. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  63118. use Symfony\Component\Console\Exception\CommandNotFoundException;
  63119. use Symfony\Component\Console\Exception\ExceptionInterface;
  63120. use Symfony\Component\Console\Exception\LogicException;
  63121. use Symfony\Component\Console\Exception\NamespaceNotFoundException;
  63122. use Symfony\Component\Console\Exception\RuntimeException;
  63123. use Symfony\Component\Console\Formatter\OutputFormatter;
  63124. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  63125. use Symfony\Component\Console\Helper\FormatterHelper;
  63126. use Symfony\Component\Console\Helper\Helper;
  63127. use Symfony\Component\Console\Helper\HelperSet;
  63128. use Symfony\Component\Console\Helper\ProcessHelper;
  63129. use Symfony\Component\Console\Helper\QuestionHelper;
  63130. use Symfony\Component\Console\Input\ArgvInput;
  63131. use Symfony\Component\Console\Input\ArrayInput;
  63132. use Symfony\Component\Console\Input\InputArgument;
  63133. use Symfony\Component\Console\Input\InputAwareInterface;
  63134. use Symfony\Component\Console\Input\InputDefinition;
  63135. use Symfony\Component\Console\Input\InputInterface;
  63136. use Symfony\Component\Console\Input\InputOption;
  63137. use Symfony\Component\Console\Output\ConsoleOutput;
  63138. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  63139. use Symfony\Component\Console\Output\OutputInterface;
  63140. use Symfony\Component\Console\SignalRegistry\SignalRegistry;
  63141. use Symfony\Component\Console\Style\SymfonyStyle;
  63142. use Symfony\Component\ErrorHandler\ErrorHandler;
  63143. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  63144. use Symfony\Contracts\Service\ResetInterface;
  63145. class Application implements ResetInterface
  63146. {
  63147. private $commands = [];
  63148. private $wantHelps = false;
  63149. private $runningCommand;
  63150. private $name;
  63151. private $version;
  63152. private $commandLoader;
  63153. private $catchExceptions = true;
  63154. private $autoExit = true;
  63155. private $definition;
  63156. private $helperSet;
  63157. private $dispatcher;
  63158. private $terminal;
  63159. private $defaultCommand;
  63160. private $singleCommand = false;
  63161. private $initialized;
  63162. private $signalRegistry;
  63163. private $signalsToDispatchEvent = [];
  63164. public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN')
  63165. {
  63166. $this->name = $name;
  63167. $this->version = $version;
  63168. $this->terminal = new Terminal();
  63169. $this->defaultCommand = 'list';
  63170. if (\defined('SIGINT') && SignalRegistry::isSupported()) {
  63171. $this->signalRegistry = new SignalRegistry();
  63172. $this->signalsToDispatchEvent = [\SIGINT, \SIGTERM, \SIGUSR1, \SIGUSR2];
  63173. }
  63174. }
  63175. public function setDispatcher(EventDispatcherInterface $dispatcher)
  63176. {
  63177. $this->dispatcher = $dispatcher;
  63178. }
  63179. public function setCommandLoader(CommandLoaderInterface $commandLoader)
  63180. {
  63181. $this->commandLoader = $commandLoader;
  63182. }
  63183. public function getSignalRegistry(): SignalRegistry
  63184. {
  63185. if (!$this->signalRegistry) {
  63186. 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.');
  63187. }
  63188. return $this->signalRegistry;
  63189. }
  63190. public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent)
  63191. {
  63192. $this->signalsToDispatchEvent = $signalsToDispatchEvent;
  63193. }
  63194. public function run(?InputInterface $input = null, ?OutputInterface $output = null)
  63195. {
  63196. if (\function_exists('putenv')) {
  63197. @putenv('LINES='.$this->terminal->getHeight());
  63198. @putenv('COLUMNS='.$this->terminal->getWidth());
  63199. }
  63200. if (null === $input) {
  63201. $input = new ArgvInput();
  63202. }
  63203. if (null === $output) {
  63204. $output = new ConsoleOutput();
  63205. }
  63206. $renderException = function (\Throwable $e) use ($output) {
  63207. if ($output instanceof ConsoleOutputInterface) {
  63208. $this->renderThrowable($e, $output->getErrorOutput());
  63209. } else {
  63210. $this->renderThrowable($e, $output);
  63211. }
  63212. };
  63213. if ($phpHandler = set_exception_handler($renderException)) {
  63214. restore_exception_handler();
  63215. if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
  63216. $errorHandler = true;
  63217. } elseif ($errorHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
  63218. $phpHandler[0]->setExceptionHandler($errorHandler);
  63219. }
  63220. }
  63221. try {
  63222. $this->configureIO($input, $output);
  63223. $exitCode = $this->doRun($input, $output);
  63224. } catch (\Exception $e) {
  63225. if (!$this->catchExceptions) {
  63226. throw $e;
  63227. }
  63228. $renderException($e);
  63229. $exitCode = $e->getCode();
  63230. if (is_numeric($exitCode)) {
  63231. $exitCode = (int) $exitCode;
  63232. if ($exitCode <= 0) {
  63233. $exitCode = 1;
  63234. }
  63235. } else {
  63236. $exitCode = 1;
  63237. }
  63238. } finally {
  63239. if (!$phpHandler) {
  63240. if (set_exception_handler($renderException) === $renderException) {
  63241. restore_exception_handler();
  63242. }
  63243. restore_exception_handler();
  63244. } elseif (!$errorHandler) {
  63245. $finalHandler = $phpHandler[0]->setExceptionHandler(null);
  63246. if ($finalHandler !== $renderException) {
  63247. $phpHandler[0]->setExceptionHandler($finalHandler);
  63248. }
  63249. }
  63250. }
  63251. if ($this->autoExit) {
  63252. if ($exitCode > 255) {
  63253. $exitCode = 255;
  63254. }
  63255. exit($exitCode);
  63256. }
  63257. return $exitCode;
  63258. }
  63259. public function doRun(InputInterface $input, OutputInterface $output)
  63260. {
  63261. if (true === $input->hasParameterOption(['--version', '-V'], true)) {
  63262. $output->writeln($this->getLongVersion());
  63263. return 0;
  63264. }
  63265. try {
  63266. $input->bind($this->getDefinition());
  63267. } catch (ExceptionInterface $e) {
  63268. }
  63269. $name = $this->getCommandName($input);
  63270. if (true === $input->hasParameterOption(['--help', '-h'], true)) {
  63271. if (!$name) {
  63272. $name = 'help';
  63273. $input = new ArrayInput(['command_name' => $this->defaultCommand]);
  63274. } else {
  63275. $this->wantHelps = true;
  63276. }
  63277. }
  63278. if (!$name) {
  63279. $name = $this->defaultCommand;
  63280. $definition = $this->getDefinition();
  63281. $definition->setArguments(array_merge(
  63282. $definition->getArguments(),
  63283. [
  63284. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  63285. ]
  63286. ));
  63287. }
  63288. try {
  63289. $this->runningCommand = null;
  63290. $command = $this->find($name);
  63291. } catch (\Throwable $e) {
  63292. if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
  63293. if (null !== $this->dispatcher) {
  63294. $event = new ConsoleErrorEvent($input, $output, $e);
  63295. $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
  63296. if (0 === $event->getExitCode()) {
  63297. return 0;
  63298. }
  63299. $e = $event->getError();
  63300. }
  63301. throw $e;
  63302. }
  63303. $alternative = $alternatives[0];
  63304. $style = new SymfonyStyle($input, $output);
  63305. $output->writeln('');
  63306. $formattedBlock = (new FormatterHelper())->formatBlock(sprintf('Command "%s" is not defined.', $name), 'error', true);
  63307. $output->writeln($formattedBlock);
  63308. if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
  63309. if (null !== $this->dispatcher) {
  63310. $event = new ConsoleErrorEvent($input, $output, $e);
  63311. $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
  63312. return $event->getExitCode();
  63313. }
  63314. return 1;
  63315. }
  63316. $command = $this->find($alternative);
  63317. }
  63318. if ($command instanceof LazyCommand) {
  63319. $command = $command->getCommand();
  63320. }
  63321. $this->runningCommand = $command;
  63322. $exitCode = $this->doRunCommand($command, $input, $output);
  63323. $this->runningCommand = null;
  63324. return $exitCode;
  63325. }
  63326. public function reset()
  63327. {
  63328. }
  63329. public function setHelperSet(HelperSet $helperSet)
  63330. {
  63331. $this->helperSet = $helperSet;
  63332. }
  63333. public function getHelperSet()
  63334. {
  63335. if (!$this->helperSet) {
  63336. $this->helperSet = $this->getDefaultHelperSet();
  63337. }
  63338. return $this->helperSet;
  63339. }
  63340. public function setDefinition(InputDefinition $definition)
  63341. {
  63342. $this->definition = $definition;
  63343. }
  63344. public function getDefinition()
  63345. {
  63346. if (!$this->definition) {
  63347. $this->definition = $this->getDefaultInputDefinition();
  63348. }
  63349. if ($this->singleCommand) {
  63350. $inputDefinition = $this->definition;
  63351. $inputDefinition->setArguments();
  63352. return $inputDefinition;
  63353. }
  63354. return $this->definition;
  63355. }
  63356. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  63357. {
  63358. if (
  63359. CompletionInput::TYPE_ARGUMENT_VALUE === $input->getCompletionType()
  63360. && 'command' === $input->getCompletionName()
  63361. ) {
  63362. $commandNames = [];
  63363. foreach ($this->all() as $name => $command) {
  63364. if ($command->isHidden() || $command->getName() !== $name) {
  63365. continue;
  63366. }
  63367. $commandNames[] = $command->getName();
  63368. foreach ($command->getAliases() as $name) {
  63369. $commandNames[] = $name;
  63370. }
  63371. }
  63372. $suggestions->suggestValues(array_filter($commandNames));
  63373. return;
  63374. }
  63375. if (CompletionInput::TYPE_OPTION_NAME === $input->getCompletionType()) {
  63376. $suggestions->suggestOptions($this->getDefinition()->getOptions());
  63377. return;
  63378. }
  63379. }
  63380. public function getHelp()
  63381. {
  63382. return $this->getLongVersion();
  63383. }
  63384. public function areExceptionsCaught()
  63385. {
  63386. return $this->catchExceptions;
  63387. }
  63388. public function setCatchExceptions(bool $boolean)
  63389. {
  63390. $this->catchExceptions = $boolean;
  63391. }
  63392. public function isAutoExitEnabled()
  63393. {
  63394. return $this->autoExit;
  63395. }
  63396. public function setAutoExit(bool $boolean)
  63397. {
  63398. $this->autoExit = $boolean;
  63399. }
  63400. public function getName()
  63401. {
  63402. return $this->name;
  63403. }
  63404. public function setName(string $name)
  63405. {
  63406. $this->name = $name;
  63407. }
  63408. public function getVersion()
  63409. {
  63410. return $this->version;
  63411. }
  63412. public function setVersion(string $version)
  63413. {
  63414. $this->version = $version;
  63415. }
  63416. public function getLongVersion()
  63417. {
  63418. if ('UNKNOWN' !== $this->getName()) {
  63419. if ('UNKNOWN' !== $this->getVersion()) {
  63420. return sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion());
  63421. }
  63422. return $this->getName();
  63423. }
  63424. return 'Console Tool';
  63425. }
  63426. public function register(string $name)
  63427. {
  63428. return $this->add(new Command($name));
  63429. }
  63430. public function addCommands(array $commands)
  63431. {
  63432. foreach ($commands as $command) {
  63433. $this->add($command);
  63434. }
  63435. }
  63436. public function add(Command $command)
  63437. {
  63438. $this->init();
  63439. $command->setApplication($this);
  63440. if (!$command->isEnabled()) {
  63441. $command->setApplication(null);
  63442. return null;
  63443. }
  63444. if (!$command instanceof LazyCommand) {
  63445. $command->getDefinition();
  63446. }
  63447. if (!$command->getName()) {
  63448. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', get_debug_type($command)));
  63449. }
  63450. $this->commands[$command->getName()] = $command;
  63451. foreach ($command->getAliases() as $alias) {
  63452. $this->commands[$alias] = $command;
  63453. }
  63454. return $command;
  63455. }
  63456. public function get(string $name)
  63457. {
  63458. $this->init();
  63459. if (!$this->has($name)) {
  63460. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  63461. }
  63462. if (!isset($this->commands[$name])) {
  63463. 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));
  63464. }
  63465. $command = $this->commands[$name];
  63466. if ($this->wantHelps) {
  63467. $this->wantHelps = false;
  63468. $helpCommand = $this->get('help');
  63469. $helpCommand->setCommand($command);
  63470. return $helpCommand;
  63471. }
  63472. return $command;
  63473. }
  63474. public function has(string $name)
  63475. {
  63476. $this->init();
  63477. return isset($this->commands[$name]) || ($this->commandLoader && $this->commandLoader->has($name) && $this->add($this->commandLoader->get($name)));
  63478. }
  63479. public function getNamespaces()
  63480. {
  63481. $namespaces = [];
  63482. foreach ($this->all() as $command) {
  63483. if ($command->isHidden()) {
  63484. continue;
  63485. }
  63486. $namespaces[] = $this->extractAllNamespaces($command->getName());
  63487. foreach ($command->getAliases() as $alias) {
  63488. $namespaces[] = $this->extractAllNamespaces($alias);
  63489. }
  63490. }
  63491. return array_values(array_unique(array_filter(array_merge([], ...$namespaces))));
  63492. }
  63493. public function findNamespace(string $namespace)
  63494. {
  63495. $allNamespaces = $this->getNamespaces();
  63496. $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $namespace))).'[^:]*';
  63497. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  63498. if (empty($namespaces)) {
  63499. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  63500. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  63501. if (1 == \count($alternatives)) {
  63502. $message .= "\n\nDid you mean this?\n ";
  63503. } else {
  63504. $message .= "\n\nDid you mean one of these?\n ";
  63505. }
  63506. $message .= implode("\n ", $alternatives);
  63507. }
  63508. throw new NamespaceNotFoundException($message, $alternatives);
  63509. }
  63510. $exact = \in_array($namespace, $namespaces, true);
  63511. if (\count($namespaces) > 1 && !$exact) {
  63512. 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));
  63513. }
  63514. return $exact ? $namespace : reset($namespaces);
  63515. }
  63516. public function find(string $name)
  63517. {
  63518. $this->init();
  63519. $aliases = [];
  63520. foreach ($this->commands as $command) {
  63521. foreach ($command->getAliases() as $alias) {
  63522. if (!$this->has($alias)) {
  63523. $this->commands[$alias] = $command;
  63524. }
  63525. }
  63526. }
  63527. if ($this->has($name)) {
  63528. return $this->get($name);
  63529. }
  63530. $allCommands = $this->commandLoader ? array_merge($this->commandLoader->getNames(), array_keys($this->commands)) : array_keys($this->commands);
  63531. $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $name))).'[^:]*';
  63532. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  63533. if (empty($commands)) {
  63534. $commands = preg_grep('{^'.$expr.'}i', $allCommands);
  63535. }
  63536. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}i', $commands)) < 1) {
  63537. if (false !== $pos = strrpos($name, ':')) {
  63538. $this->findNamespace(substr($name, 0, $pos));
  63539. }
  63540. $message = sprintf('Command "%s" is not defined.', $name);
  63541. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  63542. $alternatives = array_filter($alternatives, function ($name) {
  63543. return !$this->get($name)->isHidden();
  63544. });
  63545. if (1 == \count($alternatives)) {
  63546. $message .= "\n\nDid you mean this?\n ";
  63547. } else {
  63548. $message .= "\n\nDid you mean one of these?\n ";
  63549. }
  63550. $message .= implode("\n ", $alternatives);
  63551. }
  63552. throw new CommandNotFoundException($message, array_values($alternatives));
  63553. }
  63554. if (\count($commands) > 1) {
  63555. $commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
  63556. $commands = array_unique(array_filter($commands, function ($nameOrAlias) use (&$commandList, $commands, &$aliases) {
  63557. if (!$commandList[$nameOrAlias] instanceof Command) {
  63558. $commandList[$nameOrAlias] = $this->commandLoader->get($nameOrAlias);
  63559. }
  63560. $commandName = $commandList[$nameOrAlias]->getName();
  63561. $aliases[$nameOrAlias] = $commandName;
  63562. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  63563. }));
  63564. }
  63565. if (\count($commands) > 1) {
  63566. $usableWidth = $this->terminal->getWidth() - 10;
  63567. $abbrevs = array_values($commands);
  63568. $maxLen = 0;
  63569. foreach ($abbrevs as $abbrev) {
  63570. $maxLen = max(Helper::width($abbrev), $maxLen);
  63571. }
  63572. $abbrevs = array_map(function ($cmd) use ($commandList, $usableWidth, $maxLen, &$commands) {
  63573. if ($commandList[$cmd]->isHidden()) {
  63574. unset($commands[array_search($cmd, $commands)]);
  63575. return false;
  63576. }
  63577. $abbrev = str_pad($cmd, $maxLen, ' ').' '.$commandList[$cmd]->getDescription();
  63578. return Helper::width($abbrev) > $usableWidth ? Helper::substr($abbrev, 0, $usableWidth - 3).'...' : $abbrev;
  63579. }, array_values($commands));
  63580. if (\count($commands) > 1) {
  63581. $suggestions = $this->getAbbreviationSuggestions(array_filter($abbrevs));
  63582. throw new CommandNotFoundException(sprintf("Command \"%s\" is ambiguous.\nDid you mean one of these?\n%s.", $name, $suggestions), array_values($commands));
  63583. }
  63584. }
  63585. $command = $this->get(reset($commands));
  63586. if ($command->isHidden()) {
  63587. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  63588. }
  63589. return $command;
  63590. }
  63591. public function all(?string $namespace = null)
  63592. {
  63593. $this->init();
  63594. if (null === $namespace) {
  63595. if (!$this->commandLoader) {
  63596. return $this->commands;
  63597. }
  63598. $commands = $this->commands;
  63599. foreach ($this->commandLoader->getNames() as $name) {
  63600. if (!isset($commands[$name]) && $this->has($name)) {
  63601. $commands[$name] = $this->get($name);
  63602. }
  63603. }
  63604. return $commands;
  63605. }
  63606. $commands = [];
  63607. foreach ($this->commands as $name => $command) {
  63608. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  63609. $commands[$name] = $command;
  63610. }
  63611. }
  63612. if ($this->commandLoader) {
  63613. foreach ($this->commandLoader->getNames() as $name) {
  63614. if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1) && $this->has($name)) {
  63615. $commands[$name] = $this->get($name);
  63616. }
  63617. }
  63618. }
  63619. return $commands;
  63620. }
  63621. public static function getAbbreviations(array $names)
  63622. {
  63623. $abbrevs = [];
  63624. foreach ($names as $name) {
  63625. for ($len = \strlen($name); $len > 0; --$len) {
  63626. $abbrev = substr($name, 0, $len);
  63627. $abbrevs[$abbrev][] = $name;
  63628. }
  63629. }
  63630. return $abbrevs;
  63631. }
  63632. public function renderThrowable(\Throwable $e, OutputInterface $output): void
  63633. {
  63634. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  63635. $this->doRenderThrowable($e, $output);
  63636. if (null !== $this->runningCommand) {
  63637. $output->writeln(sprintf('<info>%s</info>', OutputFormatter::escape(sprintf($this->runningCommand->getSynopsis(), $this->getName()))), OutputInterface::VERBOSITY_QUIET);
  63638. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  63639. }
  63640. }
  63641. protected function doRenderThrowable(\Throwable $e, OutputInterface $output): void
  63642. {
  63643. do {
  63644. $message = trim($e->getMessage());
  63645. if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  63646. $class = get_debug_type($e);
  63647. $title = sprintf(' [%s%s] ', $class, 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
  63648. $len = Helper::width($title);
  63649. } else {
  63650. $len = 0;
  63651. }
  63652. if (str_contains($message, "@anonymous\0")) {
  63653. $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) {
  63654. return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0];
  63655. }, $message);
  63656. }
  63657. $width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : \PHP_INT_MAX;
  63658. $lines = [];
  63659. foreach ('' !== $message ? preg_split('/\r?\n/', $message) : [] as $line) {
  63660. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  63661. $lineLength = Helper::width($line) + 4;
  63662. $lines[] = [$line, $lineLength];
  63663. $len = max($lineLength, $len);
  63664. }
  63665. }
  63666. $messages = [];
  63667. if (!$e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  63668. $messages[] = sprintf('<comment>%s</comment>', OutputFormatter::escape(sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a')));
  63669. }
  63670. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  63671. if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  63672. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::width($title))));
  63673. }
  63674. foreach ($lines as $line) {
  63675. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  63676. }
  63677. $messages[] = $emptyLine;
  63678. $messages[] = '';
  63679. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  63680. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  63681. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  63682. $trace = $e->getTrace();
  63683. array_unshift($trace, [
  63684. 'function' => '',
  63685. 'file' => $e->getFile() ?: 'n/a',
  63686. 'line' => $e->getLine() ?: 'n/a',
  63687. 'args' => [],
  63688. ]);
  63689. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  63690. $class = $trace[$i]['class'] ?? '';
  63691. $type = $trace[$i]['type'] ?? '';
  63692. $function = $trace[$i]['function'] ?? '';
  63693. $file = $trace[$i]['file'] ?? 'n/a';
  63694. $line = $trace[$i]['line'] ?? 'n/a';
  63695. $output->writeln(sprintf(' %s%s at <info>%s:%s</info>', $class, $function ? $type.$function.'()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET);
  63696. }
  63697. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  63698. }
  63699. } while ($e = $e->getPrevious());
  63700. }
  63701. protected function configureIO(InputInterface $input, OutputInterface $output)
  63702. {
  63703. if (true === $input->hasParameterOption(['--ansi'], true)) {
  63704. $output->setDecorated(true);
  63705. } elseif (true === $input->hasParameterOption(['--no-ansi'], true)) {
  63706. $output->setDecorated(false);
  63707. }
  63708. if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
  63709. $input->setInteractive(false);
  63710. }
  63711. switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
  63712. case -1:
  63713. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  63714. break;
  63715. case 1:
  63716. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  63717. break;
  63718. case 2:
  63719. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  63720. break;
  63721. case 3:
  63722. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  63723. break;
  63724. default:
  63725. $shellVerbosity = 0;
  63726. break;
  63727. }
  63728. if (true === $input->hasParameterOption(['--quiet', '-q'], true)) {
  63729. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  63730. $shellVerbosity = -1;
  63731. } else {
  63732. if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || 3 === $input->getParameterOption('--verbose', false, true)) {
  63733. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  63734. $shellVerbosity = 3;
  63735. } elseif ($input->hasParameterOption('-vv', true) || $input->hasParameterOption('--verbose=2', true) || 2 === $input->getParameterOption('--verbose', false, true)) {
  63736. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  63737. $shellVerbosity = 2;
  63738. } elseif ($input->hasParameterOption('-v', true) || $input->hasParameterOption('--verbose=1', true) || $input->hasParameterOption('--verbose', true) || $input->getParameterOption('--verbose', false, true)) {
  63739. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  63740. $shellVerbosity = 1;
  63741. }
  63742. }
  63743. if (-1 === $shellVerbosity) {
  63744. $input->setInteractive(false);
  63745. }
  63746. if (\function_exists('putenv')) {
  63747. @putenv('SHELL_VERBOSITY='.$shellVerbosity);
  63748. }
  63749. $_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
  63750. $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
  63751. }
  63752. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  63753. {
  63754. foreach ($command->getHelperSet() as $helper) {
  63755. if ($helper instanceof InputAwareInterface) {
  63756. $helper->setInput($input);
  63757. }
  63758. }
  63759. if ($this->signalsToDispatchEvent) {
  63760. $commandSignals = $command instanceof SignalableCommandInterface ? $command->getSubscribedSignals() : [];
  63761. if ($commandSignals || null !== $this->dispatcher) {
  63762. if (!$this->signalRegistry) {
  63763. 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.');
  63764. }
  63765. if (Terminal::hasSttyAvailable()) {
  63766. $sttyMode = shell_exec('stty -g');
  63767. foreach ([\SIGINT, \SIGTERM] as $signal) {
  63768. $this->signalRegistry->register($signal, static function () use ($sttyMode) {
  63769. shell_exec('stty '.$sttyMode);
  63770. });
  63771. }
  63772. }
  63773. }
  63774. if (null !== $this->dispatcher) {
  63775. foreach ($this->signalsToDispatchEvent as $signal) {
  63776. $event = new ConsoleSignalEvent($command, $input, $output, $signal);
  63777. $this->signalRegistry->register($signal, function ($signal, $hasNext) use ($event) {
  63778. $this->dispatcher->dispatch($event, ConsoleEvents::SIGNAL);
  63779. if (!$hasNext) {
  63780. if (!\in_array($signal, [\SIGUSR1, \SIGUSR2], true)) {
  63781. exit(0);
  63782. }
  63783. }
  63784. });
  63785. }
  63786. }
  63787. foreach ($commandSignals as $signal) {
  63788. $this->signalRegistry->register($signal, [$command, 'handleSignal']);
  63789. }
  63790. }
  63791. if (null === $this->dispatcher) {
  63792. return $command->run($input, $output);
  63793. }
  63794. try {
  63795. $command->mergeApplicationDefinition();
  63796. $input->bind($command->getDefinition());
  63797. } catch (ExceptionInterface $e) {
  63798. }
  63799. $event = new ConsoleCommandEvent($command, $input, $output);
  63800. $e = null;
  63801. try {
  63802. $this->dispatcher->dispatch($event, ConsoleEvents::COMMAND);
  63803. if ($event->commandShouldRun()) {
  63804. $exitCode = $command->run($input, $output);
  63805. } else {
  63806. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  63807. }
  63808. } catch (\Throwable $e) {
  63809. $event = new ConsoleErrorEvent($input, $output, $e, $command);
  63810. $this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
  63811. $e = $event->getError();
  63812. if (0 === $exitCode = $event->getExitCode()) {
  63813. $e = null;
  63814. }
  63815. }
  63816. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  63817. $this->dispatcher->dispatch($event, ConsoleEvents::TERMINATE);
  63818. if (null !== $e) {
  63819. throw $e;
  63820. }
  63821. return $event->getExitCode();
  63822. }
  63823. protected function getCommandName(InputInterface $input)
  63824. {
  63825. return $this->singleCommand ? $this->defaultCommand : $input->getFirstArgument();
  63826. }
  63827. protected function getDefaultInputDefinition()
  63828. {
  63829. return new InputDefinition([
  63830. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  63831. 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'),
  63832. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  63833. 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'),
  63834. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  63835. new InputOption('--ansi', '', InputOption::VALUE_NEGATABLE, 'Force (or disable --no-ansi) ANSI output', null),
  63836. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  63837. ]);
  63838. }
  63839. protected function getDefaultCommands()
  63840. {
  63841. return [new HelpCommand(), new ListCommand(), new CompleteCommand(), new DumpCompletionCommand()];
  63842. }
  63843. protected function getDefaultHelperSet()
  63844. {
  63845. return new HelperSet([
  63846. new FormatterHelper(),
  63847. new DebugFormatterHelper(),
  63848. new ProcessHelper(),
  63849. new QuestionHelper(),
  63850. ]);
  63851. }
  63852. private function getAbbreviationSuggestions(array $abbrevs): string
  63853. {
  63854. return ' '.implode("\n ", $abbrevs);
  63855. }
  63856. public function extractNamespace(string $name, ?int $limit = null)
  63857. {
  63858. $parts = explode(':', $name, -1);
  63859. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  63860. }
  63861. private function findAlternatives(string $name, iterable $collection): array
  63862. {
  63863. $threshold = 1e3;
  63864. $alternatives = [];
  63865. $collectionParts = [];
  63866. foreach ($collection as $item) {
  63867. $collectionParts[$item] = explode(':', $item);
  63868. }
  63869. foreach (explode(':', $name) as $i => $subname) {
  63870. foreach ($collectionParts as $collectionName => $parts) {
  63871. $exists = isset($alternatives[$collectionName]);
  63872. if (!isset($parts[$i]) && $exists) {
  63873. $alternatives[$collectionName] += $threshold;
  63874. continue;
  63875. } elseif (!isset($parts[$i])) {
  63876. continue;
  63877. }
  63878. $lev = levenshtein($subname, $parts[$i]);
  63879. if ($lev <= \strlen($subname) / 3 || '' !== $subname && str_contains($parts[$i], $subname)) {
  63880. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  63881. } elseif ($exists) {
  63882. $alternatives[$collectionName] += $threshold;
  63883. }
  63884. }
  63885. }
  63886. foreach ($collection as $item) {
  63887. $lev = levenshtein($name, $item);
  63888. if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) {
  63889. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  63890. }
  63891. }
  63892. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  63893. ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE);
  63894. return array_keys($alternatives);
  63895. }
  63896. public function setDefaultCommand(string $commandName, bool $isSingleCommand = false)
  63897. {
  63898. $this->defaultCommand = explode('|', ltrim($commandName, '|'))[0];
  63899. if ($isSingleCommand) {
  63900. $this->find($commandName);
  63901. $this->singleCommand = true;
  63902. }
  63903. return $this;
  63904. }
  63905. public function isSingleCommand(): bool
  63906. {
  63907. return $this->singleCommand;
  63908. }
  63909. private function splitStringByWidth(string $string, int $width): array
  63910. {
  63911. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  63912. return str_split($string, $width);
  63913. }
  63914. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  63915. $lines = [];
  63916. $line = '';
  63917. $offset = 0;
  63918. while (preg_match('/.{1,10000}/u', $utf8String, $m, 0, $offset)) {
  63919. $offset += \strlen($m[0]);
  63920. foreach (preg_split('//u', $m[0]) as $char) {
  63921. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  63922. $line .= $char;
  63923. continue;
  63924. }
  63925. $lines[] = str_pad($line, $width);
  63926. $line = $char;
  63927. }
  63928. }
  63929. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  63930. mb_convert_variables($encoding, 'utf8', $lines);
  63931. return $lines;
  63932. }
  63933. private function extractAllNamespaces(string $name): array
  63934. {
  63935. $parts = explode(':', $name, -1);
  63936. $namespaces = [];
  63937. foreach ($parts as $part) {
  63938. if (\count($namespaces)) {
  63939. $namespaces[] = end($namespaces).':'.$part;
  63940. } else {
  63941. $namespaces[] = $part;
  63942. }
  63943. }
  63944. return $namespaces;
  63945. }
  63946. private function init()
  63947. {
  63948. if ($this->initialized) {
  63949. return;
  63950. }
  63951. $this->initialized = true;
  63952. foreach ($this->getDefaultCommands() as $command) {
  63953. $this->add($command);
  63954. }
  63955. }
  63956. }
  63957. <?php
  63958. namespace Symfony\Component\Console\Attribute;
  63959. #[\Attribute(\Attribute::TARGET_CLASS)]
  63960. class AsCommand
  63961. {
  63962. public function __construct(
  63963. public string $name,
  63964. public ?string $description = null,
  63965. array $aliases = [],
  63966. bool $hidden = false,
  63967. ) {
  63968. if (!$hidden && !$aliases) {
  63969. return;
  63970. }
  63971. $name = explode('|', $name);
  63972. $name = array_merge($name, $aliases);
  63973. if ($hidden && '' !== $name[0]) {
  63974. array_unshift($name, '');
  63975. }
  63976. $this->name = implode('|', $name);
  63977. }
  63978. }
  63979. <?php
  63980. namespace Symfony\Component\Console\CI;
  63981. use Symfony\Component\Console\Output\OutputInterface;
  63982. class GithubActionReporter
  63983. {
  63984. private $output;
  63985. private const ESCAPED_DATA = [
  63986. '%' => '%25',
  63987. "\r" => '%0D',
  63988. "\n" => '%0A',
  63989. ];
  63990. private const ESCAPED_PROPERTIES = [
  63991. '%' => '%25',
  63992. "\r" => '%0D',
  63993. "\n" => '%0A',
  63994. ':' => '%3A',
  63995. ',' => '%2C',
  63996. ];
  63997. public function __construct(OutputInterface $output)
  63998. {
  63999. $this->output = $output;
  64000. }
  64001. public static function isGithubActionEnvironment(): bool
  64002. {
  64003. return false !== getenv('GITHUB_ACTIONS');
  64004. }
  64005. public function error(string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
  64006. {
  64007. $this->log('error', $message, $file, $line, $col);
  64008. }
  64009. public function warning(string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
  64010. {
  64011. $this->log('warning', $message, $file, $line, $col);
  64012. }
  64013. public function debug(string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
  64014. {
  64015. $this->log('debug', $message, $file, $line, $col);
  64016. }
  64017. private function log(string $type, string $message, ?string $file = null, ?int $line = null, ?int $col = null): void
  64018. {
  64019. $message = strtr($message, self::ESCAPED_DATA);
  64020. if (!$file) {
  64021. $this->output->writeln(sprintf('::%s::%s', $type, $message));
  64022. return;
  64023. }
  64024. $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));
  64025. }
  64026. }
  64027. <?php
  64028. namespace Symfony\Component\Console;
  64029. use Symfony\Component\Console\Exception\InvalidArgumentException;
  64030. final class Color
  64031. {
  64032. private const COLORS = [
  64033. 'black' => 0,
  64034. 'red' => 1,
  64035. 'green' => 2,
  64036. 'yellow' => 3,
  64037. 'blue' => 4,
  64038. 'magenta' => 5,
  64039. 'cyan' => 6,
  64040. 'white' => 7,
  64041. 'default' => 9,
  64042. ];
  64043. private const BRIGHT_COLORS = [
  64044. 'gray' => 0,
  64045. 'bright-red' => 1,
  64046. 'bright-green' => 2,
  64047. 'bright-yellow' => 3,
  64048. 'bright-blue' => 4,
  64049. 'bright-magenta' => 5,
  64050. 'bright-cyan' => 6,
  64051. 'bright-white' => 7,
  64052. ];
  64053. private const AVAILABLE_OPTIONS = [
  64054. 'bold' => ['set' => 1, 'unset' => 22],
  64055. 'underscore' => ['set' => 4, 'unset' => 24],
  64056. 'blink' => ['set' => 5, 'unset' => 25],
  64057. 'reverse' => ['set' => 7, 'unset' => 27],
  64058. 'conceal' => ['set' => 8, 'unset' => 28],
  64059. ];
  64060. private $foreground;
  64061. private $background;
  64062. private $options = [];
  64063. public function __construct(string $foreground = '', string $background = '', array $options = [])
  64064. {
  64065. $this->foreground = $this->parseColor($foreground);
  64066. $this->background = $this->parseColor($background, true);
  64067. foreach ($options as $option) {
  64068. if (!isset(self::AVAILABLE_OPTIONS[$option])) {
  64069. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s).', $option, implode(', ', array_keys(self::AVAILABLE_OPTIONS))));
  64070. }
  64071. $this->options[$option] = self::AVAILABLE_OPTIONS[$option];
  64072. }
  64073. }
  64074. public function apply(string $text): string
  64075. {
  64076. return $this->set().$text.$this->unset();
  64077. }
  64078. public function set(): string
  64079. {
  64080. $setCodes = [];
  64081. if ('' !== $this->foreground) {
  64082. $setCodes[] = $this->foreground;
  64083. }
  64084. if ('' !== $this->background) {
  64085. $setCodes[] = $this->background;
  64086. }
  64087. foreach ($this->options as $option) {
  64088. $setCodes[] = $option['set'];
  64089. }
  64090. if (0 === \count($setCodes)) {
  64091. return '';
  64092. }
  64093. return sprintf("\033[%sm", implode(';', $setCodes));
  64094. }
  64095. public function unset(): string
  64096. {
  64097. $unsetCodes = [];
  64098. if ('' !== $this->foreground) {
  64099. $unsetCodes[] = 39;
  64100. }
  64101. if ('' !== $this->background) {
  64102. $unsetCodes[] = 49;
  64103. }
  64104. foreach ($this->options as $option) {
  64105. $unsetCodes[] = $option['unset'];
  64106. }
  64107. if (0 === \count($unsetCodes)) {
  64108. return '';
  64109. }
  64110. return sprintf("\033[%sm", implode(';', $unsetCodes));
  64111. }
  64112. private function parseColor(string $color, bool $background = false): string
  64113. {
  64114. if ('' === $color) {
  64115. return '';
  64116. }
  64117. if ('#' === $color[0]) {
  64118. $color = substr($color, 1);
  64119. if (3 === \strlen($color)) {
  64120. $color = $color[0].$color[0].$color[1].$color[1].$color[2].$color[2];
  64121. }
  64122. if (6 !== \strlen($color)) {
  64123. throw new InvalidArgumentException(sprintf('Invalid "%s" color.', $color));
  64124. }
  64125. return ($background ? '4' : '3').$this->convertHexColorToAnsi(hexdec($color));
  64126. }
  64127. if (isset(self::COLORS[$color])) {
  64128. return ($background ? '4' : '3').self::COLORS[$color];
  64129. }
  64130. if (isset(self::BRIGHT_COLORS[$color])) {
  64131. return ($background ? '10' : '9').self::BRIGHT_COLORS[$color];
  64132. }
  64133. throw new InvalidArgumentException(sprintf('Invalid "%s" color; expected one of (%s).', $color, implode(', ', array_merge(array_keys(self::COLORS), array_keys(self::BRIGHT_COLORS)))));
  64134. }
  64135. private function convertHexColorToAnsi(int $color): string
  64136. {
  64137. $r = ($color >> 16) & 255;
  64138. $g = ($color >> 8) & 255;
  64139. $b = $color & 255;
  64140. if ('truecolor' !== getenv('COLORTERM')) {
  64141. return (string) $this->degradeHexColorToAnsi($r, $g, $b);
  64142. }
  64143. return sprintf('8;2;%d;%d;%d', $r, $g, $b);
  64144. }
  64145. private function degradeHexColorToAnsi(int $r, int $g, int $b): int
  64146. {
  64147. if (0 === round($this->getSaturation($r, $g, $b) / 50)) {
  64148. return 0;
  64149. }
  64150. return (round($b / 255) << 2) | (round($g / 255) << 1) | round($r / 255);
  64151. }
  64152. private function getSaturation(int $r, int $g, int $b): int
  64153. {
  64154. $r = $r / 255;
  64155. $g = $g / 255;
  64156. $b = $b / 255;
  64157. $v = max($r, $g, $b);
  64158. if (0 === $diff = $v - min($r, $g, $b)) {
  64159. return 0;
  64160. }
  64161. return (int) $diff * 100 / $v;
  64162. }
  64163. }
  64164. <?php
  64165. namespace Symfony\Component\Console\Command;
  64166. use Symfony\Component\Console\Application;
  64167. use Symfony\Component\Console\Attribute\AsCommand;
  64168. use Symfony\Component\Console\Completion\CompletionInput;
  64169. use Symfony\Component\Console\Completion\CompletionSuggestions;
  64170. use Symfony\Component\Console\Exception\ExceptionInterface;
  64171. use Symfony\Component\Console\Exception\InvalidArgumentException;
  64172. use Symfony\Component\Console\Exception\LogicException;
  64173. use Symfony\Component\Console\Helper\HelperSet;
  64174. use Symfony\Component\Console\Input\InputArgument;
  64175. use Symfony\Component\Console\Input\InputDefinition;
  64176. use Symfony\Component\Console\Input\InputInterface;
  64177. use Symfony\Component\Console\Input\InputOption;
  64178. use Symfony\Component\Console\Output\OutputInterface;
  64179. class Command
  64180. {
  64181. public const SUCCESS = 0;
  64182. public const FAILURE = 1;
  64183. public const INVALID = 2;
  64184. protected static $defaultName;
  64185. protected static $defaultDescription;
  64186. private $application;
  64187. private $name;
  64188. private $processTitle;
  64189. private $aliases = [];
  64190. private $definition;
  64191. private $hidden = false;
  64192. private $help = '';
  64193. private $description = '';
  64194. private $fullDefinition;
  64195. private $ignoreValidationErrors = false;
  64196. private $code;
  64197. private $synopsis = [];
  64198. private $usages = [];
  64199. private $helperSet;
  64200. public static function getDefaultName()
  64201. {
  64202. $class = static::class;
  64203. if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
  64204. return $attribute[0]->newInstance()->name;
  64205. }
  64206. $r = new \ReflectionProperty($class, 'defaultName');
  64207. return $class === $r->class ? static::$defaultName : null;
  64208. }
  64209. public static function getDefaultDescription(): ?string
  64210. {
  64211. $class = static::class;
  64212. if (\PHP_VERSION_ID >= 80000 && $attribute = (new \ReflectionClass($class))->getAttributes(AsCommand::class)) {
  64213. return $attribute[0]->newInstance()->description;
  64214. }
  64215. $r = new \ReflectionProperty($class, 'defaultDescription');
  64216. return $class === $r->class ? static::$defaultDescription : null;
  64217. }
  64218. public function __construct(?string $name = null)
  64219. {
  64220. $this->definition = new InputDefinition();
  64221. if (null === $name && null !== $name = static::getDefaultName()) {
  64222. $aliases = explode('|', $name);
  64223. if ('' === $name = array_shift($aliases)) {
  64224. $this->setHidden(true);
  64225. $name = array_shift($aliases);
  64226. }
  64227. $this->setAliases($aliases);
  64228. }
  64229. if (null !== $name) {
  64230. $this->setName($name);
  64231. }
  64232. if ('' === $this->description) {
  64233. $this->setDescription(static::getDefaultDescription() ?? '');
  64234. }
  64235. $this->configure();
  64236. }
  64237. public function ignoreValidationErrors()
  64238. {
  64239. $this->ignoreValidationErrors = true;
  64240. }
  64241. public function setApplication(?Application $application = null)
  64242. {
  64243. $this->application = $application;
  64244. if ($application) {
  64245. $this->setHelperSet($application->getHelperSet());
  64246. } else {
  64247. $this->helperSet = null;
  64248. }
  64249. $this->fullDefinition = null;
  64250. }
  64251. public function setHelperSet(HelperSet $helperSet)
  64252. {
  64253. $this->helperSet = $helperSet;
  64254. }
  64255. public function getHelperSet()
  64256. {
  64257. return $this->helperSet;
  64258. }
  64259. public function getApplication()
  64260. {
  64261. return $this->application;
  64262. }
  64263. public function isEnabled()
  64264. {
  64265. return true;
  64266. }
  64267. protected function configure()
  64268. {
  64269. }
  64270. protected function execute(InputInterface $input, OutputInterface $output)
  64271. {
  64272. throw new LogicException('You must override the execute() method in the concrete command class.');
  64273. }
  64274. protected function interact(InputInterface $input, OutputInterface $output)
  64275. {
  64276. }
  64277. protected function initialize(InputInterface $input, OutputInterface $output)
  64278. {
  64279. }
  64280. public function run(InputInterface $input, OutputInterface $output)
  64281. {
  64282. $this->mergeApplicationDefinition();
  64283. try {
  64284. $input->bind($this->getDefinition());
  64285. } catch (ExceptionInterface $e) {
  64286. if (!$this->ignoreValidationErrors) {
  64287. throw $e;
  64288. }
  64289. }
  64290. $this->initialize($input, $output);
  64291. if (null !== $this->processTitle) {
  64292. if (\function_exists('cli_set_process_title')) {
  64293. if (!@cli_set_process_title($this->processTitle)) {
  64294. if ('Darwin' === \PHP_OS) {
  64295. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  64296. } else {
  64297. cli_set_process_title($this->processTitle);
  64298. }
  64299. }
  64300. } elseif (\function_exists('setproctitle')) {
  64301. setproctitle($this->processTitle);
  64302. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  64303. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  64304. }
  64305. }
  64306. if ($input->isInteractive()) {
  64307. $this->interact($input, $output);
  64308. }
  64309. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  64310. $input->setArgument('command', $this->getName());
  64311. }
  64312. $input->validate();
  64313. if ($this->code) {
  64314. $statusCode = ($this->code)($input, $output);
  64315. } else {
  64316. $statusCode = $this->execute($input, $output);
  64317. if (!\is_int($statusCode)) {
  64318. throw new \TypeError(sprintf('Return value of "%s::execute()" must be of the type int, "%s" returned.', static::class, get_debug_type($statusCode)));
  64319. }
  64320. }
  64321. return is_numeric($statusCode) ? (int) $statusCode : 0;
  64322. }
  64323. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  64324. {
  64325. }
  64326. public function setCode(callable $code)
  64327. {
  64328. if ($code instanceof \Closure) {
  64329. $r = new \ReflectionFunction($code);
  64330. if (null === $r->getClosureThis()) {
  64331. set_error_handler(static function () {});
  64332. try {
  64333. if ($c = \Closure::bind($code, $this)) {
  64334. $code = $c;
  64335. }
  64336. } finally {
  64337. restore_error_handler();
  64338. }
  64339. }
  64340. }
  64341. $this->code = $code;
  64342. return $this;
  64343. }
  64344. public function mergeApplicationDefinition(bool $mergeArgs = true)
  64345. {
  64346. if (null === $this->application) {
  64347. return;
  64348. }
  64349. $this->fullDefinition = new InputDefinition();
  64350. $this->fullDefinition->setOptions($this->definition->getOptions());
  64351. $this->fullDefinition->addOptions($this->application->getDefinition()->getOptions());
  64352. if ($mergeArgs) {
  64353. $this->fullDefinition->setArguments($this->application->getDefinition()->getArguments());
  64354. $this->fullDefinition->addArguments($this->definition->getArguments());
  64355. } else {
  64356. $this->fullDefinition->setArguments($this->definition->getArguments());
  64357. }
  64358. }
  64359. public function setDefinition($definition)
  64360. {
  64361. if ($definition instanceof InputDefinition) {
  64362. $this->definition = $definition;
  64363. } else {
  64364. $this->definition->setDefinition($definition);
  64365. }
  64366. $this->fullDefinition = null;
  64367. return $this;
  64368. }
  64369. public function getDefinition()
  64370. {
  64371. return $this->fullDefinition ?? $this->getNativeDefinition();
  64372. }
  64373. public function getNativeDefinition()
  64374. {
  64375. if (null === $this->definition) {
  64376. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', static::class));
  64377. }
  64378. return $this->definition;
  64379. }
  64380. public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null)
  64381. {
  64382. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  64383. if (null !== $this->fullDefinition) {
  64384. $this->fullDefinition->addArgument(new InputArgument($name, $mode, $description, $default));
  64385. }
  64386. return $this;
  64387. }
  64388. public function addOption(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null)
  64389. {
  64390. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  64391. if (null !== $this->fullDefinition) {
  64392. $this->fullDefinition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  64393. }
  64394. return $this;
  64395. }
  64396. public function setName(string $name)
  64397. {
  64398. $this->validateName($name);
  64399. $this->name = $name;
  64400. return $this;
  64401. }
  64402. public function setProcessTitle(string $title)
  64403. {
  64404. $this->processTitle = $title;
  64405. return $this;
  64406. }
  64407. public function getName()
  64408. {
  64409. return $this->name;
  64410. }
  64411. public function setHidden(bool $hidden )
  64412. {
  64413. $this->hidden = $hidden;
  64414. return $this;
  64415. }
  64416. public function isHidden()
  64417. {
  64418. return $this->hidden;
  64419. }
  64420. public function setDescription(string $description)
  64421. {
  64422. $this->description = $description;
  64423. return $this;
  64424. }
  64425. public function getDescription()
  64426. {
  64427. return $this->description;
  64428. }
  64429. public function setHelp(string $help)
  64430. {
  64431. $this->help = $help;
  64432. return $this;
  64433. }
  64434. public function getHelp()
  64435. {
  64436. return $this->help;
  64437. }
  64438. public function getProcessedHelp()
  64439. {
  64440. $name = $this->name;
  64441. $isSingleCommand = $this->application && $this->application->isSingleCommand();
  64442. $placeholders = [
  64443. '%command.name%',
  64444. '%command.full_name%',
  64445. ];
  64446. $replacements = [
  64447. $name,
  64448. $isSingleCommand ? $_SERVER['PHP_SELF'] : $_SERVER['PHP_SELF'].' '.$name,
  64449. ];
  64450. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  64451. }
  64452. public function setAliases(iterable $aliases)
  64453. {
  64454. $list = [];
  64455. foreach ($aliases as $alias) {
  64456. $this->validateName($alias);
  64457. $list[] = $alias;
  64458. }
  64459. $this->aliases = \is_array($aliases) ? $aliases : $list;
  64460. return $this;
  64461. }
  64462. public function getAliases()
  64463. {
  64464. return $this->aliases;
  64465. }
  64466. public function getSynopsis(bool $short = false)
  64467. {
  64468. $key = $short ? 'short' : 'long';
  64469. if (!isset($this->synopsis[$key])) {
  64470. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  64471. }
  64472. return $this->synopsis[$key];
  64473. }
  64474. public function addUsage(string $usage)
  64475. {
  64476. if (!str_starts_with($usage, $this->name)) {
  64477. $usage = sprintf('%s %s', $this->name, $usage);
  64478. }
  64479. $this->usages[] = $usage;
  64480. return $this;
  64481. }
  64482. public function getUsages()
  64483. {
  64484. return $this->usages;
  64485. }
  64486. public function getHelper(string $name)
  64487. {
  64488. if (null === $this->helperSet) {
  64489. 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));
  64490. }
  64491. return $this->helperSet->get($name);
  64492. }
  64493. private function validateName(string $name)
  64494. {
  64495. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  64496. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  64497. }
  64498. }
  64499. }
  64500. <?php
  64501. namespace Symfony\Component\Console\Command;
  64502. use Symfony\Component\Console\Completion\CompletionInput;
  64503. use Symfony\Component\Console\Completion\CompletionSuggestions;
  64504. use Symfony\Component\Console\Completion\Output\BashCompletionOutput;
  64505. use Symfony\Component\Console\Completion\Output\CompletionOutputInterface;
  64506. use Symfony\Component\Console\Exception\CommandNotFoundException;
  64507. use Symfony\Component\Console\Exception\ExceptionInterface;
  64508. use Symfony\Component\Console\Input\InputInterface;
  64509. use Symfony\Component\Console\Input\InputOption;
  64510. use Symfony\Component\Console\Output\OutputInterface;
  64511. final class CompleteCommand extends Command
  64512. {
  64513. protected static $defaultName = '|_complete';
  64514. protected static $defaultDescription = 'Internal command to provide shell completion suggestions';
  64515. private $completionOutputs;
  64516. private $isDebug = false;
  64517. public function __construct(array $completionOutputs = [])
  64518. {
  64519. $this->completionOutputs = $completionOutputs + ['bash' => BashCompletionOutput::class];
  64520. parent::__construct();
  64521. }
  64522. protected function configure(): void
  64523. {
  64524. $this
  64525. ->addOption('shell', 's', InputOption::VALUE_REQUIRED, 'The shell type ("'.implode('", "', array_keys($this->completionOutputs)).'")')
  64526. ->addOption('input', 'i', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'An array of input tokens (e.g. COMP_WORDS or argv)')
  64527. ->addOption('current', 'c', InputOption::VALUE_REQUIRED, 'The index of the "input" array that the cursor is in (e.g. COMP_CWORD)')
  64528. ->addOption('symfony', 'S', InputOption::VALUE_REQUIRED, 'The version of the completion script')
  64529. ;
  64530. }
  64531. protected function initialize(InputInterface $input, OutputInterface $output)
  64532. {
  64533. $this->isDebug = filter_var(getenv('SYMFONY_COMPLETION_DEBUG'), \FILTER_VALIDATE_BOOLEAN);
  64534. }
  64535. protected function execute(InputInterface $input, OutputInterface $output): int
  64536. {
  64537. try {
  64538. $shell = $input->getOption('shell');
  64539. if (!$shell) {
  64540. throw new \RuntimeException('The "--shell" option must be set.');
  64541. }
  64542. if (!$completionOutput = $this->completionOutputs[$shell] ?? false) {
  64543. throw new \RuntimeException(sprintf('Shell completion is not supported for your shell: "%s" (supported: "%s").', $shell, implode('", "', array_keys($this->completionOutputs))));
  64544. }
  64545. $completionInput = $this->createCompletionInput($input);
  64546. $suggestions = new CompletionSuggestions();
  64547. $this->log([
  64548. '',
  64549. '<comment>'.date('Y-m-d H:i:s').'</>',
  64550. '<info>Input:</> <comment>("|" indicates the cursor position)</>',
  64551. ' '.(string) $completionInput,
  64552. '<info>Command:</>',
  64553. ' '.(string) implode(' ', $_SERVER['argv']),
  64554. '<info>Messages:</>',
  64555. ]);
  64556. $command = $this->findCommand($completionInput, $output);
  64557. if (null === $command) {
  64558. $this->log(' No command found, completing using the Application class.');
  64559. $this->getApplication()->complete($completionInput, $suggestions);
  64560. } elseif (
  64561. $completionInput->mustSuggestArgumentValuesFor('command')
  64562. && $command->getName() !== $completionInput->getCompletionValue()
  64563. && !\in_array($completionInput->getCompletionValue(), $command->getAliases(), true)
  64564. ) {
  64565. $this->log(' No command found, completing using the Application class.');
  64566. $suggestions->suggestValues(array_filter(array_merge([$command->getName()], $command->getAliases())));
  64567. } else {
  64568. $command->mergeApplicationDefinition();
  64569. $completionInput->bind($command->getDefinition());
  64570. if (CompletionInput::TYPE_OPTION_NAME === $completionInput->getCompletionType()) {
  64571. $this->log(' Completing option names for the <comment>'.\get_class($command instanceof LazyCommand ? $command->getCommand() : $command).'</> command.');
  64572. $suggestions->suggestOptions($command->getDefinition()->getOptions());
  64573. } else {
  64574. $this->log([
  64575. ' Completing using the <comment>'.\get_class($command instanceof LazyCommand ? $command->getCommand() : $command).'</> class.',
  64576. ' Completing <comment>'.$completionInput->getCompletionType().'</> for <comment>'.$completionInput->getCompletionName().'</>',
  64577. ]);
  64578. if (null !== $compval = $completionInput->getCompletionValue()) {
  64579. $this->log(' Current value: <comment>'.$compval.'</>');
  64580. }
  64581. $command->complete($completionInput, $suggestions);
  64582. }
  64583. }
  64584. $completionOutput = new $completionOutput();
  64585. $this->log('<info>Suggestions:</>');
  64586. if ($options = $suggestions->getOptionSuggestions()) {
  64587. $this->log(' --'.implode(' --', array_map(function ($o) { return $o->getName(); }, $options)));
  64588. } elseif ($values = $suggestions->getValueSuggestions()) {
  64589. $this->log(' '.implode(' ', $values));
  64590. } else {
  64591. $this->log(' <comment>No suggestions were provided</>');
  64592. }
  64593. $completionOutput->write($suggestions, $output);
  64594. } catch (\Throwable $e) {
  64595. $this->log([
  64596. '<error>Error!</error>',
  64597. (string) $e,
  64598. ]);
  64599. if ($output->isDebug()) {
  64600. throw $e;
  64601. }
  64602. return 2;
  64603. }
  64604. return 0;
  64605. }
  64606. private function createCompletionInput(InputInterface $input): CompletionInput
  64607. {
  64608. $currentIndex = $input->getOption('current');
  64609. if (!$currentIndex || !ctype_digit($currentIndex)) {
  64610. throw new \RuntimeException('The "--current" option must be set and it must be an integer.');
  64611. }
  64612. $completionInput = CompletionInput::fromTokens($input->getOption('input'), (int) $currentIndex);
  64613. try {
  64614. $completionInput->bind($this->getApplication()->getDefinition());
  64615. } catch (ExceptionInterface $e) {
  64616. }
  64617. return $completionInput;
  64618. }
  64619. private function findCommand(CompletionInput $completionInput, OutputInterface $output): ?Command
  64620. {
  64621. try {
  64622. $inputName = $completionInput->getFirstArgument();
  64623. if (null === $inputName) {
  64624. return null;
  64625. }
  64626. return $this->getApplication()->find($inputName);
  64627. } catch (CommandNotFoundException $e) {
  64628. }
  64629. return null;
  64630. }
  64631. private function log($messages): void
  64632. {
  64633. if (!$this->isDebug) {
  64634. return;
  64635. }
  64636. $commandName = basename($_SERVER['argv'][0]);
  64637. file_put_contents(sys_get_temp_dir().'/sf_'.$commandName.'.log', implode(\PHP_EOL, (array) $messages).\PHP_EOL, \FILE_APPEND);
  64638. }
  64639. }
  64640. <?php
  64641. namespace Symfony\Component\Console\Command;
  64642. use Symfony\Component\Console\Completion\CompletionInput;
  64643. use Symfony\Component\Console\Completion\CompletionSuggestions;
  64644. use Symfony\Component\Console\Input\InputArgument;
  64645. use Symfony\Component\Console\Input\InputInterface;
  64646. use Symfony\Component\Console\Input\InputOption;
  64647. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  64648. use Symfony\Component\Console\Output\OutputInterface;
  64649. use Symfony\Component\Process\Process;
  64650. final class DumpCompletionCommand extends Command
  64651. {
  64652. protected static $defaultName = 'completion';
  64653. protected static $defaultDescription = 'Dump the shell completion script';
  64654. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  64655. {
  64656. if ($input->mustSuggestArgumentValuesFor('shell')) {
  64657. $suggestions->suggestValues($this->getSupportedShells());
  64658. }
  64659. }
  64660. protected function configure()
  64661. {
  64662. $fullCommand = $_SERVER['PHP_SELF'];
  64663. $commandName = basename($fullCommand);
  64664. $fullCommand = @realpath($fullCommand) ?: $fullCommand;
  64665. $this
  64666. ->setHelp(<<<EOH
  64667. The <info>%command.name%</> command dumps the shell completion script required
  64668. to use shell autocompletion (currently only bash completion is supported).
  64669. <comment>Static installation
  64670. -------------------</>
  64671. Dump the script to a global completion file and restart your shell:
  64672. <info>%command.full_name% bash | sudo tee /etc/bash_completion.d/{$commandName}</>
  64673. Or dump the script to a local file and source it:
  64674. <info>%command.full_name% bash > completion.sh</>
  64675. <comment># source the file whenever you use the project</>
  64676. <info>source completion.sh</>
  64677. <comment># or add this line at the end of your "~/.bashrc" file:</>
  64678. <info>source /path/to/completion.sh</>
  64679. <comment>Dynamic installation
  64680. --------------------</>
  64681. Add this to the end of your shell configuration file (e.g. <info>"~/.bashrc"</>):
  64682. <info>eval "$({$fullCommand} completion bash)"</>
  64683. EOH
  64684. )
  64685. ->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')
  64686. ->addOption('debug', null, InputOption::VALUE_NONE, 'Tail the completion debug log')
  64687. ;
  64688. }
  64689. protected function execute(InputInterface $input, OutputInterface $output): int
  64690. {
  64691. $commandName = basename($_SERVER['argv'][0]);
  64692. if ($input->getOption('debug')) {
  64693. $this->tailDebugLog($commandName, $output);
  64694. return 0;
  64695. }
  64696. $shell = $input->getArgument('shell') ?? self::guessShell();
  64697. $completionFile = __DIR__.'/../Resources/completion.'.$shell;
  64698. if (!file_exists($completionFile)) {
  64699. $supportedShells = $this->getSupportedShells();
  64700. if ($output instanceof ConsoleOutputInterface) {
  64701. $output = $output->getErrorOutput();
  64702. }
  64703. if ($shell) {
  64704. $output->writeln(sprintf('<error>Detected shell "%s", which is not supported by Symfony shell completion (supported shells: "%s").</>', $shell, implode('", "', $supportedShells)));
  64705. } else {
  64706. $output->writeln(sprintf('<error>Shell not detected, Symfony shell completion only supports "%s").</>', implode('", "', $supportedShells)));
  64707. }
  64708. return 2;
  64709. }
  64710. $output->write(str_replace(['{{ COMMAND_NAME }}', '{{ VERSION }}'], [$commandName, $this->getApplication()->getVersion()], file_get_contents($completionFile)));
  64711. return 0;
  64712. }
  64713. private static function guessShell(): string
  64714. {
  64715. return basename($_SERVER['SHELL'] ?? '');
  64716. }
  64717. private function tailDebugLog(string $commandName, OutputInterface $output): void
  64718. {
  64719. $debugFile = sys_get_temp_dir().'/sf_'.$commandName.'.log';
  64720. if (!file_exists($debugFile)) {
  64721. touch($debugFile);
  64722. }
  64723. $process = new Process(['tail', '-f', $debugFile], null, null, null, 0);
  64724. $process->run(function (string $type, string $line) use ($output): void {
  64725. $output->write($line);
  64726. });
  64727. }
  64728. private function getSupportedShells(): array
  64729. {
  64730. $shells = [];
  64731. foreach (new \DirectoryIterator(__DIR__.'/../Resources/') as $file) {
  64732. if (str_starts_with($file->getBasename(), 'completion.') && $file->isFile()) {
  64733. $shells[] = $file->getExtension();
  64734. }
  64735. }
  64736. return $shells;
  64737. }
  64738. }
  64739. <?php
  64740. namespace Symfony\Component\Console\Command;
  64741. use Symfony\Component\Console\Completion\CompletionInput;
  64742. use Symfony\Component\Console\Completion\CompletionSuggestions;
  64743. use Symfony\Component\Console\Descriptor\ApplicationDescription;
  64744. use Symfony\Component\Console\Helper\DescriptorHelper;
  64745. use Symfony\Component\Console\Input\InputArgument;
  64746. use Symfony\Component\Console\Input\InputInterface;
  64747. use Symfony\Component\Console\Input\InputOption;
  64748. use Symfony\Component\Console\Output\OutputInterface;
  64749. class HelpCommand extends Command
  64750. {
  64751. private $command;
  64752. protected function configure()
  64753. {
  64754. $this->ignoreValidationErrors();
  64755. $this
  64756. ->setName('help')
  64757. ->setDefinition([
  64758. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  64759. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  64760. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  64761. ])
  64762. ->setDescription('Display help for a command')
  64763. ->setHelp(<<<'EOF'
  64764. The <info>%command.name%</info> command displays help for a given command:
  64765. <info>%command.full_name% list</info>
  64766. You can also output the help in other formats by using the <comment>--format</comment> option:
  64767. <info>%command.full_name% --format=xml list</info>
  64768. To display the list of available commands, please use the <info>list</info> command.
  64769. EOF
  64770. )
  64771. ;
  64772. }
  64773. public function setCommand(Command $command)
  64774. {
  64775. $this->command = $command;
  64776. }
  64777. protected function execute(InputInterface $input, OutputInterface $output)
  64778. {
  64779. if (null === $this->command) {
  64780. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  64781. }
  64782. $helper = new DescriptorHelper();
  64783. $helper->describe($output, $this->command, [
  64784. 'format' => $input->getOption('format'),
  64785. 'raw_text' => $input->getOption('raw'),
  64786. ]);
  64787. $this->command = null;
  64788. return 0;
  64789. }
  64790. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  64791. {
  64792. if ($input->mustSuggestArgumentValuesFor('command_name')) {
  64793. $descriptor = new ApplicationDescription($this->getApplication());
  64794. $suggestions->suggestValues(array_keys($descriptor->getCommands()));
  64795. return;
  64796. }
  64797. if ($input->mustSuggestOptionValuesFor('format')) {
  64798. $helper = new DescriptorHelper();
  64799. $suggestions->suggestValues($helper->getFormats());
  64800. }
  64801. }
  64802. }
  64803. <?php
  64804. namespace Symfony\Component\Console\Command;
  64805. use Symfony\Component\Console\Application;
  64806. use Symfony\Component\Console\Completion\CompletionInput;
  64807. use Symfony\Component\Console\Completion\CompletionSuggestions;
  64808. use Symfony\Component\Console\Helper\HelperSet;
  64809. use Symfony\Component\Console\Input\InputDefinition;
  64810. use Symfony\Component\Console\Input\InputInterface;
  64811. use Symfony\Component\Console\Output\OutputInterface;
  64812. final class LazyCommand extends Command
  64813. {
  64814. private $command;
  64815. private $isEnabled;
  64816. public function __construct(string $name, array $aliases, string $description, bool $isHidden, \Closure $commandFactory, ?bool $isEnabled = true)
  64817. {
  64818. $this->setName($name)
  64819. ->setAliases($aliases)
  64820. ->setHidden($isHidden)
  64821. ->setDescription($description);
  64822. $this->command = $commandFactory;
  64823. $this->isEnabled = $isEnabled;
  64824. }
  64825. public function ignoreValidationErrors(): void
  64826. {
  64827. $this->getCommand()->ignoreValidationErrors();
  64828. }
  64829. public function setApplication(?Application $application = null): void
  64830. {
  64831. if ($this->command instanceof parent) {
  64832. $this->command->setApplication($application);
  64833. }
  64834. parent::setApplication($application);
  64835. }
  64836. public function setHelperSet(HelperSet $helperSet): void
  64837. {
  64838. if ($this->command instanceof parent) {
  64839. $this->command->setHelperSet($helperSet);
  64840. }
  64841. parent::setHelperSet($helperSet);
  64842. }
  64843. public function isEnabled(): bool
  64844. {
  64845. return $this->isEnabled ?? $this->getCommand()->isEnabled();
  64846. }
  64847. public function run(InputInterface $input, OutputInterface $output): int
  64848. {
  64849. return $this->getCommand()->run($input, $output);
  64850. }
  64851. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  64852. {
  64853. $this->getCommand()->complete($input, $suggestions);
  64854. }
  64855. public function setCode(callable $code): self
  64856. {
  64857. $this->getCommand()->setCode($code);
  64858. return $this;
  64859. }
  64860. public function mergeApplicationDefinition(bool $mergeArgs = true): void
  64861. {
  64862. $this->getCommand()->mergeApplicationDefinition($mergeArgs);
  64863. }
  64864. public function setDefinition($definition): self
  64865. {
  64866. $this->getCommand()->setDefinition($definition);
  64867. return $this;
  64868. }
  64869. public function getDefinition(): InputDefinition
  64870. {
  64871. return $this->getCommand()->getDefinition();
  64872. }
  64873. public function getNativeDefinition(): InputDefinition
  64874. {
  64875. return $this->getCommand()->getNativeDefinition();
  64876. }
  64877. public function addArgument(string $name, ?int $mode = null, string $description = '', $default = null): self
  64878. {
  64879. $this->getCommand()->addArgument($name, $mode, $description, $default);
  64880. return $this;
  64881. }
  64882. public function addOption(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null): self
  64883. {
  64884. $this->getCommand()->addOption($name, $shortcut, $mode, $description, $default);
  64885. return $this;
  64886. }
  64887. public function setProcessTitle(string $title): self
  64888. {
  64889. $this->getCommand()->setProcessTitle($title);
  64890. return $this;
  64891. }
  64892. public function setHelp(string $help): self
  64893. {
  64894. $this->getCommand()->setHelp($help);
  64895. return $this;
  64896. }
  64897. public function getHelp(): string
  64898. {
  64899. return $this->getCommand()->getHelp();
  64900. }
  64901. public function getProcessedHelp(): string
  64902. {
  64903. return $this->getCommand()->getProcessedHelp();
  64904. }
  64905. public function getSynopsis(bool $short = false): string
  64906. {
  64907. return $this->getCommand()->getSynopsis($short);
  64908. }
  64909. public function addUsage(string $usage): self
  64910. {
  64911. $this->getCommand()->addUsage($usage);
  64912. return $this;
  64913. }
  64914. public function getUsages(): array
  64915. {
  64916. return $this->getCommand()->getUsages();
  64917. }
  64918. public function getHelper(string $name)
  64919. {
  64920. return $this->getCommand()->getHelper($name);
  64921. }
  64922. public function getCommand(): parent
  64923. {
  64924. if (!$this->command instanceof \Closure) {
  64925. return $this->command;
  64926. }
  64927. $command = $this->command = ($this->command)();
  64928. $command->setApplication($this->getApplication());
  64929. if (null !== $this->getHelperSet()) {
  64930. $command->setHelperSet($this->getHelperSet());
  64931. }
  64932. $command->setName($this->getName())
  64933. ->setAliases($this->getAliases())
  64934. ->setHidden($this->isHidden())
  64935. ->setDescription($this->getDescription());
  64936. $command->getDefinition();
  64937. return $command;
  64938. }
  64939. }
  64940. <?php
  64941. namespace Symfony\Component\Console\Command;
  64942. use Symfony\Component\Console\Completion\CompletionInput;
  64943. use Symfony\Component\Console\Completion\CompletionSuggestions;
  64944. use Symfony\Component\Console\Descriptor\ApplicationDescription;
  64945. use Symfony\Component\Console\Helper\DescriptorHelper;
  64946. use Symfony\Component\Console\Input\InputArgument;
  64947. use Symfony\Component\Console\Input\InputInterface;
  64948. use Symfony\Component\Console\Input\InputOption;
  64949. use Symfony\Component\Console\Output\OutputInterface;
  64950. class ListCommand extends Command
  64951. {
  64952. protected function configure()
  64953. {
  64954. $this
  64955. ->setName('list')
  64956. ->setDefinition([
  64957. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  64958. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  64959. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  64960. new InputOption('short', null, InputOption::VALUE_NONE, 'To skip describing commands\' arguments'),
  64961. ])
  64962. ->setDescription('List commands')
  64963. ->setHelp(<<<'EOF'
  64964. The <info>%command.name%</info> command lists all commands:
  64965. <info>%command.full_name%</info>
  64966. You can also display the commands for a specific namespace:
  64967. <info>%command.full_name% test</info>
  64968. You can also output the information in other formats by using the <comment>--format</comment> option:
  64969. <info>%command.full_name% --format=xml</info>
  64970. It's also possible to get raw list of commands (useful for embedding command runner):
  64971. <info>%command.full_name% --raw</info>
  64972. EOF
  64973. )
  64974. ;
  64975. }
  64976. protected function execute(InputInterface $input, OutputInterface $output)
  64977. {
  64978. $helper = new DescriptorHelper();
  64979. $helper->describe($output, $this->getApplication(), [
  64980. 'format' => $input->getOption('format'),
  64981. 'raw_text' => $input->getOption('raw'),
  64982. 'namespace' => $input->getArgument('namespace'),
  64983. 'short' => $input->getOption('short'),
  64984. ]);
  64985. return 0;
  64986. }
  64987. public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
  64988. {
  64989. if ($input->mustSuggestArgumentValuesFor('namespace')) {
  64990. $descriptor = new ApplicationDescription($this->getApplication());
  64991. $suggestions->suggestValues(array_keys($descriptor->getNamespaces()));
  64992. return;
  64993. }
  64994. if ($input->mustSuggestOptionValuesFor('format')) {
  64995. $helper = new DescriptorHelper();
  64996. $suggestions->suggestValues($helper->getFormats());
  64997. }
  64998. }
  64999. }
  65000. <?php
  65001. namespace Symfony\Component\Console\Command;
  65002. use Symfony\Component\Console\Exception\LogicException;
  65003. use Symfony\Component\Lock\LockFactory;
  65004. use Symfony\Component\Lock\LockInterface;
  65005. use Symfony\Component\Lock\Store\FlockStore;
  65006. use Symfony\Component\Lock\Store\SemaphoreStore;
  65007. trait LockableTrait
  65008. {
  65009. private $lock;
  65010. private function lock(?string $name = null, bool $blocking = false): bool
  65011. {
  65012. if (!class_exists(SemaphoreStore::class)) {
  65013. throw new LogicException('To enable the locking feature you must install the symfony/lock component.');
  65014. }
  65015. if (null !== $this->lock) {
  65016. throw new LogicException('A lock is already in place.');
  65017. }
  65018. if (SemaphoreStore::isSupported()) {
  65019. $store = new SemaphoreStore();
  65020. } else {
  65021. $store = new FlockStore();
  65022. }
  65023. $this->lock = (new LockFactory($store))->createLock($name ?: $this->getName());
  65024. if (!$this->lock->acquire($blocking)) {
  65025. $this->lock = null;
  65026. return false;
  65027. }
  65028. return true;
  65029. }
  65030. private function release()
  65031. {
  65032. if ($this->lock) {
  65033. $this->lock->release();
  65034. $this->lock = null;
  65035. }
  65036. }
  65037. }
  65038. <?php
  65039. namespace Symfony\Component\Console\Command;
  65040. interface SignalableCommandInterface
  65041. {
  65042. public function getSubscribedSignals(): array;
  65043. public function handleSignal(int $signal): void;
  65044. }
  65045. <?php
  65046. namespace Symfony\Component\Console\CommandLoader;
  65047. use Symfony\Component\Console\Command\Command;
  65048. use Symfony\Component\Console\Exception\CommandNotFoundException;
  65049. interface CommandLoaderInterface
  65050. {
  65051. public function get(string $name);
  65052. public function has(string $name);
  65053. public function getNames();
  65054. }
  65055. <?php
  65056. namespace Symfony\Component\Console\CommandLoader;
  65057. use Psr\Container\ContainerInterface;
  65058. use Symfony\Component\Console\Exception\CommandNotFoundException;
  65059. class ContainerCommandLoader implements CommandLoaderInterface
  65060. {
  65061. private $container;
  65062. private $commandMap;
  65063. public function __construct(ContainerInterface $container, array $commandMap)
  65064. {
  65065. $this->container = $container;
  65066. $this->commandMap = $commandMap;
  65067. }
  65068. public function get(string $name)
  65069. {
  65070. if (!$this->has($name)) {
  65071. throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
  65072. }
  65073. return $this->container->get($this->commandMap[$name]);
  65074. }
  65075. public function has(string $name)
  65076. {
  65077. return isset($this->commandMap[$name]) && $this->container->has($this->commandMap[$name]);
  65078. }
  65079. public function getNames()
  65080. {
  65081. return array_keys($this->commandMap);
  65082. }
  65083. }
  65084. <?php
  65085. namespace Symfony\Component\Console\CommandLoader;
  65086. use Symfony\Component\Console\Exception\CommandNotFoundException;
  65087. class FactoryCommandLoader implements CommandLoaderInterface
  65088. {
  65089. private $factories;
  65090. public function __construct(array $factories)
  65091. {
  65092. $this->factories = $factories;
  65093. }
  65094. public function has(string $name)
  65095. {
  65096. return isset($this->factories[$name]);
  65097. }
  65098. public function get(string $name)
  65099. {
  65100. if (!isset($this->factories[$name])) {
  65101. throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
  65102. }
  65103. $factory = $this->factories[$name];
  65104. return $factory();
  65105. }
  65106. public function getNames()
  65107. {
  65108. return array_keys($this->factories);
  65109. }
  65110. }
  65111. <?php
  65112. namespace Symfony\Component\Console\Completion;
  65113. use Symfony\Component\Console\Exception\RuntimeException;
  65114. use Symfony\Component\Console\Input\ArgvInput;
  65115. use Symfony\Component\Console\Input\InputDefinition;
  65116. use Symfony\Component\Console\Input\InputOption;
  65117. final class CompletionInput extends ArgvInput
  65118. {
  65119. public const TYPE_ARGUMENT_VALUE = 'argument_value';
  65120. public const TYPE_OPTION_VALUE = 'option_value';
  65121. public const TYPE_OPTION_NAME = 'option_name';
  65122. public const TYPE_NONE = 'none';
  65123. private $tokens;
  65124. private $currentIndex;
  65125. private $completionType;
  65126. private $completionName = null;
  65127. private $completionValue = '';
  65128. public static function fromString(string $inputStr, int $currentIndex): self
  65129. {
  65130. preg_match_all('/(?<=^|\s)([\'"]?)(.+?)(?<!\\\\)\1(?=$|\s)/', $inputStr, $tokens);
  65131. return self::fromTokens($tokens[0], $currentIndex);
  65132. }
  65133. public static function fromTokens(array $tokens, int $currentIndex): self
  65134. {
  65135. $input = new self($tokens);
  65136. $input->tokens = $tokens;
  65137. $input->currentIndex = $currentIndex;
  65138. return $input;
  65139. }
  65140. public function bind(InputDefinition $definition): void
  65141. {
  65142. parent::bind($definition);
  65143. $relevantToken = $this->getRelevantToken();
  65144. if ('-' === $relevantToken[0]) {
  65145. [$optionToken, $optionValue] = explode('=', $relevantToken, 2) + ['', ''];
  65146. $option = $this->getOptionFromToken($optionToken);
  65147. if (null === $option && !$this->isCursorFree()) {
  65148. $this->completionType = self::TYPE_OPTION_NAME;
  65149. $this->completionValue = $relevantToken;
  65150. return;
  65151. }
  65152. if (null !== $option && $option->acceptValue()) {
  65153. $this->completionType = self::TYPE_OPTION_VALUE;
  65154. $this->completionName = $option->getName();
  65155. $this->completionValue = $optionValue ?: (!str_starts_with($optionToken, '--') ? substr($optionToken, 2) : '');
  65156. return;
  65157. }
  65158. }
  65159. $previousToken = $this->tokens[$this->currentIndex - 1];
  65160. if ('-' === $previousToken[0] && '' !== trim($previousToken, '-')) {
  65161. $previousOption = $this->getOptionFromToken($previousToken);
  65162. if (null !== $previousOption && $previousOption->acceptValue()) {
  65163. $this->completionType = self::TYPE_OPTION_VALUE;
  65164. $this->completionName = $previousOption->getName();
  65165. $this->completionValue = $relevantToken;
  65166. return;
  65167. }
  65168. }
  65169. $this->completionType = self::TYPE_ARGUMENT_VALUE;
  65170. foreach ($this->definition->getArguments() as $argumentName => $argument) {
  65171. if (!isset($this->arguments[$argumentName])) {
  65172. break;
  65173. }
  65174. $argumentValue = $this->arguments[$argumentName];
  65175. $this->completionName = $argumentName;
  65176. if (\is_array($argumentValue)) {
  65177. $this->completionValue = $argumentValue ? $argumentValue[array_key_last($argumentValue)] : null;
  65178. } else {
  65179. $this->completionValue = $argumentValue;
  65180. }
  65181. }
  65182. if ($this->currentIndex >= \count($this->tokens)) {
  65183. if (!isset($this->arguments[$argumentName]) || $this->definition->getArgument($argumentName)->isArray()) {
  65184. $this->completionName = $argumentName;
  65185. $this->completionValue = '';
  65186. } else {
  65187. $this->completionType = self::TYPE_NONE;
  65188. $this->completionName = null;
  65189. $this->completionValue = '';
  65190. }
  65191. }
  65192. }
  65193. public function getCompletionType(): string
  65194. {
  65195. return $this->completionType;
  65196. }
  65197. public function getCompletionName(): ?string
  65198. {
  65199. return $this->completionName;
  65200. }
  65201. public function getCompletionValue(): string
  65202. {
  65203. return $this->completionValue;
  65204. }
  65205. public function mustSuggestOptionValuesFor(string $optionName): bool
  65206. {
  65207. return self::TYPE_OPTION_VALUE === $this->getCompletionType() && $optionName === $this->getCompletionName();
  65208. }
  65209. public function mustSuggestArgumentValuesFor(string $argumentName): bool
  65210. {
  65211. return self::TYPE_ARGUMENT_VALUE === $this->getCompletionType() && $argumentName === $this->getCompletionName();
  65212. }
  65213. protected function parseToken(string $token, bool $parseOptions): bool
  65214. {
  65215. try {
  65216. return parent::parseToken($token, $parseOptions);
  65217. } catch (RuntimeException $e) {
  65218. }
  65219. return $parseOptions;
  65220. }
  65221. private function getOptionFromToken(string $optionToken): ?InputOption
  65222. {
  65223. $optionName = ltrim($optionToken, '-');
  65224. if (!$optionName) {
  65225. return null;
  65226. }
  65227. if ('-' === ($optionToken[1] ?? ' ')) {
  65228. return $this->definition->hasOption($optionName) ? $this->definition->getOption($optionName) : null;
  65229. }
  65230. return $this->definition->hasShortcut($optionName[0]) ? $this->definition->getOptionForShortcut($optionName[0]) : null;
  65231. }
  65232. private function getRelevantToken(): string
  65233. {
  65234. return $this->tokens[$this->isCursorFree() ? $this->currentIndex - 1 : $this->currentIndex];
  65235. }
  65236. private function isCursorFree(): bool
  65237. {
  65238. $nrOfTokens = \count($this->tokens);
  65239. if ($this->currentIndex > $nrOfTokens) {
  65240. throw new \LogicException('Current index is invalid, it must be the number of input tokens or one more.');
  65241. }
  65242. return $this->currentIndex >= $nrOfTokens;
  65243. }
  65244. public function __toString()
  65245. {
  65246. $str = '';
  65247. foreach ($this->tokens as $i => $token) {
  65248. $str .= $token;
  65249. if ($this->currentIndex === $i) {
  65250. $str .= '|';
  65251. }
  65252. $str .= ' ';
  65253. }
  65254. if ($this->currentIndex > $i) {
  65255. $str .= '|';
  65256. }
  65257. return rtrim($str);
  65258. }
  65259. }
  65260. <?php
  65261. namespace Symfony\Component\Console\Completion;
  65262. use Symfony\Component\Console\Input\InputOption;
  65263. final class CompletionSuggestions
  65264. {
  65265. private $valueSuggestions = [];
  65266. private $optionSuggestions = [];
  65267. public function suggestValue($value): self
  65268. {
  65269. $this->valueSuggestions[] = !$value instanceof Suggestion ? new Suggestion($value) : $value;
  65270. return $this;
  65271. }
  65272. public function suggestValues(array $values): self
  65273. {
  65274. foreach ($values as $value) {
  65275. $this->suggestValue($value);
  65276. }
  65277. return $this;
  65278. }
  65279. public function suggestOption(InputOption $option): self
  65280. {
  65281. $this->optionSuggestions[] = $option;
  65282. return $this;
  65283. }
  65284. public function suggestOptions(array $options): self
  65285. {
  65286. foreach ($options as $option) {
  65287. $this->suggestOption($option);
  65288. }
  65289. return $this;
  65290. }
  65291. public function getOptionSuggestions(): array
  65292. {
  65293. return $this->optionSuggestions;
  65294. }
  65295. public function getValueSuggestions(): array
  65296. {
  65297. return $this->valueSuggestions;
  65298. }
  65299. }
  65300. <?php
  65301. namespace Symfony\Component\Console\Completion\Output;
  65302. use Symfony\Component\Console\Completion\CompletionSuggestions;
  65303. use Symfony\Component\Console\Output\OutputInterface;
  65304. class BashCompletionOutput implements CompletionOutputInterface
  65305. {
  65306. public function write(CompletionSuggestions $suggestions, OutputInterface $output): void
  65307. {
  65308. $values = $suggestions->getValueSuggestions();
  65309. foreach ($suggestions->getOptionSuggestions() as $option) {
  65310. $values[] = '--'.$option->getName();
  65311. if ($option->isNegatable()) {
  65312. $values[] = '--no-'.$option->getName();
  65313. }
  65314. }
  65315. $output->writeln(implode("\n", $values));
  65316. }
  65317. }
  65318. <?php
  65319. namespace Symfony\Component\Console\Completion\Output;
  65320. use Symfony\Component\Console\Completion\CompletionSuggestions;
  65321. use Symfony\Component\Console\Output\OutputInterface;
  65322. interface CompletionOutputInterface
  65323. {
  65324. public function write(CompletionSuggestions $suggestions, OutputInterface $output): void;
  65325. }
  65326. <?php
  65327. namespace Symfony\Component\Console\Completion;
  65328. class Suggestion
  65329. {
  65330. private $value;
  65331. public function __construct(string $value)
  65332. {
  65333. $this->value = $value;
  65334. }
  65335. public function getValue(): string
  65336. {
  65337. return $this->value;
  65338. }
  65339. public function __toString(): string
  65340. {
  65341. return $this->getValue();
  65342. }
  65343. }
  65344. <?php
  65345. namespace Symfony\Component\Console;
  65346. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  65347. use Symfony\Component\Console\Event\ConsoleErrorEvent;
  65348. use Symfony\Component\Console\Event\ConsoleSignalEvent;
  65349. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  65350. final class ConsoleEvents
  65351. {
  65352. public const COMMAND = 'console.command';
  65353. public const SIGNAL = 'console.signal';
  65354. public const TERMINATE = 'console.terminate';
  65355. public const ERROR = 'console.error';
  65356. public const ALIASES = [
  65357. ConsoleCommandEvent::class => self::COMMAND,
  65358. ConsoleErrorEvent::class => self::ERROR,
  65359. ConsoleSignalEvent::class => self::SIGNAL,
  65360. ConsoleTerminateEvent::class => self::TERMINATE,
  65361. ];
  65362. }
  65363. <?php
  65364. namespace Symfony\Component\Console;
  65365. use Symfony\Component\Console\Output\OutputInterface;
  65366. final class Cursor
  65367. {
  65368. private $output;
  65369. private $input;
  65370. public function __construct(OutputInterface $output, $input = null)
  65371. {
  65372. $this->output = $output;
  65373. $this->input = $input ?? (\defined('STDIN') ? \STDIN : fopen('php://input', 'r+'));
  65374. }
  65375. public function moveUp(int $lines = 1): self
  65376. {
  65377. $this->output->write(sprintf("\x1b[%dA", $lines));
  65378. return $this;
  65379. }
  65380. public function moveDown(int $lines = 1): self
  65381. {
  65382. $this->output->write(sprintf("\x1b[%dB", $lines));
  65383. return $this;
  65384. }
  65385. public function moveRight(int $columns = 1): self
  65386. {
  65387. $this->output->write(sprintf("\x1b[%dC", $columns));
  65388. return $this;
  65389. }
  65390. public function moveLeft(int $columns = 1): self
  65391. {
  65392. $this->output->write(sprintf("\x1b[%dD", $columns));
  65393. return $this;
  65394. }
  65395. public function moveToColumn(int $column): self
  65396. {
  65397. $this->output->write(sprintf("\x1b[%dG", $column));
  65398. return $this;
  65399. }
  65400. public function moveToPosition(int $column, int $row): self
  65401. {
  65402. $this->output->write(sprintf("\x1b[%d;%dH", $row + 1, $column));
  65403. return $this;
  65404. }
  65405. public function savePosition(): self
  65406. {
  65407. $this->output->write("\x1b7");
  65408. return $this;
  65409. }
  65410. public function restorePosition(): self
  65411. {
  65412. $this->output->write("\x1b8");
  65413. return $this;
  65414. }
  65415. public function hide(): self
  65416. {
  65417. $this->output->write("\x1b[?25l");
  65418. return $this;
  65419. }
  65420. public function show(): self
  65421. {
  65422. $this->output->write("\x1b[?25h\x1b[?0c");
  65423. return $this;
  65424. }
  65425. public function clearLine(): self
  65426. {
  65427. $this->output->write("\x1b[2K");
  65428. return $this;
  65429. }
  65430. public function clearLineAfter(): self
  65431. {
  65432. $this->output->write("\x1b[K");
  65433. return $this;
  65434. }
  65435. public function clearOutput(): self
  65436. {
  65437. $this->output->write("\x1b[0J");
  65438. return $this;
  65439. }
  65440. public function clearScreen(): self
  65441. {
  65442. $this->output->write("\x1b[2J");
  65443. return $this;
  65444. }
  65445. public function getCurrentPosition(): array
  65446. {
  65447. static $isTtySupported;
  65448. if (null === $isTtySupported && \function_exists('proc_open')) {
  65449. $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
  65450. }
  65451. if (!$isTtySupported) {
  65452. return [1, 1];
  65453. }
  65454. $sttyMode = shell_exec('stty -g');
  65455. shell_exec('stty -icanon -echo');
  65456. @fwrite($this->input, "\033[6n");
  65457. $code = trim(fread($this->input, 1024));
  65458. shell_exec(sprintf('stty %s', $sttyMode));
  65459. sscanf($code, "\033[%d;%dR", $row, $col);
  65460. return [$col, $row];
  65461. }
  65462. }
  65463. <?php
  65464. namespace Symfony\Component\Console\DependencyInjection;
  65465. use Symfony\Component\Console\Command\Command;
  65466. use Symfony\Component\Console\Command\LazyCommand;
  65467. use Symfony\Component\Console\CommandLoader\ContainerCommandLoader;
  65468. use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
  65469. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  65470. use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
  65471. use Symfony\Component\DependencyInjection\ContainerBuilder;
  65472. use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  65473. use Symfony\Component\DependencyInjection\Reference;
  65474. use Symfony\Component\DependencyInjection\TypedReference;
  65475. class AddConsoleCommandPass implements CompilerPassInterface
  65476. {
  65477. private $commandLoaderServiceId;
  65478. private $commandTag;
  65479. private $noPreloadTag;
  65480. private $privateTagName;
  65481. public function __construct(string $commandLoaderServiceId = 'console.command_loader', string $commandTag = 'console.command', string $noPreloadTag = 'container.no_preload', string $privateTagName = 'container.private')
  65482. {
  65483. if (0 < \func_num_args()) {
  65484. trigger_deprecation('symfony/console', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);
  65485. }
  65486. $this->commandLoaderServiceId = $commandLoaderServiceId;
  65487. $this->commandTag = $commandTag;
  65488. $this->noPreloadTag = $noPreloadTag;
  65489. $this->privateTagName = $privateTagName;
  65490. }
  65491. public function process(ContainerBuilder $container)
  65492. {
  65493. $commandServices = $container->findTaggedServiceIds($this->commandTag, true);
  65494. $lazyCommandMap = [];
  65495. $lazyCommandRefs = [];
  65496. $serviceIds = [];
  65497. foreach ($commandServices as $id => $tags) {
  65498. $definition = $container->getDefinition($id);
  65499. $definition->addTag($this->noPreloadTag);
  65500. $class = $container->getParameterBag()->resolveValue($definition->getClass());
  65501. if (isset($tags[0]['command'])) {
  65502. $aliases = $tags[0]['command'];
  65503. } else {
  65504. if (!$r = $container->getReflectionClass($class)) {
  65505. throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
  65506. }
  65507. if (!$r->isSubclassOf(Command::class)) {
  65508. throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
  65509. }
  65510. $aliases = str_replace('%', '%%', $class::getDefaultName() ?? '');
  65511. }
  65512. $aliases = explode('|', $aliases ?? '');
  65513. $commandName = array_shift($aliases);
  65514. if ($isHidden = '' === $commandName) {
  65515. $commandName = array_shift($aliases);
  65516. }
  65517. if (null === $commandName) {
  65518. if (!$definition->isPublic() || $definition->isPrivate() || $definition->hasTag($this->privateTagName)) {
  65519. $commandId = 'console.command.public_alias.'.$id;
  65520. $container->setAlias($commandId, $id)->setPublic(true);
  65521. $id = $commandId;
  65522. }
  65523. $serviceIds[] = $id;
  65524. continue;
  65525. }
  65526. $description = $tags[0]['description'] ?? null;
  65527. unset($tags[0]);
  65528. $lazyCommandMap[$commandName] = $id;
  65529. $lazyCommandRefs[$id] = new TypedReference($id, $class);
  65530. foreach ($aliases as $alias) {
  65531. $lazyCommandMap[$alias] = $id;
  65532. }
  65533. foreach ($tags as $tag) {
  65534. if (isset($tag['command'])) {
  65535. $aliases[] = $tag['command'];
  65536. $lazyCommandMap[$tag['command']] = $id;
  65537. }
  65538. $description = $description ?? $tag['description'] ?? null;
  65539. }
  65540. $definition->addMethodCall('setName', [$commandName]);
  65541. if ($aliases) {
  65542. $definition->addMethodCall('setAliases', [$aliases]);
  65543. }
  65544. if ($isHidden) {
  65545. $definition->addMethodCall('setHidden', [true]);
  65546. }
  65547. if (!$description) {
  65548. if (!$r = $container->getReflectionClass($class)) {
  65549. throw new InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id));
  65550. }
  65551. if (!$r->isSubclassOf(Command::class)) {
  65552. throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must be a subclass of "%s".', $id, $this->commandTag, Command::class));
  65553. }
  65554. $description = str_replace('%', '%%', $class::getDefaultDescription() ?? '');
  65555. }
  65556. if ($description) {
  65557. $definition->addMethodCall('setDescription', [$description]);
  65558. $container->register('.'.$id.'.lazy', LazyCommand::class)
  65559. ->setArguments([$commandName, $aliases, $description, $isHidden, new ServiceClosureArgument($lazyCommandRefs[$id])]);
  65560. $lazyCommandRefs[$id] = new Reference('.'.$id.'.lazy');
  65561. }
  65562. }
  65563. $container
  65564. ->register($this->commandLoaderServiceId, ContainerCommandLoader::class)
  65565. ->setPublic(true)
  65566. ->addTag($this->noPreloadTag)
  65567. ->setArguments([ServiceLocatorTagPass::register($container, $lazyCommandRefs), $lazyCommandMap]);
  65568. $container->setParameter('console.command.ids', $serviceIds);
  65569. }
  65570. }
  65571. <?php
  65572. namespace Symfony\Component\Console\Descriptor;
  65573. use Symfony\Component\Console\Application;
  65574. use Symfony\Component\Console\Command\Command;
  65575. use Symfony\Component\Console\Exception\CommandNotFoundException;
  65576. class ApplicationDescription
  65577. {
  65578. public const GLOBAL_NAMESPACE = '_global';
  65579. private $application;
  65580. private $namespace;
  65581. private $showHidden;
  65582. private $namespaces;
  65583. private $commands;
  65584. private $aliases;
  65585. public function __construct(Application $application, ?string $namespace = null, bool $showHidden = false)
  65586. {
  65587. $this->application = $application;
  65588. $this->namespace = $namespace;
  65589. $this->showHidden = $showHidden;
  65590. }
  65591. public function getNamespaces(): array
  65592. {
  65593. if (null === $this->namespaces) {
  65594. $this->inspectApplication();
  65595. }
  65596. return $this->namespaces;
  65597. }
  65598. public function getCommands(): array
  65599. {
  65600. if (null === $this->commands) {
  65601. $this->inspectApplication();
  65602. }
  65603. return $this->commands;
  65604. }
  65605. public function getCommand(string $name): Command
  65606. {
  65607. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  65608. throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
  65609. }
  65610. return $this->commands[$name] ?? $this->aliases[$name];
  65611. }
  65612. private function inspectApplication()
  65613. {
  65614. $this->commands = [];
  65615. $this->namespaces = [];
  65616. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  65617. foreach ($this->sortCommands($all) as $namespace => $commands) {
  65618. $names = [];
  65619. foreach ($commands as $name => $command) {
  65620. if (!$command->getName() || (!$this->showHidden && $command->isHidden())) {
  65621. continue;
  65622. }
  65623. if ($command->getName() === $name) {
  65624. $this->commands[$name] = $command;
  65625. } else {
  65626. $this->aliases[$name] = $command;
  65627. }
  65628. $names[] = $name;
  65629. }
  65630. $this->namespaces[$namespace] = ['id' => $namespace, 'commands' => $names];
  65631. }
  65632. }
  65633. private function sortCommands(array $commands): array
  65634. {
  65635. $namespacedCommands = [];
  65636. $globalCommands = [];
  65637. $sortedCommands = [];
  65638. foreach ($commands as $name => $command) {
  65639. $key = $this->application->extractNamespace($name, 1);
  65640. if (\in_array($key, ['', self::GLOBAL_NAMESPACE], true)) {
  65641. $globalCommands[$name] = $command;
  65642. } else {
  65643. $namespacedCommands[$key][$name] = $command;
  65644. }
  65645. }
  65646. if ($globalCommands) {
  65647. ksort($globalCommands);
  65648. $sortedCommands[self::GLOBAL_NAMESPACE] = $globalCommands;
  65649. }
  65650. if ($namespacedCommands) {
  65651. ksort($namespacedCommands, \SORT_STRING);
  65652. foreach ($namespacedCommands as $key => $commandsSet) {
  65653. ksort($commandsSet);
  65654. $sortedCommands[$key] = $commandsSet;
  65655. }
  65656. }
  65657. return $sortedCommands;
  65658. }
  65659. }
  65660. <?php
  65661. namespace Symfony\Component\Console\Descriptor;
  65662. use Symfony\Component\Console\Application;
  65663. use Symfony\Component\Console\Command\Command;
  65664. use Symfony\Component\Console\Exception\InvalidArgumentException;
  65665. use Symfony\Component\Console\Input\InputArgument;
  65666. use Symfony\Component\Console\Input\InputDefinition;
  65667. use Symfony\Component\Console\Input\InputOption;
  65668. use Symfony\Component\Console\Output\OutputInterface;
  65669. abstract class Descriptor implements DescriptorInterface
  65670. {
  65671. protected $output;
  65672. public function describe(OutputInterface $output, object $object, array $options = [])
  65673. {
  65674. $this->output = $output;
  65675. switch (true) {
  65676. case $object instanceof InputArgument:
  65677. $this->describeInputArgument($object, $options);
  65678. break;
  65679. case $object instanceof InputOption:
  65680. $this->describeInputOption($object, $options);
  65681. break;
  65682. case $object instanceof InputDefinition:
  65683. $this->describeInputDefinition($object, $options);
  65684. break;
  65685. case $object instanceof Command:
  65686. $this->describeCommand($object, $options);
  65687. break;
  65688. case $object instanceof Application:
  65689. $this->describeApplication($object, $options);
  65690. break;
  65691. default:
  65692. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object)));
  65693. }
  65694. }
  65695. protected function write(string $content, bool $decorated = false)
  65696. {
  65697. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  65698. }
  65699. abstract protected function describeInputArgument(InputArgument $argument, array $options = []);
  65700. abstract protected function describeInputOption(InputOption $option, array $options = []);
  65701. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []);
  65702. abstract protected function describeCommand(Command $command, array $options = []);
  65703. abstract protected function describeApplication(Application $application, array $options = []);
  65704. }
  65705. <?php
  65706. namespace Symfony\Component\Console\Descriptor;
  65707. use Symfony\Component\Console\Output\OutputInterface;
  65708. interface DescriptorInterface
  65709. {
  65710. public function describe(OutputInterface $output, object $object, array $options = []);
  65711. }
  65712. <?php
  65713. namespace Symfony\Component\Console\Descriptor;
  65714. use Symfony\Component\Console\Application;
  65715. use Symfony\Component\Console\Command\Command;
  65716. use Symfony\Component\Console\Input\InputArgument;
  65717. use Symfony\Component\Console\Input\InputDefinition;
  65718. use Symfony\Component\Console\Input\InputOption;
  65719. class JsonDescriptor extends Descriptor
  65720. {
  65721. protected function describeInputArgument(InputArgument $argument, array $options = [])
  65722. {
  65723. $this->writeData($this->getInputArgumentData($argument), $options);
  65724. }
  65725. protected function describeInputOption(InputOption $option, array $options = [])
  65726. {
  65727. $this->writeData($this->getInputOptionData($option), $options);
  65728. if ($option->isNegatable()) {
  65729. $this->writeData($this->getInputOptionData($option, true), $options);
  65730. }
  65731. }
  65732. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  65733. {
  65734. $this->writeData($this->getInputDefinitionData($definition), $options);
  65735. }
  65736. protected function describeCommand(Command $command, array $options = [])
  65737. {
  65738. $this->writeData($this->getCommandData($command, $options['short'] ?? false), $options);
  65739. }
  65740. protected function describeApplication(Application $application, array $options = [])
  65741. {
  65742. $describedNamespace = $options['namespace'] ?? null;
  65743. $description = new ApplicationDescription($application, $describedNamespace, true);
  65744. $commands = [];
  65745. foreach ($description->getCommands() as $command) {
  65746. $commands[] = $this->getCommandData($command, $options['short'] ?? false);
  65747. }
  65748. $data = [];
  65749. if ('UNKNOWN' !== $application->getName()) {
  65750. $data['application']['name'] = $application->getName();
  65751. if ('UNKNOWN' !== $application->getVersion()) {
  65752. $data['application']['version'] = $application->getVersion();
  65753. }
  65754. }
  65755. $data['commands'] = $commands;
  65756. if ($describedNamespace) {
  65757. $data['namespace'] = $describedNamespace;
  65758. } else {
  65759. $data['namespaces'] = array_values($description->getNamespaces());
  65760. }
  65761. $this->writeData($data, $options);
  65762. }
  65763. private function writeData(array $data, array $options)
  65764. {
  65765. $flags = $options['json_encoding'] ?? 0;
  65766. $this->write(json_encode($data, $flags));
  65767. }
  65768. private function getInputArgumentData(InputArgument $argument): array
  65769. {
  65770. return [
  65771. 'name' => $argument->getName(),
  65772. 'is_required' => $argument->isRequired(),
  65773. 'is_array' => $argument->isArray(),
  65774. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  65775. 'default' => \INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  65776. ];
  65777. }
  65778. private function getInputOptionData(InputOption $option, bool $negated = false): array
  65779. {
  65780. return $negated ? [
  65781. 'name' => '--no-'.$option->getName(),
  65782. 'shortcut' => '',
  65783. 'accept_value' => false,
  65784. 'is_value_required' => false,
  65785. 'is_multiple' => false,
  65786. 'description' => 'Negate the "--'.$option->getName().'" option',
  65787. 'default' => false,
  65788. ] : [
  65789. 'name' => '--'.$option->getName(),
  65790. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  65791. 'accept_value' => $option->acceptValue(),
  65792. 'is_value_required' => $option->isValueRequired(),
  65793. 'is_multiple' => $option->isArray(),
  65794. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  65795. 'default' => \INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  65796. ];
  65797. }
  65798. private function getInputDefinitionData(InputDefinition $definition): array
  65799. {
  65800. $inputArguments = [];
  65801. foreach ($definition->getArguments() as $name => $argument) {
  65802. $inputArguments[$name] = $this->getInputArgumentData($argument);
  65803. }
  65804. $inputOptions = [];
  65805. foreach ($definition->getOptions() as $name => $option) {
  65806. $inputOptions[$name] = $this->getInputOptionData($option);
  65807. if ($option->isNegatable()) {
  65808. $inputOptions['no-'.$name] = $this->getInputOptionData($option, true);
  65809. }
  65810. }
  65811. return ['arguments' => $inputArguments, 'options' => $inputOptions];
  65812. }
  65813. private function getCommandData(Command $command, bool $short = false): array
  65814. {
  65815. $data = [
  65816. 'name' => $command->getName(),
  65817. 'description' => $command->getDescription(),
  65818. ];
  65819. if ($short) {
  65820. $data += [
  65821. 'usage' => $command->getAliases(),
  65822. ];
  65823. } else {
  65824. $command->mergeApplicationDefinition(false);
  65825. $data += [
  65826. 'usage' => array_merge([$command->getSynopsis()], $command->getUsages(), $command->getAliases()),
  65827. 'help' => $command->getProcessedHelp(),
  65828. 'definition' => $this->getInputDefinitionData($command->getDefinition()),
  65829. ];
  65830. }
  65831. $data['hidden'] = $command->isHidden();
  65832. return $data;
  65833. }
  65834. }
  65835. <?php
  65836. namespace Symfony\Component\Console\Descriptor;
  65837. use Symfony\Component\Console\Application;
  65838. use Symfony\Component\Console\Command\Command;
  65839. use Symfony\Component\Console\Helper\Helper;
  65840. use Symfony\Component\Console\Input\InputArgument;
  65841. use Symfony\Component\Console\Input\InputDefinition;
  65842. use Symfony\Component\Console\Input\InputOption;
  65843. use Symfony\Component\Console\Output\OutputInterface;
  65844. class MarkdownDescriptor extends Descriptor
  65845. {
  65846. public function describe(OutputInterface $output, object $object, array $options = [])
  65847. {
  65848. $decorated = $output->isDecorated();
  65849. $output->setDecorated(false);
  65850. parent::describe($output, $object, $options);
  65851. $output->setDecorated($decorated);
  65852. }
  65853. protected function write(string $content, bool $decorated = true)
  65854. {
  65855. parent::write($content, $decorated);
  65856. }
  65857. protected function describeInputArgument(InputArgument $argument, array $options = [])
  65858. {
  65859. $this->write(
  65860. '#### `'.($argument->getName() ?: '<none>')."`\n\n"
  65861. .($argument->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $argument->getDescription())."\n\n" : '')
  65862. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  65863. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  65864. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  65865. );
  65866. }
  65867. protected function describeInputOption(InputOption $option, array $options = [])
  65868. {
  65869. $name = '--'.$option->getName();
  65870. if ($option->isNegatable()) {
  65871. $name .= '|--no-'.$option->getName();
  65872. }
  65873. if ($option->getShortcut()) {
  65874. $name .= '|-'.str_replace('|', '|-', $option->getShortcut()).'';
  65875. }
  65876. $this->write(
  65877. '#### `'.$name.'`'."\n\n"
  65878. .($option->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $option->getDescription())."\n\n" : '')
  65879. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  65880. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  65881. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  65882. .'* Is negatable: '.($option->isNegatable() ? 'yes' : 'no')."\n"
  65883. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  65884. );
  65885. }
  65886. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  65887. {
  65888. if ($showArguments = \count($definition->getArguments()) > 0) {
  65889. $this->write('### Arguments');
  65890. foreach ($definition->getArguments() as $argument) {
  65891. $this->write("\n\n");
  65892. if (null !== $describeInputArgument = $this->describeInputArgument($argument)) {
  65893. $this->write($describeInputArgument);
  65894. }
  65895. }
  65896. }
  65897. if (\count($definition->getOptions()) > 0) {
  65898. if ($showArguments) {
  65899. $this->write("\n\n");
  65900. }
  65901. $this->write('### Options');
  65902. foreach ($definition->getOptions() as $option) {
  65903. $this->write("\n\n");
  65904. if (null !== $describeInputOption = $this->describeInputOption($option)) {
  65905. $this->write($describeInputOption);
  65906. }
  65907. }
  65908. }
  65909. }
  65910. protected function describeCommand(Command $command, array $options = [])
  65911. {
  65912. if ($options['short'] ?? false) {
  65913. $this->write(
  65914. '`'.$command->getName()."`\n"
  65915. .str_repeat('-', Helper::width($command->getName()) + 2)."\n\n"
  65916. .($command->getDescription() ? $command->getDescription()."\n\n" : '')
  65917. .'### Usage'."\n\n"
  65918. .array_reduce($command->getAliases(), function ($carry, $usage) {
  65919. return $carry.'* `'.$usage.'`'."\n";
  65920. })
  65921. );
  65922. return;
  65923. }
  65924. $command->mergeApplicationDefinition(false);
  65925. $this->write(
  65926. '`'.$command->getName()."`\n"
  65927. .str_repeat('-', Helper::width($command->getName()) + 2)."\n\n"
  65928. .($command->getDescription() ? $command->getDescription()."\n\n" : '')
  65929. .'### Usage'."\n\n"
  65930. .array_reduce(array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  65931. return $carry.'* `'.$usage.'`'."\n";
  65932. })
  65933. );
  65934. if ($help = $command->getProcessedHelp()) {
  65935. $this->write("\n");
  65936. $this->write($help);
  65937. }
  65938. $definition = $command->getDefinition();
  65939. if ($definition->getOptions() || $definition->getArguments()) {
  65940. $this->write("\n\n");
  65941. $this->describeInputDefinition($definition);
  65942. }
  65943. }
  65944. protected function describeApplication(Application $application, array $options = [])
  65945. {
  65946. $describedNamespace = $options['namespace'] ?? null;
  65947. $description = new ApplicationDescription($application, $describedNamespace);
  65948. $title = $this->getApplicationTitle($application);
  65949. $this->write($title."\n".str_repeat('=', Helper::width($title)));
  65950. foreach ($description->getNamespaces() as $namespace) {
  65951. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  65952. $this->write("\n\n");
  65953. $this->write('**'.$namespace['id'].':**');
  65954. }
  65955. $this->write("\n\n");
  65956. $this->write(implode("\n", array_map(function ($commandName) use ($description) {
  65957. return sprintf('* [`%s`](#%s)', $commandName, str_replace(':', '', $description->getCommand($commandName)->getName()));
  65958. }, $namespace['commands'])));
  65959. }
  65960. foreach ($description->getCommands() as $command) {
  65961. $this->write("\n\n");
  65962. if (null !== $describeCommand = $this->describeCommand($command, $options)) {
  65963. $this->write($describeCommand);
  65964. }
  65965. }
  65966. }
  65967. private function getApplicationTitle(Application $application): string
  65968. {
  65969. if ('UNKNOWN' !== $application->getName()) {
  65970. if ('UNKNOWN' !== $application->getVersion()) {
  65971. return sprintf('%s %s', $application->getName(), $application->getVersion());
  65972. }
  65973. return $application->getName();
  65974. }
  65975. return 'Console Tool';
  65976. }
  65977. }
  65978. <?php
  65979. namespace Symfony\Component\Console\Descriptor;
  65980. use Symfony\Component\Console\Application;
  65981. use Symfony\Component\Console\Command\Command;
  65982. use Symfony\Component\Console\Formatter\OutputFormatter;
  65983. use Symfony\Component\Console\Helper\Helper;
  65984. use Symfony\Component\Console\Input\InputArgument;
  65985. use Symfony\Component\Console\Input\InputDefinition;
  65986. use Symfony\Component\Console\Input\InputOption;
  65987. class TextDescriptor extends Descriptor
  65988. {
  65989. protected function describeInputArgument(InputArgument $argument, array $options = [])
  65990. {
  65991. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  65992. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  65993. } else {
  65994. $default = '';
  65995. }
  65996. $totalWidth = $options['total_width'] ?? Helper::width($argument->getName());
  65997. $spacingWidth = $totalWidth - \strlen($argument->getName());
  65998. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  65999. $argument->getName(),
  66000. str_repeat(' ', $spacingWidth),
  66001. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  66002. $default
  66003. ), $options);
  66004. }
  66005. protected function describeInputOption(InputOption $option, array $options = [])
  66006. {
  66007. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  66008. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  66009. } else {
  66010. $default = '';
  66011. }
  66012. $value = '';
  66013. if ($option->acceptValue()) {
  66014. $value = '='.strtoupper($option->getName());
  66015. if ($option->isValueOptional()) {
  66016. $value = '['.$value.']';
  66017. }
  66018. }
  66019. $totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]);
  66020. $synopsis = sprintf('%s%s',
  66021. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  66022. sprintf($option->isNegatable() ? '--%1$s|--no-%1$s' : '--%1$s%2$s', $option->getName(), $value)
  66023. );
  66024. $spacingWidth = $totalWidth - Helper::width($synopsis);
  66025. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  66026. $synopsis,
  66027. str_repeat(' ', $spacingWidth),
  66028. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  66029. $default,
  66030. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  66031. ), $options);
  66032. }
  66033. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  66034. {
  66035. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  66036. foreach ($definition->getArguments() as $argument) {
  66037. $totalWidth = max($totalWidth, Helper::width($argument->getName()));
  66038. }
  66039. if ($definition->getArguments()) {
  66040. $this->writeText('<comment>Arguments:</comment>', $options);
  66041. $this->writeText("\n");
  66042. foreach ($definition->getArguments() as $argument) {
  66043. $this->describeInputArgument($argument, array_merge($options, ['total_width' => $totalWidth]));
  66044. $this->writeText("\n");
  66045. }
  66046. }
  66047. if ($definition->getArguments() && $definition->getOptions()) {
  66048. $this->writeText("\n");
  66049. }
  66050. if ($definition->getOptions()) {
  66051. $laterOptions = [];
  66052. $this->writeText('<comment>Options:</comment>', $options);
  66053. foreach ($definition->getOptions() as $option) {
  66054. if (\strlen($option->getShortcut() ?? '') > 1) {
  66055. $laterOptions[] = $option;
  66056. continue;
  66057. }
  66058. $this->writeText("\n");
  66059. $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth]));
  66060. }
  66061. foreach ($laterOptions as $option) {
  66062. $this->writeText("\n");
  66063. $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth]));
  66064. }
  66065. }
  66066. }
  66067. protected function describeCommand(Command $command, array $options = [])
  66068. {
  66069. $command->mergeApplicationDefinition(false);
  66070. if ($description = $command->getDescription()) {
  66071. $this->writeText('<comment>Description:</comment>', $options);
  66072. $this->writeText("\n");
  66073. $this->writeText(' '.$description);
  66074. $this->writeText("\n\n");
  66075. }
  66076. $this->writeText('<comment>Usage:</comment>', $options);
  66077. foreach (array_merge([$command->getSynopsis(true)], $command->getAliases(), $command->getUsages()) as $usage) {
  66078. $this->writeText("\n");
  66079. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  66080. }
  66081. $this->writeText("\n");
  66082. $definition = $command->getDefinition();
  66083. if ($definition->getOptions() || $definition->getArguments()) {
  66084. $this->writeText("\n");
  66085. $this->describeInputDefinition($definition, $options);
  66086. $this->writeText("\n");
  66087. }
  66088. $help = $command->getProcessedHelp();
  66089. if ($help && $help !== $description) {
  66090. $this->writeText("\n");
  66091. $this->writeText('<comment>Help:</comment>', $options);
  66092. $this->writeText("\n");
  66093. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  66094. $this->writeText("\n");
  66095. }
  66096. }
  66097. protected function describeApplication(Application $application, array $options = [])
  66098. {
  66099. $describedNamespace = $options['namespace'] ?? null;
  66100. $description = new ApplicationDescription($application, $describedNamespace);
  66101. if (isset($options['raw_text']) && $options['raw_text']) {
  66102. $width = $this->getColumnWidth($description->getCommands());
  66103. foreach ($description->getCommands() as $command) {
  66104. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  66105. $this->writeText("\n");
  66106. }
  66107. } else {
  66108. if ('' != $help = $application->getHelp()) {
  66109. $this->writeText("$help\n\n", $options);
  66110. }
  66111. $this->writeText("<comment>Usage:</comment>\n", $options);
  66112. $this->writeText(" command [options] [arguments]\n\n", $options);
  66113. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  66114. $this->writeText("\n");
  66115. $this->writeText("\n");
  66116. $commands = $description->getCommands();
  66117. $namespaces = $description->getNamespaces();
  66118. if ($describedNamespace && $namespaces) {
  66119. $describedNamespaceInfo = reset($namespaces);
  66120. foreach ($describedNamespaceInfo['commands'] as $name) {
  66121. $commands[$name] = $description->getCommand($name);
  66122. }
  66123. }
  66124. $width = $this->getColumnWidth(array_merge(...array_values(array_map(function ($namespace) use ($commands) {
  66125. return array_intersect($namespace['commands'], array_keys($commands));
  66126. }, array_values($namespaces)))));
  66127. if ($describedNamespace) {
  66128. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  66129. } else {
  66130. $this->writeText('<comment>Available commands:</comment>', $options);
  66131. }
  66132. foreach ($namespaces as $namespace) {
  66133. $namespace['commands'] = array_filter($namespace['commands'], function ($name) use ($commands) {
  66134. return isset($commands[$name]);
  66135. });
  66136. if (!$namespace['commands']) {
  66137. continue;
  66138. }
  66139. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  66140. $this->writeText("\n");
  66141. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  66142. }
  66143. foreach ($namespace['commands'] as $name) {
  66144. $this->writeText("\n");
  66145. $spacingWidth = $width - Helper::width($name);
  66146. $command = $commands[$name];
  66147. $commandAliases = $name === $command->getName() ? $this->getCommandAliasesText($command) : '';
  66148. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
  66149. }
  66150. }
  66151. $this->writeText("\n");
  66152. }
  66153. }
  66154. private function writeText(string $content, array $options = [])
  66155. {
  66156. $this->write(
  66157. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  66158. isset($options['raw_output']) ? !$options['raw_output'] : true
  66159. );
  66160. }
  66161. private function getCommandAliasesText(Command $command): string
  66162. {
  66163. $text = '';
  66164. $aliases = $command->getAliases();
  66165. if ($aliases) {
  66166. $text = '['.implode('|', $aliases).'] ';
  66167. }
  66168. return $text;
  66169. }
  66170. private function formatDefaultValue($default): string
  66171. {
  66172. if (\INF === $default) {
  66173. return 'INF';
  66174. }
  66175. if (\is_string($default)) {
  66176. $default = OutputFormatter::escape($default);
  66177. } elseif (\is_array($default)) {
  66178. foreach ($default as $key => $value) {
  66179. if (\is_string($value)) {
  66180. $default[$key] = OutputFormatter::escape($value);
  66181. }
  66182. }
  66183. }
  66184. return str_replace('\\\\', '\\', json_encode($default, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
  66185. }
  66186. private function getColumnWidth(array $commands): int
  66187. {
  66188. $widths = [];
  66189. foreach ($commands as $command) {
  66190. if ($command instanceof Command) {
  66191. $widths[] = Helper::width($command->getName());
  66192. foreach ($command->getAliases() as $alias) {
  66193. $widths[] = Helper::width($alias);
  66194. }
  66195. } else {
  66196. $widths[] = Helper::width($command);
  66197. }
  66198. }
  66199. return $widths ? max($widths) + 2 : 0;
  66200. }
  66201. private function calculateTotalWidthForOptions(array $options): int
  66202. {
  66203. $totalWidth = 0;
  66204. foreach ($options as $option) {
  66205. $nameLength = 1 + max(Helper::width($option->getShortcut()), 1) + 4 + Helper::width($option->getName());
  66206. if ($option->isNegatable()) {
  66207. $nameLength += 6 + Helper::width($option->getName());
  66208. } elseif ($option->acceptValue()) {
  66209. $valueLength = 1 + Helper::width($option->getName());
  66210. $valueLength += $option->isValueOptional() ? 2 : 0;
  66211. $nameLength += $valueLength;
  66212. }
  66213. $totalWidth = max($totalWidth, $nameLength);
  66214. }
  66215. return $totalWidth;
  66216. }
  66217. }
  66218. <?php
  66219. namespace Symfony\Component\Console\Descriptor;
  66220. use Symfony\Component\Console\Application;
  66221. use Symfony\Component\Console\Command\Command;
  66222. use Symfony\Component\Console\Input\InputArgument;
  66223. use Symfony\Component\Console\Input\InputDefinition;
  66224. use Symfony\Component\Console\Input\InputOption;
  66225. class XmlDescriptor extends Descriptor
  66226. {
  66227. public function getInputDefinitionDocument(InputDefinition $definition): \DOMDocument
  66228. {
  66229. $dom = new \DOMDocument('1.0', 'UTF-8');
  66230. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  66231. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  66232. foreach ($definition->getArguments() as $argument) {
  66233. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  66234. }
  66235. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  66236. foreach ($definition->getOptions() as $option) {
  66237. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  66238. }
  66239. return $dom;
  66240. }
  66241. public function getCommandDocument(Command $command, bool $short = false): \DOMDocument
  66242. {
  66243. $dom = new \DOMDocument('1.0', 'UTF-8');
  66244. $dom->appendChild($commandXML = $dom->createElement('command'));
  66245. $commandXML->setAttribute('id', $command->getName());
  66246. $commandXML->setAttribute('name', $command->getName());
  66247. $commandXML->setAttribute('hidden', $command->isHidden() ? 1 : 0);
  66248. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  66249. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  66250. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  66251. if ($short) {
  66252. foreach ($command->getAliases() as $usage) {
  66253. $usagesXML->appendChild($dom->createElement('usage', $usage));
  66254. }
  66255. } else {
  66256. $command->mergeApplicationDefinition(false);
  66257. foreach (array_merge([$command->getSynopsis()], $command->getAliases(), $command->getUsages()) as $usage) {
  66258. $usagesXML->appendChild($dom->createElement('usage', $usage));
  66259. }
  66260. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  66261. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  66262. $definitionXML = $this->getInputDefinitionDocument($command->getDefinition());
  66263. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  66264. }
  66265. return $dom;
  66266. }
  66267. public function getApplicationDocument(Application $application, ?string $namespace = null, bool $short = false): \DOMDocument
  66268. {
  66269. $dom = new \DOMDocument('1.0', 'UTF-8');
  66270. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  66271. if ('UNKNOWN' !== $application->getName()) {
  66272. $rootXml->setAttribute('name', $application->getName());
  66273. if ('UNKNOWN' !== $application->getVersion()) {
  66274. $rootXml->setAttribute('version', $application->getVersion());
  66275. }
  66276. }
  66277. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  66278. $description = new ApplicationDescription($application, $namespace, true);
  66279. if ($namespace) {
  66280. $commandsXML->setAttribute('namespace', $namespace);
  66281. }
  66282. foreach ($description->getCommands() as $command) {
  66283. $this->appendDocument($commandsXML, $this->getCommandDocument($command, $short));
  66284. }
  66285. if (!$namespace) {
  66286. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  66287. foreach ($description->getNamespaces() as $namespaceDescription) {
  66288. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  66289. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  66290. foreach ($namespaceDescription['commands'] as $name) {
  66291. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  66292. $commandXML->appendChild($dom->createTextNode($name));
  66293. }
  66294. }
  66295. }
  66296. return $dom;
  66297. }
  66298. protected function describeInputArgument(InputArgument $argument, array $options = [])
  66299. {
  66300. $this->writeDocument($this->getInputArgumentDocument($argument));
  66301. }
  66302. protected function describeInputOption(InputOption $option, array $options = [])
  66303. {
  66304. $this->writeDocument($this->getInputOptionDocument($option));
  66305. }
  66306. protected function describeInputDefinition(InputDefinition $definition, array $options = [])
  66307. {
  66308. $this->writeDocument($this->getInputDefinitionDocument($definition));
  66309. }
  66310. protected function describeCommand(Command $command, array $options = [])
  66311. {
  66312. $this->writeDocument($this->getCommandDocument($command, $options['short'] ?? false));
  66313. }
  66314. protected function describeApplication(Application $application, array $options = [])
  66315. {
  66316. $this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null, $options['short'] ?? false));
  66317. }
  66318. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  66319. {
  66320. foreach ($importedParent->childNodes as $childNode) {
  66321. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  66322. }
  66323. }
  66324. private function writeDocument(\DOMDocument $dom)
  66325. {
  66326. $dom->formatOutput = true;
  66327. $this->write($dom->saveXML());
  66328. }
  66329. private function getInputArgumentDocument(InputArgument $argument): \DOMDocument
  66330. {
  66331. $dom = new \DOMDocument('1.0', 'UTF-8');
  66332. $dom->appendChild($objectXML = $dom->createElement('argument'));
  66333. $objectXML->setAttribute('name', $argument->getName());
  66334. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  66335. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  66336. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  66337. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  66338. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  66339. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? [var_export($argument->getDefault(), true)] : ($argument->getDefault() ? [$argument->getDefault()] : []));
  66340. foreach ($defaults as $default) {
  66341. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  66342. $defaultXML->appendChild($dom->createTextNode($default));
  66343. }
  66344. return $dom;
  66345. }
  66346. private function getInputOptionDocument(InputOption $option): \DOMDocument
  66347. {
  66348. $dom = new \DOMDocument('1.0', 'UTF-8');
  66349. $dom->appendChild($objectXML = $dom->createElement('option'));
  66350. $objectXML->setAttribute('name', '--'.$option->getName());
  66351. $pos = strpos($option->getShortcut() ?? '', '|');
  66352. if (false !== $pos) {
  66353. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  66354. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  66355. } else {
  66356. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  66357. }
  66358. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  66359. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  66360. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  66361. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  66362. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  66363. if ($option->acceptValue()) {
  66364. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? [var_export($option->getDefault(), true)] : ($option->getDefault() ? [$option->getDefault()] : []));
  66365. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  66366. if (!empty($defaults)) {
  66367. foreach ($defaults as $default) {
  66368. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  66369. $defaultXML->appendChild($dom->createTextNode($default));
  66370. }
  66371. }
  66372. }
  66373. if ($option->isNegatable()) {
  66374. $dom->appendChild($objectXML = $dom->createElement('option'));
  66375. $objectXML->setAttribute('name', '--no-'.$option->getName());
  66376. $objectXML->setAttribute('shortcut', '');
  66377. $objectXML->setAttribute('accept_value', 0);
  66378. $objectXML->setAttribute('is_value_required', 0);
  66379. $objectXML->setAttribute('is_multiple', 0);
  66380. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  66381. $descriptionXML->appendChild($dom->createTextNode('Negate the "--'.$option->getName().'" option'));
  66382. }
  66383. return $dom;
  66384. }
  66385. }
  66386. <?php
  66387. namespace Symfony\Component\Console\Event;
  66388. final class ConsoleCommandEvent extends ConsoleEvent
  66389. {
  66390. public const RETURN_CODE_DISABLED = 113;
  66391. private $commandShouldRun = true;
  66392. public function disableCommand(): bool
  66393. {
  66394. return $this->commandShouldRun = false;
  66395. }
  66396. public function enableCommand(): bool
  66397. {
  66398. return $this->commandShouldRun = true;
  66399. }
  66400. public function commandShouldRun(): bool
  66401. {
  66402. return $this->commandShouldRun;
  66403. }
  66404. }
  66405. <?php
  66406. namespace Symfony\Component\Console\Event;
  66407. use Symfony\Component\Console\Command\Command;
  66408. use Symfony\Component\Console\Input\InputInterface;
  66409. use Symfony\Component\Console\Output\OutputInterface;
  66410. final class ConsoleErrorEvent extends ConsoleEvent
  66411. {
  66412. private $error;
  66413. private $exitCode;
  66414. public function __construct(InputInterface $input, OutputInterface $output, \Throwable $error, ?Command $command = null)
  66415. {
  66416. parent::__construct($command, $input, $output);
  66417. $this->error = $error;
  66418. }
  66419. public function getError(): \Throwable
  66420. {
  66421. return $this->error;
  66422. }
  66423. public function setError(\Throwable $error): void
  66424. {
  66425. $this->error = $error;
  66426. }
  66427. public function setExitCode(int $exitCode): void
  66428. {
  66429. $this->exitCode = $exitCode;
  66430. $r = new \ReflectionProperty($this->error, 'code');
  66431. $r->setAccessible(true);
  66432. $r->setValue($this->error, $this->exitCode);
  66433. }
  66434. public function getExitCode(): int
  66435. {
  66436. return $this->exitCode ?? (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
  66437. }
  66438. }
  66439. <?php
  66440. namespace Symfony\Component\Console\Event;
  66441. use Symfony\Component\Console\Command\Command;
  66442. use Symfony\Component\Console\Input\InputInterface;
  66443. use Symfony\Component\Console\Output\OutputInterface;
  66444. use Symfony\Contracts\EventDispatcher\Event;
  66445. class ConsoleEvent extends Event
  66446. {
  66447. protected $command;
  66448. private $input;
  66449. private $output;
  66450. public function __construct(?Command $command, InputInterface $input, OutputInterface $output)
  66451. {
  66452. $this->command = $command;
  66453. $this->input = $input;
  66454. $this->output = $output;
  66455. }
  66456. public function getCommand()
  66457. {
  66458. return $this->command;
  66459. }
  66460. public function getInput()
  66461. {
  66462. return $this->input;
  66463. }
  66464. public function getOutput()
  66465. {
  66466. return $this->output;
  66467. }
  66468. }
  66469. <?php
  66470. namespace Symfony\Component\Console\Event;
  66471. use Symfony\Component\Console\Command\Command;
  66472. use Symfony\Component\Console\Input\InputInterface;
  66473. use Symfony\Component\Console\Output\OutputInterface;
  66474. final class ConsoleSignalEvent extends ConsoleEvent
  66475. {
  66476. private $handlingSignal;
  66477. public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $handlingSignal)
  66478. {
  66479. parent::__construct($command, $input, $output);
  66480. $this->handlingSignal = $handlingSignal;
  66481. }
  66482. public function getHandlingSignal(): int
  66483. {
  66484. return $this->handlingSignal;
  66485. }
  66486. }
  66487. <?php
  66488. namespace Symfony\Component\Console\Event;
  66489. use Symfony\Component\Console\Command\Command;
  66490. use Symfony\Component\Console\Input\InputInterface;
  66491. use Symfony\Component\Console\Output\OutputInterface;
  66492. final class ConsoleTerminateEvent extends ConsoleEvent
  66493. {
  66494. private $exitCode;
  66495. public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $exitCode)
  66496. {
  66497. parent::__construct($command, $input, $output);
  66498. $this->setExitCode($exitCode);
  66499. }
  66500. public function setExitCode(int $exitCode): void
  66501. {
  66502. $this->exitCode = $exitCode;
  66503. }
  66504. public function getExitCode(): int
  66505. {
  66506. return $this->exitCode;
  66507. }
  66508. }
  66509. <?php
  66510. namespace Symfony\Component\Console\EventListener;
  66511. use Psr\Log\LoggerInterface;
  66512. use Symfony\Component\Console\ConsoleEvents;
  66513. use Symfony\Component\Console\Event\ConsoleErrorEvent;
  66514. use Symfony\Component\Console\Event\ConsoleEvent;
  66515. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  66516. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  66517. class ErrorListener implements EventSubscriberInterface
  66518. {
  66519. private $logger;
  66520. public function __construct(?LoggerInterface $logger = null)
  66521. {
  66522. $this->logger = $logger;
  66523. }
  66524. public function onConsoleError(ConsoleErrorEvent $event)
  66525. {
  66526. if (null === $this->logger) {
  66527. return;
  66528. }
  66529. $error = $event->getError();
  66530. if (!$inputString = $this->getInputString($event)) {
  66531. $this->logger->critical('An error occurred while using the console. Message: "{message}"', ['exception' => $error, 'message' => $error->getMessage()]);
  66532. return;
  66533. }
  66534. $this->logger->critical('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]);
  66535. }
  66536. public function onConsoleTerminate(ConsoleTerminateEvent $event)
  66537. {
  66538. if (null === $this->logger) {
  66539. return;
  66540. }
  66541. $exitCode = $event->getExitCode();
  66542. if (0 === $exitCode) {
  66543. return;
  66544. }
  66545. if (!$inputString = $this->getInputString($event)) {
  66546. $this->logger->debug('The console exited with code "{code}"', ['code' => $exitCode]);
  66547. return;
  66548. }
  66549. $this->logger->debug('Command "{command}" exited with code "{code}"', ['command' => $inputString, 'code' => $exitCode]);
  66550. }
  66551. public static function getSubscribedEvents()
  66552. {
  66553. return [
  66554. ConsoleEvents::ERROR => ['onConsoleError', -128],
  66555. ConsoleEvents::TERMINATE => ['onConsoleTerminate', -128],
  66556. ];
  66557. }
  66558. private static function getInputString(ConsoleEvent $event): ?string
  66559. {
  66560. $commandName = $event->getCommand() ? $event->getCommand()->getName() : null;
  66561. $input = $event->getInput();
  66562. if (method_exists($input, '__toString')) {
  66563. if ($commandName) {
  66564. return str_replace(["'$commandName'", "\"$commandName\""], $commandName, (string) $input);
  66565. }
  66566. return (string) $input;
  66567. }
  66568. return $commandName;
  66569. }
  66570. }
  66571. <?php
  66572. namespace Symfony\Component\Console\Exception;
  66573. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  66574. {
  66575. private $alternatives;
  66576. public function __construct(string $message, array $alternatives = [], int $code = 0, ?\Throwable $previous = null)
  66577. {
  66578. parent::__construct($message, $code, $previous);
  66579. $this->alternatives = $alternatives;
  66580. }
  66581. public function getAlternatives()
  66582. {
  66583. return $this->alternatives;
  66584. }
  66585. }
  66586. <?php
  66587. namespace Symfony\Component\Console\Exception;
  66588. interface ExceptionInterface extends \Throwable
  66589. {
  66590. }
  66591. <?php
  66592. namespace Symfony\Component\Console\Exception;
  66593. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  66594. {
  66595. }
  66596. <?php
  66597. namespace Symfony\Component\Console\Exception;
  66598. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  66599. {
  66600. }
  66601. <?php
  66602. namespace Symfony\Component\Console\Exception;
  66603. class LogicException extends \LogicException implements ExceptionInterface
  66604. {
  66605. }
  66606. <?php
  66607. namespace Symfony\Component\Console\Exception;
  66608. class MissingInputException extends RuntimeException implements ExceptionInterface
  66609. {
  66610. }
  66611. <?php
  66612. namespace Symfony\Component\Console\Exception;
  66613. class NamespaceNotFoundException extends CommandNotFoundException
  66614. {
  66615. }
  66616. <?php
  66617. namespace Symfony\Component\Console\Exception;
  66618. class RuntimeException extends \RuntimeException implements ExceptionInterface
  66619. {
  66620. }
  66621. <?php
  66622. namespace Symfony\Component\Console\Formatter;
  66623. final class NullOutputFormatter implements OutputFormatterInterface
  66624. {
  66625. private $style;
  66626. public function format(?string $message): ?string
  66627. {
  66628. return null;
  66629. }
  66630. public function getStyle(string $name): OutputFormatterStyleInterface
  66631. {
  66632. return $this->style ?? $this->style = new NullOutputFormatterStyle();
  66633. }
  66634. public function hasStyle(string $name): bool
  66635. {
  66636. return false;
  66637. }
  66638. public function isDecorated(): bool
  66639. {
  66640. return false;
  66641. }
  66642. public function setDecorated(bool $decorated): void
  66643. {
  66644. }
  66645. public function setStyle(string $name, OutputFormatterStyleInterface $style): void
  66646. {
  66647. }
  66648. }
  66649. <?php
  66650. namespace Symfony\Component\Console\Formatter;
  66651. final class NullOutputFormatterStyle implements OutputFormatterStyleInterface
  66652. {
  66653. public function apply(string $text): string
  66654. {
  66655. return $text;
  66656. }
  66657. public function setBackground(?string $color = null): void
  66658. {
  66659. }
  66660. public function setForeground(?string $color = null): void
  66661. {
  66662. }
  66663. public function setOption(string $option): void
  66664. {
  66665. }
  66666. public function setOptions(array $options): void
  66667. {
  66668. }
  66669. public function unsetOption(string $option): void
  66670. {
  66671. }
  66672. }
  66673. <?php
  66674. namespace Symfony\Component\Console\Formatter;
  66675. use Symfony\Component\Console\Exception\InvalidArgumentException;
  66676. use function Symfony\Component\String\b;
  66677. class OutputFormatter implements WrappableOutputFormatterInterface
  66678. {
  66679. private $decorated;
  66680. private $styles = [];
  66681. private $styleStack;
  66682. public function __clone()
  66683. {
  66684. $this->styleStack = clone $this->styleStack;
  66685. foreach ($this->styles as $key => $value) {
  66686. $this->styles[$key] = clone $value;
  66687. }
  66688. }
  66689. public static function escape(string $text)
  66690. {
  66691. $text = preg_replace('/([^\\\\]|^)([<>])/', '$1\\\\$2', $text);
  66692. return self::escapeTrailingBackslash($text);
  66693. }
  66694. public static function escapeTrailingBackslash(string $text): string
  66695. {
  66696. if (str_ends_with($text, '\\')) {
  66697. $len = \strlen($text);
  66698. $text = rtrim($text, '\\');
  66699. $text = str_replace("\0", '', $text);
  66700. $text .= str_repeat("\0", $len - \strlen($text));
  66701. }
  66702. return $text;
  66703. }
  66704. public function __construct(bool $decorated = false, array $styles = [])
  66705. {
  66706. $this->decorated = $decorated;
  66707. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  66708. $this->setStyle('info', new OutputFormatterStyle('green'));
  66709. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  66710. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  66711. foreach ($styles as $name => $style) {
  66712. $this->setStyle($name, $style);
  66713. }
  66714. $this->styleStack = new OutputFormatterStyleStack();
  66715. }
  66716. public function setDecorated(bool $decorated)
  66717. {
  66718. $this->decorated = $decorated;
  66719. }
  66720. public function isDecorated()
  66721. {
  66722. return $this->decorated;
  66723. }
  66724. public function setStyle(string $name, OutputFormatterStyleInterface $style)
  66725. {
  66726. $this->styles[strtolower($name)] = $style;
  66727. }
  66728. public function hasStyle(string $name)
  66729. {
  66730. return isset($this->styles[strtolower($name)]);
  66731. }
  66732. public function getStyle(string $name)
  66733. {
  66734. if (!$this->hasStyle($name)) {
  66735. throw new InvalidArgumentException(sprintf('Undefined style: "%s".', $name));
  66736. }
  66737. return $this->styles[strtolower($name)];
  66738. }
  66739. public function format(?string $message)
  66740. {
  66741. return $this->formatAndWrap($message, 0);
  66742. }
  66743. public function formatAndWrap(?string $message, int $width)
  66744. {
  66745. if (null === $message) {
  66746. return '';
  66747. }
  66748. $offset = 0;
  66749. $output = '';
  66750. $openTagRegex = '[a-z](?:[^\\\\<>]*+ | \\\\.)*';
  66751. $closeTagRegex = '[a-z][^<>]*+';
  66752. $currentLineLength = 0;
  66753. preg_match_all("#<(($openTagRegex) | /($closeTagRegex)?)>#ix", $message, $matches, \PREG_OFFSET_CAPTURE);
  66754. foreach ($matches[0] as $i => $match) {
  66755. $pos = $match[1];
  66756. $text = $match[0];
  66757. if (0 != $pos && '\\' == $message[$pos - 1]) {
  66758. continue;
  66759. }
  66760. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset), $output, $width, $currentLineLength);
  66761. $offset = $pos + \strlen($text);
  66762. if ($open = '/' != $text[1]) {
  66763. $tag = $matches[1][$i][0];
  66764. } else {
  66765. $tag = $matches[3][$i][0] ?? '';
  66766. }
  66767. if (!$open && !$tag) {
  66768. $this->styleStack->pop();
  66769. } elseif (null === $style = $this->createStyleFromString($tag)) {
  66770. $output .= $this->applyCurrentStyle($text, $output, $width, $currentLineLength);
  66771. } elseif ($open) {
  66772. $this->styleStack->push($style);
  66773. } else {
  66774. $this->styleStack->pop($style);
  66775. }
  66776. }
  66777. $output .= $this->applyCurrentStyle(substr($message, $offset), $output, $width, $currentLineLength);
  66778. return strtr($output, ["\0" => '\\', '\\<' => '<', '\\>' => '>']);
  66779. }
  66780. public function getStyleStack()
  66781. {
  66782. return $this->styleStack;
  66783. }
  66784. private function createStyleFromString(string $string): ?OutputFormatterStyleInterface
  66785. {
  66786. if (isset($this->styles[$string])) {
  66787. return $this->styles[$string];
  66788. }
  66789. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, \PREG_SET_ORDER)) {
  66790. return null;
  66791. }
  66792. $style = new OutputFormatterStyle();
  66793. foreach ($matches as $match) {
  66794. array_shift($match);
  66795. $match[0] = strtolower($match[0]);
  66796. if ('fg' == $match[0]) {
  66797. $style->setForeground(strtolower($match[1]));
  66798. } elseif ('bg' == $match[0]) {
  66799. $style->setBackground(strtolower($match[1]));
  66800. } elseif ('href' === $match[0]) {
  66801. $url = preg_replace('{\\\\([<>])}', '$1', $match[1]);
  66802. $style->setHref($url);
  66803. } elseif ('options' === $match[0]) {
  66804. preg_match_all('([^,;]+)', strtolower($match[1]), $options);
  66805. $options = array_shift($options);
  66806. foreach ($options as $option) {
  66807. $style->setOption($option);
  66808. }
  66809. } else {
  66810. return null;
  66811. }
  66812. }
  66813. return $style;
  66814. }
  66815. private function applyCurrentStyle(string $text, string $current, int $width, int &$currentLineLength): string
  66816. {
  66817. if ('' === $text) {
  66818. return '';
  66819. }
  66820. if (!$width) {
  66821. return $this->isDecorated() ? $this->styleStack->getCurrent()->apply($text) : $text;
  66822. }
  66823. if (!$currentLineLength && '' !== $current) {
  66824. $text = ltrim($text);
  66825. }
  66826. if ($currentLineLength) {
  66827. $prefix = substr($text, 0, $i = $width - $currentLineLength)."\n";
  66828. $text = substr($text, $i);
  66829. } else {
  66830. $prefix = '';
  66831. }
  66832. preg_match('~(\\n)$~', $text, $matches);
  66833. $text = $prefix.$this->addLineBreaks($text, $width);
  66834. $text = rtrim($text, "\n").($matches[1] ?? '');
  66835. if (!$currentLineLength && '' !== $current && "\n" !== substr($current, -1)) {
  66836. $text = "\n".$text;
  66837. }
  66838. $lines = explode("\n", $text);
  66839. foreach ($lines as $line) {
  66840. $currentLineLength += \strlen($line);
  66841. if ($width <= $currentLineLength) {
  66842. $currentLineLength = 0;
  66843. }
  66844. }
  66845. if ($this->isDecorated()) {
  66846. foreach ($lines as $i => $line) {
  66847. $lines[$i] = $this->styleStack->getCurrent()->apply($line);
  66848. }
  66849. }
  66850. return implode("\n", $lines);
  66851. }
  66852. private function addLineBreaks(string $text, int $width): string
  66853. {
  66854. $encoding = mb_detect_encoding($text, null, true) ?: 'UTF-8';
  66855. return b($text)->toCodePointString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding);
  66856. }
  66857. }
  66858. <?php
  66859. namespace Symfony\Component\Console\Formatter;
  66860. interface OutputFormatterInterface
  66861. {
  66862. public function setDecorated(bool $decorated);
  66863. public function isDecorated();
  66864. public function setStyle(string $name, OutputFormatterStyleInterface $style);
  66865. public function hasStyle(string $name);
  66866. public function getStyle(string $name);
  66867. public function format(?string $message);
  66868. }
  66869. <?php
  66870. namespace Symfony\Component\Console\Formatter;
  66871. use Symfony\Component\Console\Color;
  66872. class OutputFormatterStyle implements OutputFormatterStyleInterface
  66873. {
  66874. private $color;
  66875. private $foreground;
  66876. private $background;
  66877. private $options;
  66878. private $href;
  66879. private $handlesHrefGracefully;
  66880. public function __construct(?string $foreground = null, ?string $background = null, array $options = [])
  66881. {
  66882. $this->color = new Color($this->foreground = $foreground ?: '', $this->background = $background ?: '', $this->options = $options);
  66883. }
  66884. public function setForeground(?string $color = null)
  66885. {
  66886. $this->color = new Color($this->foreground = $color ?: '', $this->background, $this->options);
  66887. }
  66888. public function setBackground(?string $color = null)
  66889. {
  66890. $this->color = new Color($this->foreground, $this->background = $color ?: '', $this->options);
  66891. }
  66892. public function setHref(string $url): void
  66893. {
  66894. $this->href = $url;
  66895. }
  66896. public function setOption(string $option)
  66897. {
  66898. $this->options[] = $option;
  66899. $this->color = new Color($this->foreground, $this->background, $this->options);
  66900. }
  66901. public function unsetOption(string $option)
  66902. {
  66903. $pos = array_search($option, $this->options);
  66904. if (false !== $pos) {
  66905. unset($this->options[$pos]);
  66906. }
  66907. $this->color = new Color($this->foreground, $this->background, $this->options);
  66908. }
  66909. public function setOptions(array $options)
  66910. {
  66911. $this->color = new Color($this->foreground, $this->background, $this->options = $options);
  66912. }
  66913. public function apply(string $text)
  66914. {
  66915. if (null === $this->handlesHrefGracefully) {
  66916. $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR')
  66917. && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100)
  66918. && !isset($_SERVER['IDEA_INITIAL_DIRECTORY']);
  66919. }
  66920. if (null !== $this->href && $this->handlesHrefGracefully) {
  66921. $text = "\033]8;;$this->href\033\\$text\033]8;;\033\\";
  66922. }
  66923. return $this->color->apply($text);
  66924. }
  66925. }
  66926. <?php
  66927. namespace Symfony\Component\Console\Formatter;
  66928. interface OutputFormatterStyleInterface
  66929. {
  66930. public function setForeground(?string $color = null);
  66931. public function setBackground(?string $color = null);
  66932. public function setOption(string $option);
  66933. public function unsetOption(string $option);
  66934. public function setOptions(array $options);
  66935. public function apply(string $text);
  66936. }
  66937. <?php
  66938. namespace Symfony\Component\Console\Formatter;
  66939. use Symfony\Component\Console\Exception\InvalidArgumentException;
  66940. use Symfony\Contracts\Service\ResetInterface;
  66941. class OutputFormatterStyleStack implements ResetInterface
  66942. {
  66943. private $styles;
  66944. private $emptyStyle;
  66945. public function __construct(?OutputFormatterStyleInterface $emptyStyle = null)
  66946. {
  66947. $this->emptyStyle = $emptyStyle ?? new OutputFormatterStyle();
  66948. $this->reset();
  66949. }
  66950. public function reset()
  66951. {
  66952. $this->styles = [];
  66953. }
  66954. public function push(OutputFormatterStyleInterface $style)
  66955. {
  66956. $this->styles[] = $style;
  66957. }
  66958. public function pop(?OutputFormatterStyleInterface $style = null)
  66959. {
  66960. if (empty($this->styles)) {
  66961. return $this->emptyStyle;
  66962. }
  66963. if (null === $style) {
  66964. return array_pop($this->styles);
  66965. }
  66966. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  66967. if ($style->apply('') === $stackedStyle->apply('')) {
  66968. $this->styles = \array_slice($this->styles, 0, $index);
  66969. return $stackedStyle;
  66970. }
  66971. }
  66972. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  66973. }
  66974. public function getCurrent()
  66975. {
  66976. if (empty($this->styles)) {
  66977. return $this->emptyStyle;
  66978. }
  66979. return $this->styles[\count($this->styles) - 1];
  66980. }
  66981. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  66982. {
  66983. $this->emptyStyle = $emptyStyle;
  66984. return $this;
  66985. }
  66986. public function getEmptyStyle()
  66987. {
  66988. return $this->emptyStyle;
  66989. }
  66990. }
  66991. <?php
  66992. namespace Symfony\Component\Console\Formatter;
  66993. interface WrappableOutputFormatterInterface extends OutputFormatterInterface
  66994. {
  66995. public function formatAndWrap(?string $message, int $width);
  66996. }
  66997. <?php
  66998. namespace Symfony\Component\Console\Helper;
  66999. class DebugFormatterHelper extends Helper
  67000. {
  67001. private const COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'];
  67002. private $started = [];
  67003. private $count = -1;
  67004. public function start(string $id, string $message, string $prefix = 'RUN')
  67005. {
  67006. $this->started[$id] = ['border' => ++$this->count % \count(self::COLORS)];
  67007. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  67008. }
  67009. public function progress(string $id, string $buffer, bool $error = false, string $prefix = 'OUT', string $errorPrefix = 'ERR')
  67010. {
  67011. $message = '';
  67012. if ($error) {
  67013. if (isset($this->started[$id]['out'])) {
  67014. $message .= "\n";
  67015. unset($this->started[$id]['out']);
  67016. }
  67017. if (!isset($this->started[$id]['err'])) {
  67018. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  67019. $this->started[$id]['err'] = true;
  67020. }
  67021. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  67022. } else {
  67023. if (isset($this->started[$id]['err'])) {
  67024. $message .= "\n";
  67025. unset($this->started[$id]['err']);
  67026. }
  67027. if (!isset($this->started[$id]['out'])) {
  67028. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  67029. $this->started[$id]['out'] = true;
  67030. }
  67031. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  67032. }
  67033. return $message;
  67034. }
  67035. public function stop(string $id, string $message, bool $successful, string $prefix = 'RES')
  67036. {
  67037. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  67038. if ($successful) {
  67039. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  67040. }
  67041. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  67042. unset($this->started[$id]['out'], $this->started[$id]['err']);
  67043. return $message;
  67044. }
  67045. private function getBorder(string $id): string
  67046. {
  67047. return sprintf('<bg=%s> </>', self::COLORS[$this->started[$id]['border']]);
  67048. }
  67049. public function getName()
  67050. {
  67051. return 'debug_formatter';
  67052. }
  67053. }
  67054. <?php
  67055. namespace Symfony\Component\Console\Helper;
  67056. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  67057. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  67058. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  67059. use Symfony\Component\Console\Descriptor\TextDescriptor;
  67060. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  67061. use Symfony\Component\Console\Exception\InvalidArgumentException;
  67062. use Symfony\Component\Console\Output\OutputInterface;
  67063. class DescriptorHelper extends Helper
  67064. {
  67065. private $descriptors = [];
  67066. public function __construct()
  67067. {
  67068. $this
  67069. ->register('txt', new TextDescriptor())
  67070. ->register('xml', new XmlDescriptor())
  67071. ->register('json', new JsonDescriptor())
  67072. ->register('md', new MarkdownDescriptor())
  67073. ;
  67074. }
  67075. public function describe(OutputInterface $output, ?object $object, array $options = [])
  67076. {
  67077. $options = array_merge([
  67078. 'raw_text' => false,
  67079. 'format' => 'txt',
  67080. ], $options);
  67081. if (!isset($this->descriptors[$options['format']])) {
  67082. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  67083. }
  67084. $descriptor = $this->descriptors[$options['format']];
  67085. $descriptor->describe($output, $object, $options);
  67086. }
  67087. public function register(string $format, DescriptorInterface $descriptor)
  67088. {
  67089. $this->descriptors[$format] = $descriptor;
  67090. return $this;
  67091. }
  67092. public function getName()
  67093. {
  67094. return 'descriptor';
  67095. }
  67096. public function getFormats(): array
  67097. {
  67098. return array_keys($this->descriptors);
  67099. }
  67100. }
  67101. <?php
  67102. namespace Symfony\Component\Console\Helper;
  67103. use Symfony\Component\Console\Output\OutputInterface;
  67104. use Symfony\Component\VarDumper\Cloner\ClonerInterface;
  67105. use Symfony\Component\VarDumper\Cloner\VarCloner;
  67106. use Symfony\Component\VarDumper\Dumper\CliDumper;
  67107. final class Dumper
  67108. {
  67109. private $output;
  67110. private $dumper;
  67111. private $cloner;
  67112. private $handler;
  67113. public function __construct(OutputInterface $output, ?CliDumper $dumper = null, ?ClonerInterface $cloner = null)
  67114. {
  67115. $this->output = $output;
  67116. $this->dumper = $dumper;
  67117. $this->cloner = $cloner;
  67118. if (class_exists(CliDumper::class)) {
  67119. $this->handler = function ($var): string {
  67120. $dumper = $this->dumper ?? $this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR);
  67121. $dumper->setColors($this->output->isDecorated());
  67122. return rtrim($dumper->dump(($this->cloner ?? $this->cloner = new VarCloner())->cloneVar($var)->withRefHandles(false), true));
  67123. };
  67124. } else {
  67125. $this->handler = function ($var): string {
  67126. switch (true) {
  67127. case null === $var:
  67128. return 'null';
  67129. case true === $var:
  67130. return 'true';
  67131. case false === $var:
  67132. return 'false';
  67133. case \is_string($var):
  67134. return '"'.$var.'"';
  67135. default:
  67136. return rtrim(print_r($var, true));
  67137. }
  67138. };
  67139. }
  67140. }
  67141. public function __invoke($var): string
  67142. {
  67143. return ($this->handler)($var);
  67144. }
  67145. }
  67146. <?php
  67147. namespace Symfony\Component\Console\Helper;
  67148. use Symfony\Component\Console\Formatter\OutputFormatter;
  67149. class FormatterHelper extends Helper
  67150. {
  67151. public function formatSection(string $section, string $message, string $style = 'info')
  67152. {
  67153. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  67154. }
  67155. public function formatBlock($messages, string $style, bool $large = false)
  67156. {
  67157. if (!\is_array($messages)) {
  67158. $messages = [$messages];
  67159. }
  67160. $len = 0;
  67161. $lines = [];
  67162. foreach ($messages as $message) {
  67163. $message = OutputFormatter::escape($message);
  67164. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  67165. $len = max(self::width($message) + ($large ? 4 : 2), $len);
  67166. }
  67167. $messages = $large ? [str_repeat(' ', $len)] : [];
  67168. for ($i = 0; isset($lines[$i]); ++$i) {
  67169. $messages[] = $lines[$i].str_repeat(' ', $len - self::width($lines[$i]));
  67170. }
  67171. if ($large) {
  67172. $messages[] = str_repeat(' ', $len);
  67173. }
  67174. for ($i = 0; isset($messages[$i]); ++$i) {
  67175. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  67176. }
  67177. return implode("\n", $messages);
  67178. }
  67179. public function truncate(string $message, int $length, string $suffix = '...')
  67180. {
  67181. $computedLength = $length - self::width($suffix);
  67182. if ($computedLength > self::width($message)) {
  67183. return $message;
  67184. }
  67185. return self::substr($message, 0, $length).$suffix;
  67186. }
  67187. public function getName()
  67188. {
  67189. return 'formatter';
  67190. }
  67191. }
  67192. <?php
  67193. namespace Symfony\Component\Console\Helper;
  67194. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  67195. use Symfony\Component\String\UnicodeString;
  67196. abstract class Helper implements HelperInterface
  67197. {
  67198. protected $helperSet = null;
  67199. public function setHelperSet(?HelperSet $helperSet = null)
  67200. {
  67201. $this->helperSet = $helperSet;
  67202. }
  67203. public function getHelperSet()
  67204. {
  67205. return $this->helperSet;
  67206. }
  67207. public static function strlen(?string $string)
  67208. {
  67209. 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__);
  67210. return self::width($string);
  67211. }
  67212. public static function width(?string $string): int
  67213. {
  67214. $string ?? $string = '';
  67215. if (preg_match('//u', $string)) {
  67216. return (new UnicodeString($string))->width(false);
  67217. }
  67218. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  67219. return \strlen($string);
  67220. }
  67221. return mb_strwidth($string, $encoding);
  67222. }
  67223. public static function length(?string $string): int
  67224. {
  67225. $string ?? $string = '';
  67226. if (preg_match('//u', $string)) {
  67227. return (new UnicodeString($string))->length();
  67228. }
  67229. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  67230. return \strlen($string);
  67231. }
  67232. return mb_strlen($string, $encoding);
  67233. }
  67234. public static function substr(?string $string, int $from, ?int $length = null)
  67235. {
  67236. $string ?? $string = '';
  67237. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  67238. return substr($string, $from, $length);
  67239. }
  67240. return mb_substr($string, $from, $length, $encoding);
  67241. }
  67242. public static function formatTime($secs)
  67243. {
  67244. static $timeFormats = [
  67245. [0, '< 1 sec'],
  67246. [1, '1 sec'],
  67247. [2, 'secs', 1],
  67248. [60, '1 min'],
  67249. [120, 'mins', 60],
  67250. [3600, '1 hr'],
  67251. [7200, 'hrs', 3600],
  67252. [86400, '1 day'],
  67253. [172800, 'days', 86400],
  67254. ];
  67255. foreach ($timeFormats as $index => $format) {
  67256. if ($secs >= $format[0]) {
  67257. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  67258. || $index == \count($timeFormats) - 1
  67259. ) {
  67260. if (2 == \count($format)) {
  67261. return $format[1];
  67262. }
  67263. return floor($secs / $format[2]).' '.$format[1];
  67264. }
  67265. }
  67266. }
  67267. }
  67268. public static function formatMemory(int $memory)
  67269. {
  67270. if ($memory >= 1024 * 1024 * 1024) {
  67271. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  67272. }
  67273. if ($memory >= 1024 * 1024) {
  67274. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  67275. }
  67276. if ($memory >= 1024) {
  67277. return sprintf('%d KiB', $memory / 1024);
  67278. }
  67279. return sprintf('%d B', $memory);
  67280. }
  67281. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
  67282. {
  67283. trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
  67284. return self::width(self::removeDecoration($formatter, $string));
  67285. }
  67286. public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
  67287. {
  67288. $isDecorated = $formatter->isDecorated();
  67289. $formatter->setDecorated(false);
  67290. $string = $formatter->format($string ?? '');
  67291. $string = preg_replace("/\033\[[^m]*m/", '', $string ?? '');
  67292. $string = preg_replace('/\\033]8;[^;]*;[^\\033]*\\033\\\\/', '', $string ?? '');
  67293. $formatter->setDecorated($isDecorated);
  67294. return $string;
  67295. }
  67296. }
  67297. <?php
  67298. namespace Symfony\Component\Console\Helper;
  67299. interface HelperInterface
  67300. {
  67301. public function setHelperSet(?HelperSet $helperSet = null);
  67302. public function getHelperSet();
  67303. public function getName();
  67304. }
  67305. <?php
  67306. namespace Symfony\Component\Console\Helper;
  67307. use Symfony\Component\Console\Command\Command;
  67308. use Symfony\Component\Console\Exception\InvalidArgumentException;
  67309. class HelperSet implements \IteratorAggregate
  67310. {
  67311. private $helpers = [];
  67312. private $command;
  67313. public function __construct(array $helpers = [])
  67314. {
  67315. foreach ($helpers as $alias => $helper) {
  67316. $this->set($helper, \is_int($alias) ? null : $alias);
  67317. }
  67318. }
  67319. public function set(HelperInterface $helper, ?string $alias = null)
  67320. {
  67321. $this->helpers[$helper->getName()] = $helper;
  67322. if (null !== $alias) {
  67323. $this->helpers[$alias] = $helper;
  67324. }
  67325. $helper->setHelperSet($this);
  67326. }
  67327. public function has(string $name)
  67328. {
  67329. return isset($this->helpers[$name]);
  67330. }
  67331. public function get(string $name)
  67332. {
  67333. if (!$this->has($name)) {
  67334. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  67335. }
  67336. return $this->helpers[$name];
  67337. }
  67338. public function setCommand(?Command $command = null)
  67339. {
  67340. trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);
  67341. $this->command = $command;
  67342. }
  67343. public function getCommand()
  67344. {
  67345. trigger_deprecation('symfony/console', '5.4', 'Method "%s()" is deprecated.', __METHOD__);
  67346. return $this->command;
  67347. }
  67348. #[\ReturnTypeWillChange]
  67349. public function getIterator()
  67350. {
  67351. return new \ArrayIterator($this->helpers);
  67352. }
  67353. }
  67354. <?php
  67355. namespace Symfony\Component\Console\Helper;
  67356. use Symfony\Component\Console\Input\InputAwareInterface;
  67357. use Symfony\Component\Console\Input\InputInterface;
  67358. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  67359. {
  67360. protected $input;
  67361. public function setInput(InputInterface $input)
  67362. {
  67363. $this->input = $input;
  67364. }
  67365. }
  67366. <?php
  67367. namespace Symfony\Component\Console\Helper;
  67368. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  67369. use Symfony\Component\Console\Output\OutputInterface;
  67370. use Symfony\Component\Process\Exception\ProcessFailedException;
  67371. use Symfony\Component\Process\Process;
  67372. class ProcessHelper extends Helper
  67373. {
  67374. public function run(OutputInterface $output, $cmd, ?string $error = null, ?callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
  67375. {
  67376. if (!class_exists(Process::class)) {
  67377. throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".');
  67378. }
  67379. if ($output instanceof ConsoleOutputInterface) {
  67380. $output = $output->getErrorOutput();
  67381. }
  67382. $formatter = $this->getHelperSet()->get('debug_formatter');
  67383. if ($cmd instanceof Process) {
  67384. $cmd = [$cmd];
  67385. }
  67386. if (!\is_array($cmd)) {
  67387. 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)));
  67388. }
  67389. if (\is_string($cmd[0] ?? null)) {
  67390. $process = new Process($cmd);
  67391. $cmd = [];
  67392. } elseif (($cmd[0] ?? null) instanceof Process) {
  67393. $process = $cmd[0];
  67394. unset($cmd[0]);
  67395. } else {
  67396. 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__));
  67397. }
  67398. if ($verbosity <= $output->getVerbosity()) {
  67399. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  67400. }
  67401. if ($output->isDebug()) {
  67402. $callback = $this->wrapCallback($output, $process, $callback);
  67403. }
  67404. $process->run($callback, $cmd);
  67405. if ($verbosity <= $output->getVerbosity()) {
  67406. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  67407. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  67408. }
  67409. if (!$process->isSuccessful() && null !== $error) {
  67410. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  67411. }
  67412. return $process;
  67413. }
  67414. public function mustRun(OutputInterface $output, $cmd, ?string $error = null, ?callable $callback = null): Process
  67415. {
  67416. $process = $this->run($output, $cmd, $error, $callback);
  67417. if (!$process->isSuccessful()) {
  67418. throw new ProcessFailedException($process);
  67419. }
  67420. return $process;
  67421. }
  67422. public function wrapCallback(OutputInterface $output, Process $process, ?callable $callback = null): callable
  67423. {
  67424. if ($output instanceof ConsoleOutputInterface) {
  67425. $output = $output->getErrorOutput();
  67426. }
  67427. $formatter = $this->getHelperSet()->get('debug_formatter');
  67428. return function ($type, $buffer) use ($output, $process, $callback, $formatter) {
  67429. $output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type));
  67430. if (null !== $callback) {
  67431. $callback($type, $buffer);
  67432. }
  67433. };
  67434. }
  67435. private function escapeString(string $str): string
  67436. {
  67437. return str_replace('<', '\\<', $str);
  67438. }
  67439. public function getName(): string
  67440. {
  67441. return 'process';
  67442. }
  67443. }
  67444. <?php
  67445. namespace Symfony\Component\Console\Helper;
  67446. use Symfony\Component\Console\Cursor;
  67447. use Symfony\Component\Console\Exception\LogicException;
  67448. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  67449. use Symfony\Component\Console\Output\ConsoleSectionOutput;
  67450. use Symfony\Component\Console\Output\OutputInterface;
  67451. use Symfony\Component\Console\Terminal;
  67452. final class ProgressBar
  67453. {
  67454. public const FORMAT_VERBOSE = 'verbose';
  67455. public const FORMAT_VERY_VERBOSE = 'very_verbose';
  67456. public const FORMAT_DEBUG = 'debug';
  67457. public const FORMAT_NORMAL = 'normal';
  67458. private const FORMAT_VERBOSE_NOMAX = 'verbose_nomax';
  67459. private const FORMAT_VERY_VERBOSE_NOMAX = 'very_verbose_nomax';
  67460. private const FORMAT_DEBUG_NOMAX = 'debug_nomax';
  67461. private const FORMAT_NORMAL_NOMAX = 'normal_nomax';
  67462. private $barWidth = 28;
  67463. private $barChar;
  67464. private $emptyBarChar = '-';
  67465. private $progressChar = '>';
  67466. private $format;
  67467. private $internalFormat;
  67468. private $redrawFreq = 1;
  67469. private $writeCount;
  67470. private $lastWriteTime;
  67471. private $minSecondsBetweenRedraws = 0;
  67472. private $maxSecondsBetweenRedraws = 1;
  67473. private $output;
  67474. private $step = 0;
  67475. private $max;
  67476. private $startTime;
  67477. private $stepWidth;
  67478. private $percent = 0.0;
  67479. private $messages = [];
  67480. private $overwrite = true;
  67481. private $terminal;
  67482. private $previousMessage;
  67483. private $cursor;
  67484. private static $formatters;
  67485. private static $formats;
  67486. public function __construct(OutputInterface $output, int $max = 0, float $minSecondsBetweenRedraws = 1 / 25)
  67487. {
  67488. if ($output instanceof ConsoleOutputInterface) {
  67489. $output = $output->getErrorOutput();
  67490. }
  67491. $this->output = $output;
  67492. $this->setMaxSteps($max);
  67493. $this->terminal = new Terminal();
  67494. if (0 < $minSecondsBetweenRedraws) {
  67495. $this->redrawFreq = null;
  67496. $this->minSecondsBetweenRedraws = $minSecondsBetweenRedraws;
  67497. }
  67498. if (!$this->output->isDecorated()) {
  67499. $this->overwrite = false;
  67500. $this->redrawFreq = null;
  67501. }
  67502. $this->startTime = time();
  67503. $this->cursor = new Cursor($output);
  67504. }
  67505. public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
  67506. {
  67507. if (!self::$formatters) {
  67508. self::$formatters = self::initPlaceholderFormatters();
  67509. }
  67510. self::$formatters[$name] = $callable;
  67511. }
  67512. public static function getPlaceholderFormatterDefinition(string $name): ?callable
  67513. {
  67514. if (!self::$formatters) {
  67515. self::$formatters = self::initPlaceholderFormatters();
  67516. }
  67517. return self::$formatters[$name] ?? null;
  67518. }
  67519. public static function setFormatDefinition(string $name, string $format): void
  67520. {
  67521. if (!self::$formats) {
  67522. self::$formats = self::initFormats();
  67523. }
  67524. self::$formats[$name] = $format;
  67525. }
  67526. public static function getFormatDefinition(string $name): ?string
  67527. {
  67528. if (!self::$formats) {
  67529. self::$formats = self::initFormats();
  67530. }
  67531. return self::$formats[$name] ?? null;
  67532. }
  67533. public function setMessage(string $message, string $name = 'message')
  67534. {
  67535. $this->messages[$name] = $message;
  67536. }
  67537. public function getMessage(string $name = 'message')
  67538. {
  67539. return $this->messages[$name] ?? null;
  67540. }
  67541. public function getStartTime(): int
  67542. {
  67543. return $this->startTime;
  67544. }
  67545. public function getMaxSteps(): int
  67546. {
  67547. return $this->max;
  67548. }
  67549. public function getProgress(): int
  67550. {
  67551. return $this->step;
  67552. }
  67553. private function getStepWidth(): int
  67554. {
  67555. return $this->stepWidth;
  67556. }
  67557. public function getProgressPercent(): float
  67558. {
  67559. return $this->percent;
  67560. }
  67561. public function getBarOffset(): float
  67562. {
  67563. return floor($this->max ? $this->percent * $this->barWidth : (null === $this->redrawFreq ? (int) (min(5, $this->barWidth / 15) * $this->writeCount) : $this->step) % $this->barWidth);
  67564. }
  67565. public function getEstimated(): float
  67566. {
  67567. if (!$this->step) {
  67568. return 0;
  67569. }
  67570. return round((time() - $this->startTime) / $this->step * $this->max);
  67571. }
  67572. public function getRemaining(): float
  67573. {
  67574. if (!$this->step) {
  67575. return 0;
  67576. }
  67577. return round((time() - $this->startTime) / $this->step * ($this->max - $this->step));
  67578. }
  67579. public function setBarWidth(int $size)
  67580. {
  67581. $this->barWidth = max(1, $size);
  67582. }
  67583. public function getBarWidth(): int
  67584. {
  67585. return $this->barWidth;
  67586. }
  67587. public function setBarCharacter(string $char)
  67588. {
  67589. $this->barChar = $char;
  67590. }
  67591. public function getBarCharacter(): string
  67592. {
  67593. return $this->barChar ?? ($this->max ? '=' : $this->emptyBarChar);
  67594. }
  67595. public function setEmptyBarCharacter(string $char)
  67596. {
  67597. $this->emptyBarChar = $char;
  67598. }
  67599. public function getEmptyBarCharacter(): string
  67600. {
  67601. return $this->emptyBarChar;
  67602. }
  67603. public function setProgressCharacter(string $char)
  67604. {
  67605. $this->progressChar = $char;
  67606. }
  67607. public function getProgressCharacter(): string
  67608. {
  67609. return $this->progressChar;
  67610. }
  67611. public function setFormat(string $format)
  67612. {
  67613. $this->format = null;
  67614. $this->internalFormat = $format;
  67615. }
  67616. public function setRedrawFrequency(?int $freq)
  67617. {
  67618. $this->redrawFreq = null !== $freq ? max(1, $freq) : null;
  67619. }
  67620. public function minSecondsBetweenRedraws(float $seconds): void
  67621. {
  67622. $this->minSecondsBetweenRedraws = $seconds;
  67623. }
  67624. public function maxSecondsBetweenRedraws(float $seconds): void
  67625. {
  67626. $this->maxSecondsBetweenRedraws = $seconds;
  67627. }
  67628. public function iterate(iterable $iterable, ?int $max = null): iterable
  67629. {
  67630. $this->start($max ?? (is_countable($iterable) ? \count($iterable) : 0));
  67631. foreach ($iterable as $key => $value) {
  67632. yield $key => $value;
  67633. $this->advance();
  67634. }
  67635. $this->finish();
  67636. }
  67637. public function start(?int $max = null)
  67638. {
  67639. $this->startTime = time();
  67640. $this->step = 0;
  67641. $this->percent = 0.0;
  67642. if (null !== $max) {
  67643. $this->setMaxSteps($max);
  67644. }
  67645. $this->display();
  67646. }
  67647. public function advance(int $step = 1)
  67648. {
  67649. $this->setProgress($this->step + $step);
  67650. }
  67651. public function setOverwrite(bool $overwrite)
  67652. {
  67653. $this->overwrite = $overwrite;
  67654. }
  67655. public function setProgress(int $step)
  67656. {
  67657. if ($this->max && $step > $this->max) {
  67658. $this->max = $step;
  67659. } elseif ($step < 0) {
  67660. $step = 0;
  67661. }
  67662. $redrawFreq = $this->redrawFreq ?? (($this->max ?: 10) / 10);
  67663. $prevPeriod = (int) ($this->step / $redrawFreq);
  67664. $currPeriod = (int) ($step / $redrawFreq);
  67665. $this->step = $step;
  67666. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  67667. $timeInterval = microtime(true) - $this->lastWriteTime;
  67668. if ($this->max === $step) {
  67669. $this->display();
  67670. return;
  67671. }
  67672. if ($timeInterval < $this->minSecondsBetweenRedraws) {
  67673. return;
  67674. }
  67675. if ($prevPeriod !== $currPeriod || $timeInterval >= $this->maxSecondsBetweenRedraws) {
  67676. $this->display();
  67677. }
  67678. }
  67679. public function setMaxSteps(int $max)
  67680. {
  67681. $this->format = null;
  67682. $this->max = max(0, $max);
  67683. $this->stepWidth = $this->max ? Helper::width((string) $this->max) : 4;
  67684. }
  67685. public function finish(): void
  67686. {
  67687. if (!$this->max) {
  67688. $this->max = $this->step;
  67689. }
  67690. if ($this->step === $this->max && !$this->overwrite) {
  67691. return;
  67692. }
  67693. $this->setProgress($this->max);
  67694. }
  67695. public function display(): void
  67696. {
  67697. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  67698. return;
  67699. }
  67700. if (null === $this->format) {
  67701. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  67702. }
  67703. $this->overwrite($this->buildLine());
  67704. }
  67705. public function clear(): void
  67706. {
  67707. if (!$this->overwrite) {
  67708. return;
  67709. }
  67710. if (null === $this->format) {
  67711. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  67712. }
  67713. $this->overwrite('');
  67714. }
  67715. private function setRealFormat(string $format)
  67716. {
  67717. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  67718. $this->format = self::getFormatDefinition($format.'_nomax');
  67719. } elseif (null !== self::getFormatDefinition($format)) {
  67720. $this->format = self::getFormatDefinition($format);
  67721. } else {
  67722. $this->format = $format;
  67723. }
  67724. }
  67725. private function overwrite(string $message): void
  67726. {
  67727. if ($this->previousMessage === $message) {
  67728. return;
  67729. }
  67730. $originalMessage = $message;
  67731. if ($this->overwrite) {
  67732. if (null !== $this->previousMessage) {
  67733. if ($this->output instanceof ConsoleSectionOutput) {
  67734. $messageLines = explode("\n", $this->previousMessage);
  67735. $lineCount = \count($messageLines);
  67736. foreach ($messageLines as $messageLine) {
  67737. $messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine));
  67738. if ($messageLineLength > $this->terminal->getWidth()) {
  67739. $lineCount += floor($messageLineLength / $this->terminal->getWidth());
  67740. }
  67741. }
  67742. $this->output->clear($lineCount);
  67743. } else {
  67744. $lineCount = substr_count($this->previousMessage, "\n");
  67745. for ($i = 0; $i < $lineCount; ++$i) {
  67746. $this->cursor->moveToColumn(1);
  67747. $this->cursor->clearLine();
  67748. $this->cursor->moveUp();
  67749. }
  67750. $this->cursor->moveToColumn(1);
  67751. $this->cursor->clearLine();
  67752. }
  67753. }
  67754. } elseif ($this->step > 0) {
  67755. $message = \PHP_EOL.$message;
  67756. }
  67757. $this->previousMessage = $originalMessage;
  67758. $this->lastWriteTime = microtime(true);
  67759. $this->output->write($message);
  67760. ++$this->writeCount;
  67761. }
  67762. private function determineBestFormat(): string
  67763. {
  67764. switch ($this->output->getVerbosity()) {
  67765. case OutputInterface::VERBOSITY_VERBOSE:
  67766. return $this->max ? self::FORMAT_VERBOSE : self::FORMAT_VERBOSE_NOMAX;
  67767. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  67768. return $this->max ? self::FORMAT_VERY_VERBOSE : self::FORMAT_VERY_VERBOSE_NOMAX;
  67769. case OutputInterface::VERBOSITY_DEBUG:
  67770. return $this->max ? self::FORMAT_DEBUG : self::FORMAT_DEBUG_NOMAX;
  67771. default:
  67772. return $this->max ? self::FORMAT_NORMAL : self::FORMAT_NORMAL_NOMAX;
  67773. }
  67774. }
  67775. private static function initPlaceholderFormatters(): array
  67776. {
  67777. return [
  67778. 'bar' => function (self $bar, OutputInterface $output) {
  67779. $completeBars = $bar->getBarOffset();
  67780. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  67781. if ($completeBars < $bar->getBarWidth()) {
  67782. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::length(Helper::removeDecoration($output->getFormatter(), $bar->getProgressCharacter()));
  67783. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  67784. }
  67785. return $display;
  67786. },
  67787. 'elapsed' => function (self $bar) {
  67788. return Helper::formatTime(time() - $bar->getStartTime());
  67789. },
  67790. 'remaining' => function (self $bar) {
  67791. if (!$bar->getMaxSteps()) {
  67792. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  67793. }
  67794. return Helper::formatTime($bar->getRemaining());
  67795. },
  67796. 'estimated' => function (self $bar) {
  67797. if (!$bar->getMaxSteps()) {
  67798. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  67799. }
  67800. return Helper::formatTime($bar->getEstimated());
  67801. },
  67802. 'memory' => function (self $bar) {
  67803. return Helper::formatMemory(memory_get_usage(true));
  67804. },
  67805. 'current' => function (self $bar) {
  67806. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT);
  67807. },
  67808. 'max' => function (self $bar) {
  67809. return $bar->getMaxSteps();
  67810. },
  67811. 'percent' => function (self $bar) {
  67812. return floor($bar->getProgressPercent() * 100);
  67813. },
  67814. ];
  67815. }
  67816. private static function initFormats(): array
  67817. {
  67818. return [
  67819. self::FORMAT_NORMAL => ' %current%/%max% [%bar%] %percent:3s%%',
  67820. self::FORMAT_NORMAL_NOMAX => ' %current% [%bar%]',
  67821. self::FORMAT_VERBOSE => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  67822. self::FORMAT_VERBOSE_NOMAX => ' %current% [%bar%] %elapsed:6s%',
  67823. self::FORMAT_VERY_VERBOSE => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  67824. self::FORMAT_VERY_VERBOSE_NOMAX => ' %current% [%bar%] %elapsed:6s%',
  67825. self::FORMAT_DEBUG => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  67826. self::FORMAT_DEBUG_NOMAX => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  67827. ];
  67828. }
  67829. private function buildLine(): string
  67830. {
  67831. $regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
  67832. $callback = function ($matches) {
  67833. if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
  67834. $text = $formatter($this, $this->output);
  67835. } elseif (isset($this->messages[$matches[1]])) {
  67836. $text = $this->messages[$matches[1]];
  67837. } else {
  67838. return $matches[0];
  67839. }
  67840. if (isset($matches[2])) {
  67841. $text = sprintf('%'.$matches[2], $text);
  67842. }
  67843. return $text;
  67844. };
  67845. $line = preg_replace_callback($regex, $callback, $this->format);
  67846. $linesLength = array_map(function ($subLine) {
  67847. return Helper::width(Helper::removeDecoration($this->output->getFormatter(), rtrim($subLine, "\r")));
  67848. }, explode("\n", $line));
  67849. $linesWidth = max($linesLength);
  67850. $terminalWidth = $this->terminal->getWidth();
  67851. if ($linesWidth <= $terminalWidth) {
  67852. return $line;
  67853. }
  67854. $this->setBarWidth($this->barWidth - $linesWidth + $terminalWidth);
  67855. return preg_replace_callback($regex, $callback, $this->format);
  67856. }
  67857. }
  67858. <?php
  67859. namespace Symfony\Component\Console\Helper;
  67860. use Symfony\Component\Console\Exception\InvalidArgumentException;
  67861. use Symfony\Component\Console\Exception\LogicException;
  67862. use Symfony\Component\Console\Output\OutputInterface;
  67863. class ProgressIndicator
  67864. {
  67865. private const FORMATS = [
  67866. 'normal' => ' %indicator% %message%',
  67867. 'normal_no_ansi' => ' %message%',
  67868. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  67869. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  67870. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  67871. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  67872. ];
  67873. private $output;
  67874. private $startTime;
  67875. private $format;
  67876. private $message;
  67877. private $indicatorValues;
  67878. private $indicatorCurrent;
  67879. private $indicatorChangeInterval;
  67880. private $indicatorUpdateTime;
  67881. private $started = false;
  67882. private static $formatters;
  67883. public function __construct(OutputInterface $output, ?string $format = null, int $indicatorChangeInterval = 100, ?array $indicatorValues = null)
  67884. {
  67885. $this->output = $output;
  67886. if (null === $format) {
  67887. $format = $this->determineBestFormat();
  67888. }
  67889. if (null === $indicatorValues) {
  67890. $indicatorValues = ['-', '\\', '|', '/'];
  67891. }
  67892. $indicatorValues = array_values($indicatorValues);
  67893. if (2 > \count($indicatorValues)) {
  67894. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  67895. }
  67896. $this->format = self::getFormatDefinition($format);
  67897. $this->indicatorChangeInterval = $indicatorChangeInterval;
  67898. $this->indicatorValues = $indicatorValues;
  67899. $this->startTime = time();
  67900. }
  67901. public function setMessage(?string $message)
  67902. {
  67903. $this->message = $message;
  67904. $this->display();
  67905. }
  67906. public function start(string $message)
  67907. {
  67908. if ($this->started) {
  67909. throw new LogicException('Progress indicator already started.');
  67910. }
  67911. $this->message = $message;
  67912. $this->started = true;
  67913. $this->startTime = time();
  67914. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  67915. $this->indicatorCurrent = 0;
  67916. $this->display();
  67917. }
  67918. public function advance()
  67919. {
  67920. if (!$this->started) {
  67921. throw new LogicException('Progress indicator has not yet been started.');
  67922. }
  67923. if (!$this->output->isDecorated()) {
  67924. return;
  67925. }
  67926. $currentTime = $this->getCurrentTimeInMilliseconds();
  67927. if ($currentTime < $this->indicatorUpdateTime) {
  67928. return;
  67929. }
  67930. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  67931. ++$this->indicatorCurrent;
  67932. $this->display();
  67933. }
  67934. public function finish(string $message)
  67935. {
  67936. if (!$this->started) {
  67937. throw new LogicException('Progress indicator has not yet been started.');
  67938. }
  67939. $this->message = $message;
  67940. $this->display();
  67941. $this->output->writeln('');
  67942. $this->started = false;
  67943. }
  67944. public static function getFormatDefinition(string $name)
  67945. {
  67946. return self::FORMATS[$name] ?? null;
  67947. }
  67948. public static function setPlaceholderFormatterDefinition(string $name, callable $callable)
  67949. {
  67950. if (!self::$formatters) {
  67951. self::$formatters = self::initPlaceholderFormatters();
  67952. }
  67953. self::$formatters[$name] = $callable;
  67954. }
  67955. public static function getPlaceholderFormatterDefinition(string $name)
  67956. {
  67957. if (!self::$formatters) {
  67958. self::$formatters = self::initPlaceholderFormatters();
  67959. }
  67960. return self::$formatters[$name] ?? null;
  67961. }
  67962. private function display()
  67963. {
  67964. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  67965. return;
  67966. }
  67967. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) {
  67968. if ($formatter = self::getPlaceholderFormatterDefinition($matches[1])) {
  67969. return $formatter($this);
  67970. }
  67971. return $matches[0];
  67972. }, $this->format ?? ''));
  67973. }
  67974. private function determineBestFormat(): string
  67975. {
  67976. switch ($this->output->getVerbosity()) {
  67977. case OutputInterface::VERBOSITY_VERBOSE:
  67978. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  67979. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  67980. case OutputInterface::VERBOSITY_DEBUG:
  67981. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  67982. default:
  67983. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  67984. }
  67985. }
  67986. private function overwrite(string $message)
  67987. {
  67988. if ($this->output->isDecorated()) {
  67989. $this->output->write("\x0D\x1B[2K");
  67990. $this->output->write($message);
  67991. } else {
  67992. $this->output->writeln($message);
  67993. }
  67994. }
  67995. private function getCurrentTimeInMilliseconds(): float
  67996. {
  67997. return round(microtime(true) * 1000);
  67998. }
  67999. private static function initPlaceholderFormatters(): array
  68000. {
  68001. return [
  68002. 'indicator' => function (self $indicator) {
  68003. return $indicator->indicatorValues[$indicator->indicatorCurrent % \count($indicator->indicatorValues)];
  68004. },
  68005. 'message' => function (self $indicator) {
  68006. return $indicator->message;
  68007. },
  68008. 'elapsed' => function (self $indicator) {
  68009. return Helper::formatTime(time() - $indicator->startTime);
  68010. },
  68011. 'memory' => function () {
  68012. return Helper::formatMemory(memory_get_usage(true));
  68013. },
  68014. ];
  68015. }
  68016. }
  68017. <?php
  68018. namespace Symfony\Component\Console\Helper;
  68019. use Symfony\Component\Console\Cursor;
  68020. use Symfony\Component\Console\Exception\MissingInputException;
  68021. use Symfony\Component\Console\Exception\RuntimeException;
  68022. use Symfony\Component\Console\Formatter\OutputFormatter;
  68023. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  68024. use Symfony\Component\Console\Input\InputInterface;
  68025. use Symfony\Component\Console\Input\StreamableInputInterface;
  68026. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  68027. use Symfony\Component\Console\Output\ConsoleSectionOutput;
  68028. use Symfony\Component\Console\Output\OutputInterface;
  68029. use Symfony\Component\Console\Question\ChoiceQuestion;
  68030. use Symfony\Component\Console\Question\Question;
  68031. use Symfony\Component\Console\Terminal;
  68032. use function Symfony\Component\String\s;
  68033. class QuestionHelper extends Helper
  68034. {
  68035. private $inputStream;
  68036. private static $stty = true;
  68037. private static $stdinIsInteractive;
  68038. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  68039. {
  68040. if ($output instanceof ConsoleOutputInterface) {
  68041. $output = $output->getErrorOutput();
  68042. }
  68043. if (!$input->isInteractive()) {
  68044. return $this->getDefaultAnswer($question);
  68045. }
  68046. if ($input instanceof StreamableInputInterface && $stream = $input->getStream()) {
  68047. $this->inputStream = $stream;
  68048. }
  68049. try {
  68050. if (!$question->getValidator()) {
  68051. return $this->doAsk($output, $question);
  68052. }
  68053. $interviewer = function () use ($output, $question) {
  68054. return $this->doAsk($output, $question);
  68055. };
  68056. return $this->validateAttempts($interviewer, $output, $question);
  68057. } catch (MissingInputException $exception) {
  68058. $input->setInteractive(false);
  68059. if (null === $fallbackOutput = $this->getDefaultAnswer($question)) {
  68060. throw $exception;
  68061. }
  68062. return $fallbackOutput;
  68063. }
  68064. }
  68065. public function getName()
  68066. {
  68067. return 'question';
  68068. }
  68069. public static function disableStty()
  68070. {
  68071. self::$stty = false;
  68072. }
  68073. private function doAsk(OutputInterface $output, Question $question)
  68074. {
  68075. $this->writePrompt($output, $question);
  68076. $inputStream = $this->inputStream ?: \STDIN;
  68077. $autocomplete = $question->getAutocompleterCallback();
  68078. if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) {
  68079. $ret = false;
  68080. if ($question->isHidden()) {
  68081. try {
  68082. $hiddenResponse = $this->getHiddenResponse($output, $inputStream, $question->isTrimmable());
  68083. $ret = $question->isTrimmable() ? trim($hiddenResponse) : $hiddenResponse;
  68084. } catch (RuntimeException $e) {
  68085. if (!$question->isHiddenFallback()) {
  68086. throw $e;
  68087. }
  68088. }
  68089. }
  68090. if (false === $ret) {
  68091. $isBlocked = stream_get_meta_data($inputStream)['blocked'] ?? true;
  68092. if (!$isBlocked) {
  68093. stream_set_blocking($inputStream, true);
  68094. }
  68095. $ret = $this->readInput($inputStream, $question);
  68096. if (!$isBlocked) {
  68097. stream_set_blocking($inputStream, false);
  68098. }
  68099. if (false === $ret) {
  68100. throw new MissingInputException('Aborted.');
  68101. }
  68102. if ($question->isTrimmable()) {
  68103. $ret = trim($ret);
  68104. }
  68105. }
  68106. } else {
  68107. $autocomplete = $this->autocomplete($output, $question, $inputStream, $autocomplete);
  68108. $ret = $question->isTrimmable() ? trim($autocomplete) : $autocomplete;
  68109. }
  68110. if ($output instanceof ConsoleSectionOutput) {
  68111. $output->addContent($ret);
  68112. }
  68113. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  68114. if ($normalizer = $question->getNormalizer()) {
  68115. return $normalizer($ret);
  68116. }
  68117. return $ret;
  68118. }
  68119. private function getDefaultAnswer(Question $question)
  68120. {
  68121. $default = $question->getDefault();
  68122. if (null === $default) {
  68123. return $default;
  68124. }
  68125. if ($validator = $question->getValidator()) {
  68126. return \call_user_func($question->getValidator(), $default);
  68127. } elseif ($question instanceof ChoiceQuestion) {
  68128. $choices = $question->getChoices();
  68129. if (!$question->isMultiselect()) {
  68130. return $choices[$default] ?? $default;
  68131. }
  68132. $default = explode(',', $default);
  68133. foreach ($default as $k => $v) {
  68134. $v = $question->isTrimmable() ? trim($v) : $v;
  68135. $default[$k] = $choices[$v] ?? $v;
  68136. }
  68137. }
  68138. return $default;
  68139. }
  68140. protected function writePrompt(OutputInterface $output, Question $question)
  68141. {
  68142. $message = $question->getQuestion();
  68143. if ($question instanceof ChoiceQuestion) {
  68144. $output->writeln(array_merge([
  68145. $question->getQuestion(),
  68146. ], $this->formatChoiceQuestionChoices($question, 'info')));
  68147. $message = $question->getPrompt();
  68148. }
  68149. $output->write($message);
  68150. }
  68151. protected function formatChoiceQuestionChoices(ChoiceQuestion $question, string $tag)
  68152. {
  68153. $messages = [];
  68154. $maxWidth = max(array_map([__CLASS__, 'width'], array_keys($choices = $question->getChoices())));
  68155. foreach ($choices as $key => $value) {
  68156. $padding = str_repeat(' ', $maxWidth - self::width($key));
  68157. $messages[] = sprintf(" [<$tag>%s$padding</$tag>] %s", $key, $value);
  68158. }
  68159. return $messages;
  68160. }
  68161. protected function writeError(OutputInterface $output, \Exception $error)
  68162. {
  68163. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  68164. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  68165. } else {
  68166. $message = '<error>'.$error->getMessage().'</error>';
  68167. }
  68168. $output->writeln($message);
  68169. }
  68170. private function autocomplete(OutputInterface $output, Question $question, $inputStream, callable $autocomplete): string
  68171. {
  68172. $cursor = new Cursor($output, $inputStream);
  68173. $fullChoice = '';
  68174. $ret = '';
  68175. $i = 0;
  68176. $ofs = -1;
  68177. $matches = $autocomplete($ret);
  68178. $numMatches = \count($matches);
  68179. $sttyMode = shell_exec('stty -g');
  68180. $isStdin = 'php://stdin' === (stream_get_meta_data($inputStream)['uri'] ?? null);
  68181. $r = [$inputStream];
  68182. $w = [];
  68183. shell_exec('stty -icanon -echo');
  68184. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  68185. while (!feof($inputStream)) {
  68186. while ($isStdin && 0 === @stream_select($r, $w, $w, 0, 100)) {
  68187. $r = [$inputStream];
  68188. }
  68189. $c = fread($inputStream, 1);
  68190. if (false === $c || ('' === $ret && '' === $c && null === $question->getDefault())) {
  68191. shell_exec('stty '.$sttyMode);
  68192. throw new MissingInputException('Aborted.');
  68193. } elseif ("\177" === $c) {
  68194. if (0 === $numMatches && 0 !== $i) {
  68195. --$i;
  68196. $cursor->moveLeft(s($fullChoice)->slice(-1)->width(false));
  68197. $fullChoice = self::substr($fullChoice, 0, $i);
  68198. }
  68199. if (0 === $i) {
  68200. $ofs = -1;
  68201. $matches = $autocomplete($ret);
  68202. $numMatches = \count($matches);
  68203. } else {
  68204. $numMatches = 0;
  68205. }
  68206. $ret = self::substr($ret, 0, $i);
  68207. } elseif ("\033" === $c) {
  68208. $c .= fread($inputStream, 2);
  68209. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  68210. if ('A' === $c[2] && -1 === $ofs) {
  68211. $ofs = 0;
  68212. }
  68213. if (0 === $numMatches) {
  68214. continue;
  68215. }
  68216. $ofs += ('A' === $c[2]) ? -1 : 1;
  68217. $ofs = ($numMatches + $ofs) % $numMatches;
  68218. }
  68219. } elseif (\ord($c) < 32) {
  68220. if ("\t" === $c || "\n" === $c) {
  68221. if ($numMatches > 0 && -1 !== $ofs) {
  68222. $ret = (string) $matches[$ofs];
  68223. $remainingCharacters = substr($ret, \strlen(trim($this->mostRecentlyEnteredValue($fullChoice))));
  68224. $output->write($remainingCharacters);
  68225. $fullChoice .= $remainingCharacters;
  68226. $i = (false === $encoding = mb_detect_encoding($fullChoice, null, true)) ? \strlen($fullChoice) : mb_strlen($fullChoice, $encoding);
  68227. $matches = array_filter(
  68228. $autocomplete($ret),
  68229. function ($match) use ($ret) {
  68230. return '' === $ret || str_starts_with($match, $ret);
  68231. }
  68232. );
  68233. $numMatches = \count($matches);
  68234. $ofs = -1;
  68235. }
  68236. if ("\n" === $c) {
  68237. $output->write($c);
  68238. break;
  68239. }
  68240. $numMatches = 0;
  68241. }
  68242. continue;
  68243. } else {
  68244. if ("\x80" <= $c) {
  68245. $c .= fread($inputStream, ["\xC0" => 1, "\xD0" => 1, "\xE0" => 2, "\xF0" => 3][$c & "\xF0"]);
  68246. }
  68247. $output->write($c);
  68248. $ret .= $c;
  68249. $fullChoice .= $c;
  68250. ++$i;
  68251. $tempRet = $ret;
  68252. if ($question instanceof ChoiceQuestion && $question->isMultiselect()) {
  68253. $tempRet = $this->mostRecentlyEnteredValue($fullChoice);
  68254. }
  68255. $numMatches = 0;
  68256. $ofs = 0;
  68257. foreach ($autocomplete($ret) as $value) {
  68258. if (str_starts_with($value, $tempRet)) {
  68259. $matches[$numMatches++] = $value;
  68260. }
  68261. }
  68262. }
  68263. $cursor->clearLineAfter();
  68264. if ($numMatches > 0 && -1 !== $ofs) {
  68265. $cursor->savePosition();
  68266. $charactersEntered = \strlen(trim($this->mostRecentlyEnteredValue($fullChoice)));
  68267. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $charactersEntered)).'</hl>');
  68268. $cursor->restorePosition();
  68269. }
  68270. }
  68271. shell_exec('stty '.$sttyMode);
  68272. return $fullChoice;
  68273. }
  68274. private function mostRecentlyEnteredValue(string $entered): string
  68275. {
  68276. if (!str_contains($entered, ',')) {
  68277. return $entered;
  68278. }
  68279. $choices = explode(',', $entered);
  68280. if ('' !== $lastChoice = trim($choices[\count($choices) - 1])) {
  68281. return $lastChoice;
  68282. }
  68283. return $entered;
  68284. }
  68285. private function getHiddenResponse(OutputInterface $output, $inputStream, bool $trimmable = true): string
  68286. {
  68287. if ('\\' === \DIRECTORY_SEPARATOR) {
  68288. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  68289. if ('phar:' === substr(__FILE__, 0, 5)) {
  68290. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  68291. copy($exe, $tmpExe);
  68292. $exe = $tmpExe;
  68293. }
  68294. $sExec = shell_exec('"'.$exe.'"');
  68295. $value = $trimmable ? rtrim($sExec) : $sExec;
  68296. $output->writeln('');
  68297. if (isset($tmpExe)) {
  68298. unlink($tmpExe);
  68299. }
  68300. return $value;
  68301. }
  68302. if (self::$stty && Terminal::hasSttyAvailable()) {
  68303. $sttyMode = shell_exec('stty -g');
  68304. shell_exec('stty -echo');
  68305. } elseif ($this->isInteractiveInput($inputStream)) {
  68306. throw new RuntimeException('Unable to hide the response.');
  68307. }
  68308. $value = fgets($inputStream, 4096);
  68309. if (self::$stty && Terminal::hasSttyAvailable()) {
  68310. shell_exec('stty '.$sttyMode);
  68311. }
  68312. if (false === $value) {
  68313. throw new MissingInputException('Aborted.');
  68314. }
  68315. if ($trimmable) {
  68316. $value = trim($value);
  68317. }
  68318. $output->writeln('');
  68319. return $value;
  68320. }
  68321. private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question)
  68322. {
  68323. $error = null;
  68324. $attempts = $question->getMaxAttempts();
  68325. while (null === $attempts || $attempts--) {
  68326. if (null !== $error) {
  68327. $this->writeError($output, $error);
  68328. }
  68329. try {
  68330. return $question->getValidator()($interviewer());
  68331. } catch (RuntimeException $e) {
  68332. throw $e;
  68333. } catch (\Exception $error) {
  68334. }
  68335. }
  68336. throw $error;
  68337. }
  68338. private function isInteractiveInput($inputStream): bool
  68339. {
  68340. if ('php://stdin' !== (stream_get_meta_data($inputStream)['uri'] ?? null)) {
  68341. return false;
  68342. }
  68343. if (null !== self::$stdinIsInteractive) {
  68344. return self::$stdinIsInteractive;
  68345. }
  68346. return self::$stdinIsInteractive = @stream_isatty(fopen('php://stdin', 'r'));
  68347. }
  68348. private function readInput($inputStream, Question $question)
  68349. {
  68350. if (!$question->isMultiline()) {
  68351. $cp = $this->setIOCodepage();
  68352. $ret = fgets($inputStream, 4096);
  68353. return $this->resetIOCodepage($cp, $ret);
  68354. }
  68355. $multiLineStreamReader = $this->cloneInputStream($inputStream);
  68356. if (null === $multiLineStreamReader) {
  68357. return false;
  68358. }
  68359. $ret = '';
  68360. $cp = $this->setIOCodepage();
  68361. while (false !== ($char = fgetc($multiLineStreamReader))) {
  68362. if (\PHP_EOL === "{$ret}{$char}") {
  68363. break;
  68364. }
  68365. $ret .= $char;
  68366. }
  68367. return $this->resetIOCodepage($cp, $ret);
  68368. }
  68369. private function setIOCodepage(): int
  68370. {
  68371. if (\function_exists('sapi_windows_cp_set')) {
  68372. $cp = sapi_windows_cp_get();
  68373. sapi_windows_cp_set(sapi_windows_cp_get('oem'));
  68374. return $cp;
  68375. }
  68376. return 0;
  68377. }
  68378. private function resetIOCodepage(int $cp, $input)
  68379. {
  68380. if (0 !== $cp) {
  68381. sapi_windows_cp_set($cp);
  68382. if (false !== $input && '' !== $input) {
  68383. $input = sapi_windows_cp_conv(sapi_windows_cp_get('oem'), $cp, $input);
  68384. }
  68385. }
  68386. return $input;
  68387. }
  68388. private function cloneInputStream($inputStream)
  68389. {
  68390. $streamMetaData = stream_get_meta_data($inputStream);
  68391. $seekable = $streamMetaData['seekable'] ?? false;
  68392. $mode = $streamMetaData['mode'] ?? 'rb';
  68393. $uri = $streamMetaData['uri'] ?? null;
  68394. if (null === $uri) {
  68395. return null;
  68396. }
  68397. $cloneStream = fopen($uri, $mode);
  68398. if (true === $seekable && !\in_array($mode, ['r', 'rb', 'rt'])) {
  68399. $offset = ftell($inputStream);
  68400. rewind($inputStream);
  68401. stream_copy_to_stream($inputStream, $cloneStream);
  68402. fseek($inputStream, $offset);
  68403. fseek($cloneStream, $offset);
  68404. }
  68405. return $cloneStream;
  68406. }
  68407. }
  68408. <?php
  68409. namespace Symfony\Component\Console\Helper;
  68410. use Symfony\Component\Console\Formatter\OutputFormatter;
  68411. use Symfony\Component\Console\Output\OutputInterface;
  68412. use Symfony\Component\Console\Question\ChoiceQuestion;
  68413. use Symfony\Component\Console\Question\ConfirmationQuestion;
  68414. use Symfony\Component\Console\Question\Question;
  68415. use Symfony\Component\Console\Style\SymfonyStyle;
  68416. class SymfonyQuestionHelper extends QuestionHelper
  68417. {
  68418. protected function writePrompt(OutputInterface $output, Question $question)
  68419. {
  68420. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  68421. $default = $question->getDefault();
  68422. if ($question->isMultiline()) {
  68423. $text .= sprintf(' (press %s to continue)', $this->getEofShortcut());
  68424. }
  68425. switch (true) {
  68426. case null === $default:
  68427. $text = sprintf(' <info>%s</info>:', $text);
  68428. break;
  68429. case $question instanceof ConfirmationQuestion:
  68430. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  68431. break;
  68432. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  68433. $choices = $question->getChoices();
  68434. $default = explode(',', $default);
  68435. foreach ($default as $key => $value) {
  68436. $default[$key] = $choices[trim($value)];
  68437. }
  68438. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  68439. break;
  68440. case $question instanceof ChoiceQuestion:
  68441. $choices = $question->getChoices();
  68442. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default] ?? $default));
  68443. break;
  68444. default:
  68445. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  68446. }
  68447. $output->writeln($text);
  68448. $prompt = ' > ';
  68449. if ($question instanceof ChoiceQuestion) {
  68450. $output->writeln($this->formatChoiceQuestionChoices($question, 'comment'));
  68451. $prompt = $question->getPrompt();
  68452. }
  68453. $output->write($prompt);
  68454. }
  68455. protected function writeError(OutputInterface $output, \Exception $error)
  68456. {
  68457. if ($output instanceof SymfonyStyle) {
  68458. $output->newLine();
  68459. $output->error($error->getMessage());
  68460. return;
  68461. }
  68462. parent::writeError($output, $error);
  68463. }
  68464. private function getEofShortcut(): string
  68465. {
  68466. if ('Windows' === \PHP_OS_FAMILY) {
  68467. return '<comment>Ctrl+Z</comment> then <comment>Enter</comment>';
  68468. }
  68469. return '<comment>Ctrl+D</comment>';
  68470. }
  68471. }
  68472. <?php
  68473. namespace Symfony\Component\Console\Helper;
  68474. use Symfony\Component\Console\Exception\InvalidArgumentException;
  68475. use Symfony\Component\Console\Exception\RuntimeException;
  68476. use Symfony\Component\Console\Formatter\OutputFormatter;
  68477. use Symfony\Component\Console\Formatter\WrappableOutputFormatterInterface;
  68478. use Symfony\Component\Console\Output\ConsoleSectionOutput;
  68479. use Symfony\Component\Console\Output\OutputInterface;
  68480. class Table
  68481. {
  68482. private const SEPARATOR_TOP = 0;
  68483. private const SEPARATOR_TOP_BOTTOM = 1;
  68484. private const SEPARATOR_MID = 2;
  68485. private const SEPARATOR_BOTTOM = 3;
  68486. private const BORDER_OUTSIDE = 0;
  68487. private const BORDER_INSIDE = 1;
  68488. private $headerTitle;
  68489. private $footerTitle;
  68490. private $headers = [];
  68491. private $rows = [];
  68492. private $horizontal = false;
  68493. private $effectiveColumnWidths = [];
  68494. private $numberOfColumns;
  68495. private $output;
  68496. private $style;
  68497. private $columnStyles = [];
  68498. private $columnWidths = [];
  68499. private $columnMaxWidths = [];
  68500. private static $styles;
  68501. private $rendered = false;
  68502. public function __construct(OutputInterface $output)
  68503. {
  68504. $this->output = $output;
  68505. if (!self::$styles) {
  68506. self::$styles = self::initStyles();
  68507. }
  68508. $this->setStyle('default');
  68509. }
  68510. public static function setStyleDefinition(string $name, TableStyle $style)
  68511. {
  68512. if (!self::$styles) {
  68513. self::$styles = self::initStyles();
  68514. }
  68515. self::$styles[$name] = $style;
  68516. }
  68517. public static function getStyleDefinition(string $name)
  68518. {
  68519. if (!self::$styles) {
  68520. self::$styles = self::initStyles();
  68521. }
  68522. if (isset(self::$styles[$name])) {
  68523. return self::$styles[$name];
  68524. }
  68525. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  68526. }
  68527. public function setStyle($name)
  68528. {
  68529. $this->style = $this->resolveStyle($name);
  68530. return $this;
  68531. }
  68532. public function getStyle()
  68533. {
  68534. return $this->style;
  68535. }
  68536. public function setColumnStyle(int $columnIndex, $name)
  68537. {
  68538. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  68539. return $this;
  68540. }
  68541. public function getColumnStyle(int $columnIndex)
  68542. {
  68543. return $this->columnStyles[$columnIndex] ?? $this->getStyle();
  68544. }
  68545. public function setColumnWidth(int $columnIndex, int $width)
  68546. {
  68547. $this->columnWidths[$columnIndex] = $width;
  68548. return $this;
  68549. }
  68550. public function setColumnWidths(array $widths)
  68551. {
  68552. $this->columnWidths = [];
  68553. foreach ($widths as $index => $width) {
  68554. $this->setColumnWidth($index, $width);
  68555. }
  68556. return $this;
  68557. }
  68558. public function setColumnMaxWidth(int $columnIndex, int $width): self
  68559. {
  68560. if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) {
  68561. 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())));
  68562. }
  68563. $this->columnMaxWidths[$columnIndex] = $width;
  68564. return $this;
  68565. }
  68566. public function setHeaders(array $headers)
  68567. {
  68568. $headers = array_values($headers);
  68569. if (!empty($headers) && !\is_array($headers[0])) {
  68570. $headers = [$headers];
  68571. }
  68572. $this->headers = $headers;
  68573. return $this;
  68574. }
  68575. public function setRows(array $rows)
  68576. {
  68577. $this->rows = [];
  68578. return $this->addRows($rows);
  68579. }
  68580. public function addRows(array $rows)
  68581. {
  68582. foreach ($rows as $row) {
  68583. $this->addRow($row);
  68584. }
  68585. return $this;
  68586. }
  68587. public function addRow($row)
  68588. {
  68589. if ($row instanceof TableSeparator) {
  68590. $this->rows[] = $row;
  68591. return $this;
  68592. }
  68593. if (!\is_array($row)) {
  68594. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  68595. }
  68596. $this->rows[] = array_values($row);
  68597. return $this;
  68598. }
  68599. public function appendRow($row): self
  68600. {
  68601. if (!$this->output instanceof ConsoleSectionOutput) {
  68602. throw new RuntimeException(sprintf('Output should be an instance of "%s" when calling "%s".', ConsoleSectionOutput::class, __METHOD__));
  68603. }
  68604. if ($this->rendered) {
  68605. $this->output->clear($this->calculateRowCount());
  68606. }
  68607. $this->addRow($row);
  68608. $this->render();
  68609. return $this;
  68610. }
  68611. public function setRow($column, array $row)
  68612. {
  68613. $this->rows[$column] = $row;
  68614. return $this;
  68615. }
  68616. public function setHeaderTitle(?string $title): self
  68617. {
  68618. $this->headerTitle = $title;
  68619. return $this;
  68620. }
  68621. public function setFooterTitle(?string $title): self
  68622. {
  68623. $this->footerTitle = $title;
  68624. return $this;
  68625. }
  68626. public function setHorizontal(bool $horizontal = true): self
  68627. {
  68628. $this->horizontal = $horizontal;
  68629. return $this;
  68630. }
  68631. public function render()
  68632. {
  68633. $divider = new TableSeparator();
  68634. if ($this->horizontal) {
  68635. $rows = [];
  68636. foreach ($this->headers[0] ?? [] as $i => $header) {
  68637. $rows[$i] = [$header];
  68638. foreach ($this->rows as $row) {
  68639. if ($row instanceof TableSeparator) {
  68640. continue;
  68641. }
  68642. if (isset($row[$i])) {
  68643. $rows[$i][] = $row[$i];
  68644. } elseif ($rows[$i][0] instanceof TableCell && $rows[$i][0]->getColspan() >= 2) {
  68645. } else {
  68646. $rows[$i][] = null;
  68647. }
  68648. }
  68649. }
  68650. } else {
  68651. $rows = array_merge($this->headers, [$divider], $this->rows);
  68652. }
  68653. $this->calculateNumberOfColumns($rows);
  68654. $rowGroups = $this->buildTableRows($rows);
  68655. $this->calculateColumnsWidth($rowGroups);
  68656. $isHeader = !$this->horizontal;
  68657. $isFirstRow = $this->horizontal;
  68658. $hasTitle = (bool) $this->headerTitle;
  68659. foreach ($rowGroups as $rowGroup) {
  68660. $isHeaderSeparatorRendered = false;
  68661. foreach ($rowGroup as $row) {
  68662. if ($divider === $row) {
  68663. $isHeader = false;
  68664. $isFirstRow = true;
  68665. continue;
  68666. }
  68667. if ($row instanceof TableSeparator) {
  68668. $this->renderRowSeparator();
  68669. continue;
  68670. }
  68671. if (!$row) {
  68672. continue;
  68673. }
  68674. if ($isHeader && !$isHeaderSeparatorRendered) {
  68675. $this->renderRowSeparator(
  68676. $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM,
  68677. $hasTitle ? $this->headerTitle : null,
  68678. $hasTitle ? $this->style->getHeaderTitleFormat() : null
  68679. );
  68680. $hasTitle = false;
  68681. $isHeaderSeparatorRendered = true;
  68682. }
  68683. if ($isFirstRow) {
  68684. $this->renderRowSeparator(
  68685. $isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM,
  68686. $hasTitle ? $this->headerTitle : null,
  68687. $hasTitle ? $this->style->getHeaderTitleFormat() : null
  68688. );
  68689. $isFirstRow = false;
  68690. $hasTitle = false;
  68691. }
  68692. if ($this->horizontal) {
  68693. $this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat());
  68694. } else {
  68695. $this->renderRow($row, $isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat());
  68696. }
  68697. }
  68698. }
  68699. $this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat());
  68700. $this->cleanup();
  68701. $this->rendered = true;
  68702. }
  68703. private function renderRowSeparator(int $type = self::SEPARATOR_MID, ?string $title = null, ?string $titleFormat = null)
  68704. {
  68705. if (0 === $count = $this->numberOfColumns) {
  68706. return;
  68707. }
  68708. $borders = $this->style->getBorderChars();
  68709. if (!$borders[0] && !$borders[2] && !$this->style->getCrossingChar()) {
  68710. return;
  68711. }
  68712. $crossings = $this->style->getCrossingChars();
  68713. if (self::SEPARATOR_MID === $type) {
  68714. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[2], $crossings[8], $crossings[0], $crossings[4]];
  68715. } elseif (self::SEPARATOR_TOP === $type) {
  68716. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[0], $crossings[1], $crossings[2], $crossings[3]];
  68717. } elseif (self::SEPARATOR_TOP_BOTTOM === $type) {
  68718. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[0], $crossings[9], $crossings[10], $crossings[11]];
  68719. } else {
  68720. [$horizontal, $leftChar, $midChar, $rightChar] = [$borders[0], $crossings[7], $crossings[6], $crossings[5]];
  68721. }
  68722. $markup = $leftChar;
  68723. for ($column = 0; $column < $count; ++$column) {
  68724. $markup .= str_repeat($horizontal, $this->effectiveColumnWidths[$column]);
  68725. $markup .= $column === $count - 1 ? $rightChar : $midChar;
  68726. }
  68727. if (null !== $title) {
  68728. $titleLength = Helper::width(Helper::removeDecoration($formatter = $this->output->getFormatter(), $formattedTitle = sprintf($titleFormat, $title)));
  68729. $markupLength = Helper::width($markup);
  68730. if ($titleLength > $limit = $markupLength - 4) {
  68731. $titleLength = $limit;
  68732. $formatLength = Helper::width(Helper::removeDecoration($formatter, sprintf($titleFormat, '')));
  68733. $formattedTitle = sprintf($titleFormat, Helper::substr($title, 0, $limit - $formatLength - 3).'...');
  68734. }
  68735. $titleStart = intdiv($markupLength - $titleLength, 2);
  68736. if (false === mb_detect_encoding($markup, null, true)) {
  68737. $markup = substr_replace($markup, $formattedTitle, $titleStart, $titleLength);
  68738. } else {
  68739. $markup = mb_substr($markup, 0, $titleStart).$formattedTitle.mb_substr($markup, $titleStart + $titleLength);
  68740. }
  68741. }
  68742. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  68743. }
  68744. private function renderColumnSeparator(int $type = self::BORDER_OUTSIDE): string
  68745. {
  68746. $borders = $this->style->getBorderChars();
  68747. return sprintf($this->style->getBorderFormat(), self::BORDER_OUTSIDE === $type ? $borders[1] : $borders[3]);
  68748. }
  68749. private function renderRow(array $row, string $cellFormat, ?string $firstCellFormat = null)
  68750. {
  68751. $rowContent = $this->renderColumnSeparator(self::BORDER_OUTSIDE);
  68752. $columns = $this->getRowColumns($row);
  68753. $last = \count($columns) - 1;
  68754. foreach ($columns as $i => $column) {
  68755. if ($firstCellFormat && 0 === $i) {
  68756. $rowContent .= $this->renderCell($row, $column, $firstCellFormat);
  68757. } else {
  68758. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  68759. }
  68760. $rowContent .= $this->renderColumnSeparator($last === $i ? self::BORDER_OUTSIDE : self::BORDER_INSIDE);
  68761. }
  68762. $this->output->writeln($rowContent);
  68763. }
  68764. private function renderCell(array $row, int $column, string $cellFormat): string
  68765. {
  68766. $cell = $row[$column] ?? '';
  68767. $width = $this->effectiveColumnWidths[$column];
  68768. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  68769. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  68770. $width += $this->getColumnSeparatorWidth() + $this->effectiveColumnWidths[$nextColumn];
  68771. }
  68772. }
  68773. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  68774. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  68775. }
  68776. $style = $this->getColumnStyle($column);
  68777. if ($cell instanceof TableSeparator) {
  68778. return sprintf($style->getBorderFormat(), str_repeat($style->getBorderChars()[2], $width));
  68779. }
  68780. $width += Helper::length($cell) - Helper::length(Helper::removeDecoration($this->output->getFormatter(), $cell));
  68781. $content = sprintf($style->getCellRowContentFormat(), $cell);
  68782. $padType = $style->getPadType();
  68783. if ($cell instanceof TableCell && $cell->getStyle() instanceof TableCellStyle) {
  68784. $isNotStyledByTag = !preg_match('/^<(\w+|(\w+=[\w,]+;?)*)>.+<\/(\w+|(\w+=\w+;?)*)?>$/', $cell);
  68785. if ($isNotStyledByTag) {
  68786. $cellFormat = $cell->getStyle()->getCellFormat();
  68787. if (!\is_string($cellFormat)) {
  68788. $tag = http_build_query($cell->getStyle()->getTagOptions(), '', ';');
  68789. $cellFormat = '<'.$tag.'>%s</>';
  68790. }
  68791. if (strstr($content, '</>')) {
  68792. $content = str_replace('</>', '', $content);
  68793. $width -= 3;
  68794. }
  68795. if (strstr($content, '<fg=default;bg=default>')) {
  68796. $content = str_replace('<fg=default;bg=default>', '', $content);
  68797. $width -= \strlen('<fg=default;bg=default>');
  68798. }
  68799. }
  68800. $padType = $cell->getStyle()->getPadByAlign();
  68801. }
  68802. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $padType));
  68803. }
  68804. private function calculateNumberOfColumns(array $rows)
  68805. {
  68806. $columns = [0];
  68807. foreach ($rows as $row) {
  68808. if ($row instanceof TableSeparator) {
  68809. continue;
  68810. }
  68811. $columns[] = $this->getNumberOfColumns($row);
  68812. }
  68813. $this->numberOfColumns = max($columns);
  68814. }
  68815. private function buildTableRows(array $rows): TableRows
  68816. {
  68817. $formatter = $this->output->getFormatter();
  68818. $unmergedRows = [];
  68819. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  68820. $rows = $this->fillNextRows($rows, $rowKey);
  68821. foreach ($rows[$rowKey] as $column => $cell) {
  68822. $colspan = $cell instanceof TableCell ? $cell->getColspan() : 1;
  68823. if (isset($this->columnMaxWidths[$column]) && Helper::width(Helper::removeDecoration($formatter, $cell)) > $this->columnMaxWidths[$column]) {
  68824. $cell = $formatter->formatAndWrap($cell, $this->columnMaxWidths[$column] * $colspan);
  68825. }
  68826. if (!strstr($cell ?? '', "\n")) {
  68827. continue;
  68828. }
  68829. $eol = str_contains($cell ?? '', "\r\n") ? "\r\n" : "\n";
  68830. $escaped = implode($eol, array_map([OutputFormatter::class, 'escapeTrailingBackslash'], explode($eol, $cell)));
  68831. $cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
  68832. $lines = explode($eol, str_replace($eol, '<fg=default;bg=default></>'.$eol, $cell));
  68833. foreach ($lines as $lineKey => $line) {
  68834. if ($colspan > 1) {
  68835. $line = new TableCell($line, ['colspan' => $colspan]);
  68836. }
  68837. if (0 === $lineKey) {
  68838. $rows[$rowKey][$column] = $line;
  68839. } else {
  68840. if (!\array_key_exists($rowKey, $unmergedRows) || !\array_key_exists($lineKey, $unmergedRows[$rowKey])) {
  68841. $unmergedRows[$rowKey][$lineKey] = $this->copyRow($rows, $rowKey);
  68842. }
  68843. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  68844. }
  68845. }
  68846. }
  68847. }
  68848. return new TableRows(function () use ($rows, $unmergedRows): \Traversable {
  68849. foreach ($rows as $rowKey => $row) {
  68850. $rowGroup = [$row instanceof TableSeparator ? $row : $this->fillCells($row)];
  68851. if (isset($unmergedRows[$rowKey])) {
  68852. foreach ($unmergedRows[$rowKey] as $row) {
  68853. $rowGroup[] = $row instanceof TableSeparator ? $row : $this->fillCells($row);
  68854. }
  68855. }
  68856. yield $rowGroup;
  68857. }
  68858. });
  68859. }
  68860. private function calculateRowCount(): int
  68861. {
  68862. $numberOfRows = \count(iterator_to_array($this->buildTableRows(array_merge($this->headers, [new TableSeparator()], $this->rows))));
  68863. if ($this->headers) {
  68864. ++$numberOfRows;
  68865. }
  68866. if (\count($this->rows) > 0) {
  68867. ++$numberOfRows;
  68868. }
  68869. return $numberOfRows;
  68870. }
  68871. private function fillNextRows(array $rows, int $line): array
  68872. {
  68873. $unmergedRows = [];
  68874. foreach ($rows[$line] as $column => $cell) {
  68875. if (null !== $cell && !$cell instanceof TableCell && !\is_scalar($cell) && !(\is_object($cell) && method_exists($cell, '__toString'))) {
  68876. throw new InvalidArgumentException(sprintf('A cell must be a TableCell, a scalar or an object implementing "__toString()", "%s" given.', get_debug_type($cell)));
  68877. }
  68878. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  68879. $nbLines = $cell->getRowspan() - 1;
  68880. $lines = [$cell];
  68881. if (strstr($cell, "\n")) {
  68882. $eol = str_contains($cell, "\r\n") ? "\r\n" : "\n";
  68883. $lines = explode($eol, str_replace($eol, '<fg=default;bg=default>'.$eol.'</>', $cell));
  68884. $nbLines = \count($lines) > $nbLines ? substr_count($cell, $eol) : $nbLines;
  68885. $rows[$line][$column] = new TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]);
  68886. unset($lines[0]);
  68887. }
  68888. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, []), $unmergedRows);
  68889. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  68890. $value = $lines[$unmergedRowKey - $line] ?? '';
  68891. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]);
  68892. if ($nbLines === $unmergedRowKey - $line) {
  68893. break;
  68894. }
  68895. }
  68896. }
  68897. }
  68898. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  68899. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  68900. foreach ($unmergedRow as $cellKey => $cell) {
  68901. array_splice($rows[$unmergedRowKey], $cellKey, 0, [$cell]);
  68902. }
  68903. } else {
  68904. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  68905. foreach ($unmergedRow as $column => $cell) {
  68906. if (!empty($cell)) {
  68907. $row[$column] = $unmergedRow[$column];
  68908. }
  68909. }
  68910. array_splice($rows, $unmergedRowKey, 0, [$row]);
  68911. }
  68912. }
  68913. return $rows;
  68914. }
  68915. private function fillCells(iterable $row)
  68916. {
  68917. $newRow = [];
  68918. foreach ($row as $column => $cell) {
  68919. $newRow[] = $cell;
  68920. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  68921. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  68922. $newRow[] = '';
  68923. }
  68924. }
  68925. }
  68926. return $newRow ?: $row;
  68927. }
  68928. private function copyRow(array $rows, int $line): array
  68929. {
  68930. $row = $rows[$line];
  68931. foreach ($row as $cellKey => $cellValue) {
  68932. $row[$cellKey] = '';
  68933. if ($cellValue instanceof TableCell) {
  68934. $row[$cellKey] = new TableCell('', ['colspan' => $cellValue->getColspan()]);
  68935. }
  68936. }
  68937. return $row;
  68938. }
  68939. private function getNumberOfColumns(array $row): int
  68940. {
  68941. $columns = \count($row);
  68942. foreach ($row as $column) {
  68943. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  68944. }
  68945. return $columns;
  68946. }
  68947. private function getRowColumns(array $row): array
  68948. {
  68949. $columns = range(0, $this->numberOfColumns - 1);
  68950. foreach ($row as $cellKey => $cell) {
  68951. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  68952. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  68953. }
  68954. }
  68955. return $columns;
  68956. }
  68957. private function calculateColumnsWidth(iterable $groups)
  68958. {
  68959. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  68960. $lengths = [];
  68961. foreach ($groups as $group) {
  68962. foreach ($group as $row) {
  68963. if ($row instanceof TableSeparator) {
  68964. continue;
  68965. }
  68966. foreach ($row as $i => $cell) {
  68967. if ($cell instanceof TableCell) {
  68968. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  68969. $textLength = Helper::width($textContent);
  68970. if ($textLength > 0) {
  68971. $contentColumns = mb_str_split($textContent, ceil($textLength / $cell->getColspan()));
  68972. foreach ($contentColumns as $position => $content) {
  68973. $row[$i + $position] = $content;
  68974. }
  68975. }
  68976. }
  68977. }
  68978. $lengths[] = $this->getCellWidth($row, $column);
  68979. }
  68980. }
  68981. $this->effectiveColumnWidths[$column] = max($lengths) + Helper::width($this->style->getCellRowContentFormat()) - 2;
  68982. }
  68983. }
  68984. private function getColumnSeparatorWidth(): int
  68985. {
  68986. return Helper::width(sprintf($this->style->getBorderFormat(), $this->style->getBorderChars()[3]));
  68987. }
  68988. private function getCellWidth(array $row, int $column): int
  68989. {
  68990. $cellWidth = 0;
  68991. if (isset($row[$column])) {
  68992. $cell = $row[$column];
  68993. $cellWidth = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $cell));
  68994. }
  68995. $columnWidth = $this->columnWidths[$column] ?? 0;
  68996. $cellWidth = max($cellWidth, $columnWidth);
  68997. return isset($this->columnMaxWidths[$column]) ? min($this->columnMaxWidths[$column], $cellWidth) : $cellWidth;
  68998. }
  68999. private function cleanup()
  69000. {
  69001. $this->effectiveColumnWidths = [];
  69002. $this->numberOfColumns = null;
  69003. }
  69004. private static function initStyles(): array
  69005. {
  69006. $borderless = new TableStyle();
  69007. $borderless
  69008. ->setHorizontalBorderChars('=')
  69009. ->setVerticalBorderChars(' ')
  69010. ->setDefaultCrossingChar(' ')
  69011. ;
  69012. $compact = new TableStyle();
  69013. $compact
  69014. ->setHorizontalBorderChars('')
  69015. ->setVerticalBorderChars('')
  69016. ->setDefaultCrossingChar('')
  69017. ->setCellRowContentFormat('%s ')
  69018. ;
  69019. $styleGuide = new TableStyle();
  69020. $styleGuide
  69021. ->setHorizontalBorderChars('-')
  69022. ->setVerticalBorderChars(' ')
  69023. ->setDefaultCrossingChar(' ')
  69024. ->setCellHeaderFormat('%s')
  69025. ;
  69026. $box = (new TableStyle())
  69027. ->setHorizontalBorderChars('─')
  69028. ->setVerticalBorderChars('│')
  69029. ->setCrossingChars('┼', '┌', '┬', '�', '┤', '┘', '┴', '└', '├')
  69030. ;
  69031. $boxDouble = (new TableStyle())
  69032. ->setHorizontalBorderChars('�', '─')
  69033. ->setVerticalBorderChars('║', '│')
  69034. ->setCrossingChars('┼', '╔', '╤', '╗', '╢', '�', '╧', '╚', '╟', '╠', '╪', '╣')
  69035. ;
  69036. return [
  69037. 'default' => new TableStyle(),
  69038. 'borderless' => $borderless,
  69039. 'compact' => $compact,
  69040. 'symfony-style-guide' => $styleGuide,
  69041. 'box' => $box,
  69042. 'box-double' => $boxDouble,
  69043. ];
  69044. }
  69045. private function resolveStyle($name): TableStyle
  69046. {
  69047. if ($name instanceof TableStyle) {
  69048. return $name;
  69049. }
  69050. if (isset(self::$styles[$name])) {
  69051. return self::$styles[$name];
  69052. }
  69053. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  69054. }
  69055. }
  69056. <?php
  69057. namespace Symfony\Component\Console\Helper;
  69058. use Symfony\Component\Console\Exception\InvalidArgumentException;
  69059. class TableCell
  69060. {
  69061. private $value;
  69062. private $options = [
  69063. 'rowspan' => 1,
  69064. 'colspan' => 1,
  69065. 'style' => null,
  69066. ];
  69067. public function __construct(string $value = '', array $options = [])
  69068. {
  69069. $this->value = $value;
  69070. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  69071. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  69072. }
  69073. if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) {
  69074. throw new InvalidArgumentException('The style option must be an instance of "TableCellStyle".');
  69075. }
  69076. $this->options = array_merge($this->options, $options);
  69077. }
  69078. public function __toString()
  69079. {
  69080. return $this->value;
  69081. }
  69082. public function getColspan()
  69083. {
  69084. return (int) $this->options['colspan'];
  69085. }
  69086. public function getRowspan()
  69087. {
  69088. return (int) $this->options['rowspan'];
  69089. }
  69090. public function getStyle(): ?TableCellStyle
  69091. {
  69092. return $this->options['style'];
  69093. }
  69094. }
  69095. <?php
  69096. namespace Symfony\Component\Console\Helper;
  69097. use Symfony\Component\Console\Exception\InvalidArgumentException;
  69098. class TableCellStyle
  69099. {
  69100. public const DEFAULT_ALIGN = 'left';
  69101. private const TAG_OPTIONS = [
  69102. 'fg',
  69103. 'bg',
  69104. 'options',
  69105. ];
  69106. private const ALIGN_MAP = [
  69107. 'left' => \STR_PAD_RIGHT,
  69108. 'center' => \STR_PAD_BOTH,
  69109. 'right' => \STR_PAD_LEFT,
  69110. ];
  69111. private $options = [
  69112. 'fg' => 'default',
  69113. 'bg' => 'default',
  69114. 'options' => null,
  69115. 'align' => self::DEFAULT_ALIGN,
  69116. 'cellFormat' => null,
  69117. ];
  69118. public function __construct(array $options = [])
  69119. {
  69120. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  69121. throw new InvalidArgumentException(sprintf('The TableCellStyle does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  69122. }
  69123. if (isset($options['align']) && !\array_key_exists($options['align'], self::ALIGN_MAP)) {
  69124. throw new InvalidArgumentException(sprintf('Wrong align value. Value must be following: \'%s\'.', implode('\', \'', array_keys(self::ALIGN_MAP))));
  69125. }
  69126. $this->options = array_merge($this->options, $options);
  69127. }
  69128. public function getOptions(): array
  69129. {
  69130. return $this->options;
  69131. }
  69132. public function getTagOptions()
  69133. {
  69134. return array_filter(
  69135. $this->getOptions(),
  69136. function ($key) {
  69137. return \in_array($key, self::TAG_OPTIONS) && isset($this->options[$key]);
  69138. },
  69139. \ARRAY_FILTER_USE_KEY
  69140. );
  69141. }
  69142. public function getPadByAlign()
  69143. {
  69144. return self::ALIGN_MAP[$this->getOptions()['align']];
  69145. }
  69146. public function getCellFormat(): ?string
  69147. {
  69148. return $this->getOptions()['cellFormat'];
  69149. }
  69150. }
  69151. <?php
  69152. namespace Symfony\Component\Console\Helper;
  69153. class TableRows implements \IteratorAggregate
  69154. {
  69155. private $generator;
  69156. public function __construct(\Closure $generator)
  69157. {
  69158. $this->generator = $generator;
  69159. }
  69160. public function getIterator(): \Traversable
  69161. {
  69162. return ($this->generator)();
  69163. }
  69164. }
  69165. <?php
  69166. namespace Symfony\Component\Console\Helper;
  69167. class TableSeparator extends TableCell
  69168. {
  69169. public function __construct(array $options = [])
  69170. {
  69171. parent::__construct('', $options);
  69172. }
  69173. }
  69174. <?php
  69175. namespace Symfony\Component\Console\Helper;
  69176. use Symfony\Component\Console\Exception\InvalidArgumentException;
  69177. use Symfony\Component\Console\Exception\LogicException;
  69178. class TableStyle
  69179. {
  69180. private $paddingChar = ' ';
  69181. private $horizontalOutsideBorderChar = '-';
  69182. private $horizontalInsideBorderChar = '-';
  69183. private $verticalOutsideBorderChar = '|';
  69184. private $verticalInsideBorderChar = '|';
  69185. private $crossingChar = '+';
  69186. private $crossingTopRightChar = '+';
  69187. private $crossingTopMidChar = '+';
  69188. private $crossingTopLeftChar = '+';
  69189. private $crossingMidRightChar = '+';
  69190. private $crossingBottomRightChar = '+';
  69191. private $crossingBottomMidChar = '+';
  69192. private $crossingBottomLeftChar = '+';
  69193. private $crossingMidLeftChar = '+';
  69194. private $crossingTopLeftBottomChar = '+';
  69195. private $crossingTopMidBottomChar = '+';
  69196. private $crossingTopRightBottomChar = '+';
  69197. private $headerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
  69198. private $footerTitleFormat = '<fg=black;bg=white;options=bold> %s </>';
  69199. private $cellHeaderFormat = '<info>%s</info>';
  69200. private $cellRowFormat = '%s';
  69201. private $cellRowContentFormat = ' %s ';
  69202. private $borderFormat = '%s';
  69203. private $padType = \STR_PAD_RIGHT;
  69204. public function setPaddingChar(string $paddingChar)
  69205. {
  69206. if (!$paddingChar) {
  69207. throw new LogicException('The padding char must not be empty.');
  69208. }
  69209. $this->paddingChar = $paddingChar;
  69210. return $this;
  69211. }
  69212. public function getPaddingChar()
  69213. {
  69214. return $this->paddingChar;
  69215. }
  69216. public function setHorizontalBorderChars(string $outside, ?string $inside = null): self
  69217. {
  69218. $this->horizontalOutsideBorderChar = $outside;
  69219. $this->horizontalInsideBorderChar = $inside ?? $outside;
  69220. return $this;
  69221. }
  69222. public function setVerticalBorderChars(string $outside, ?string $inside = null): self
  69223. {
  69224. $this->verticalOutsideBorderChar = $outside;
  69225. $this->verticalInsideBorderChar = $inside ?? $outside;
  69226. return $this;
  69227. }
  69228. public function getBorderChars(): array
  69229. {
  69230. return [
  69231. $this->horizontalOutsideBorderChar,
  69232. $this->verticalOutsideBorderChar,
  69233. $this->horizontalInsideBorderChar,
  69234. $this->verticalInsideBorderChar,
  69235. ];
  69236. }
  69237. 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
  69238. {
  69239. $this->crossingChar = $cross;
  69240. $this->crossingTopLeftChar = $topLeft;
  69241. $this->crossingTopMidChar = $topMid;
  69242. $this->crossingTopRightChar = $topRight;
  69243. $this->crossingMidRightChar = $midRight;
  69244. $this->crossingBottomRightChar = $bottomRight;
  69245. $this->crossingBottomMidChar = $bottomMid;
  69246. $this->crossingBottomLeftChar = $bottomLeft;
  69247. $this->crossingMidLeftChar = $midLeft;
  69248. $this->crossingTopLeftBottomChar = $topLeftBottom ?? $midLeft;
  69249. $this->crossingTopMidBottomChar = $topMidBottom ?? $cross;
  69250. $this->crossingTopRightBottomChar = $topRightBottom ?? $midRight;
  69251. return $this;
  69252. }
  69253. public function setDefaultCrossingChar(string $char): self
  69254. {
  69255. return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char);
  69256. }
  69257. public function getCrossingChar()
  69258. {
  69259. return $this->crossingChar;
  69260. }
  69261. public function getCrossingChars(): array
  69262. {
  69263. return [
  69264. $this->crossingChar,
  69265. $this->crossingTopLeftChar,
  69266. $this->crossingTopMidChar,
  69267. $this->crossingTopRightChar,
  69268. $this->crossingMidRightChar,
  69269. $this->crossingBottomRightChar,
  69270. $this->crossingBottomMidChar,
  69271. $this->crossingBottomLeftChar,
  69272. $this->crossingMidLeftChar,
  69273. $this->crossingTopLeftBottomChar,
  69274. $this->crossingTopMidBottomChar,
  69275. $this->crossingTopRightBottomChar,
  69276. ];
  69277. }
  69278. public function setCellHeaderFormat(string $cellHeaderFormat)
  69279. {
  69280. $this->cellHeaderFormat = $cellHeaderFormat;
  69281. return $this;
  69282. }
  69283. public function getCellHeaderFormat()
  69284. {
  69285. return $this->cellHeaderFormat;
  69286. }
  69287. public function setCellRowFormat(string $cellRowFormat)
  69288. {
  69289. $this->cellRowFormat = $cellRowFormat;
  69290. return $this;
  69291. }
  69292. public function getCellRowFormat()
  69293. {
  69294. return $this->cellRowFormat;
  69295. }
  69296. public function setCellRowContentFormat(string $cellRowContentFormat)
  69297. {
  69298. $this->cellRowContentFormat = $cellRowContentFormat;
  69299. return $this;
  69300. }
  69301. public function getCellRowContentFormat()
  69302. {
  69303. return $this->cellRowContentFormat;
  69304. }
  69305. public function setBorderFormat(string $borderFormat)
  69306. {
  69307. $this->borderFormat = $borderFormat;
  69308. return $this;
  69309. }
  69310. public function getBorderFormat()
  69311. {
  69312. return $this->borderFormat;
  69313. }
  69314. public function setPadType(int $padType)
  69315. {
  69316. if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) {
  69317. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  69318. }
  69319. $this->padType = $padType;
  69320. return $this;
  69321. }
  69322. public function getPadType()
  69323. {
  69324. return $this->padType;
  69325. }
  69326. public function getHeaderTitleFormat(): string
  69327. {
  69328. return $this->headerTitleFormat;
  69329. }
  69330. public function setHeaderTitleFormat(string $format): self
  69331. {
  69332. $this->headerTitleFormat = $format;
  69333. return $this;
  69334. }
  69335. public function getFooterTitleFormat(): string
  69336. {
  69337. return $this->footerTitleFormat;
  69338. }
  69339. public function setFooterTitleFormat(string $format): self
  69340. {
  69341. $this->footerTitleFormat = $format;
  69342. return $this;
  69343. }
  69344. }
  69345. <?php
  69346. namespace Symfony\Component\Console\Input;
  69347. use Symfony\Component\Console\Exception\RuntimeException;
  69348. class ArgvInput extends Input
  69349. {
  69350. private $tokens;
  69351. private $parsed;
  69352. public function __construct(?array $argv = null, ?InputDefinition $definition = null)
  69353. {
  69354. $argv = $argv ?? $_SERVER['argv'] ?? [];
  69355. array_shift($argv);
  69356. $this->tokens = $argv;
  69357. parent::__construct($definition);
  69358. }
  69359. protected function setTokens(array $tokens)
  69360. {
  69361. $this->tokens = $tokens;
  69362. }
  69363. protected function parse()
  69364. {
  69365. $parseOptions = true;
  69366. $this->parsed = $this->tokens;
  69367. while (null !== $token = array_shift($this->parsed)) {
  69368. $parseOptions = $this->parseToken($token, $parseOptions);
  69369. }
  69370. }
  69371. protected function parseToken(string $token, bool $parseOptions): bool
  69372. {
  69373. if ($parseOptions && '' == $token) {
  69374. $this->parseArgument($token);
  69375. } elseif ($parseOptions && '--' == $token) {
  69376. return false;
  69377. } elseif ($parseOptions && str_starts_with($token, '--')) {
  69378. $this->parseLongOption($token);
  69379. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  69380. $this->parseShortOption($token);
  69381. } else {
  69382. $this->parseArgument($token);
  69383. }
  69384. return $parseOptions;
  69385. }
  69386. private function parseShortOption(string $token)
  69387. {
  69388. $name = substr($token, 1);
  69389. if (\strlen($name) > 1) {
  69390. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  69391. $this->addShortOption($name[0], substr($name, 1));
  69392. } else {
  69393. $this->parseShortOptionSet($name);
  69394. }
  69395. } else {
  69396. $this->addShortOption($name, null);
  69397. }
  69398. }
  69399. private function parseShortOptionSet(string $name)
  69400. {
  69401. $len = \strlen($name);
  69402. for ($i = 0; $i < $len; ++$i) {
  69403. if (!$this->definition->hasShortcut($name[$i])) {
  69404. $encoding = mb_detect_encoding($name, null, true);
  69405. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  69406. }
  69407. $option = $this->definition->getOptionForShortcut($name[$i]);
  69408. if ($option->acceptValue()) {
  69409. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  69410. break;
  69411. } else {
  69412. $this->addLongOption($option->getName(), null);
  69413. }
  69414. }
  69415. }
  69416. private function parseLongOption(string $token)
  69417. {
  69418. $name = substr($token, 2);
  69419. if (false !== $pos = strpos($name, '=')) {
  69420. if ('' === $value = substr($name, $pos + 1)) {
  69421. array_unshift($this->parsed, $value);
  69422. }
  69423. $this->addLongOption(substr($name, 0, $pos), $value);
  69424. } else {
  69425. $this->addLongOption($name, null);
  69426. }
  69427. }
  69428. private function parseArgument(string $token)
  69429. {
  69430. $c = \count($this->arguments);
  69431. if ($this->definition->hasArgument($c)) {
  69432. $arg = $this->definition->getArgument($c);
  69433. $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token;
  69434. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  69435. $arg = $this->definition->getArgument($c - 1);
  69436. $this->arguments[$arg->getName()][] = $token;
  69437. } else {
  69438. $all = $this->definition->getArguments();
  69439. $symfonyCommandName = null;
  69440. if (($inputArgument = $all[$key = array_key_first($all)] ?? null) && 'command' === $inputArgument->getName()) {
  69441. $symfonyCommandName = $this->arguments['command'] ?? null;
  69442. unset($all[$key]);
  69443. }
  69444. if (\count($all)) {
  69445. if ($symfonyCommandName) {
  69446. $message = sprintf('Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, implode('" "', array_keys($all)));
  69447. } else {
  69448. $message = sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)));
  69449. }
  69450. } elseif ($symfonyCommandName) {
  69451. $message = sprintf('No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token);
  69452. } else {
  69453. $message = sprintf('No arguments expected, got "%s".', $token);
  69454. }
  69455. throw new RuntimeException($message);
  69456. }
  69457. }
  69458. private function addShortOption(string $shortcut, $value)
  69459. {
  69460. if (!$this->definition->hasShortcut($shortcut)) {
  69461. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  69462. }
  69463. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  69464. }
  69465. private function addLongOption(string $name, $value)
  69466. {
  69467. if (!$this->definition->hasOption($name)) {
  69468. if (!$this->definition->hasNegation($name)) {
  69469. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  69470. }
  69471. $optionName = $this->definition->negationToName($name);
  69472. if (null !== $value) {
  69473. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  69474. }
  69475. $this->options[$optionName] = false;
  69476. return;
  69477. }
  69478. $option = $this->definition->getOption($name);
  69479. if (null !== $value && !$option->acceptValue()) {
  69480. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  69481. }
  69482. if (\in_array($value, ['', null], true) && $option->acceptValue() && \count($this->parsed)) {
  69483. $next = array_shift($this->parsed);
  69484. if ((isset($next[0]) && '-' !== $next[0]) || \in_array($next, ['', null], true)) {
  69485. $value = $next;
  69486. } else {
  69487. array_unshift($this->parsed, $next);
  69488. }
  69489. }
  69490. if (null === $value) {
  69491. if ($option->isValueRequired()) {
  69492. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  69493. }
  69494. if (!$option->isArray() && !$option->isValueOptional()) {
  69495. $value = true;
  69496. }
  69497. }
  69498. if ($option->isArray()) {
  69499. $this->options[$name][] = $value;
  69500. } else {
  69501. $this->options[$name] = $value;
  69502. }
  69503. }
  69504. public function getFirstArgument()
  69505. {
  69506. $isOption = false;
  69507. foreach ($this->tokens as $i => $token) {
  69508. if ($token && '-' === $token[0]) {
  69509. if (str_contains($token, '=') || !isset($this->tokens[$i + 1])) {
  69510. continue;
  69511. }
  69512. $name = '-' === $token[1] ? substr($token, 2) : substr($token, -1);
  69513. if (!isset($this->options[$name]) && !$this->definition->hasShortcut($name)) {
  69514. } elseif ((isset($this->options[$name]) || isset($this->options[$name = $this->definition->shortcutToName($name)])) && $this->tokens[$i + 1] === $this->options[$name]) {
  69515. $isOption = true;
  69516. }
  69517. continue;
  69518. }
  69519. if ($isOption) {
  69520. $isOption = false;
  69521. continue;
  69522. }
  69523. return $token;
  69524. }
  69525. return null;
  69526. }
  69527. public function hasParameterOption($values, bool $onlyParams = false)
  69528. {
  69529. $values = (array) $values;
  69530. foreach ($this->tokens as $token) {
  69531. if ($onlyParams && '--' === $token) {
  69532. return false;
  69533. }
  69534. foreach ($values as $value) {
  69535. $leading = str_starts_with($value, '--') ? $value.'=' : $value;
  69536. if ($token === $value || '' !== $leading && str_starts_with($token, $leading)) {
  69537. return true;
  69538. }
  69539. }
  69540. }
  69541. return false;
  69542. }
  69543. public function getParameterOption($values, $default = false, bool $onlyParams = false)
  69544. {
  69545. $values = (array) $values;
  69546. $tokens = $this->tokens;
  69547. while (0 < \count($tokens)) {
  69548. $token = array_shift($tokens);
  69549. if ($onlyParams && '--' === $token) {
  69550. return $default;
  69551. }
  69552. foreach ($values as $value) {
  69553. if ($token === $value) {
  69554. return array_shift($tokens);
  69555. }
  69556. $leading = str_starts_with($value, '--') ? $value.'=' : $value;
  69557. if ('' !== $leading && str_starts_with($token, $leading)) {
  69558. return substr($token, \strlen($leading));
  69559. }
  69560. }
  69561. }
  69562. return $default;
  69563. }
  69564. public function __toString()
  69565. {
  69566. $tokens = array_map(function ($token) {
  69567. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  69568. return $match[1].$this->escapeToken($match[2]);
  69569. }
  69570. if ($token && '-' !== $token[0]) {
  69571. return $this->escapeToken($token);
  69572. }
  69573. return $token;
  69574. }, $this->tokens);
  69575. return implode(' ', $tokens);
  69576. }
  69577. }
  69578. <?php
  69579. namespace Symfony\Component\Console\Input;
  69580. use Symfony\Component\Console\Exception\InvalidArgumentException;
  69581. use Symfony\Component\Console\Exception\InvalidOptionException;
  69582. class ArrayInput extends Input
  69583. {
  69584. private $parameters;
  69585. public function __construct(array $parameters, ?InputDefinition $definition = null)
  69586. {
  69587. $this->parameters = $parameters;
  69588. parent::__construct($definition);
  69589. }
  69590. public function getFirstArgument()
  69591. {
  69592. foreach ($this->parameters as $param => $value) {
  69593. if ($param && \is_string($param) && '-' === $param[0]) {
  69594. continue;
  69595. }
  69596. return $value;
  69597. }
  69598. return null;
  69599. }
  69600. public function hasParameterOption($values, bool $onlyParams = false)
  69601. {
  69602. $values = (array) $values;
  69603. foreach ($this->parameters as $k => $v) {
  69604. if (!\is_int($k)) {
  69605. $v = $k;
  69606. }
  69607. if ($onlyParams && '--' === $v) {
  69608. return false;
  69609. }
  69610. if (\in_array($v, $values)) {
  69611. return true;
  69612. }
  69613. }
  69614. return false;
  69615. }
  69616. public function getParameterOption($values, $default = false, bool $onlyParams = false)
  69617. {
  69618. $values = (array) $values;
  69619. foreach ($this->parameters as $k => $v) {
  69620. if ($onlyParams && ('--' === $k || (\is_int($k) && '--' === $v))) {
  69621. return $default;
  69622. }
  69623. if (\is_int($k)) {
  69624. if (\in_array($v, $values)) {
  69625. return true;
  69626. }
  69627. } elseif (\in_array($k, $values)) {
  69628. return $v;
  69629. }
  69630. }
  69631. return $default;
  69632. }
  69633. public function __toString()
  69634. {
  69635. $params = [];
  69636. foreach ($this->parameters as $param => $val) {
  69637. if ($param && \is_string($param) && '-' === $param[0]) {
  69638. $glue = ('-' === $param[1]) ? '=' : ' ';
  69639. if (\is_array($val)) {
  69640. foreach ($val as $v) {
  69641. $params[] = $param.('' != $v ? $glue.$this->escapeToken($v) : '');
  69642. }
  69643. } else {
  69644. $params[] = $param.('' != $val ? $glue.$this->escapeToken($val) : '');
  69645. }
  69646. } else {
  69647. $params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val);
  69648. }
  69649. }
  69650. return implode(' ', $params);
  69651. }
  69652. protected function parse()
  69653. {
  69654. foreach ($this->parameters as $key => $value) {
  69655. if ('--' === $key) {
  69656. return;
  69657. }
  69658. if (str_starts_with($key, '--')) {
  69659. $this->addLongOption(substr($key, 2), $value);
  69660. } elseif (str_starts_with($key, '-')) {
  69661. $this->addShortOption(substr($key, 1), $value);
  69662. } else {
  69663. $this->addArgument($key, $value);
  69664. }
  69665. }
  69666. }
  69667. private function addShortOption(string $shortcut, $value)
  69668. {
  69669. if (!$this->definition->hasShortcut($shortcut)) {
  69670. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  69671. }
  69672. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  69673. }
  69674. private function addLongOption(string $name, $value)
  69675. {
  69676. if (!$this->definition->hasOption($name)) {
  69677. if (!$this->definition->hasNegation($name)) {
  69678. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  69679. }
  69680. $optionName = $this->definition->negationToName($name);
  69681. $this->options[$optionName] = false;
  69682. return;
  69683. }
  69684. $option = $this->definition->getOption($name);
  69685. if (null === $value) {
  69686. if ($option->isValueRequired()) {
  69687. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  69688. }
  69689. if (!$option->isValueOptional()) {
  69690. $value = true;
  69691. }
  69692. }
  69693. $this->options[$name] = $value;
  69694. }
  69695. private function addArgument($name, $value)
  69696. {
  69697. if (!$this->definition->hasArgument($name)) {
  69698. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  69699. }
  69700. $this->arguments[$name] = $value;
  69701. }
  69702. }
  69703. <?php
  69704. namespace Symfony\Component\Console\Input;
  69705. use Symfony\Component\Console\Exception\InvalidArgumentException;
  69706. use Symfony\Component\Console\Exception\RuntimeException;
  69707. abstract class Input implements InputInterface, StreamableInputInterface
  69708. {
  69709. protected $definition;
  69710. protected $stream;
  69711. protected $options = [];
  69712. protected $arguments = [];
  69713. protected $interactive = true;
  69714. public function __construct(?InputDefinition $definition = null)
  69715. {
  69716. if (null === $definition) {
  69717. $this->definition = new InputDefinition();
  69718. } else {
  69719. $this->bind($definition);
  69720. $this->validate();
  69721. }
  69722. }
  69723. public function bind(InputDefinition $definition)
  69724. {
  69725. $this->arguments = [];
  69726. $this->options = [];
  69727. $this->definition = $definition;
  69728. $this->parse();
  69729. }
  69730. abstract protected function parse();
  69731. public function validate()
  69732. {
  69733. $definition = $this->definition;
  69734. $givenArguments = $this->arguments;
  69735. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  69736. return !\array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  69737. });
  69738. if (\count($missingArguments) > 0) {
  69739. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  69740. }
  69741. }
  69742. public function isInteractive()
  69743. {
  69744. return $this->interactive;
  69745. }
  69746. public function setInteractive(bool $interactive)
  69747. {
  69748. $this->interactive = $interactive;
  69749. }
  69750. public function getArguments()
  69751. {
  69752. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  69753. }
  69754. public function getArgument(string $name)
  69755. {
  69756. if (!$this->definition->hasArgument($name)) {
  69757. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  69758. }
  69759. return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
  69760. }
  69761. public function setArgument(string $name, $value)
  69762. {
  69763. if (!$this->definition->hasArgument($name)) {
  69764. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  69765. }
  69766. $this->arguments[$name] = $value;
  69767. }
  69768. public function hasArgument(string $name)
  69769. {
  69770. return $this->definition->hasArgument($name);
  69771. }
  69772. public function getOptions()
  69773. {
  69774. return array_merge($this->definition->getOptionDefaults(), $this->options);
  69775. }
  69776. public function getOption(string $name)
  69777. {
  69778. if ($this->definition->hasNegation($name)) {
  69779. if (null === $value = $this->getOption($this->definition->negationToName($name))) {
  69780. return $value;
  69781. }
  69782. return !$value;
  69783. }
  69784. if (!$this->definition->hasOption($name)) {
  69785. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  69786. }
  69787. return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  69788. }
  69789. public function setOption(string $name, $value)
  69790. {
  69791. if ($this->definition->hasNegation($name)) {
  69792. $this->options[$this->definition->negationToName($name)] = !$value;
  69793. return;
  69794. } elseif (!$this->definition->hasOption($name)) {
  69795. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  69796. }
  69797. $this->options[$name] = $value;
  69798. }
  69799. public function hasOption(string $name)
  69800. {
  69801. return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
  69802. }
  69803. public function escapeToken(string $token)
  69804. {
  69805. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  69806. }
  69807. public function setStream($stream)
  69808. {
  69809. $this->stream = $stream;
  69810. }
  69811. public function getStream()
  69812. {
  69813. return $this->stream;
  69814. }
  69815. }
  69816. <?php
  69817. namespace Symfony\Component\Console\Input;
  69818. use Symfony\Component\Console\Exception\InvalidArgumentException;
  69819. use Symfony\Component\Console\Exception\LogicException;
  69820. class InputArgument
  69821. {
  69822. public const REQUIRED = 1;
  69823. public const OPTIONAL = 2;
  69824. public const IS_ARRAY = 4;
  69825. private $name;
  69826. private $mode;
  69827. private $default;
  69828. private $description;
  69829. public function __construct(string $name, ?int $mode = null, string $description = '', $default = null)
  69830. {
  69831. if (null === $mode) {
  69832. $mode = self::OPTIONAL;
  69833. } elseif ($mode > 7 || $mode < 1) {
  69834. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  69835. }
  69836. $this->name = $name;
  69837. $this->mode = $mode;
  69838. $this->description = $description;
  69839. $this->setDefault($default);
  69840. }
  69841. public function getName()
  69842. {
  69843. return $this->name;
  69844. }
  69845. public function isRequired()
  69846. {
  69847. return self::REQUIRED === (self::REQUIRED & $this->mode);
  69848. }
  69849. public function isArray()
  69850. {
  69851. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  69852. }
  69853. public function setDefault($default = null)
  69854. {
  69855. if ($this->isRequired() && null !== $default) {
  69856. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  69857. }
  69858. if ($this->isArray()) {
  69859. if (null === $default) {
  69860. $default = [];
  69861. } elseif (!\is_array($default)) {
  69862. throw new LogicException('A default value for an array argument must be an array.');
  69863. }
  69864. }
  69865. $this->default = $default;
  69866. }
  69867. public function getDefault()
  69868. {
  69869. return $this->default;
  69870. }
  69871. public function getDescription()
  69872. {
  69873. return $this->description;
  69874. }
  69875. }
  69876. <?php
  69877. namespace Symfony\Component\Console\Input;
  69878. interface InputAwareInterface
  69879. {
  69880. public function setInput(InputInterface $input);
  69881. }
  69882. <?php
  69883. namespace Symfony\Component\Console\Input;
  69884. use Symfony\Component\Console\Exception\InvalidArgumentException;
  69885. use Symfony\Component\Console\Exception\LogicException;
  69886. class InputDefinition
  69887. {
  69888. private $arguments;
  69889. private $requiredCount;
  69890. private $lastArrayArgument;
  69891. private $lastOptionalArgument;
  69892. private $options;
  69893. private $negations;
  69894. private $shortcuts;
  69895. public function __construct(array $definition = [])
  69896. {
  69897. $this->setDefinition($definition);
  69898. }
  69899. public function setDefinition(array $definition)
  69900. {
  69901. $arguments = [];
  69902. $options = [];
  69903. foreach ($definition as $item) {
  69904. if ($item instanceof InputOption) {
  69905. $options[] = $item;
  69906. } else {
  69907. $arguments[] = $item;
  69908. }
  69909. }
  69910. $this->setArguments($arguments);
  69911. $this->setOptions($options);
  69912. }
  69913. public function setArguments(array $arguments = [])
  69914. {
  69915. $this->arguments = [];
  69916. $this->requiredCount = 0;
  69917. $this->lastOptionalArgument = null;
  69918. $this->lastArrayArgument = null;
  69919. $this->addArguments($arguments);
  69920. }
  69921. public function addArguments(?array $arguments = [])
  69922. {
  69923. if (null !== $arguments) {
  69924. foreach ($arguments as $argument) {
  69925. $this->addArgument($argument);
  69926. }
  69927. }
  69928. }
  69929. public function addArgument(InputArgument $argument)
  69930. {
  69931. if (isset($this->arguments[$argument->getName()])) {
  69932. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  69933. }
  69934. if (null !== $this->lastArrayArgument) {
  69935. throw new LogicException(sprintf('Cannot add a required argument "%s" after an array argument "%s".', $argument->getName(), $this->lastArrayArgument->getName()));
  69936. }
  69937. if ($argument->isRequired() && null !== $this->lastOptionalArgument) {
  69938. throw new LogicException(sprintf('Cannot add a required argument "%s" after an optional one "%s".', $argument->getName(), $this->lastOptionalArgument->getName()));
  69939. }
  69940. if ($argument->isArray()) {
  69941. $this->lastArrayArgument = $argument;
  69942. }
  69943. if ($argument->isRequired()) {
  69944. ++$this->requiredCount;
  69945. } else {
  69946. $this->lastOptionalArgument = $argument;
  69947. }
  69948. $this->arguments[$argument->getName()] = $argument;
  69949. }
  69950. public function getArgument($name)
  69951. {
  69952. if (!$this->hasArgument($name)) {
  69953. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  69954. }
  69955. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  69956. return $arguments[$name];
  69957. }
  69958. public function hasArgument($name)
  69959. {
  69960. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  69961. return isset($arguments[$name]);
  69962. }
  69963. public function getArguments()
  69964. {
  69965. return $this->arguments;
  69966. }
  69967. public function getArgumentCount()
  69968. {
  69969. return null !== $this->lastArrayArgument ? \PHP_INT_MAX : \count($this->arguments);
  69970. }
  69971. public function getArgumentRequiredCount()
  69972. {
  69973. return $this->requiredCount;
  69974. }
  69975. public function getArgumentDefaults()
  69976. {
  69977. $values = [];
  69978. foreach ($this->arguments as $argument) {
  69979. $values[$argument->getName()] = $argument->getDefault();
  69980. }
  69981. return $values;
  69982. }
  69983. public function setOptions(array $options = [])
  69984. {
  69985. $this->options = [];
  69986. $this->shortcuts = [];
  69987. $this->negations = [];
  69988. $this->addOptions($options);
  69989. }
  69990. public function addOptions(array $options = [])
  69991. {
  69992. foreach ($options as $option) {
  69993. $this->addOption($option);
  69994. }
  69995. }
  69996. public function addOption(InputOption $option)
  69997. {
  69998. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  69999. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  70000. }
  70001. if (isset($this->negations[$option->getName()])) {
  70002. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  70003. }
  70004. if ($option->getShortcut()) {
  70005. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  70006. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  70007. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  70008. }
  70009. }
  70010. }
  70011. $this->options[$option->getName()] = $option;
  70012. if ($option->getShortcut()) {
  70013. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  70014. $this->shortcuts[$shortcut] = $option->getName();
  70015. }
  70016. }
  70017. if ($option->isNegatable()) {
  70018. $negatedName = 'no-'.$option->getName();
  70019. if (isset($this->options[$negatedName])) {
  70020. throw new LogicException(sprintf('An option named "%s" already exists.', $negatedName));
  70021. }
  70022. $this->negations[$negatedName] = $option->getName();
  70023. }
  70024. }
  70025. public function getOption(string $name)
  70026. {
  70027. if (!$this->hasOption($name)) {
  70028. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  70029. }
  70030. return $this->options[$name];
  70031. }
  70032. public function hasOption(string $name)
  70033. {
  70034. return isset($this->options[$name]);
  70035. }
  70036. public function getOptions()
  70037. {
  70038. return $this->options;
  70039. }
  70040. public function hasShortcut(string $name)
  70041. {
  70042. return isset($this->shortcuts[$name]);
  70043. }
  70044. public function hasNegation(string $name): bool
  70045. {
  70046. return isset($this->negations[$name]);
  70047. }
  70048. public function getOptionForShortcut(string $shortcut)
  70049. {
  70050. return $this->getOption($this->shortcutToName($shortcut));
  70051. }
  70052. public function getOptionDefaults()
  70053. {
  70054. $values = [];
  70055. foreach ($this->options as $option) {
  70056. $values[$option->getName()] = $option->getDefault();
  70057. }
  70058. return $values;
  70059. }
  70060. public function shortcutToName(string $shortcut): string
  70061. {
  70062. if (!isset($this->shortcuts[$shortcut])) {
  70063. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  70064. }
  70065. return $this->shortcuts[$shortcut];
  70066. }
  70067. public function negationToName(string $negation): string
  70068. {
  70069. if (!isset($this->negations[$negation])) {
  70070. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $negation));
  70071. }
  70072. return $this->negations[$negation];
  70073. }
  70074. public function getSynopsis(bool $short = false)
  70075. {
  70076. $elements = [];
  70077. if ($short && $this->getOptions()) {
  70078. $elements[] = '[options]';
  70079. } elseif (!$short) {
  70080. foreach ($this->getOptions() as $option) {
  70081. $value = '';
  70082. if ($option->acceptValue()) {
  70083. $value = sprintf(
  70084. ' %s%s%s',
  70085. $option->isValueOptional() ? '[' : '',
  70086. strtoupper($option->getName()),
  70087. $option->isValueOptional() ? ']' : ''
  70088. );
  70089. }
  70090. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  70091. $negation = $option->isNegatable() ? sprintf('|--no-%s', $option->getName()) : '';
  70092. $elements[] = sprintf('[%s--%s%s%s]', $shortcut, $option->getName(), $value, $negation);
  70093. }
  70094. }
  70095. if (\count($elements) && $this->getArguments()) {
  70096. $elements[] = '[--]';
  70097. }
  70098. $tail = '';
  70099. foreach ($this->getArguments() as $argument) {
  70100. $element = '<'.$argument->getName().'>';
  70101. if ($argument->isArray()) {
  70102. $element .= '...';
  70103. }
  70104. if (!$argument->isRequired()) {
  70105. $element = '['.$element;
  70106. $tail .= ']';
  70107. }
  70108. $elements[] = $element;
  70109. }
  70110. return implode(' ', $elements).$tail;
  70111. }
  70112. }
  70113. <?php
  70114. namespace Symfony\Component\Console\Input;
  70115. use Symfony\Component\Console\Exception\InvalidArgumentException;
  70116. use Symfony\Component\Console\Exception\RuntimeException;
  70117. interface InputInterface
  70118. {
  70119. public function getFirstArgument();
  70120. public function hasParameterOption($values, bool $onlyParams = false);
  70121. public function getParameterOption($values, $default = false, bool $onlyParams = false);
  70122. public function bind(InputDefinition $definition);
  70123. public function validate();
  70124. public function getArguments();
  70125. public function getArgument(string $name);
  70126. public function setArgument(string $name, $value);
  70127. public function hasArgument(string $name);
  70128. public function getOptions();
  70129. public function getOption(string $name);
  70130. public function setOption(string $name, $value);
  70131. public function hasOption(string $name);
  70132. public function isInteractive();
  70133. public function setInteractive(bool $interactive);
  70134. }
  70135. <?php
  70136. namespace Symfony\Component\Console\Input;
  70137. use Symfony\Component\Console\Exception\InvalidArgumentException;
  70138. use Symfony\Component\Console\Exception\LogicException;
  70139. class InputOption
  70140. {
  70141. public const VALUE_NONE = 1;
  70142. public const VALUE_REQUIRED = 2;
  70143. public const VALUE_OPTIONAL = 4;
  70144. public const VALUE_IS_ARRAY = 8;
  70145. public const VALUE_NEGATABLE = 16;
  70146. private $name;
  70147. private $shortcut;
  70148. private $mode;
  70149. private $default;
  70150. private $description;
  70151. public function __construct(string $name, $shortcut = null, ?int $mode = null, string $description = '', $default = null)
  70152. {
  70153. if (str_starts_with($name, '--')) {
  70154. $name = substr($name, 2);
  70155. }
  70156. if (empty($name)) {
  70157. throw new InvalidArgumentException('An option name cannot be empty.');
  70158. }
  70159. if ('' === $shortcut || [] === $shortcut || false === $shortcut) {
  70160. $shortcut = null;
  70161. }
  70162. if (null !== $shortcut) {
  70163. if (\is_array($shortcut)) {
  70164. $shortcut = implode('|', $shortcut);
  70165. }
  70166. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  70167. $shortcuts = array_filter($shortcuts, 'strlen');
  70168. $shortcut = implode('|', $shortcuts);
  70169. if ('' === $shortcut) {
  70170. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  70171. }
  70172. }
  70173. if (null === $mode) {
  70174. $mode = self::VALUE_NONE;
  70175. } elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) {
  70176. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  70177. }
  70178. $this->name = $name;
  70179. $this->shortcut = $shortcut;
  70180. $this->mode = $mode;
  70181. $this->description = $description;
  70182. if ($this->isArray() && !$this->acceptValue()) {
  70183. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  70184. }
  70185. if ($this->isNegatable() && $this->acceptValue()) {
  70186. throw new InvalidArgumentException('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
  70187. }
  70188. $this->setDefault($default);
  70189. }
  70190. public function getShortcut()
  70191. {
  70192. return $this->shortcut;
  70193. }
  70194. public function getName()
  70195. {
  70196. return $this->name;
  70197. }
  70198. public function acceptValue()
  70199. {
  70200. return $this->isValueRequired() || $this->isValueOptional();
  70201. }
  70202. public function isValueRequired()
  70203. {
  70204. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  70205. }
  70206. public function isValueOptional()
  70207. {
  70208. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  70209. }
  70210. public function isArray()
  70211. {
  70212. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  70213. }
  70214. public function isNegatable(): bool
  70215. {
  70216. return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
  70217. }
  70218. public function setDefault($default = null)
  70219. {
  70220. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  70221. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  70222. }
  70223. if ($this->isArray()) {
  70224. if (null === $default) {
  70225. $default = [];
  70226. } elseif (!\is_array($default)) {
  70227. throw new LogicException('A default value for an array option must be an array.');
  70228. }
  70229. }
  70230. $this->default = $this->acceptValue() || $this->isNegatable() ? $default : false;
  70231. }
  70232. public function getDefault()
  70233. {
  70234. return $this->default;
  70235. }
  70236. public function getDescription()
  70237. {
  70238. return $this->description;
  70239. }
  70240. public function equals(self $option)
  70241. {
  70242. return $option->getName() === $this->getName()
  70243. && $option->getShortcut() === $this->getShortcut()
  70244. && $option->getDefault() === $this->getDefault()
  70245. && $option->isNegatable() === $this->isNegatable()
  70246. && $option->isArray() === $this->isArray()
  70247. && $option->isValueRequired() === $this->isValueRequired()
  70248. && $option->isValueOptional() === $this->isValueOptional()
  70249. ;
  70250. }
  70251. }
  70252. <?php
  70253. namespace Symfony\Component\Console\Input;
  70254. interface StreamableInputInterface extends InputInterface
  70255. {
  70256. public function setStream($stream);
  70257. public function getStream();
  70258. }
  70259. <?php
  70260. namespace Symfony\Component\Console\Input;
  70261. use Symfony\Component\Console\Exception\InvalidArgumentException;
  70262. class StringInput extends ArgvInput
  70263. {
  70264. public const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  70265. public const REGEX_UNQUOTED_STRING = '([^\s\\\\]+?)';
  70266. public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  70267. public function __construct(string $input)
  70268. {
  70269. parent::__construct([]);
  70270. $this->setTokens($this->tokenize($input));
  70271. }
  70272. private function tokenize(string $input): array
  70273. {
  70274. $tokens = [];
  70275. $length = \strlen($input);
  70276. $cursor = 0;
  70277. $token = null;
  70278. while ($cursor < $length) {
  70279. if ('\\' === $input[$cursor]) {
  70280. $token .= $input[++$cursor] ?? '';
  70281. ++$cursor;
  70282. continue;
  70283. }
  70284. if (preg_match('/\s+/A', $input, $match, 0, $cursor)) {
  70285. if (null !== $token) {
  70286. $tokens[] = $token;
  70287. $token = null;
  70288. }
  70289. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, 0, $cursor)) {
  70290. $token .= $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, -1)));
  70291. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
  70292. $token .= stripcslashes(substr($match[0], 1, -1));
  70293. } elseif (preg_match('/'.self::REGEX_UNQUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
  70294. $token .= $match[1];
  70295. } else {
  70296. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ...".', substr($input, $cursor, 10)));
  70297. }
  70298. $cursor += \strlen($match[0]);
  70299. }
  70300. if (null !== $token) {
  70301. $tokens[] = $token;
  70302. }
  70303. return $tokens;
  70304. }
  70305. }
  70306. Copyright (c) 2004-present Fabien Potencier
  70307. Permission is hereby granted, free of charge, to any person obtaining a copy
  70308. of this software and associated documentation files (the "Software"), to deal
  70309. in the Software without restriction, including without limitation the rights
  70310. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  70311. copies of the Software, and to permit persons to whom the Software is furnished
  70312. to do so, subject to the following conditions:
  70313. The above copyright notice and this permission notice shall be included in all
  70314. copies or substantial portions of the Software.
  70315. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  70316. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  70317. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  70318. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  70319. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  70320. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  70321. THE SOFTWARE.
  70322. <?php
  70323. namespace Symfony\Component\Console\Logger;
  70324. use Psr\Log\AbstractLogger;
  70325. use Psr\Log\InvalidArgumentException;
  70326. use Psr\Log\LogLevel;
  70327. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  70328. use Symfony\Component\Console\Output\OutputInterface;
  70329. class ConsoleLogger extends AbstractLogger
  70330. {
  70331. public const INFO = 'info';
  70332. public const ERROR = 'error';
  70333. private $output;
  70334. private $verbosityLevelMap = [
  70335. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  70336. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  70337. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  70338. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  70339. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  70340. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  70341. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  70342. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  70343. ];
  70344. private $formatLevelMap = [
  70345. LogLevel::EMERGENCY => self::ERROR,
  70346. LogLevel::ALERT => self::ERROR,
  70347. LogLevel::CRITICAL => self::ERROR,
  70348. LogLevel::ERROR => self::ERROR,
  70349. LogLevel::WARNING => self::INFO,
  70350. LogLevel::NOTICE => self::INFO,
  70351. LogLevel::INFO => self::INFO,
  70352. LogLevel::DEBUG => self::INFO,
  70353. ];
  70354. private $errored = false;
  70355. public function __construct(OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = [])
  70356. {
  70357. $this->output = $output;
  70358. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  70359. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  70360. }
  70361. public function log($level, $message, array $context = [])
  70362. {
  70363. if (!isset($this->verbosityLevelMap[$level])) {
  70364. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  70365. }
  70366. $output = $this->output;
  70367. if (self::ERROR === $this->formatLevelMap[$level]) {
  70368. if ($this->output instanceof ConsoleOutputInterface) {
  70369. $output = $output->getErrorOutput();
  70370. }
  70371. $this->errored = true;
  70372. }
  70373. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  70374. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)), $this->verbosityLevelMap[$level]);
  70375. }
  70376. }
  70377. public function hasErrored()
  70378. {
  70379. return $this->errored;
  70380. }
  70381. private function interpolate(string $message, array $context): string
  70382. {
  70383. if (!str_contains($message, '{')) {
  70384. return $message;
  70385. }
  70386. $replacements = [];
  70387. foreach ($context as $key => $val) {
  70388. if (null === $val || \is_scalar($val) || (\is_object($val) && method_exists($val, '__toString'))) {
  70389. $replacements["{{$key}}"] = $val;
  70390. } elseif ($val instanceof \DateTimeInterface) {
  70391. $replacements["{{$key}}"] = $val->format(\DateTime::RFC3339);
  70392. } elseif (\is_object($val)) {
  70393. $replacements["{{$key}}"] = '[object '.\get_class($val).']';
  70394. } else {
  70395. $replacements["{{$key}}"] = '['.\gettype($val).']';
  70396. }
  70397. }
  70398. return strtr($message, $replacements);
  70399. }
  70400. }
  70401. <?php
  70402. namespace Symfony\Component\Console\Output;
  70403. class BufferedOutput extends Output
  70404. {
  70405. private $buffer = '';
  70406. public function fetch()
  70407. {
  70408. $content = $this->buffer;
  70409. $this->buffer = '';
  70410. return $content;
  70411. }
  70412. protected function doWrite(string $message, bool $newline)
  70413. {
  70414. $this->buffer .= $message;
  70415. if ($newline) {
  70416. $this->buffer .= \PHP_EOL;
  70417. }
  70418. }
  70419. }
  70420. <?php
  70421. namespace Symfony\Component\Console\Output;
  70422. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  70423. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  70424. {
  70425. private $stderr;
  70426. private $consoleSectionOutputs = [];
  70427. public function __construct(int $verbosity = self::VERBOSITY_NORMAL, ?bool $decorated = null, ?OutputFormatterInterface $formatter = null)
  70428. {
  70429. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  70430. if (null === $formatter) {
  70431. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated);
  70432. return;
  70433. }
  70434. $actualDecorated = $this->isDecorated();
  70435. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  70436. if (null === $decorated) {
  70437. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  70438. }
  70439. }
  70440. public function section(): ConsoleSectionOutput
  70441. {
  70442. return new ConsoleSectionOutput($this->getStream(), $this->consoleSectionOutputs, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter());
  70443. }
  70444. public function setDecorated(bool $decorated)
  70445. {
  70446. parent::setDecorated($decorated);
  70447. $this->stderr->setDecorated($decorated);
  70448. }
  70449. public function setFormatter(OutputFormatterInterface $formatter)
  70450. {
  70451. parent::setFormatter($formatter);
  70452. $this->stderr->setFormatter($formatter);
  70453. }
  70454. public function setVerbosity(int $level)
  70455. {
  70456. parent::setVerbosity($level);
  70457. $this->stderr->setVerbosity($level);
  70458. }
  70459. public function getErrorOutput()
  70460. {
  70461. return $this->stderr;
  70462. }
  70463. public function setErrorOutput(OutputInterface $error)
  70464. {
  70465. $this->stderr = $error;
  70466. }
  70467. protected function hasStdoutSupport()
  70468. {
  70469. return false === $this->isRunningOS400();
  70470. }
  70471. protected function hasStderrSupport()
  70472. {
  70473. return false === $this->isRunningOS400();
  70474. }
  70475. private function isRunningOS400(): bool
  70476. {
  70477. $checks = [
  70478. \function_exists('php_uname') ? php_uname('s') : '',
  70479. getenv('OSTYPE'),
  70480. \PHP_OS,
  70481. ];
  70482. return false !== stripos(implode(';', $checks), 'OS400');
  70483. }
  70484. private function openOutputStream()
  70485. {
  70486. if (!$this->hasStdoutSupport()) {
  70487. return fopen('php://output', 'w');
  70488. }
  70489. return \defined('STDOUT') ? \STDOUT : (@fopen('php://stdout', 'w') ?: fopen('php://output', 'w'));
  70490. }
  70491. private function openErrorStream()
  70492. {
  70493. if (!$this->hasStderrSupport()) {
  70494. return fopen('php://output', 'w');
  70495. }
  70496. return \defined('STDERR') ? \STDERR : (@fopen('php://stderr', 'w') ?: fopen('php://output', 'w'));
  70497. }
  70498. }
  70499. <?php
  70500. namespace Symfony\Component\Console\Output;
  70501. interface ConsoleOutputInterface extends OutputInterface
  70502. {
  70503. public function getErrorOutput();
  70504. public function setErrorOutput(OutputInterface $error);
  70505. public function section(): ConsoleSectionOutput;
  70506. }
  70507. <?php
  70508. namespace Symfony\Component\Console\Output;
  70509. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  70510. use Symfony\Component\Console\Helper\Helper;
  70511. use Symfony\Component\Console\Terminal;
  70512. class ConsoleSectionOutput extends StreamOutput
  70513. {
  70514. private $content = [];
  70515. private $lines = 0;
  70516. private $sections;
  70517. private $terminal;
  70518. public function __construct($stream, array &$sections, int $verbosity, bool $decorated, OutputFormatterInterface $formatter)
  70519. {
  70520. parent::__construct($stream, $verbosity, $decorated, $formatter);
  70521. array_unshift($sections, $this);
  70522. $this->sections = &$sections;
  70523. $this->terminal = new Terminal();
  70524. }
  70525. public function clear(?int $lines = null)
  70526. {
  70527. if (empty($this->content) || !$this->isDecorated()) {
  70528. return;
  70529. }
  70530. if ($lines) {
  70531. array_splice($this->content, -($lines * 2));
  70532. } else {
  70533. $lines = $this->lines;
  70534. $this->content = [];
  70535. }
  70536. $this->lines -= $lines;
  70537. parent::doWrite($this->popStreamContentUntilCurrentSection($lines), false);
  70538. }
  70539. public function overwrite($message)
  70540. {
  70541. $this->clear();
  70542. $this->writeln($message);
  70543. }
  70544. public function getContent(): string
  70545. {
  70546. return implode('', $this->content);
  70547. }
  70548. public function addContent(string $input)
  70549. {
  70550. foreach (explode(\PHP_EOL, $input) as $lineContent) {
  70551. $this->lines += ceil($this->getDisplayLength($lineContent) / $this->terminal->getWidth()) ?: 1;
  70552. $this->content[] = $lineContent;
  70553. $this->content[] = \PHP_EOL;
  70554. }
  70555. }
  70556. protected function doWrite(string $message, bool $newline)
  70557. {
  70558. if (!$this->isDecorated()) {
  70559. parent::doWrite($message, $newline);
  70560. return;
  70561. }
  70562. $erasedContent = $this->popStreamContentUntilCurrentSection();
  70563. $this->addContent($message);
  70564. parent::doWrite($message, true);
  70565. parent::doWrite($erasedContent, false);
  70566. }
  70567. private function popStreamContentUntilCurrentSection(int $numberOfLinesToClearFromCurrentSection = 0): string
  70568. {
  70569. $numberOfLinesToClear = $numberOfLinesToClearFromCurrentSection;
  70570. $erasedContent = [];
  70571. foreach ($this->sections as $section) {
  70572. if ($section === $this) {
  70573. break;
  70574. }
  70575. $numberOfLinesToClear += $section->lines;
  70576. $erasedContent[] = $section->getContent();
  70577. }
  70578. if ($numberOfLinesToClear > 0) {
  70579. parent::doWrite(sprintf("\x1b[%dA", $numberOfLinesToClear), false);
  70580. parent::doWrite("\x1b[0J", false);
  70581. }
  70582. return implode('', array_reverse($erasedContent));
  70583. }
  70584. private function getDisplayLength(string $text): int
  70585. {
  70586. return Helper::width(Helper::removeDecoration($this->getFormatter(), str_replace("\t", ' ', $text)));
  70587. }
  70588. }
  70589. <?php
  70590. namespace Symfony\Component\Console\Output;
  70591. use Symfony\Component\Console\Formatter\NullOutputFormatter;
  70592. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  70593. class NullOutput implements OutputInterface
  70594. {
  70595. private $formatter;
  70596. public function setFormatter(OutputFormatterInterface $formatter)
  70597. {
  70598. }
  70599. public function getFormatter()
  70600. {
  70601. if ($this->formatter) {
  70602. return $this->formatter;
  70603. }
  70604. return $this->formatter = new NullOutputFormatter();
  70605. }
  70606. public function setDecorated(bool $decorated)
  70607. {
  70608. }
  70609. public function isDecorated()
  70610. {
  70611. return false;
  70612. }
  70613. public function setVerbosity(int $level)
  70614. {
  70615. }
  70616. public function getVerbosity()
  70617. {
  70618. return self::VERBOSITY_QUIET;
  70619. }
  70620. public function isQuiet()
  70621. {
  70622. return true;
  70623. }
  70624. public function isVerbose()
  70625. {
  70626. return false;
  70627. }
  70628. public function isVeryVerbose()
  70629. {
  70630. return false;
  70631. }
  70632. public function isDebug()
  70633. {
  70634. return false;
  70635. }
  70636. public function writeln($messages, int $options = self::OUTPUT_NORMAL)
  70637. {
  70638. }
  70639. public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
  70640. {
  70641. }
  70642. }
  70643. <?php
  70644. namespace Symfony\Component\Console\Output;
  70645. use Symfony\Component\Console\Formatter\OutputFormatter;
  70646. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  70647. abstract class Output implements OutputInterface
  70648. {
  70649. private $verbosity;
  70650. private $formatter;
  70651. public function __construct(?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, ?OutputFormatterInterface $formatter = null)
  70652. {
  70653. $this->verbosity = $verbosity ?? self::VERBOSITY_NORMAL;
  70654. $this->formatter = $formatter ?? new OutputFormatter();
  70655. $this->formatter->setDecorated($decorated);
  70656. }
  70657. public function setFormatter(OutputFormatterInterface $formatter)
  70658. {
  70659. $this->formatter = $formatter;
  70660. }
  70661. public function getFormatter()
  70662. {
  70663. return $this->formatter;
  70664. }
  70665. public function setDecorated(bool $decorated)
  70666. {
  70667. $this->formatter->setDecorated($decorated);
  70668. }
  70669. public function isDecorated()
  70670. {
  70671. return $this->formatter->isDecorated();
  70672. }
  70673. public function setVerbosity(int $level)
  70674. {
  70675. $this->verbosity = $level;
  70676. }
  70677. public function getVerbosity()
  70678. {
  70679. return $this->verbosity;
  70680. }
  70681. public function isQuiet()
  70682. {
  70683. return self::VERBOSITY_QUIET === $this->verbosity;
  70684. }
  70685. public function isVerbose()
  70686. {
  70687. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  70688. }
  70689. public function isVeryVerbose()
  70690. {
  70691. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  70692. }
  70693. public function isDebug()
  70694. {
  70695. return self::VERBOSITY_DEBUG <= $this->verbosity;
  70696. }
  70697. public function writeln($messages, int $options = self::OUTPUT_NORMAL)
  70698. {
  70699. $this->write($messages, true, $options);
  70700. }
  70701. public function write($messages, bool $newline = false, int $options = self::OUTPUT_NORMAL)
  70702. {
  70703. if (!is_iterable($messages)) {
  70704. $messages = [$messages];
  70705. }
  70706. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  70707. $type = $types & $options ?: self::OUTPUT_NORMAL;
  70708. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  70709. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  70710. if ($verbosity > $this->getVerbosity()) {
  70711. return;
  70712. }
  70713. foreach ($messages as $message) {
  70714. switch ($type) {
  70715. case OutputInterface::OUTPUT_NORMAL:
  70716. $message = $this->formatter->format($message);
  70717. break;
  70718. case OutputInterface::OUTPUT_RAW:
  70719. break;
  70720. case OutputInterface::OUTPUT_PLAIN:
  70721. $message = strip_tags($this->formatter->format($message));
  70722. break;
  70723. }
  70724. $this->doWrite($message ?? '', $newline);
  70725. }
  70726. }
  70727. abstract protected function doWrite(string $message, bool $newline);
  70728. }
  70729. <?php
  70730. namespace Symfony\Component\Console\Output;
  70731. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  70732. interface OutputInterface
  70733. {
  70734. public const VERBOSITY_QUIET = 16;
  70735. public const VERBOSITY_NORMAL = 32;
  70736. public const VERBOSITY_VERBOSE = 64;
  70737. public const VERBOSITY_VERY_VERBOSE = 128;
  70738. public const VERBOSITY_DEBUG = 256;
  70739. public const OUTPUT_NORMAL = 1;
  70740. public const OUTPUT_RAW = 2;
  70741. public const OUTPUT_PLAIN = 4;
  70742. public function write($messages, bool $newline = false, int $options = 0);
  70743. public function writeln($messages, int $options = 0);
  70744. public function setVerbosity(int $level);
  70745. public function getVerbosity();
  70746. public function isQuiet();
  70747. public function isVerbose();
  70748. public function isVeryVerbose();
  70749. public function isDebug();
  70750. public function setDecorated(bool $decorated);
  70751. public function isDecorated();
  70752. public function setFormatter(OutputFormatterInterface $formatter);
  70753. public function getFormatter();
  70754. }
  70755. <?php
  70756. namespace Symfony\Component\Console\Output;
  70757. use Symfony\Component\Console\Exception\InvalidArgumentException;
  70758. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  70759. class StreamOutput extends Output
  70760. {
  70761. private $stream;
  70762. public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, ?bool $decorated = null, ?OutputFormatterInterface $formatter = null)
  70763. {
  70764. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  70765. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  70766. }
  70767. $this->stream = $stream;
  70768. if (null === $decorated) {
  70769. $decorated = $this->hasColorSupport();
  70770. }
  70771. parent::__construct($verbosity, $decorated, $formatter);
  70772. }
  70773. public function getStream()
  70774. {
  70775. return $this->stream;
  70776. }
  70777. protected function doWrite(string $message, bool $newline)
  70778. {
  70779. if ($newline) {
  70780. $message .= \PHP_EOL;
  70781. }
  70782. @fwrite($this->stream, $message);
  70783. fflush($this->stream);
  70784. }
  70785. protected function hasColorSupport()
  70786. {
  70787. if ('' !== (($_SERVER['NO_COLOR'] ?? getenv('NO_COLOR'))[0] ?? '')) {
  70788. return false;
  70789. }
  70790. if (!@stream_isatty($this->stream) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
  70791. return false;
  70792. }
  70793. if ('\\' === \DIRECTORY_SEPARATOR && @sapi_windows_vt100_support($this->stream)) {
  70794. return true;
  70795. }
  70796. if ('Hyper' === getenv('TERM_PROGRAM')
  70797. || false !== getenv('COLORTERM')
  70798. || false !== getenv('ANSICON')
  70799. || 'ON' === getenv('ConEmuANSI')
  70800. ) {
  70801. return true;
  70802. }
  70803. if ('dumb' === $term = (string) getenv('TERM')) {
  70804. return false;
  70805. }
  70806. return preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
  70807. }
  70808. }
  70809. <?php
  70810. namespace Symfony\Component\Console\Output;
  70811. use Symfony\Component\Console\Exception\InvalidArgumentException;
  70812. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  70813. class TrimmedBufferOutput extends Output
  70814. {
  70815. private $maxLength;
  70816. private $buffer = '';
  70817. public function __construct(int $maxLength, ?int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, ?OutputFormatterInterface $formatter = null)
  70818. {
  70819. if ($maxLength <= 0) {
  70820. throw new InvalidArgumentException(sprintf('"%s()" expects a strictly positive maxLength. Got %d.', __METHOD__, $maxLength));
  70821. }
  70822. parent::__construct($verbosity, $decorated, $formatter);
  70823. $this->maxLength = $maxLength;
  70824. }
  70825. public function fetch()
  70826. {
  70827. $content = $this->buffer;
  70828. $this->buffer = '';
  70829. return $content;
  70830. }
  70831. protected function doWrite(string $message, bool $newline)
  70832. {
  70833. $this->buffer .= $message;
  70834. if ($newline) {
  70835. $this->buffer .= \PHP_EOL;
  70836. }
  70837. $this->buffer = substr($this->buffer, 0 - $this->maxLength);
  70838. }
  70839. }
  70840. <?php
  70841. namespace Symfony\Component\Console\Question;
  70842. use Symfony\Component\Console\Exception\InvalidArgumentException;
  70843. class ChoiceQuestion extends Question
  70844. {
  70845. private $choices;
  70846. private $multiselect = false;
  70847. private $prompt = ' > ';
  70848. private $errorMessage = 'Value "%s" is invalid';
  70849. public function __construct(string $question, array $choices, $default = null)
  70850. {
  70851. if (!$choices) {
  70852. throw new \LogicException('Choice question must have at least 1 choice available.');
  70853. }
  70854. parent::__construct($question, $default);
  70855. $this->choices = $choices;
  70856. $this->setValidator($this->getDefaultValidator());
  70857. $this->setAutocompleterValues($choices);
  70858. }
  70859. public function getChoices()
  70860. {
  70861. return $this->choices;
  70862. }
  70863. public function setMultiselect(bool $multiselect)
  70864. {
  70865. $this->multiselect = $multiselect;
  70866. $this->setValidator($this->getDefaultValidator());
  70867. return $this;
  70868. }
  70869. public function isMultiselect()
  70870. {
  70871. return $this->multiselect;
  70872. }
  70873. public function getPrompt()
  70874. {
  70875. return $this->prompt;
  70876. }
  70877. public function setPrompt(string $prompt)
  70878. {
  70879. $this->prompt = $prompt;
  70880. return $this;
  70881. }
  70882. public function setErrorMessage(string $errorMessage)
  70883. {
  70884. $this->errorMessage = $errorMessage;
  70885. $this->setValidator($this->getDefaultValidator());
  70886. return $this;
  70887. }
  70888. private function getDefaultValidator(): callable
  70889. {
  70890. $choices = $this->choices;
  70891. $errorMessage = $this->errorMessage;
  70892. $multiselect = $this->multiselect;
  70893. $isAssoc = $this->isAssoc($choices);
  70894. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  70895. if ($multiselect) {
  70896. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', (string) $selected, $matches)) {
  70897. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  70898. }
  70899. $selectedChoices = explode(',', (string) $selected);
  70900. } else {
  70901. $selectedChoices = [$selected];
  70902. }
  70903. if ($this->isTrimmable()) {
  70904. foreach ($selectedChoices as $k => $v) {
  70905. $selectedChoices[$k] = trim((string) $v);
  70906. }
  70907. }
  70908. $multiselectChoices = [];
  70909. foreach ($selectedChoices as $value) {
  70910. $results = [];
  70911. foreach ($choices as $key => $choice) {
  70912. if ($choice === $value) {
  70913. $results[] = $key;
  70914. }
  70915. }
  70916. if (\count($results) > 1) {
  70917. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of "%s".', implode('" or "', $results)));
  70918. }
  70919. $result = array_search($value, $choices);
  70920. if (!$isAssoc) {
  70921. if (false !== $result) {
  70922. $result = $choices[$result];
  70923. } elseif (isset($choices[$value])) {
  70924. $result = $choices[$value];
  70925. }
  70926. } elseif (false === $result && isset($choices[$value])) {
  70927. $result = $value;
  70928. }
  70929. if (false === $result) {
  70930. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  70931. }
  70932. $multiselectChoices[] = $isAssoc ? (string) $result : $result;
  70933. }
  70934. if ($multiselect) {
  70935. return $multiselectChoices;
  70936. }
  70937. return current($multiselectChoices);
  70938. };
  70939. }
  70940. }
  70941. <?php
  70942. namespace Symfony\Component\Console\Question;
  70943. class ConfirmationQuestion extends Question
  70944. {
  70945. private $trueAnswerRegex;
  70946. public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i')
  70947. {
  70948. parent::__construct($question, $default);
  70949. $this->trueAnswerRegex = $trueAnswerRegex;
  70950. $this->setNormalizer($this->getDefaultNormalizer());
  70951. }
  70952. private function getDefaultNormalizer(): callable
  70953. {
  70954. $default = $this->getDefault();
  70955. $regex = $this->trueAnswerRegex;
  70956. return function ($answer) use ($default, $regex) {
  70957. if (\is_bool($answer)) {
  70958. return $answer;
  70959. }
  70960. $answerIsTrue = (bool) preg_match($regex, $answer);
  70961. if (false === $default) {
  70962. return $answer && $answerIsTrue;
  70963. }
  70964. return '' === $answer || $answerIsTrue;
  70965. };
  70966. }
  70967. }
  70968. <?php
  70969. namespace Symfony\Component\Console\Question;
  70970. use Symfony\Component\Console\Exception\InvalidArgumentException;
  70971. use Symfony\Component\Console\Exception\LogicException;
  70972. class Question
  70973. {
  70974. private $question;
  70975. private $attempts;
  70976. private $hidden = false;
  70977. private $hiddenFallback = true;
  70978. private $autocompleterCallback;
  70979. private $validator;
  70980. private $default;
  70981. private $normalizer;
  70982. private $trimmable = true;
  70983. private $multiline = false;
  70984. public function __construct(string $question, $default = null)
  70985. {
  70986. $this->question = $question;
  70987. $this->default = $default;
  70988. }
  70989. public function getQuestion()
  70990. {
  70991. return $this->question;
  70992. }
  70993. public function getDefault()
  70994. {
  70995. return $this->default;
  70996. }
  70997. public function isMultiline(): bool
  70998. {
  70999. return $this->multiline;
  71000. }
  71001. public function setMultiline(bool $multiline): self
  71002. {
  71003. $this->multiline = $multiline;
  71004. return $this;
  71005. }
  71006. public function isHidden()
  71007. {
  71008. return $this->hidden;
  71009. }
  71010. public function setHidden(bool $hidden)
  71011. {
  71012. if ($this->autocompleterCallback) {
  71013. throw new LogicException('A hidden question cannot use the autocompleter.');
  71014. }
  71015. $this->hidden = $hidden;
  71016. return $this;
  71017. }
  71018. public function isHiddenFallback()
  71019. {
  71020. return $this->hiddenFallback;
  71021. }
  71022. public function setHiddenFallback(bool $fallback)
  71023. {
  71024. $this->hiddenFallback = $fallback;
  71025. return $this;
  71026. }
  71027. public function getAutocompleterValues()
  71028. {
  71029. $callback = $this->getAutocompleterCallback();
  71030. return $callback ? $callback('') : null;
  71031. }
  71032. public function setAutocompleterValues(?iterable $values)
  71033. {
  71034. if (\is_array($values)) {
  71035. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  71036. $callback = static function () use ($values) {
  71037. return $values;
  71038. };
  71039. } elseif ($values instanceof \Traversable) {
  71040. $valueCache = null;
  71041. $callback = static function () use ($values, &$valueCache) {
  71042. return $valueCache ?? $valueCache = iterator_to_array($values, false);
  71043. };
  71044. } else {
  71045. $callback = null;
  71046. }
  71047. return $this->setAutocompleterCallback($callback);
  71048. }
  71049. public function getAutocompleterCallback(): ?callable
  71050. {
  71051. return $this->autocompleterCallback;
  71052. }
  71053. public function setAutocompleterCallback(?callable $callback = null): self
  71054. {
  71055. if ($this->hidden && null !== $callback) {
  71056. throw new LogicException('A hidden question cannot use the autocompleter.');
  71057. }
  71058. $this->autocompleterCallback = $callback;
  71059. return $this;
  71060. }
  71061. public function setValidator(?callable $validator = null)
  71062. {
  71063. $this->validator = $validator;
  71064. return $this;
  71065. }
  71066. public function getValidator()
  71067. {
  71068. return $this->validator;
  71069. }
  71070. public function setMaxAttempts(?int $attempts)
  71071. {
  71072. if (null !== $attempts && $attempts < 1) {
  71073. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  71074. }
  71075. $this->attempts = $attempts;
  71076. return $this;
  71077. }
  71078. public function getMaxAttempts()
  71079. {
  71080. return $this->attempts;
  71081. }
  71082. public function setNormalizer(callable $normalizer)
  71083. {
  71084. $this->normalizer = $normalizer;
  71085. return $this;
  71086. }
  71087. public function getNormalizer()
  71088. {
  71089. return $this->normalizer;
  71090. }
  71091. protected function isAssoc(array $array)
  71092. {
  71093. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  71094. }
  71095. public function isTrimmable(): bool
  71096. {
  71097. return $this->trimmable;
  71098. }
  71099. public function setTrimmable(bool $trimmable): self
  71100. {
  71101. $this->trimmable = $trimmable;
  71102. return $this;
  71103. }
  71104. }
  71105. MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  71106. $�������Æ,Í;§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��������à�  ��
  71107. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  71108. ����������������� ��`.rdata����� ���
  71109. �����������������@��@.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
  71110. 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
  71111. 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
  71112. 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">
  71113. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  71114. <security>
  71115. <requestedPrivileges>
  71116. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  71117. </requestedPrivileges>
  71118. </security>
  71119. </trustInfo>
  71120. <dependency>
  71121. <dependentAssembly>
  71122. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  71123. </dependentAssembly>
  71124. </dependency>
  71125. </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.
  71126. #
  71127. # (c) Fabien Potencier <fabien@symfony.com>
  71128. #
  71129. # For the full copyright and license information, please view
  71130. # https://symfony.com/doc/current/contributing/code/license.html
  71131. _sf_{{ COMMAND_NAME }}() {
  71132. # Use newline as only separator to allow space in completion values
  71133. local IFS=$'\n'
  71134. local sf_cmd="${COMP_WORDS[0]}"
  71135. # for an alias, get the real script behind it
  71136. sf_cmd_type=$(type -t $sf_cmd)
  71137. if [[ $sf_cmd_type == "alias" ]]; then
  71138. sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/")
  71139. elif [[ $sf_cmd_type == "file" ]]; then
  71140. sf_cmd=$(type -p $sf_cmd)
  71141. fi
  71142. if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then
  71143. return 1
  71144. fi
  71145. local cur prev words cword
  71146. _get_comp_words_by_ref -n := cur prev words cword
  71147. local completecmd=("$sf_cmd" "_complete" "--no-interaction" "-sbash" "-c$cword" "-S{{ VERSION }}")
  71148. for w in ${words[@]}; do
  71149. w=$(printf -- '%b' "$w")
  71150. # remove quotes from typed values
  71151. quote="${w:0:1}"
  71152. if [ "$quote" == \' ]; then
  71153. w="${w%\'}"
  71154. w="${w#\'}"
  71155. elif [ "$quote" == \" ]; then
  71156. w="${w%\"}"
  71157. w="${w#\"}"
  71158. fi
  71159. # empty values are ignored
  71160. if [ ! -z "$w" ]; then
  71161. completecmd+=("-i$w")
  71162. fi
  71163. done
  71164. local sfcomplete
  71165. if sfcomplete=$(${completecmd[@]} 2>&1); then
  71166. local quote suggestions
  71167. quote=${cur:0:1}
  71168. # Use single quotes by default if suggestions contains backslash (FQCN)
  71169. if [ "$quote" == '' ] && [[ "$sfcomplete" =~ \\ ]]; then
  71170. quote=\'
  71171. fi
  71172. if [ "$quote" == \' ]; then
  71173. # single quotes: no additional escaping (does not accept ' in values)
  71174. suggestions=$(for s in $sfcomplete; do printf $'%q%q%q\n' "$quote" "$s" "$quote"; done)
  71175. elif [ "$quote" == \" ]; then
  71176. # double quotes: double escaping for \ $ ` "
  71177. suggestions=$(for s in $sfcomplete; do
  71178. s=${s//\\/\\\\}
  71179. s=${s//\$/\\\$}
  71180. s=${s//\`/\\\`}
  71181. s=${s//\"/\\\"}
  71182. printf $'%q%q%q\n' "$quote" "$s" "$quote";
  71183. done)
  71184. else
  71185. # no quotes: double escaping
  71186. suggestions=$(for s in $sfcomplete; do printf $'%q\n' $(printf '%q' "$s"); done)
  71187. fi
  71188. COMPREPLY=($(IFS=$'\n' compgen -W "$suggestions" -- $(printf -- "%q" "$cur")))
  71189. __ltrim_colon_completions "$cur"
  71190. else
  71191. if [[ "$sfcomplete" != *"Command \"_complete\" is not defined."* ]]; then
  71192. >&2 echo
  71193. >&2 echo $sfcomplete
  71194. fi
  71195. return 1
  71196. fi
  71197. }
  71198. complete -F _sf_{{ COMMAND_NAME }} {{ COMMAND_NAME }}
  71199. <?php
  71200. namespace Symfony\Component\Console\SignalRegistry;
  71201. final class SignalRegistry
  71202. {
  71203. private $signalHandlers = [];
  71204. public function __construct()
  71205. {
  71206. if (\function_exists('pcntl_async_signals')) {
  71207. pcntl_async_signals(true);
  71208. }
  71209. }
  71210. public function register(int $signal, callable $signalHandler): void
  71211. {
  71212. if (!isset($this->signalHandlers[$signal])) {
  71213. $previousCallback = pcntl_signal_get_handler($signal);
  71214. if (\is_callable($previousCallback)) {
  71215. $this->signalHandlers[$signal][] = $previousCallback;
  71216. }
  71217. }
  71218. $this->signalHandlers[$signal][] = $signalHandler;
  71219. pcntl_signal($signal, [$this, 'handle']);
  71220. }
  71221. public static function isSupported(): bool
  71222. {
  71223. if (!\function_exists('pcntl_signal')) {
  71224. return false;
  71225. }
  71226. if (\in_array('pcntl_signal', explode(',', \ini_get('disable_functions')))) {
  71227. return false;
  71228. }
  71229. return true;
  71230. }
  71231. public function handle(int $signal): void
  71232. {
  71233. $count = \count($this->signalHandlers[$signal]);
  71234. foreach ($this->signalHandlers[$signal] as $i => $signalHandler) {
  71235. $hasNext = $i !== $count - 1;
  71236. $signalHandler($signal, $hasNext);
  71237. }
  71238. }
  71239. }
  71240. <?php
  71241. namespace Symfony\Component\Console;
  71242. use Symfony\Component\Console\Command\Command;
  71243. use Symfony\Component\Console\Input\InputInterface;
  71244. use Symfony\Component\Console\Output\OutputInterface;
  71245. class SingleCommandApplication extends Command
  71246. {
  71247. private $version = 'UNKNOWN';
  71248. private $autoExit = true;
  71249. private $running = false;
  71250. public function setVersion(string $version): self
  71251. {
  71252. $this->version = $version;
  71253. return $this;
  71254. }
  71255. public function setAutoExit(bool $autoExit): self
  71256. {
  71257. $this->autoExit = $autoExit;
  71258. return $this;
  71259. }
  71260. public function run(?InputInterface $input = null, ?OutputInterface $output = null): int
  71261. {
  71262. if ($this->running) {
  71263. return parent::run($input, $output);
  71264. }
  71265. $application = new Application($this->getName() ?: 'UNKNOWN', $this->version);
  71266. $application->setAutoExit($this->autoExit);
  71267. $this->setName($_SERVER['argv'][0]);
  71268. $application->add($this);
  71269. $application->setDefaultCommand($this->getName(), true);
  71270. $this->running = true;
  71271. try {
  71272. $ret = $application->run($input, $output);
  71273. } finally {
  71274. $this->running = false;
  71275. }
  71276. return $ret ?? 1;
  71277. }
  71278. }
  71279. <?php
  71280. namespace Symfony\Component\Console\Style;
  71281. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  71282. use Symfony\Component\Console\Helper\ProgressBar;
  71283. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  71284. use Symfony\Component\Console\Output\OutputInterface;
  71285. abstract class OutputStyle implements OutputInterface, StyleInterface
  71286. {
  71287. private $output;
  71288. public function __construct(OutputInterface $output)
  71289. {
  71290. $this->output = $output;
  71291. }
  71292. public function newLine(int $count = 1)
  71293. {
  71294. $this->output->write(str_repeat(\PHP_EOL, $count));
  71295. }
  71296. public function createProgressBar(int $max = 0)
  71297. {
  71298. return new ProgressBar($this->output, $max);
  71299. }
  71300. public function write($messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
  71301. {
  71302. $this->output->write($messages, $newline, $type);
  71303. }
  71304. public function writeln($messages, int $type = self::OUTPUT_NORMAL)
  71305. {
  71306. $this->output->writeln($messages, $type);
  71307. }
  71308. public function setVerbosity(int $level)
  71309. {
  71310. $this->output->setVerbosity($level);
  71311. }
  71312. public function getVerbosity()
  71313. {
  71314. return $this->output->getVerbosity();
  71315. }
  71316. public function setDecorated(bool $decorated)
  71317. {
  71318. $this->output->setDecorated($decorated);
  71319. }
  71320. public function isDecorated()
  71321. {
  71322. return $this->output->isDecorated();
  71323. }
  71324. public function setFormatter(OutputFormatterInterface $formatter)
  71325. {
  71326. $this->output->setFormatter($formatter);
  71327. }
  71328. public function getFormatter()
  71329. {
  71330. return $this->output->getFormatter();
  71331. }
  71332. public function isQuiet()
  71333. {
  71334. return $this->output->isQuiet();
  71335. }
  71336. public function isVerbose()
  71337. {
  71338. return $this->output->isVerbose();
  71339. }
  71340. public function isVeryVerbose()
  71341. {
  71342. return $this->output->isVeryVerbose();
  71343. }
  71344. public function isDebug()
  71345. {
  71346. return $this->output->isDebug();
  71347. }
  71348. protected function getErrorOutput()
  71349. {
  71350. if (!$this->output instanceof ConsoleOutputInterface) {
  71351. return $this->output;
  71352. }
  71353. return $this->output->getErrorOutput();
  71354. }
  71355. }
  71356. <?php
  71357. namespace Symfony\Component\Console\Style;
  71358. interface StyleInterface
  71359. {
  71360. public function title(string $message);
  71361. public function section(string $message);
  71362. public function listing(array $elements);
  71363. public function text($message);
  71364. public function success($message);
  71365. public function error($message);
  71366. public function warning($message);
  71367. public function note($message);
  71368. public function caution($message);
  71369. public function table(array $headers, array $rows);
  71370. public function ask(string $question, ?string $default = null, ?callable $validator = null);
  71371. public function askHidden(string $question, ?callable $validator = null);
  71372. public function confirm(string $question, bool $default = true);
  71373. public function choice(string $question, array $choices, $default = null);
  71374. public function newLine(int $count = 1);
  71375. public function progressStart(int $max = 0);
  71376. public function progressAdvance(int $step = 1);
  71377. public function progressFinish();
  71378. }
  71379. <?php
  71380. namespace Symfony\Component\Console\Style;
  71381. use Symfony\Component\Console\Exception\InvalidArgumentException;
  71382. use Symfony\Component\Console\Exception\RuntimeException;
  71383. use Symfony\Component\Console\Formatter\OutputFormatter;
  71384. use Symfony\Component\Console\Helper\Helper;
  71385. use Symfony\Component\Console\Helper\ProgressBar;
  71386. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  71387. use Symfony\Component\Console\Helper\Table;
  71388. use Symfony\Component\Console\Helper\TableCell;
  71389. use Symfony\Component\Console\Helper\TableSeparator;
  71390. use Symfony\Component\Console\Input\InputInterface;
  71391. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  71392. use Symfony\Component\Console\Output\OutputInterface;
  71393. use Symfony\Component\Console\Output\TrimmedBufferOutput;
  71394. use Symfony\Component\Console\Question\ChoiceQuestion;
  71395. use Symfony\Component\Console\Question\ConfirmationQuestion;
  71396. use Symfony\Component\Console\Question\Question;
  71397. use Symfony\Component\Console\Terminal;
  71398. class SymfonyStyle extends OutputStyle
  71399. {
  71400. public const MAX_LINE_LENGTH = 120;
  71401. private $input;
  71402. private $output;
  71403. private $questionHelper;
  71404. private $progressBar;
  71405. private $lineLength;
  71406. private $bufferedOutput;
  71407. public function __construct(InputInterface $input, OutputInterface $output)
  71408. {
  71409. $this->input = $input;
  71410. $this->bufferedOutput = new TrimmedBufferOutput(\DIRECTORY_SEPARATOR === '\\' ? 4 : 2, $output->getVerbosity(), false, clone $output->getFormatter());
  71411. $width = (new Terminal())->getWidth() ?: self::MAX_LINE_LENGTH;
  71412. $this->lineLength = min($width - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  71413. parent::__construct($this->output = $output);
  71414. }
  71415. public function block($messages, ?string $type = null, ?string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = true)
  71416. {
  71417. $messages = \is_array($messages) ? array_values($messages) : [$messages];
  71418. $this->autoPrependBlock();
  71419. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, $escape));
  71420. $this->newLine();
  71421. }
  71422. public function title(string $message)
  71423. {
  71424. $this->autoPrependBlock();
  71425. $this->writeln([
  71426. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  71427. sprintf('<comment>%s</>', str_repeat('=', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
  71428. ]);
  71429. $this->newLine();
  71430. }
  71431. public function section(string $message)
  71432. {
  71433. $this->autoPrependBlock();
  71434. $this->writeln([
  71435. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  71436. sprintf('<comment>%s</>', str_repeat('-', Helper::width(Helper::removeDecoration($this->getFormatter(), $message)))),
  71437. ]);
  71438. $this->newLine();
  71439. }
  71440. public function listing(array $elements)
  71441. {
  71442. $this->autoPrependText();
  71443. $elements = array_map(function ($element) {
  71444. return sprintf(' * %s', $element);
  71445. }, $elements);
  71446. $this->writeln($elements);
  71447. $this->newLine();
  71448. }
  71449. public function text($message)
  71450. {
  71451. $this->autoPrependText();
  71452. $messages = \is_array($message) ? array_values($message) : [$message];
  71453. foreach ($messages as $message) {
  71454. $this->writeln(sprintf(' %s', $message));
  71455. }
  71456. }
  71457. public function comment($message)
  71458. {
  71459. $this->block($message, null, null, '<fg=default;bg=default> // </>', false, false);
  71460. }
  71461. public function success($message)
  71462. {
  71463. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  71464. }
  71465. public function error($message)
  71466. {
  71467. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  71468. }
  71469. public function warning($message)
  71470. {
  71471. $this->block($message, 'WARNING', 'fg=black;bg=yellow', ' ', true);
  71472. }
  71473. public function note($message)
  71474. {
  71475. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  71476. }
  71477. public function info($message)
  71478. {
  71479. $this->block($message, 'INFO', 'fg=green', ' ', true);
  71480. }
  71481. public function caution($message)
  71482. {
  71483. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  71484. }
  71485. public function table(array $headers, array $rows)
  71486. {
  71487. $this->createTable()
  71488. ->setHeaders($headers)
  71489. ->setRows($rows)
  71490. ->render()
  71491. ;
  71492. $this->newLine();
  71493. }
  71494. public function horizontalTable(array $headers, array $rows)
  71495. {
  71496. $this->createTable()
  71497. ->setHorizontal(true)
  71498. ->setHeaders($headers)
  71499. ->setRows($rows)
  71500. ->render()
  71501. ;
  71502. $this->newLine();
  71503. }
  71504. public function definitionList(...$list)
  71505. {
  71506. $headers = [];
  71507. $row = [];
  71508. foreach ($list as $value) {
  71509. if ($value instanceof TableSeparator) {
  71510. $headers[] = $value;
  71511. $row[] = $value;
  71512. continue;
  71513. }
  71514. if (\is_string($value)) {
  71515. $headers[] = new TableCell($value, ['colspan' => 2]);
  71516. $row[] = null;
  71517. continue;
  71518. }
  71519. if (!\is_array($value)) {
  71520. throw new InvalidArgumentException('Value should be an array, string, or an instance of TableSeparator.');
  71521. }
  71522. $headers[] = key($value);
  71523. $row[] = current($value);
  71524. }
  71525. $this->horizontalTable($headers, [$row]);
  71526. }
  71527. public function ask(string $question, ?string $default = null, ?callable $validator = null)
  71528. {
  71529. $question = new Question($question, $default);
  71530. $question->setValidator($validator);
  71531. return $this->askQuestion($question);
  71532. }
  71533. public function askHidden(string $question, ?callable $validator = null)
  71534. {
  71535. $question = new Question($question);
  71536. $question->setHidden(true);
  71537. $question->setValidator($validator);
  71538. return $this->askQuestion($question);
  71539. }
  71540. public function confirm(string $question, bool $default = true)
  71541. {
  71542. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  71543. }
  71544. public function choice(string $question, array $choices, $default = null)
  71545. {
  71546. if (null !== $default) {
  71547. $values = array_flip($choices);
  71548. $default = $values[$default] ?? $default;
  71549. }
  71550. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  71551. }
  71552. public function progressStart(int $max = 0)
  71553. {
  71554. $this->progressBar = $this->createProgressBar($max);
  71555. $this->progressBar->start();
  71556. }
  71557. public function progressAdvance(int $step = 1)
  71558. {
  71559. $this->getProgressBar()->advance($step);
  71560. }
  71561. public function progressFinish()
  71562. {
  71563. $this->getProgressBar()->finish();
  71564. $this->newLine(2);
  71565. $this->progressBar = null;
  71566. }
  71567. public function createProgressBar(int $max = 0)
  71568. {
  71569. $progressBar = parent::createProgressBar($max);
  71570. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  71571. $progressBar->setEmptyBarCharacter('â–‘');
  71572. $progressBar->setProgressCharacter('');
  71573. $progressBar->setBarCharacter('â–“');
  71574. }
  71575. return $progressBar;
  71576. }
  71577. public function progressIterate(iterable $iterable, ?int $max = null): iterable
  71578. {
  71579. yield from $this->createProgressBar()->iterate($iterable, $max);
  71580. $this->newLine(2);
  71581. }
  71582. public function askQuestion(Question $question)
  71583. {
  71584. if ($this->input->isInteractive()) {
  71585. $this->autoPrependBlock();
  71586. }
  71587. if (!$this->questionHelper) {
  71588. $this->questionHelper = new SymfonyQuestionHelper();
  71589. }
  71590. $answer = $this->questionHelper->ask($this->input, $this, $question);
  71591. if ($this->input->isInteractive()) {
  71592. $this->newLine();
  71593. $this->bufferedOutput->write("\n");
  71594. }
  71595. return $answer;
  71596. }
  71597. public function writeln($messages, int $type = self::OUTPUT_NORMAL)
  71598. {
  71599. if (!is_iterable($messages)) {
  71600. $messages = [$messages];
  71601. }
  71602. foreach ($messages as $message) {
  71603. parent::writeln($message, $type);
  71604. $this->writeBuffer($message, true, $type);
  71605. }
  71606. }
  71607. public function write($messages, bool $newline = false, int $type = self::OUTPUT_NORMAL)
  71608. {
  71609. if (!is_iterable($messages)) {
  71610. $messages = [$messages];
  71611. }
  71612. foreach ($messages as $message) {
  71613. parent::write($message, $newline, $type);
  71614. $this->writeBuffer($message, $newline, $type);
  71615. }
  71616. }
  71617. public function newLine(int $count = 1)
  71618. {
  71619. parent::newLine($count);
  71620. $this->bufferedOutput->write(str_repeat("\n", $count));
  71621. }
  71622. public function getErrorStyle()
  71623. {
  71624. return new self($this->input, $this->getErrorOutput());
  71625. }
  71626. public function createTable(): Table
  71627. {
  71628. $output = $this->output instanceof ConsoleOutputInterface ? $this->output->section() : $this->output;
  71629. $style = clone Table::getStyleDefinition('symfony-style-guide');
  71630. $style->setCellHeaderFormat('<info>%s</info>');
  71631. return (new Table($output))->setStyle($style);
  71632. }
  71633. private function getProgressBar(): ProgressBar
  71634. {
  71635. if (!$this->progressBar) {
  71636. throw new RuntimeException('The ProgressBar is not started.');
  71637. }
  71638. return $this->progressBar;
  71639. }
  71640. private function autoPrependBlock(): void
  71641. {
  71642. $chars = substr(str_replace(\PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  71643. if (!isset($chars[0])) {
  71644. $this->newLine();
  71645. return;
  71646. }
  71647. $this->newLine(2 - substr_count($chars, "\n"));
  71648. }
  71649. private function autoPrependText(): void
  71650. {
  71651. $fetched = $this->bufferedOutput->fetch();
  71652. if (!str_ends_with($fetched, "\n")) {
  71653. $this->newLine();
  71654. }
  71655. }
  71656. private function writeBuffer(string $message, bool $newLine, int $type): void
  71657. {
  71658. $this->bufferedOutput->write($message, $newLine, $type);
  71659. }
  71660. private function createBlock(iterable $messages, ?string $type = null, ?string $style = null, string $prefix = ' ', bool $padding = false, bool $escape = false): array
  71661. {
  71662. $indentLength = 0;
  71663. $prefixLength = Helper::width(Helper::removeDecoration($this->getFormatter(), $prefix));
  71664. $lines = [];
  71665. if (null !== $type) {
  71666. $type = sprintf('[%s] ', $type);
  71667. $indentLength = \strlen($type);
  71668. $lineIndentation = str_repeat(' ', $indentLength);
  71669. }
  71670. foreach ($messages as $key => $message) {
  71671. if ($escape) {
  71672. $message = OutputFormatter::escape($message);
  71673. }
  71674. $decorationLength = Helper::width($message) - Helper::width(Helper::removeDecoration($this->getFormatter(), $message));
  71675. $messageLineLength = min($this->lineLength - $prefixLength - $indentLength + $decorationLength, $this->lineLength);
  71676. $messageLines = explode(\PHP_EOL, wordwrap($message, $messageLineLength, \PHP_EOL, true));
  71677. foreach ($messageLines as $messageLine) {
  71678. $lines[] = $messageLine;
  71679. }
  71680. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  71681. $lines[] = '';
  71682. }
  71683. }
  71684. $firstLineIndex = 0;
  71685. if ($padding && $this->isDecorated()) {
  71686. $firstLineIndex = 1;
  71687. array_unshift($lines, '');
  71688. $lines[] = '';
  71689. }
  71690. foreach ($lines as $i => &$line) {
  71691. if (null !== $type) {
  71692. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  71693. }
  71694. $line = $prefix.$line;
  71695. $line .= str_repeat(' ', max($this->lineLength - Helper::width(Helper::removeDecoration($this->getFormatter(), $line)), 0));
  71696. if ($style) {
  71697. $line = sprintf('<%s>%s</>', $style, $line);
  71698. }
  71699. }
  71700. return $lines;
  71701. }
  71702. }
  71703. <?php
  71704. namespace Symfony\Component\Console;
  71705. class Terminal
  71706. {
  71707. private static $width;
  71708. private static $height;
  71709. private static $stty;
  71710. public function getWidth()
  71711. {
  71712. $width = getenv('COLUMNS');
  71713. if (false !== $width) {
  71714. return (int) trim($width);
  71715. }
  71716. if (null === self::$width) {
  71717. self::initDimensions();
  71718. }
  71719. return self::$width ?: 80;
  71720. }
  71721. public function getHeight()
  71722. {
  71723. $height = getenv('LINES');
  71724. if (false !== $height) {
  71725. return (int) trim($height);
  71726. }
  71727. if (null === self::$height) {
  71728. self::initDimensions();
  71729. }
  71730. return self::$height ?: 50;
  71731. }
  71732. public static function hasSttyAvailable(): bool
  71733. {
  71734. if (null !== self::$stty) {
  71735. return self::$stty;
  71736. }
  71737. if (!\function_exists('shell_exec')) {
  71738. return false;
  71739. }
  71740. return self::$stty = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
  71741. }
  71742. private static function initDimensions()
  71743. {
  71744. if ('\\' === \DIRECTORY_SEPARATOR) {
  71745. $ansicon = getenv('ANSICON');
  71746. if (false !== $ansicon && preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim($ansicon), $matches)) {
  71747. self::$width = (int) $matches[1];
  71748. self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
  71749. } elseif (!self::hasVt100Support() && self::hasSttyAvailable()) {
  71750. self::initDimensionsUsingStty();
  71751. } elseif (null !== $dimensions = self::getConsoleMode()) {
  71752. self::$width = (int) $dimensions[0];
  71753. self::$height = (int) $dimensions[1];
  71754. }
  71755. } else {
  71756. self::initDimensionsUsingStty();
  71757. }
  71758. }
  71759. private static function hasVt100Support(): bool
  71760. {
  71761. return \function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(fopen('php://stdout', 'w'));
  71762. }
  71763. private static function initDimensionsUsingStty()
  71764. {
  71765. if ($sttyString = self::getSttyColumns()) {
  71766. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  71767. self::$width = (int) $matches[2];
  71768. self::$height = (int) $matches[1];
  71769. } elseif (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  71770. self::$width = (int) $matches[2];
  71771. self::$height = (int) $matches[1];
  71772. }
  71773. }
  71774. }
  71775. private static function getConsoleMode(): ?array
  71776. {
  71777. $info = self::readFromProcess('mode CON');
  71778. if (null === $info || !preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  71779. return null;
  71780. }
  71781. return [(int) $matches[2], (int) $matches[1]];
  71782. }
  71783. private static function getSttyColumns(): ?string
  71784. {
  71785. return self::readFromProcess('stty -a | grep columns');
  71786. }
  71787. private static function readFromProcess(string $command): ?string
  71788. {
  71789. if (!\function_exists('proc_open')) {
  71790. return null;
  71791. }
  71792. $descriptorspec = [
  71793. 1 => ['pipe', 'w'],
  71794. 2 => ['pipe', 'w'],
  71795. ];
  71796. $cp = \function_exists('sapi_windows_cp_set') ? sapi_windows_cp_get() : 0;
  71797. if (!$process = @proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true])) {
  71798. return null;
  71799. }
  71800. $info = stream_get_contents($pipes[1]);
  71801. fclose($pipes[1]);
  71802. fclose($pipes[2]);
  71803. proc_close($process);
  71804. if ($cp) {
  71805. sapi_windows_cp_set($cp);
  71806. }
  71807. return $info;
  71808. }
  71809. }
  71810. <?php
  71811. namespace Symfony\Component\Console\Tester;
  71812. use Symfony\Component\Console\Application;
  71813. use Symfony\Component\Console\Input\ArrayInput;
  71814. class ApplicationTester
  71815. {
  71816. use TesterTrait;
  71817. private $application;
  71818. public function __construct(Application $application)
  71819. {
  71820. $this->application = $application;
  71821. }
  71822. public function run(array $input, array $options = [])
  71823. {
  71824. $prevShellVerbosity = getenv('SHELL_VERBOSITY');
  71825. try {
  71826. $this->input = new ArrayInput($input);
  71827. if (isset($options['interactive'])) {
  71828. $this->input->setInteractive($options['interactive']);
  71829. }
  71830. if ($this->inputs) {
  71831. $this->input->setStream(self::createStream($this->inputs));
  71832. }
  71833. $this->initOutput($options);
  71834. return $this->statusCode = $this->application->run($this->input, $this->output);
  71835. } finally {
  71836. if (false === $prevShellVerbosity) {
  71837. if (\function_exists('putenv')) {
  71838. @putenv('SHELL_VERBOSITY');
  71839. }
  71840. unset($_ENV['SHELL_VERBOSITY']);
  71841. unset($_SERVER['SHELL_VERBOSITY']);
  71842. } else {
  71843. if (\function_exists('putenv')) {
  71844. @putenv('SHELL_VERBOSITY='.$prevShellVerbosity);
  71845. }
  71846. $_ENV['SHELL_VERBOSITY'] = $prevShellVerbosity;
  71847. $_SERVER['SHELL_VERBOSITY'] = $prevShellVerbosity;
  71848. }
  71849. }
  71850. }
  71851. }
  71852. <?php
  71853. namespace Symfony\Component\Console\Tester;
  71854. use Symfony\Component\Console\Command\Command;
  71855. use Symfony\Component\Console\Completion\CompletionInput;
  71856. use Symfony\Component\Console\Completion\CompletionSuggestions;
  71857. class CommandCompletionTester
  71858. {
  71859. private $command;
  71860. public function __construct(Command $command)
  71861. {
  71862. $this->command = $command;
  71863. }
  71864. public function complete(array $input): array
  71865. {
  71866. $currentIndex = \count($input);
  71867. if ('' === end($input)) {
  71868. array_pop($input);
  71869. }
  71870. array_unshift($input, $this->command->getName());
  71871. $completionInput = CompletionInput::fromTokens($input, $currentIndex);
  71872. $completionInput->bind($this->command->getDefinition());
  71873. $suggestions = new CompletionSuggestions();
  71874. $this->command->complete($completionInput, $suggestions);
  71875. $options = [];
  71876. foreach ($suggestions->getOptionSuggestions() as $option) {
  71877. $options[] = '--'.$option->getName();
  71878. }
  71879. return array_map('strval', array_merge($options, $suggestions->getValueSuggestions()));
  71880. }
  71881. }
  71882. <?php
  71883. namespace Symfony\Component\Console\Tester;
  71884. use Symfony\Component\Console\Command\Command;
  71885. use Symfony\Component\Console\Input\ArrayInput;
  71886. class CommandTester
  71887. {
  71888. use TesterTrait;
  71889. private $command;
  71890. public function __construct(Command $command)
  71891. {
  71892. $this->command = $command;
  71893. }
  71894. public function execute(array $input, array $options = [])
  71895. {
  71896. if (!isset($input['command'])
  71897. && (null !== $application = $this->command->getApplication())
  71898. && $application->getDefinition()->hasArgument('command')
  71899. ) {
  71900. $input = array_merge(['command' => $this->command->getName()], $input);
  71901. }
  71902. $this->input = new ArrayInput($input);
  71903. $this->input->setStream(self::createStream($this->inputs));
  71904. if (isset($options['interactive'])) {
  71905. $this->input->setInteractive($options['interactive']);
  71906. }
  71907. if (!isset($options['decorated'])) {
  71908. $options['decorated'] = false;
  71909. }
  71910. $this->initOutput($options);
  71911. return $this->statusCode = $this->command->run($this->input, $this->output);
  71912. }
  71913. }
  71914. <?php
  71915. namespace Symfony\Component\Console\Tester\Constraint;
  71916. use PHPUnit\Framework\Constraint\Constraint;
  71917. use Symfony\Component\Console\Command\Command;
  71918. final class CommandIsSuccessful extends Constraint
  71919. {
  71920. public function toString(): string
  71921. {
  71922. return 'is successful';
  71923. }
  71924. protected function matches($other): bool
  71925. {
  71926. return Command::SUCCESS === $other;
  71927. }
  71928. protected function failureDescription($other): string
  71929. {
  71930. return 'the command '.$this->toString();
  71931. }
  71932. protected function additionalFailureDescription($other): string
  71933. {
  71934. $mapping = [
  71935. Command::FAILURE => 'Command failed.',
  71936. Command::INVALID => 'Command was invalid.',
  71937. ];
  71938. return $mapping[$other] ?? sprintf('Command returned exit status %d.', $other);
  71939. }
  71940. }
  71941. <?php
  71942. namespace Symfony\Component\Console\Tester;
  71943. use PHPUnit\Framework\Assert;
  71944. use Symfony\Component\Console\Input\InputInterface;
  71945. use Symfony\Component\Console\Output\ConsoleOutput;
  71946. use Symfony\Component\Console\Output\OutputInterface;
  71947. use Symfony\Component\Console\Output\StreamOutput;
  71948. use Symfony\Component\Console\Tester\Constraint\CommandIsSuccessful;
  71949. trait TesterTrait
  71950. {
  71951. private $output;
  71952. private $inputs = [];
  71953. private $captureStreamsIndependently = false;
  71954. private $input;
  71955. private $statusCode;
  71956. public function getDisplay(bool $normalize = false)
  71957. {
  71958. if (null === $this->output) {
  71959. throw new \RuntimeException('Output not initialized, did you execute the command before requesting the display?');
  71960. }
  71961. rewind($this->output->getStream());
  71962. $display = stream_get_contents($this->output->getStream());
  71963. if ($normalize) {
  71964. $display = str_replace(\PHP_EOL, "\n", $display);
  71965. }
  71966. return $display;
  71967. }
  71968. public function getErrorOutput(bool $normalize = false)
  71969. {
  71970. if (!$this->captureStreamsIndependently) {
  71971. throw new \LogicException('The error output is not available when the tester is run without "capture_stderr_separately" option set.');
  71972. }
  71973. rewind($this->output->getErrorOutput()->getStream());
  71974. $display = stream_get_contents($this->output->getErrorOutput()->getStream());
  71975. if ($normalize) {
  71976. $display = str_replace(\PHP_EOL, "\n", $display);
  71977. }
  71978. return $display;
  71979. }
  71980. public function getInput()
  71981. {
  71982. return $this->input;
  71983. }
  71984. public function getOutput()
  71985. {
  71986. return $this->output;
  71987. }
  71988. public function getStatusCode()
  71989. {
  71990. if (null === $this->statusCode) {
  71991. throw new \RuntimeException('Status code not initialized, did you execute the command before requesting the status code?');
  71992. }
  71993. return $this->statusCode;
  71994. }
  71995. public function assertCommandIsSuccessful(string $message = ''): void
  71996. {
  71997. Assert::assertThat($this->statusCode, new CommandIsSuccessful(), $message);
  71998. }
  71999. public function setInputs(array $inputs)
  72000. {
  72001. $this->inputs = $inputs;
  72002. return $this;
  72003. }
  72004. private function initOutput(array $options)
  72005. {
  72006. $this->captureStreamsIndependently = \array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
  72007. if (!$this->captureStreamsIndependently) {
  72008. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  72009. if (isset($options['decorated'])) {
  72010. $this->output->setDecorated($options['decorated']);
  72011. }
  72012. if (isset($options['verbosity'])) {
  72013. $this->output->setVerbosity($options['verbosity']);
  72014. }
  72015. } else {
  72016. $this->output = new ConsoleOutput(
  72017. $options['verbosity'] ?? ConsoleOutput::VERBOSITY_NORMAL,
  72018. $options['decorated'] ?? null
  72019. );
  72020. $errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
  72021. $errorOutput->setFormatter($this->output->getFormatter());
  72022. $errorOutput->setVerbosity($this->output->getVerbosity());
  72023. $errorOutput->setDecorated($this->output->isDecorated());
  72024. $reflectedOutput = new \ReflectionObject($this->output);
  72025. $strErrProperty = $reflectedOutput->getProperty('stderr');
  72026. $strErrProperty->setAccessible(true);
  72027. $strErrProperty->setValue($this->output, $errorOutput);
  72028. $reflectedParent = $reflectedOutput->getParentClass();
  72029. $streamProperty = $reflectedParent->getProperty('stream');
  72030. $streamProperty->setAccessible(true);
  72031. $streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
  72032. }
  72033. }
  72034. private static function createStream(array $inputs)
  72035. {
  72036. $stream = fopen('php://memory', 'r+', false);
  72037. foreach ($inputs as $input) {
  72038. fwrite($stream, $input.\PHP_EOL);
  72039. }
  72040. rewind($stream);
  72041. return $stream;
  72042. }
  72043. }
  72044. Copyright (c) 2020-present Fabien Potencier
  72045. Permission is hereby granted, free of charge, to any person obtaining a copy
  72046. of this software and associated documentation files (the "Software"), to deal
  72047. in the Software without restriction, including without limitation the rights
  72048. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  72049. copies of the Software, and to permit persons to whom the Software is furnished
  72050. to do so, subject to the following conditions:
  72051. The above copyright notice and this permission notice shall be included in all
  72052. copies or substantial portions of the Software.
  72053. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  72054. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  72055. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  72056. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  72057. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  72058. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  72059. THE SOFTWARE.
  72060. <?php
  72061. if (!function_exists('trigger_deprecation')) {
  72062. function trigger_deprecation(string $package, string $version, string $message, ...$args): void
  72063. {
  72064. @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED);
  72065. }
  72066. }
  72067. <?php
  72068. namespace Symfony\Component\Filesystem\Exception;
  72069. interface ExceptionInterface extends \Throwable
  72070. {
  72071. }
  72072. <?php
  72073. namespace Symfony\Component\Filesystem\Exception;
  72074. class FileNotFoundException extends IOException
  72075. {
  72076. public function __construct(?string $message = null, int $code = 0, ?\Throwable $previous = null, ?string $path = null)
  72077. {
  72078. if (null === $message) {
  72079. if (null === $path) {
  72080. $message = 'File could not be found.';
  72081. } else {
  72082. $message = sprintf('File "%s" could not be found.', $path);
  72083. }
  72084. }
  72085. parent::__construct($message, $code, $previous, $path);
  72086. }
  72087. }
  72088. <?php
  72089. namespace Symfony\Component\Filesystem\Exception;
  72090. class IOException extends \RuntimeException implements IOExceptionInterface
  72091. {
  72092. private $path;
  72093. public function __construct(string $message, int $code = 0, ?\Throwable $previous = null, ?string $path = null)
  72094. {
  72095. $this->path = $path;
  72096. parent::__construct($message, $code, $previous);
  72097. }
  72098. public function getPath()
  72099. {
  72100. return $this->path;
  72101. }
  72102. }
  72103. <?php
  72104. namespace Symfony\Component\Filesystem\Exception;
  72105. interface IOExceptionInterface extends ExceptionInterface
  72106. {
  72107. public function getPath();
  72108. }
  72109. <?php
  72110. namespace Symfony\Component\Filesystem\Exception;
  72111. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  72112. {
  72113. }
  72114. <?php
  72115. namespace Symfony\Component\Filesystem\Exception;
  72116. class RuntimeException extends \RuntimeException implements ExceptionInterface
  72117. {
  72118. }
  72119. <?php
  72120. namespace Symfony\Component\Filesystem;
  72121. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  72122. use Symfony\Component\Filesystem\Exception\InvalidArgumentException;
  72123. use Symfony\Component\Filesystem\Exception\IOException;
  72124. class Filesystem
  72125. {
  72126. private static $lastError;
  72127. public function copy(string $originFile, string $targetFile, bool $overwriteNewerFiles = false)
  72128. {
  72129. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  72130. if ($originIsLocal && !is_file($originFile)) {
  72131. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  72132. }
  72133. $this->mkdir(\dirname($targetFile));
  72134. $doCopy = true;
  72135. if (!$overwriteNewerFiles && !parse_url($originFile, \PHP_URL_HOST) && is_file($targetFile)) {
  72136. $doCopy = filemtime($originFile) > filemtime($targetFile);
  72137. }
  72138. if ($doCopy) {
  72139. if (!$source = self::box('fopen', $originFile, 'r')) {
  72140. 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);
  72141. }
  72142. if (!$target = self::box('fopen', $targetFile, 'w', false, stream_context_create(['ftp' => ['overwrite' => true]]))) {
  72143. 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);
  72144. }
  72145. $bytesCopied = stream_copy_to_stream($source, $target);
  72146. fclose($source);
  72147. fclose($target);
  72148. unset($source, $target);
  72149. if (!is_file($targetFile)) {
  72150. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  72151. }
  72152. if ($originIsLocal) {
  72153. self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  72154. self::box('touch', $targetFile, filemtime($originFile));
  72155. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  72156. 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);
  72157. }
  72158. }
  72159. }
  72160. }
  72161. public function mkdir($dirs, int $mode = 0777)
  72162. {
  72163. foreach ($this->toIterable($dirs) as $dir) {
  72164. if (is_dir($dir)) {
  72165. continue;
  72166. }
  72167. if (!self::box('mkdir', $dir, $mode, true) && !is_dir($dir)) {
  72168. throw new IOException(sprintf('Failed to create "%s": ', $dir).self::$lastError, 0, null, $dir);
  72169. }
  72170. }
  72171. }
  72172. public function exists($files)
  72173. {
  72174. $maxPathLength = \PHP_MAXPATHLEN - 2;
  72175. foreach ($this->toIterable($files) as $file) {
  72176. if (\strlen($file) > $maxPathLength) {
  72177. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  72178. }
  72179. if (!file_exists($file)) {
  72180. return false;
  72181. }
  72182. }
  72183. return true;
  72184. }
  72185. public function touch($files, ?int $time = null, ?int $atime = null)
  72186. {
  72187. foreach ($this->toIterable($files) as $file) {
  72188. if (!($time ? self::box('touch', $file, $time, $atime) : self::box('touch', $file))) {
  72189. throw new IOException(sprintf('Failed to touch "%s": ', $file).self::$lastError, 0, null, $file);
  72190. }
  72191. }
  72192. }
  72193. public function remove($files)
  72194. {
  72195. if ($files instanceof \Traversable) {
  72196. $files = iterator_to_array($files, false);
  72197. } elseif (!\is_array($files)) {
  72198. $files = [$files];
  72199. }
  72200. self::doRemove($files, false);
  72201. }
  72202. private static function doRemove(array $files, bool $isRecursive): void
  72203. {
  72204. $files = array_reverse($files);
  72205. foreach ($files as $file) {
  72206. if (is_link($file)) {
  72207. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  72208. throw new IOException(sprintf('Failed to remove symlink "%s": ', $file).self::$lastError);
  72209. }
  72210. } elseif (is_dir($file)) {
  72211. if (!$isRecursive) {
  72212. $tmpName = \dirname(realpath($file)).'/.!'.strrev(strtr(base64_encode(random_bytes(2)), '/=', '-!'));
  72213. if (file_exists($tmpName)) {
  72214. try {
  72215. self::doRemove([$tmpName], true);
  72216. } catch (IOException $e) {
  72217. }
  72218. }
  72219. if (!file_exists($tmpName) && self::box('rename', $file, $tmpName)) {
  72220. $origFile = $file;
  72221. $file = $tmpName;
  72222. } else {
  72223. $origFile = null;
  72224. }
  72225. }
  72226. $files = new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS);
  72227. self::doRemove(iterator_to_array($files, true), true);
  72228. if (!self::box('rmdir', $file) && file_exists($file) && !$isRecursive) {
  72229. $lastError = self::$lastError;
  72230. if (null !== $origFile && self::box('rename', $file, $origFile)) {
  72231. $file = $origFile;
  72232. }
  72233. throw new IOException(sprintf('Failed to remove directory "%s": ', $file).$lastError);
  72234. }
  72235. } elseif (!self::box('unlink', $file) && ((self::$lastError && str_contains(self::$lastError, 'Permission denied')) || file_exists($file))) {
  72236. throw new IOException(sprintf('Failed to remove file "%s": ', $file).self::$lastError);
  72237. }
  72238. }
  72239. }
  72240. public function chmod($files, int $mode, int $umask = 0000, bool $recursive = false)
  72241. {
  72242. foreach ($this->toIterable($files) as $file) {
  72243. if ((\PHP_VERSION_ID < 80000 || \is_int($mode)) && !self::box('chmod', $file, $mode & ~$umask)) {
  72244. throw new IOException(sprintf('Failed to chmod file "%s": ', $file).self::$lastError, 0, null, $file);
  72245. }
  72246. if ($recursive && is_dir($file) && !is_link($file)) {
  72247. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  72248. }
  72249. }
  72250. }
  72251. public function chown($files, $user, bool $recursive = false)
  72252. {
  72253. foreach ($this->toIterable($files) as $file) {
  72254. if ($recursive && is_dir($file) && !is_link($file)) {
  72255. $this->chown(new \FilesystemIterator($file), $user, true);
  72256. }
  72257. if (is_link($file) && \function_exists('lchown')) {
  72258. if (!self::box('lchown', $file, $user)) {
  72259. throw new IOException(sprintf('Failed to chown file "%s": ', $file).self::$lastError, 0, null, $file);
  72260. }
  72261. } else {
  72262. if (!self::box('chown', $file, $user)) {
  72263. throw new IOException(sprintf('Failed to chown file "%s": ', $file).self::$lastError, 0, null, $file);
  72264. }
  72265. }
  72266. }
  72267. }
  72268. public function chgrp($files, $group, bool $recursive = false)
  72269. {
  72270. foreach ($this->toIterable($files) as $file) {
  72271. if ($recursive && is_dir($file) && !is_link($file)) {
  72272. $this->chgrp(new \FilesystemIterator($file), $group, true);
  72273. }
  72274. if (is_link($file) && \function_exists('lchgrp')) {
  72275. if (!self::box('lchgrp', $file, $group)) {
  72276. throw new IOException(sprintf('Failed to chgrp file "%s": ', $file).self::$lastError, 0, null, $file);
  72277. }
  72278. } else {
  72279. if (!self::box('chgrp', $file, $group)) {
  72280. throw new IOException(sprintf('Failed to chgrp file "%s": ', $file).self::$lastError, 0, null, $file);
  72281. }
  72282. }
  72283. }
  72284. }
  72285. public function rename(string $origin, string $target, bool $overwrite = false)
  72286. {
  72287. if (!$overwrite && $this->isReadable($target)) {
  72288. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  72289. }
  72290. if (!self::box('rename', $origin, $target)) {
  72291. if (is_dir($origin)) {
  72292. $this->mirror($origin, $target, null, ['override' => $overwrite, 'delete' => $overwrite]);
  72293. $this->remove($origin);
  72294. return;
  72295. }
  72296. throw new IOException(sprintf('Cannot rename "%s" to "%s": ', $origin, $target).self::$lastError, 0, null, $target);
  72297. }
  72298. }
  72299. private function isReadable(string $filename): bool
  72300. {
  72301. $maxPathLength = \PHP_MAXPATHLEN - 2;
  72302. if (\strlen($filename) > $maxPathLength) {
  72303. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  72304. }
  72305. return is_readable($filename);
  72306. }
  72307. public function symlink(string $originDir, string $targetDir, bool $copyOnWindows = false)
  72308. {
  72309. self::assertFunctionExists('symlink');
  72310. if ('\\' === \DIRECTORY_SEPARATOR) {
  72311. $originDir = strtr($originDir, '/', '\\');
  72312. $targetDir = strtr($targetDir, '/', '\\');
  72313. if ($copyOnWindows) {
  72314. $this->mirror($originDir, $targetDir);
  72315. return;
  72316. }
  72317. }
  72318. $this->mkdir(\dirname($targetDir));
  72319. if (is_link($targetDir)) {
  72320. if (readlink($targetDir) === $originDir) {
  72321. return;
  72322. }
  72323. $this->remove($targetDir);
  72324. }
  72325. if (!self::box('symlink', $originDir, $targetDir)) {
  72326. $this->linkException($originDir, $targetDir, 'symbolic');
  72327. }
  72328. }
  72329. public function hardlink(string $originFile, $targetFiles)
  72330. {
  72331. self::assertFunctionExists('link');
  72332. if (!$this->exists($originFile)) {
  72333. throw new FileNotFoundException(null, 0, null, $originFile);
  72334. }
  72335. if (!is_file($originFile)) {
  72336. throw new FileNotFoundException(sprintf('Origin file "%s" is not a file.', $originFile));
  72337. }
  72338. foreach ($this->toIterable($targetFiles) as $targetFile) {
  72339. if (is_file($targetFile)) {
  72340. if (fileinode($originFile) === fileinode($targetFile)) {
  72341. continue;
  72342. }
  72343. $this->remove($targetFile);
  72344. }
  72345. if (!self::box('link', $originFile, $targetFile)) {
  72346. $this->linkException($originFile, $targetFile, 'hard');
  72347. }
  72348. }
  72349. }
  72350. private function linkException(string $origin, string $target, string $linkType)
  72351. {
  72352. if (self::$lastError) {
  72353. if ('\\' === \DIRECTORY_SEPARATOR && str_contains(self::$lastError, 'error code(1314)')) {
  72354. 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);
  72355. }
  72356. }
  72357. throw new IOException(sprintf('Failed to create "%s" link from "%s" to "%s": ', $linkType, $origin, $target).self::$lastError, 0, null, $target);
  72358. }
  72359. public function readlink(string $path, bool $canonicalize = false)
  72360. {
  72361. if (!$canonicalize && !is_link($path)) {
  72362. return null;
  72363. }
  72364. if ($canonicalize) {
  72365. if (!$this->exists($path)) {
  72366. return null;
  72367. }
  72368. if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70410) {
  72369. $path = readlink($path);
  72370. }
  72371. return realpath($path);
  72372. }
  72373. if ('\\' === \DIRECTORY_SEPARATOR && \PHP_VERSION_ID < 70400) {
  72374. return realpath($path);
  72375. }
  72376. return readlink($path);
  72377. }
  72378. public function makePathRelative(string $endPath, string $startPath)
  72379. {
  72380. if (!$this->isAbsolutePath($startPath)) {
  72381. throw new InvalidArgumentException(sprintf('The start path "%s" is not absolute.', $startPath));
  72382. }
  72383. if (!$this->isAbsolutePath($endPath)) {
  72384. throw new InvalidArgumentException(sprintf('The end path "%s" is not absolute.', $endPath));
  72385. }
  72386. if ('\\' === \DIRECTORY_SEPARATOR) {
  72387. $endPath = str_replace('\\', '/', $endPath);
  72388. $startPath = str_replace('\\', '/', $startPath);
  72389. }
  72390. $splitDriveLetter = function ($path) {
  72391. return (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0]))
  72392. ? [substr($path, 2), strtoupper($path[0])]
  72393. : [$path, null];
  72394. };
  72395. $splitPath = function ($path) {
  72396. $result = [];
  72397. foreach (explode('/', trim($path, '/')) as $segment) {
  72398. if ('..' === $segment) {
  72399. array_pop($result);
  72400. } elseif ('.' !== $segment && '' !== $segment) {
  72401. $result[] = $segment;
  72402. }
  72403. }
  72404. return $result;
  72405. };
  72406. [$endPath, $endDriveLetter] = $splitDriveLetter($endPath);
  72407. [$startPath, $startDriveLetter] = $splitDriveLetter($startPath);
  72408. $startPathArr = $splitPath($startPath);
  72409. $endPathArr = $splitPath($endPath);
  72410. if ($endDriveLetter && $startDriveLetter && $endDriveLetter != $startDriveLetter) {
  72411. return $endDriveLetter.':/'.($endPathArr ? implode('/', $endPathArr).'/' : '');
  72412. }
  72413. $index = 0;
  72414. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  72415. ++$index;
  72416. }
  72417. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  72418. $depth = 0;
  72419. } else {
  72420. $depth = \count($startPathArr) - $index;
  72421. }
  72422. $traverser = str_repeat('../', $depth);
  72423. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  72424. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  72425. return '' === $relativePath ? './' : $relativePath;
  72426. }
  72427. public function mirror(string $originDir, string $targetDir, ?\Traversable $iterator = null, array $options = [])
  72428. {
  72429. $targetDir = rtrim($targetDir, '/\\');
  72430. $originDir = rtrim($originDir, '/\\');
  72431. $originDirLen = \strlen($originDir);
  72432. if (!$this->exists($originDir)) {
  72433. throw new IOException(sprintf('The origin directory specified "%s" was not found.', $originDir), 0, null, $originDir);
  72434. }
  72435. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  72436. $deleteIterator = $iterator;
  72437. if (null === $deleteIterator) {
  72438. $flags = \FilesystemIterator::SKIP_DOTS;
  72439. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  72440. }
  72441. $targetDirLen = \strlen($targetDir);
  72442. foreach ($deleteIterator as $file) {
  72443. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  72444. if (!$this->exists($origin)) {
  72445. $this->remove($file);
  72446. }
  72447. }
  72448. }
  72449. $copyOnWindows = $options['copy_on_windows'] ?? false;
  72450. if (null === $iterator) {
  72451. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  72452. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  72453. }
  72454. $this->mkdir($targetDir);
  72455. $filesCreatedWhileMirroring = [];
  72456. foreach ($iterator as $file) {
  72457. if ($file->getPathname() === $targetDir || $file->getRealPath() === $targetDir || isset($filesCreatedWhileMirroring[$file->getRealPath()])) {
  72458. continue;
  72459. }
  72460. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  72461. $filesCreatedWhileMirroring[$target] = true;
  72462. if (!$copyOnWindows && is_link($file)) {
  72463. $this->symlink($file->getLinkTarget(), $target);
  72464. } elseif (is_dir($file)) {
  72465. $this->mkdir($target);
  72466. } elseif (is_file($file)) {
  72467. $this->copy($file, $target, $options['override'] ?? false);
  72468. } else {
  72469. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  72470. }
  72471. }
  72472. }
  72473. public function isAbsolutePath(string $file)
  72474. {
  72475. return '' !== $file && (strspn($file, '/\\', 0, 1)
  72476. || (\strlen($file) > 3 && ctype_alpha($file[0])
  72477. && ':' === $file[1]
  72478. && strspn($file, '/\\', 2, 1)
  72479. )
  72480. || null !== parse_url($file, \PHP_URL_SCHEME)
  72481. );
  72482. }
  72483. public function tempnam(string $dir, string $prefix)
  72484. {
  72485. $suffix = \func_num_args() > 2 ? func_get_arg(2) : '';
  72486. [$scheme, $hierarchy] = $this->getSchemeAndHierarchy($dir);
  72487. if ((null === $scheme || 'file' === $scheme || 'gs' === $scheme) && '' === $suffix) {
  72488. if ($tmpFile = self::box('tempnam', $hierarchy, $prefix)) {
  72489. if (null !== $scheme && 'gs' !== $scheme) {
  72490. return $scheme.'://'.$tmpFile;
  72491. }
  72492. return $tmpFile;
  72493. }
  72494. throw new IOException('A temporary file could not be created: '.self::$lastError);
  72495. }
  72496. for ($i = 0; $i < 10; ++$i) {
  72497. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true).$suffix;
  72498. if (!$handle = self::box('fopen', $tmpFile, 'x+')) {
  72499. continue;
  72500. }
  72501. self::box('fclose', $handle);
  72502. return $tmpFile;
  72503. }
  72504. throw new IOException('A temporary file could not be created: '.self::$lastError);
  72505. }
  72506. public function dumpFile(string $filename, $content)
  72507. {
  72508. if (\is_array($content)) {
  72509. throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
  72510. }
  72511. $dir = \dirname($filename);
  72512. if (is_link($filename) && $linkTarget = $this->readlink($filename)) {
  72513. $this->dumpFile(Path::makeAbsolute($linkTarget, $dir), $content);
  72514. return;
  72515. }
  72516. if (!is_dir($dir)) {
  72517. $this->mkdir($dir);
  72518. }
  72519. $tmpFile = $this->tempnam($dir, basename($filename));
  72520. try {
  72521. if (false === self::box('file_put_contents', $tmpFile, $content)) {
  72522. throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
  72523. }
  72524. self::box('chmod', $tmpFile, self::box('fileperms', $filename) ?: 0666 & ~umask());
  72525. $this->rename($tmpFile, $filename, true);
  72526. } finally {
  72527. if (file_exists($tmpFile)) {
  72528. if ('\\' === \DIRECTORY_SEPARATOR && !is_writable($tmpFile)) {
  72529. self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0200);
  72530. }
  72531. self::box('unlink', $tmpFile);
  72532. }
  72533. }
  72534. }
  72535. public function appendToFile(string $filename, $content)
  72536. {
  72537. if (\is_array($content)) {
  72538. throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be string or resource, array given.', __METHOD__));
  72539. }
  72540. $dir = \dirname($filename);
  72541. if (!is_dir($dir)) {
  72542. $this->mkdir($dir);
  72543. }
  72544. $lock = \func_num_args() > 2 && func_get_arg(2);
  72545. if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND | ($lock ? \LOCK_EX : 0))) {
  72546. throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
  72547. }
  72548. }
  72549. private function toIterable($files): iterable
  72550. {
  72551. return is_iterable($files) ? $files : [$files];
  72552. }
  72553. private function getSchemeAndHierarchy(string $filename): array
  72554. {
  72555. $components = explode('://', $filename, 2);
  72556. return 2 === \count($components) ? [$components[0], $components[1]] : [null, $components[0]];
  72557. }
  72558. private static function assertFunctionExists(string $func): void
  72559. {
  72560. if (!\function_exists($func)) {
  72561. throw new IOException(sprintf('Unable to perform filesystem operation because the "%s()" function has been disabled.', $func));
  72562. }
  72563. }
  72564. private static function box(string $func, ...$args)
  72565. {
  72566. self::assertFunctionExists($func);
  72567. self::$lastError = null;
  72568. set_error_handler(__CLASS__.'::handleError');
  72569. try {
  72570. return $func(...$args);
  72571. } finally {
  72572. restore_error_handler();
  72573. }
  72574. }
  72575. public static function handleError(int $type, string $msg)
  72576. {
  72577. self::$lastError = $msg;
  72578. }
  72579. }
  72580. Copyright (c) 2004-present Fabien Potencier
  72581. Permission is hereby granted, free of charge, to any person obtaining a copy
  72582. of this software and associated documentation files (the "Software"), to deal
  72583. in the Software without restriction, including without limitation the rights
  72584. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  72585. copies of the Software, and to permit persons to whom the Software is furnished
  72586. to do so, subject to the following conditions:
  72587. The above copyright notice and this permission notice shall be included in all
  72588. copies or substantial portions of the Software.
  72589. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  72590. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  72591. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  72592. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  72593. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  72594. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  72595. THE SOFTWARE.
  72596. <?php
  72597. namespace Symfony\Component\Filesystem;
  72598. use Symfony\Component\Filesystem\Exception\InvalidArgumentException;
  72599. use Symfony\Component\Filesystem\Exception\RuntimeException;
  72600. final class Path
  72601. {
  72602. private const CLEANUP_THRESHOLD = 1250;
  72603. private const CLEANUP_SIZE = 1000;
  72604. private static $buffer = [];
  72605. private static $bufferSize = 0;
  72606. public static function canonicalize(string $path): string
  72607. {
  72608. if ('' === $path) {
  72609. return '';
  72610. }
  72611. if (isset(self::$buffer[$path])) {
  72612. return self::$buffer[$path];
  72613. }
  72614. if ('~' === $path[0]) {
  72615. $path = self::getHomeDirectory().substr($path, 1);
  72616. }
  72617. $path = self::normalize($path);
  72618. [$root, $pathWithoutRoot] = self::split($path);
  72619. $canonicalParts = self::findCanonicalParts($root, $pathWithoutRoot);
  72620. self::$buffer[$path] = $canonicalPath = $root.implode('/', $canonicalParts);
  72621. ++self::$bufferSize;
  72622. if (self::$bufferSize > self::CLEANUP_THRESHOLD) {
  72623. self::$buffer = \array_slice(self::$buffer, -self::CLEANUP_SIZE, null, true);
  72624. self::$bufferSize = self::CLEANUP_SIZE;
  72625. }
  72626. return $canonicalPath;
  72627. }
  72628. public static function normalize(string $path): string
  72629. {
  72630. return str_replace('\\', '/', $path);
  72631. }
  72632. public static function getDirectory(string $path): string
  72633. {
  72634. if ('' === $path) {
  72635. return '';
  72636. }
  72637. $path = self::canonicalize($path);
  72638. if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
  72639. $scheme = substr($path, 0, $schemeSeparatorPosition + 3);
  72640. $path = substr($path, $schemeSeparatorPosition + 3);
  72641. } else {
  72642. $scheme = '';
  72643. }
  72644. if (false === $dirSeparatorPosition = strrpos($path, '/')) {
  72645. return '';
  72646. }
  72647. if (0 === $dirSeparatorPosition) {
  72648. return $scheme.'/';
  72649. }
  72650. if (2 === $dirSeparatorPosition && ctype_alpha($path[0]) && ':' === $path[1]) {
  72651. return $scheme.substr($path, 0, 3);
  72652. }
  72653. return $scheme.substr($path, 0, $dirSeparatorPosition);
  72654. }
  72655. public static function getHomeDirectory(): string
  72656. {
  72657. if (getenv('HOME')) {
  72658. return self::canonicalize(getenv('HOME'));
  72659. }
  72660. if (getenv('HOMEDRIVE') && getenv('HOMEPATH')) {
  72661. return self::canonicalize(getenv('HOMEDRIVE').getenv('HOMEPATH'));
  72662. }
  72663. throw new RuntimeException("Cannot find the home directory path: Your environment or operating system isn't supported.");
  72664. }
  72665. public static function getRoot(string $path): string
  72666. {
  72667. if ('' === $path) {
  72668. return '';
  72669. }
  72670. if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
  72671. $scheme = substr($path, 0, $schemeSeparatorPosition + 3);
  72672. $path = substr($path, $schemeSeparatorPosition + 3);
  72673. } else {
  72674. $scheme = '';
  72675. }
  72676. $firstCharacter = $path[0];
  72677. if ('/' === $firstCharacter || '\\' === $firstCharacter) {
  72678. return $scheme.'/';
  72679. }
  72680. $length = \strlen($path);
  72681. if ($length > 1 && ':' === $path[1] && ctype_alpha($firstCharacter)) {
  72682. if (2 === $length) {
  72683. return $scheme.$path.'/';
  72684. }
  72685. if ('/' === $path[2] || '\\' === $path[2]) {
  72686. return $scheme.$firstCharacter.$path[1].'/';
  72687. }
  72688. }
  72689. return '';
  72690. }
  72691. public static function getFilenameWithoutExtension(string $path, ?string $extension = null): string
  72692. {
  72693. if ('' === $path) {
  72694. return '';
  72695. }
  72696. if (null !== $extension) {
  72697. return rtrim(basename($path, $extension), '.');
  72698. }
  72699. return pathinfo($path, \PATHINFO_FILENAME);
  72700. }
  72701. public static function getExtension(string $path, bool $forceLowerCase = false): string
  72702. {
  72703. if ('' === $path) {
  72704. return '';
  72705. }
  72706. $extension = pathinfo($path, \PATHINFO_EXTENSION);
  72707. if ($forceLowerCase) {
  72708. $extension = self::toLower($extension);
  72709. }
  72710. return $extension;
  72711. }
  72712. public static function hasExtension(string $path, $extensions = null, bool $ignoreCase = false): bool
  72713. {
  72714. if ('' === $path) {
  72715. return false;
  72716. }
  72717. $actualExtension = self::getExtension($path, $ignoreCase);
  72718. if ([] === $extensions || null === $extensions) {
  72719. return '' !== $actualExtension;
  72720. }
  72721. if (\is_string($extensions)) {
  72722. $extensions = [$extensions];
  72723. }
  72724. foreach ($extensions as $key => $extension) {
  72725. if ($ignoreCase) {
  72726. $extension = self::toLower($extension);
  72727. }
  72728. $extensions[$key] = ltrim($extension, '.');
  72729. }
  72730. return \in_array($actualExtension, $extensions, true);
  72731. }
  72732. public static function changeExtension(string $path, string $extension): string
  72733. {
  72734. if ('' === $path) {
  72735. return '';
  72736. }
  72737. $actualExtension = self::getExtension($path);
  72738. $extension = ltrim($extension, '.');
  72739. if ('/' === substr($path, -1)) {
  72740. return $path;
  72741. }
  72742. if (empty($actualExtension)) {
  72743. return $path.('.' === substr($path, -1) ? '' : '.').$extension;
  72744. }
  72745. return substr($path, 0, -\strlen($actualExtension)).$extension;
  72746. }
  72747. public static function isAbsolute(string $path): bool
  72748. {
  72749. if ('' === $path) {
  72750. return false;
  72751. }
  72752. if (false !== ($schemeSeparatorPosition = strpos($path, '://')) && 1 !== $schemeSeparatorPosition) {
  72753. $path = substr($path, $schemeSeparatorPosition + 3);
  72754. }
  72755. $firstCharacter = $path[0];
  72756. if ('/' === $firstCharacter || '\\' === $firstCharacter) {
  72757. return true;
  72758. }
  72759. if (\strlen($path) > 1 && ctype_alpha($firstCharacter) && ':' === $path[1]) {
  72760. if (2 === \strlen($path)) {
  72761. return true;
  72762. }
  72763. if ('/' === $path[2] || '\\' === $path[2]) {
  72764. return true;
  72765. }
  72766. }
  72767. return false;
  72768. }
  72769. public static function isRelative(string $path): bool
  72770. {
  72771. return !self::isAbsolute($path);
  72772. }
  72773. public static function makeAbsolute(string $path, string $basePath): string
  72774. {
  72775. if ('' === $basePath) {
  72776. throw new InvalidArgumentException(sprintf('The base path must be a non-empty string. Got: "%s".', $basePath));
  72777. }
  72778. if (!self::isAbsolute($basePath)) {
  72779. throw new InvalidArgumentException(sprintf('The base path "%s" is not an absolute path.', $basePath));
  72780. }
  72781. if (self::isAbsolute($path)) {
  72782. return self::canonicalize($path);
  72783. }
  72784. if (false !== $schemeSeparatorPosition = strpos($basePath, '://')) {
  72785. $scheme = substr($basePath, 0, $schemeSeparatorPosition + 3);
  72786. $basePath = substr($basePath, $schemeSeparatorPosition + 3);
  72787. } else {
  72788. $scheme = '';
  72789. }
  72790. return $scheme.self::canonicalize(rtrim($basePath, '/\\').'/'.$path);
  72791. }
  72792. public static function makeRelative(string $path, string $basePath): string
  72793. {
  72794. $path = self::canonicalize($path);
  72795. $basePath = self::canonicalize($basePath);
  72796. [$root, $relativePath] = self::split($path);
  72797. [$baseRoot, $relativeBasePath] = self::split($basePath);
  72798. if ('' === $root && '' !== $baseRoot) {
  72799. if ('' === $relativeBasePath) {
  72800. $relativePath = ltrim($relativePath, './\\');
  72801. }
  72802. return $relativePath;
  72803. }
  72804. if ('' !== $root && '' === $baseRoot) {
  72805. 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));
  72806. }
  72807. if ($baseRoot && $root !== $baseRoot) {
  72808. 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));
  72809. }
  72810. if ('' === $relativeBasePath) {
  72811. return $relativePath;
  72812. }
  72813. $parts = explode('/', $relativePath);
  72814. $baseParts = explode('/', $relativeBasePath);
  72815. $dotDotPrefix = '';
  72816. $match = true;
  72817. foreach ($baseParts as $index => $basePart) {
  72818. if ($match && isset($parts[$index]) && $basePart === $parts[$index]) {
  72819. unset($parts[$index]);
  72820. continue;
  72821. }
  72822. $match = false;
  72823. $dotDotPrefix .= '../';
  72824. }
  72825. return rtrim($dotDotPrefix.implode('/', $parts), '/');
  72826. }
  72827. public static function isLocal(string $path): bool
  72828. {
  72829. return '' !== $path && false === strpos($path, '://');
  72830. }
  72831. public static function getLongestCommonBasePath(string ...$paths): ?string
  72832. {
  72833. [$bpRoot, $basePath] = self::split(self::canonicalize(reset($paths)));
  72834. for (next($paths); null !== key($paths) && '' !== $basePath; next($paths)) {
  72835. [$root, $path] = self::split(self::canonicalize(current($paths)));
  72836. if ($root !== $bpRoot) {
  72837. return null;
  72838. }
  72839. while (true) {
  72840. if ('.' === $basePath) {
  72841. $basePath = '';
  72842. continue 2;
  72843. }
  72844. if (0 === strpos($path.'/', $basePath.'/')) {
  72845. continue 2;
  72846. }
  72847. $basePath = \dirname($basePath);
  72848. }
  72849. }
  72850. return $bpRoot.$basePath;
  72851. }
  72852. public static function join(string ...$paths): string
  72853. {
  72854. $finalPath = null;
  72855. $wasScheme = false;
  72856. foreach ($paths as $path) {
  72857. if ('' === $path) {
  72858. continue;
  72859. }
  72860. if (null === $finalPath) {
  72861. $finalPath = $path;
  72862. $wasScheme = (false !== strpos($path, '://'));
  72863. continue;
  72864. }
  72865. if (!\in_array(substr($finalPath, -1), ['/', '\\'])) {
  72866. $finalPath .= '/';
  72867. }
  72868. $finalPath .= $wasScheme ? $path : ltrim($path, '/');
  72869. $wasScheme = false;
  72870. }
  72871. if (null === $finalPath) {
  72872. return '';
  72873. }
  72874. return self::canonicalize($finalPath);
  72875. }
  72876. public static function isBasePath(string $basePath, string $ofPath): bool
  72877. {
  72878. $basePath = self::canonicalize($basePath);
  72879. $ofPath = self::canonicalize($ofPath);
  72880. return 0 === strpos($ofPath.'/', rtrim($basePath, '/').'/');
  72881. }
  72882. private static function findCanonicalParts(string $root, string $pathWithoutRoot): array
  72883. {
  72884. $parts = explode('/', $pathWithoutRoot);
  72885. $canonicalParts = [];
  72886. foreach ($parts as $part) {
  72887. if ('.' === $part || '' === $part) {
  72888. continue;
  72889. }
  72890. if ('..' === $part && \count($canonicalParts) > 0 && '..' !== $canonicalParts[\count($canonicalParts) - 1]) {
  72891. array_pop($canonicalParts);
  72892. continue;
  72893. }
  72894. if ('..' !== $part || '' === $root) {
  72895. $canonicalParts[] = $part;
  72896. }
  72897. }
  72898. return $canonicalParts;
  72899. }
  72900. private static function split(string $path): array
  72901. {
  72902. if ('' === $path) {
  72903. return ['', ''];
  72904. }
  72905. if (false !== $schemeSeparatorPosition = strpos($path, '://')) {
  72906. $root = substr($path, 0, $schemeSeparatorPosition + 3);
  72907. $path = substr($path, $schemeSeparatorPosition + 3);
  72908. } else {
  72909. $root = '';
  72910. }
  72911. $length = \strlen($path);
  72912. if (0 === strpos($path, '/')) {
  72913. $root .= '/';
  72914. $path = $length > 1 ? substr($path, 1) : '';
  72915. } elseif ($length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
  72916. if (2 === $length) {
  72917. $root .= $path.'/';
  72918. $path = '';
  72919. } elseif ('/' === $path[2]) {
  72920. $root .= substr($path, 0, 3);
  72921. $path = $length > 3 ? substr($path, 3) : '';
  72922. }
  72923. }
  72924. return [$root, $path];
  72925. }
  72926. private static function toLower(string $string): string
  72927. {
  72928. if (false !== $encoding = mb_detect_encoding($string, null, true)) {
  72929. return mb_strtolower($string, $encoding);
  72930. }
  72931. return strtolower($string);
  72932. }
  72933. private function __construct()
  72934. {
  72935. }
  72936. }
  72937. <?php
  72938. namespace Symfony\Component\Finder\Comparator;
  72939. class Comparator
  72940. {
  72941. private $target;
  72942. private $operator = '==';
  72943. public function __construct(?string $target = null, string $operator = '==')
  72944. {
  72945. if (null === $target) {
  72946. trigger_deprecation('symfony/finder', '5.4', 'Constructing a "%s" without setting "$target" is deprecated.', __CLASS__);
  72947. }
  72948. $this->target = $target;
  72949. $this->doSetOperator($operator);
  72950. }
  72951. public function getTarget()
  72952. {
  72953. if (null === $this->target) {
  72954. trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
  72955. }
  72956. return $this->target;
  72957. }
  72958. public function setTarget(string $target)
  72959. {
  72960. trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the target via the constructor instead.', __METHOD__);
  72961. $this->target = $target;
  72962. }
  72963. public function getOperator()
  72964. {
  72965. return $this->operator;
  72966. }
  72967. public function setOperator(string $operator)
  72968. {
  72969. trigger_deprecation('symfony/finder', '5.4', '"%s" is deprecated. Set the operator via the constructor instead.', __METHOD__);
  72970. $this->doSetOperator('' === $operator ? '==' : $operator);
  72971. }
  72972. public function test($test)
  72973. {
  72974. if (null === $this->target) {
  72975. trigger_deprecation('symfony/finder', '5.4', 'Calling "%s" without initializing the target is deprecated.', __METHOD__);
  72976. }
  72977. switch ($this->operator) {
  72978. case '>':
  72979. return $test > $this->target;
  72980. case '>=':
  72981. return $test >= $this->target;
  72982. case '<':
  72983. return $test < $this->target;
  72984. case '<=':
  72985. return $test <= $this->target;
  72986. case '!=':
  72987. return $test != $this->target;
  72988. }
  72989. return $test == $this->target;
  72990. }
  72991. private function doSetOperator(string $operator): void
  72992. {
  72993. if (!\in_array($operator, ['>', '<', '>=', '<=', '==', '!='])) {
  72994. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  72995. }
  72996. $this->operator = $operator;
  72997. }
  72998. }
  72999. <?php
  73000. namespace Symfony\Component\Finder\Comparator;
  73001. class DateComparator extends Comparator
  73002. {
  73003. public function __construct(string $test)
  73004. {
  73005. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  73006. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  73007. }
  73008. try {
  73009. $date = new \DateTime($matches[2]);
  73010. $target = $date->format('U');
  73011. } catch (\Exception $e) {
  73012. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  73013. }
  73014. $operator = $matches[1] ?? '==';
  73015. if ('since' === $operator || 'after' === $operator) {
  73016. $operator = '>';
  73017. }
  73018. if ('until' === $operator || 'before' === $operator) {
  73019. $operator = '<';
  73020. }
  73021. parent::__construct($target, $operator);
  73022. }
  73023. }
  73024. <?php
  73025. namespace Symfony\Component\Finder\Comparator;
  73026. class NumberComparator extends Comparator
  73027. {
  73028. public function __construct(?string $test)
  73029. {
  73030. if (null === $test || !preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  73031. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test ?? 'null'));
  73032. }
  73033. $target = $matches[2];
  73034. if (!is_numeric($target)) {
  73035. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  73036. }
  73037. if (isset($matches[3])) {
  73038. switch (strtolower($matches[3])) {
  73039. case 'k':
  73040. $target *= 1000;
  73041. break;
  73042. case 'ki':
  73043. $target *= 1024;
  73044. break;
  73045. case 'm':
  73046. $target *= 1000000;
  73047. break;
  73048. case 'mi':
  73049. $target *= 1024 * 1024;
  73050. break;
  73051. case 'g':
  73052. $target *= 1000000000;
  73053. break;
  73054. case 'gi':
  73055. $target *= 1024 * 1024 * 1024;
  73056. break;
  73057. }
  73058. }
  73059. parent::__construct($target, $matches[1] ?: '==');
  73060. }
  73061. }
  73062. <?php
  73063. namespace Symfony\Component\Finder\Exception;
  73064. class AccessDeniedException extends \UnexpectedValueException
  73065. {
  73066. }
  73067. <?php
  73068. namespace Symfony\Component\Finder\Exception;
  73069. class DirectoryNotFoundException extends \InvalidArgumentException
  73070. {
  73071. }
  73072. <?php
  73073. namespace Symfony\Component\Finder;
  73074. use Symfony\Component\Finder\Comparator\DateComparator;
  73075. use Symfony\Component\Finder\Comparator\NumberComparator;
  73076. use Symfony\Component\Finder\Exception\DirectoryNotFoundException;
  73077. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  73078. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  73079. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  73080. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  73081. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  73082. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  73083. use Symfony\Component\Finder\Iterator\LazyIterator;
  73084. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  73085. use Symfony\Component\Finder\Iterator\SortableIterator;
  73086. class Finder implements \IteratorAggregate, \Countable
  73087. {
  73088. public const IGNORE_VCS_FILES = 1;
  73089. public const IGNORE_DOT_FILES = 2;
  73090. public const IGNORE_VCS_IGNORED_FILES = 4;
  73091. private $mode = 0;
  73092. private $names = [];
  73093. private $notNames = [];
  73094. private $exclude = [];
  73095. private $filters = [];
  73096. private $depths = [];
  73097. private $sizes = [];
  73098. private $followLinks = false;
  73099. private $reverseSorting = false;
  73100. private $sort = false;
  73101. private $ignore = 0;
  73102. private $dirs = [];
  73103. private $dates = [];
  73104. private $iterators = [];
  73105. private $contains = [];
  73106. private $notContains = [];
  73107. private $paths = [];
  73108. private $notPaths = [];
  73109. private $ignoreUnreadableDirs = false;
  73110. private static $vcsPatterns = ['.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg'];
  73111. public function __construct()
  73112. {
  73113. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  73114. }
  73115. public static function create()
  73116. {
  73117. return new static();
  73118. }
  73119. public function directories()
  73120. {
  73121. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  73122. return $this;
  73123. }
  73124. public function files()
  73125. {
  73126. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  73127. return $this;
  73128. }
  73129. public function depth($levels)
  73130. {
  73131. foreach ((array) $levels as $level) {
  73132. $this->depths[] = new Comparator\NumberComparator($level);
  73133. }
  73134. return $this;
  73135. }
  73136. public function date($dates)
  73137. {
  73138. foreach ((array) $dates as $date) {
  73139. $this->dates[] = new Comparator\DateComparator($date);
  73140. }
  73141. return $this;
  73142. }
  73143. public function name($patterns)
  73144. {
  73145. $this->names = array_merge($this->names, (array) $patterns);
  73146. return $this;
  73147. }
  73148. public function notName($patterns)
  73149. {
  73150. $this->notNames = array_merge($this->notNames, (array) $patterns);
  73151. return $this;
  73152. }
  73153. public function contains($patterns)
  73154. {
  73155. $this->contains = array_merge($this->contains, (array) $patterns);
  73156. return $this;
  73157. }
  73158. public function notContains($patterns)
  73159. {
  73160. $this->notContains = array_merge($this->notContains, (array) $patterns);
  73161. return $this;
  73162. }
  73163. public function path($patterns)
  73164. {
  73165. $this->paths = array_merge($this->paths, (array) $patterns);
  73166. return $this;
  73167. }
  73168. public function notPath($patterns)
  73169. {
  73170. $this->notPaths = array_merge($this->notPaths, (array) $patterns);
  73171. return $this;
  73172. }
  73173. public function size($sizes)
  73174. {
  73175. foreach ((array) $sizes as $size) {
  73176. $this->sizes[] = new Comparator\NumberComparator($size);
  73177. }
  73178. return $this;
  73179. }
  73180. public function exclude($dirs)
  73181. {
  73182. $this->exclude = array_merge($this->exclude, (array) $dirs);
  73183. return $this;
  73184. }
  73185. public function ignoreDotFiles(bool $ignoreDotFiles)
  73186. {
  73187. if ($ignoreDotFiles) {
  73188. $this->ignore |= static::IGNORE_DOT_FILES;
  73189. } else {
  73190. $this->ignore &= ~static::IGNORE_DOT_FILES;
  73191. }
  73192. return $this;
  73193. }
  73194. public function ignoreVCS(bool $ignoreVCS)
  73195. {
  73196. if ($ignoreVCS) {
  73197. $this->ignore |= static::IGNORE_VCS_FILES;
  73198. } else {
  73199. $this->ignore &= ~static::IGNORE_VCS_FILES;
  73200. }
  73201. return $this;
  73202. }
  73203. public function ignoreVCSIgnored(bool $ignoreVCSIgnored)
  73204. {
  73205. if ($ignoreVCSIgnored) {
  73206. $this->ignore |= static::IGNORE_VCS_IGNORED_FILES;
  73207. } else {
  73208. $this->ignore &= ~static::IGNORE_VCS_IGNORED_FILES;
  73209. }
  73210. return $this;
  73211. }
  73212. public static function addVCSPattern($pattern)
  73213. {
  73214. foreach ((array) $pattern as $p) {
  73215. self::$vcsPatterns[] = $p;
  73216. }
  73217. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  73218. }
  73219. public function sort(\Closure $closure)
  73220. {
  73221. $this->sort = $closure;
  73222. return $this;
  73223. }
  73224. public function sortByName(bool $useNaturalSort = false)
  73225. {
  73226. $this->sort = $useNaturalSort ? Iterator\SortableIterator::SORT_BY_NAME_NATURAL : Iterator\SortableIterator::SORT_BY_NAME;
  73227. return $this;
  73228. }
  73229. public function sortByType()
  73230. {
  73231. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  73232. return $this;
  73233. }
  73234. public function sortByAccessedTime()
  73235. {
  73236. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  73237. return $this;
  73238. }
  73239. public function reverseSorting()
  73240. {
  73241. $this->reverseSorting = true;
  73242. return $this;
  73243. }
  73244. public function sortByChangedTime()
  73245. {
  73246. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  73247. return $this;
  73248. }
  73249. public function sortByModifiedTime()
  73250. {
  73251. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  73252. return $this;
  73253. }
  73254. public function filter(\Closure $closure)
  73255. {
  73256. $this->filters[] = $closure;
  73257. return $this;
  73258. }
  73259. public function followLinks()
  73260. {
  73261. $this->followLinks = true;
  73262. return $this;
  73263. }
  73264. public function ignoreUnreadableDirs(bool $ignore = true)
  73265. {
  73266. $this->ignoreUnreadableDirs = $ignore;
  73267. return $this;
  73268. }
  73269. public function in($dirs)
  73270. {
  73271. $resolvedDirs = [];
  73272. foreach ((array) $dirs as $dir) {
  73273. if (is_dir($dir)) {
  73274. $resolvedDirs[] = [$this->normalizeDir($dir)];
  73275. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? \GLOB_BRACE : 0) | \GLOB_ONLYDIR | \GLOB_NOSORT)) {
  73276. sort($glob);
  73277. $resolvedDirs[] = array_map([$this, 'normalizeDir'], $glob);
  73278. } else {
  73279. throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
  73280. }
  73281. }
  73282. $this->dirs = array_merge($this->dirs, ...$resolvedDirs);
  73283. return $this;
  73284. }
  73285. #[\ReturnTypeWillChange]
  73286. public function getIterator()
  73287. {
  73288. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  73289. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  73290. }
  73291. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  73292. $iterator = $this->searchInDirectory($this->dirs[0]);
  73293. if ($this->sort || $this->reverseSorting) {
  73294. $iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
  73295. }
  73296. return $iterator;
  73297. }
  73298. $iterator = new \AppendIterator();
  73299. foreach ($this->dirs as $dir) {
  73300. $iterator->append(new \IteratorIterator(new LazyIterator(function () use ($dir) {
  73301. return $this->searchInDirectory($dir);
  73302. })));
  73303. }
  73304. foreach ($this->iterators as $it) {
  73305. $iterator->append($it);
  73306. }
  73307. if ($this->sort || $this->reverseSorting) {
  73308. $iterator = (new Iterator\SortableIterator($iterator, $this->sort, $this->reverseSorting))->getIterator();
  73309. }
  73310. return $iterator;
  73311. }
  73312. public function append(iterable $iterator)
  73313. {
  73314. if ($iterator instanceof \IteratorAggregate) {
  73315. $this->iterators[] = $iterator->getIterator();
  73316. } elseif ($iterator instanceof \Iterator) {
  73317. $this->iterators[] = $iterator;
  73318. } elseif (is_iterable($iterator)) {
  73319. $it = new \ArrayIterator();
  73320. foreach ($iterator as $file) {
  73321. $file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);
  73322. $it[$file->getPathname()] = $file;
  73323. }
  73324. $this->iterators[] = $it;
  73325. } else {
  73326. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  73327. }
  73328. return $this;
  73329. }
  73330. public function hasResults()
  73331. {
  73332. foreach ($this->getIterator() as $_) {
  73333. return true;
  73334. }
  73335. return false;
  73336. }
  73337. #[\ReturnTypeWillChange]
  73338. public function count()
  73339. {
  73340. return iterator_count($this->getIterator());
  73341. }
  73342. private function searchInDirectory(string $dir): \Iterator
  73343. {
  73344. $exclude = $this->exclude;
  73345. $notPaths = $this->notPaths;
  73346. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  73347. $exclude = array_merge($exclude, self::$vcsPatterns);
  73348. }
  73349. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  73350. $notPaths[] = '#(^|/)\..+(/|$)#';
  73351. }
  73352. $minDepth = 0;
  73353. $maxDepth = \PHP_INT_MAX;
  73354. foreach ($this->depths as $comparator) {
  73355. switch ($comparator->getOperator()) {
  73356. case '>':
  73357. $minDepth = $comparator->getTarget() + 1;
  73358. break;
  73359. case '>=':
  73360. $minDepth = $comparator->getTarget();
  73361. break;
  73362. case '<':
  73363. $maxDepth = $comparator->getTarget() - 1;
  73364. break;
  73365. case '<=':
  73366. $maxDepth = $comparator->getTarget();
  73367. break;
  73368. default:
  73369. $minDepth = $maxDepth = $comparator->getTarget();
  73370. }
  73371. }
  73372. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  73373. if ($this->followLinks) {
  73374. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  73375. }
  73376. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  73377. if ($exclude) {
  73378. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $exclude);
  73379. }
  73380. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  73381. if ($minDepth > 0 || $maxDepth < \PHP_INT_MAX) {
  73382. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  73383. }
  73384. if ($this->mode) {
  73385. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  73386. }
  73387. if ($this->names || $this->notNames) {
  73388. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  73389. }
  73390. if ($this->contains || $this->notContains) {
  73391. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  73392. }
  73393. if ($this->sizes) {
  73394. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  73395. }
  73396. if ($this->dates) {
  73397. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  73398. }
  73399. if ($this->filters) {
  73400. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  73401. }
  73402. if ($this->paths || $notPaths) {
  73403. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $notPaths);
  73404. }
  73405. if (static::IGNORE_VCS_IGNORED_FILES === (static::IGNORE_VCS_IGNORED_FILES & $this->ignore)) {
  73406. $iterator = new Iterator\VcsIgnoredFilterIterator($iterator, $dir);
  73407. }
  73408. return $iterator;
  73409. }
  73410. private function normalizeDir(string $dir): string
  73411. {
  73412. if ('/' === $dir) {
  73413. return $dir;
  73414. }
  73415. $dir = rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  73416. if (preg_match('#^(ssh2\.)?s?ftp://#', $dir)) {
  73417. $dir .= '/';
  73418. }
  73419. return $dir;
  73420. }
  73421. }
  73422. <?php
  73423. namespace Symfony\Component\Finder;
  73424. class Gitignore
  73425. {
  73426. public static function toRegex(string $gitignoreFileContent): string
  73427. {
  73428. return self::buildRegex($gitignoreFileContent, false);
  73429. }
  73430. public static function toRegexMatchingNegatedPatterns(string $gitignoreFileContent): string
  73431. {
  73432. return self::buildRegex($gitignoreFileContent, true);
  73433. }
  73434. private static function buildRegex(string $gitignoreFileContent, bool $inverted): string
  73435. {
  73436. $gitignoreFileContent = preg_replace('~(?<!\\\\)#[^\n\r]*~', '', $gitignoreFileContent);
  73437. $gitignoreLines = preg_split('~\r\n?|\n~', $gitignoreFileContent);
  73438. $res = self::lineToRegex('');
  73439. foreach ($gitignoreLines as $line) {
  73440. $line = preg_replace('~(?<!\\\\)[ \t]+$~', '', $line);
  73441. if ('!' === substr($line, 0, 1)) {
  73442. $line = substr($line, 1);
  73443. $isNegative = true;
  73444. } else {
  73445. $isNegative = false;
  73446. }
  73447. if ('' !== $line) {
  73448. if ($isNegative xor $inverted) {
  73449. $res = '(?!'.self::lineToRegex($line).'$)'.$res;
  73450. } else {
  73451. $res = '(?:'.$res.'|'.self::lineToRegex($line).')';
  73452. }
  73453. }
  73454. }
  73455. return '~^(?:'.$res.')~s';
  73456. }
  73457. private static function lineToRegex(string $gitignoreLine): string
  73458. {
  73459. if ('' === $gitignoreLine) {
  73460. return '$f';
  73461. }
  73462. $slashPos = strpos($gitignoreLine, '/');
  73463. if (false !== $slashPos && \strlen($gitignoreLine) - 1 !== $slashPos) {
  73464. if (0 === $slashPos) {
  73465. $gitignoreLine = substr($gitignoreLine, 1);
  73466. }
  73467. $isAbsolute = true;
  73468. } else {
  73469. $isAbsolute = false;
  73470. }
  73471. $regex = preg_quote(str_replace('\\', '', $gitignoreLine), '~');
  73472. $regex = preg_replace_callback('~\\\\\[((?:\\\\!)?)([^\[\]]*)\\\\\]~', function (array $matches): string {
  73473. return '['.('' !== $matches[1] ? '^' : '').str_replace('\\-', '-', $matches[2]).']';
  73474. }, $regex);
  73475. $regex = preg_replace('~(?:(?:\\\\\*){2,}(/?))+~', '(?:(?:(?!//).(?<!//))+$1)?', $regex);
  73476. $regex = preg_replace('~\\\\\*~', '[^/]*', $regex);
  73477. $regex = preg_replace('~\\\\\?~', '[^/]', $regex);
  73478. return ($isAbsolute ? '' : '(?:[^/]+/)*')
  73479. .$regex
  73480. .(!str_ends_with($gitignoreLine, '/') ? '(?:$|/)' : '');
  73481. }
  73482. }
  73483. <?php
  73484. namespace Symfony\Component\Finder;
  73485. class Glob
  73486. {
  73487. public static function toRegex(string $glob, bool $strictLeadingDot = true, bool $strictWildcardSlash = true, string $delimiter = '#')
  73488. {
  73489. $firstByte = true;
  73490. $escaping = false;
  73491. $inCurlies = 0;
  73492. $regex = '';
  73493. $sizeGlob = \strlen($glob);
  73494. for ($i = 0; $i < $sizeGlob; ++$i) {
  73495. $car = $glob[$i];
  73496. if ($firstByte && $strictLeadingDot && '.' !== $car) {
  73497. $regex .= '(?=[^\.])';
  73498. }
  73499. $firstByte = '/' === $car;
  73500. if ($firstByte && $strictWildcardSlash && isset($glob[$i + 2]) && '**' === $glob[$i + 1].$glob[$i + 2] && (!isset($glob[$i + 3]) || '/' === $glob[$i + 3])) {
  73501. $car = '[^/]++/';
  73502. if (!isset($glob[$i + 3])) {
  73503. $car .= '?';
  73504. }
  73505. if ($strictLeadingDot) {
  73506. $car = '(?=[^\.])'.$car;
  73507. }
  73508. $car = '/(?:'.$car.')*';
  73509. $i += 2 + isset($glob[$i + 3]);
  73510. if ('/' === $delimiter) {
  73511. $car = str_replace('/', '\\/', $car);
  73512. }
  73513. }
  73514. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  73515. $regex .= "\\$car";
  73516. } elseif ('*' === $car) {
  73517. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  73518. } elseif ('?' === $car) {
  73519. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  73520. } elseif ('{' === $car) {
  73521. $regex .= $escaping ? '\\{' : '(';
  73522. if (!$escaping) {
  73523. ++$inCurlies;
  73524. }
  73525. } elseif ('}' === $car && $inCurlies) {
  73526. $regex .= $escaping ? '}' : ')';
  73527. if (!$escaping) {
  73528. --$inCurlies;
  73529. }
  73530. } elseif (',' === $car && $inCurlies) {
  73531. $regex .= $escaping ? ',' : '|';
  73532. } elseif ('\\' === $car) {
  73533. if ($escaping) {
  73534. $regex .= '\\\\';
  73535. $escaping = false;
  73536. } else {
  73537. $escaping = true;
  73538. }
  73539. continue;
  73540. } else {
  73541. $regex .= $car;
  73542. }
  73543. $escaping = false;
  73544. }
  73545. return $delimiter.'^'.$regex.'$'.$delimiter;
  73546. }
  73547. }
  73548. <?php
  73549. namespace Symfony\Component\Finder\Iterator;
  73550. class CustomFilterIterator extends \FilterIterator
  73551. {
  73552. private $filters = [];
  73553. public function __construct(\Iterator $iterator, array $filters)
  73554. {
  73555. foreach ($filters as $filter) {
  73556. if (!\is_callable($filter)) {
  73557. throw new \InvalidArgumentException('Invalid PHP callback.');
  73558. }
  73559. }
  73560. $this->filters = $filters;
  73561. parent::__construct($iterator);
  73562. }
  73563. #[\ReturnTypeWillChange]
  73564. public function accept()
  73565. {
  73566. $fileinfo = $this->current();
  73567. foreach ($this->filters as $filter) {
  73568. if (false === $filter($fileinfo)) {
  73569. return false;
  73570. }
  73571. }
  73572. return true;
  73573. }
  73574. }
  73575. <?php
  73576. namespace Symfony\Component\Finder\Iterator;
  73577. use Symfony\Component\Finder\Comparator\DateComparator;
  73578. class DateRangeFilterIterator extends \FilterIterator
  73579. {
  73580. private $comparators = [];
  73581. public function __construct(\Iterator $iterator, array $comparators)
  73582. {
  73583. $this->comparators = $comparators;
  73584. parent::__construct($iterator);
  73585. }
  73586. #[\ReturnTypeWillChange]
  73587. public function accept()
  73588. {
  73589. $fileinfo = $this->current();
  73590. if (!file_exists($fileinfo->getPathname())) {
  73591. return false;
  73592. }
  73593. $filedate = $fileinfo->getMTime();
  73594. foreach ($this->comparators as $compare) {
  73595. if (!$compare->test($filedate)) {
  73596. return false;
  73597. }
  73598. }
  73599. return true;
  73600. }
  73601. }
  73602. <?php
  73603. namespace Symfony\Component\Finder\Iterator;
  73604. class DepthRangeFilterIterator extends \FilterIterator
  73605. {
  73606. private $minDepth = 0;
  73607. public function __construct(\RecursiveIteratorIterator $iterator, int $minDepth = 0, int $maxDepth = \PHP_INT_MAX)
  73608. {
  73609. $this->minDepth = $minDepth;
  73610. $iterator->setMaxDepth(\PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  73611. parent::__construct($iterator);
  73612. }
  73613. #[\ReturnTypeWillChange]
  73614. public function accept()
  73615. {
  73616. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  73617. }
  73618. }
  73619. <?php
  73620. namespace Symfony\Component\Finder\Iterator;
  73621. class ExcludeDirectoryFilterIterator extends \FilterIterator implements \RecursiveIterator
  73622. {
  73623. private $iterator;
  73624. private $isRecursive;
  73625. private $excludedDirs = [];
  73626. private $excludedPattern;
  73627. public function __construct(\Iterator $iterator, array $directories)
  73628. {
  73629. $this->iterator = $iterator;
  73630. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  73631. $patterns = [];
  73632. foreach ($directories as $directory) {
  73633. $directory = rtrim($directory, '/');
  73634. if (!$this->isRecursive || str_contains($directory, '/')) {
  73635. $patterns[] = preg_quote($directory, '#');
  73636. } else {
  73637. $this->excludedDirs[$directory] = true;
  73638. }
  73639. }
  73640. if ($patterns) {
  73641. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  73642. }
  73643. parent::__construct($iterator);
  73644. }
  73645. #[\ReturnTypeWillChange]
  73646. public function accept()
  73647. {
  73648. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  73649. return false;
  73650. }
  73651. if ($this->excludedPattern) {
  73652. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  73653. $path = str_replace('\\', '/', $path);
  73654. return !preg_match($this->excludedPattern, $path);
  73655. }
  73656. return true;
  73657. }
  73658. #[\ReturnTypeWillChange]
  73659. public function hasChildren()
  73660. {
  73661. return $this->isRecursive && $this->iterator->hasChildren();
  73662. }
  73663. #[\ReturnTypeWillChange]
  73664. public function getChildren()
  73665. {
  73666. $children = new self($this->iterator->getChildren(), []);
  73667. $children->excludedDirs = $this->excludedDirs;
  73668. $children->excludedPattern = $this->excludedPattern;
  73669. return $children;
  73670. }
  73671. }
  73672. <?php
  73673. namespace Symfony\Component\Finder\Iterator;
  73674. class FileTypeFilterIterator extends \FilterIterator
  73675. {
  73676. public const ONLY_FILES = 1;
  73677. public const ONLY_DIRECTORIES = 2;
  73678. private $mode;
  73679. public function __construct(\Iterator $iterator, int $mode)
  73680. {
  73681. $this->mode = $mode;
  73682. parent::__construct($iterator);
  73683. }
  73684. #[\ReturnTypeWillChange]
  73685. public function accept()
  73686. {
  73687. $fileinfo = $this->current();
  73688. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  73689. return false;
  73690. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  73691. return false;
  73692. }
  73693. return true;
  73694. }
  73695. }
  73696. <?php
  73697. namespace Symfony\Component\Finder\Iterator;
  73698. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  73699. {
  73700. #[\ReturnTypeWillChange]
  73701. public function accept()
  73702. {
  73703. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  73704. return true;
  73705. }
  73706. $fileinfo = $this->current();
  73707. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  73708. return false;
  73709. }
  73710. $content = $fileinfo->getContents();
  73711. if (!$content) {
  73712. return false;
  73713. }
  73714. return $this->isAccepted($content);
  73715. }
  73716. protected function toRegex(string $str)
  73717. {
  73718. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  73719. }
  73720. }
  73721. <?php
  73722. namespace Symfony\Component\Finder\Iterator;
  73723. use Symfony\Component\Finder\Glob;
  73724. class FilenameFilterIterator extends MultiplePcreFilterIterator
  73725. {
  73726. #[\ReturnTypeWillChange]
  73727. public function accept()
  73728. {
  73729. return $this->isAccepted($this->current()->getFilename());
  73730. }
  73731. protected function toRegex(string $str)
  73732. {
  73733. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  73734. }
  73735. }
  73736. <?php
  73737. namespace Symfony\Component\Finder\Iterator;
  73738. class LazyIterator implements \IteratorAggregate
  73739. {
  73740. private $iteratorFactory;
  73741. public function __construct(callable $iteratorFactory)
  73742. {
  73743. $this->iteratorFactory = $iteratorFactory;
  73744. }
  73745. public function getIterator(): \Traversable
  73746. {
  73747. yield from ($this->iteratorFactory)();
  73748. }
  73749. }
  73750. <?php
  73751. namespace Symfony\Component\Finder\Iterator;
  73752. abstract class MultiplePcreFilterIterator extends \FilterIterator
  73753. {
  73754. protected $matchRegexps = [];
  73755. protected $noMatchRegexps = [];
  73756. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  73757. {
  73758. foreach ($matchPatterns as $pattern) {
  73759. $this->matchRegexps[] = $this->toRegex($pattern);
  73760. }
  73761. foreach ($noMatchPatterns as $pattern) {
  73762. $this->noMatchRegexps[] = $this->toRegex($pattern);
  73763. }
  73764. parent::__construct($iterator);
  73765. }
  73766. protected function isAccepted(string $string)
  73767. {
  73768. foreach ($this->noMatchRegexps as $regex) {
  73769. if (preg_match($regex, $string)) {
  73770. return false;
  73771. }
  73772. }
  73773. if ($this->matchRegexps) {
  73774. foreach ($this->matchRegexps as $regex) {
  73775. if (preg_match($regex, $string)) {
  73776. return true;
  73777. }
  73778. }
  73779. return false;
  73780. }
  73781. return true;
  73782. }
  73783. protected function isRegex(string $str)
  73784. {
  73785. $availableModifiers = 'imsxuADU';
  73786. if (\PHP_VERSION_ID >= 80200) {
  73787. $availableModifiers .= 'n';
  73788. }
  73789. if (preg_match('/^(.{3,}?)['.$availableModifiers.']*$/', $str, $m)) {
  73790. $start = substr($m[1], 0, 1);
  73791. $end = substr($m[1], -1);
  73792. if ($start === $end) {
  73793. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  73794. }
  73795. foreach ([['{', '}'], ['(', ')'], ['[', ']'], ['<', '>']] as $delimiters) {
  73796. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  73797. return true;
  73798. }
  73799. }
  73800. }
  73801. return false;
  73802. }
  73803. abstract protected function toRegex(string $str);
  73804. }
  73805. <?php
  73806. namespace Symfony\Component\Finder\Iterator;
  73807. class PathFilterIterator extends MultiplePcreFilterIterator
  73808. {
  73809. #[\ReturnTypeWillChange]
  73810. public function accept()
  73811. {
  73812. $filename = $this->current()->getRelativePathname();
  73813. if ('\\' === \DIRECTORY_SEPARATOR) {
  73814. $filename = str_replace('\\', '/', $filename);
  73815. }
  73816. return $this->isAccepted($filename);
  73817. }
  73818. protected function toRegex(string $str)
  73819. {
  73820. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  73821. }
  73822. }
  73823. <?php
  73824. namespace Symfony\Component\Finder\Iterator;
  73825. use Symfony\Component\Finder\Exception\AccessDeniedException;
  73826. use Symfony\Component\Finder\SplFileInfo;
  73827. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  73828. {
  73829. private $ignoreUnreadableDirs;
  73830. private $ignoreFirstRewind = true;
  73831. private $rootPath;
  73832. private $subPath;
  73833. private $directorySeparator = '/';
  73834. public function __construct(string $path, int $flags, bool $ignoreUnreadableDirs = false)
  73835. {
  73836. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  73837. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  73838. }
  73839. parent::__construct($path, $flags);
  73840. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  73841. $this->rootPath = $path;
  73842. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  73843. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  73844. }
  73845. }
  73846. #[\ReturnTypeWillChange]
  73847. public function current()
  73848. {
  73849. if (null === $subPathname = $this->subPath) {
  73850. $subPathname = $this->subPath = $this->getSubPath();
  73851. }
  73852. if ('' !== $subPathname) {
  73853. $subPathname .= $this->directorySeparator;
  73854. }
  73855. $subPathname .= $this->getFilename();
  73856. $basePath = $this->rootPath;
  73857. if ('/' !== $basePath && !str_ends_with($basePath, $this->directorySeparator) && !str_ends_with($basePath, '/')) {
  73858. $basePath .= $this->directorySeparator;
  73859. }
  73860. return new SplFileInfo($basePath.$subPathname, $this->subPath, $subPathname);
  73861. }
  73862. #[\ReturnTypeWillChange]
  73863. public function hasChildren($allowLinks = false)
  73864. {
  73865. $hasChildren = parent::hasChildren($allowLinks);
  73866. if (!$hasChildren || !$this->ignoreUnreadableDirs) {
  73867. return $hasChildren;
  73868. }
  73869. try {
  73870. parent::getChildren();
  73871. return true;
  73872. } catch (\UnexpectedValueException $e) {
  73873. return false;
  73874. }
  73875. }
  73876. #[\ReturnTypeWillChange]
  73877. public function getChildren()
  73878. {
  73879. try {
  73880. $children = parent::getChildren();
  73881. if ($children instanceof self) {
  73882. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  73883. $children->rootPath = $this->rootPath;
  73884. }
  73885. return $children;
  73886. } catch (\UnexpectedValueException $e) {
  73887. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  73888. }
  73889. }
  73890. #[\ReturnTypeWillChange]
  73891. public function next()
  73892. {
  73893. $this->ignoreFirstRewind = false;
  73894. parent::next();
  73895. }
  73896. #[\ReturnTypeWillChange]
  73897. public function rewind()
  73898. {
  73899. if ($this->ignoreFirstRewind) {
  73900. $this->ignoreFirstRewind = false;
  73901. return;
  73902. }
  73903. parent::rewind();
  73904. }
  73905. }
  73906. <?php
  73907. namespace Symfony\Component\Finder\Iterator;
  73908. use Symfony\Component\Finder\Comparator\NumberComparator;
  73909. class SizeRangeFilterIterator extends \FilterIterator
  73910. {
  73911. private $comparators = [];
  73912. public function __construct(\Iterator $iterator, array $comparators)
  73913. {
  73914. $this->comparators = $comparators;
  73915. parent::__construct($iterator);
  73916. }
  73917. #[\ReturnTypeWillChange]
  73918. public function accept()
  73919. {
  73920. $fileinfo = $this->current();
  73921. if (!$fileinfo->isFile()) {
  73922. return true;
  73923. }
  73924. $filesize = $fileinfo->getSize();
  73925. foreach ($this->comparators as $compare) {
  73926. if (!$compare->test($filesize)) {
  73927. return false;
  73928. }
  73929. }
  73930. return true;
  73931. }
  73932. }
  73933. <?php
  73934. namespace Symfony\Component\Finder\Iterator;
  73935. class SortableIterator implements \IteratorAggregate
  73936. {
  73937. public const SORT_BY_NONE = 0;
  73938. public const SORT_BY_NAME = 1;
  73939. public const SORT_BY_TYPE = 2;
  73940. public const SORT_BY_ACCESSED_TIME = 3;
  73941. public const SORT_BY_CHANGED_TIME = 4;
  73942. public const SORT_BY_MODIFIED_TIME = 5;
  73943. public const SORT_BY_NAME_NATURAL = 6;
  73944. private $iterator;
  73945. private $sort;
  73946. public function __construct(\Traversable $iterator, $sort, bool $reverseOrder = false)
  73947. {
  73948. $this->iterator = $iterator;
  73949. $order = $reverseOrder ? -1 : 1;
  73950. if (self::SORT_BY_NAME === $sort) {
  73951. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  73952. return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
  73953. };
  73954. } elseif (self::SORT_BY_NAME_NATURAL === $sort) {
  73955. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  73956. return $order * strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
  73957. };
  73958. } elseif (self::SORT_BY_TYPE === $sort) {
  73959. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  73960. if ($a->isDir() && $b->isFile()) {
  73961. return -$order;
  73962. } elseif ($a->isFile() && $b->isDir()) {
  73963. return $order;
  73964. }
  73965. return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
  73966. };
  73967. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  73968. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  73969. return $order * ($a->getATime() - $b->getATime());
  73970. };
  73971. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  73972. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  73973. return $order * ($a->getCTime() - $b->getCTime());
  73974. };
  73975. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  73976. $this->sort = static function (\SplFileInfo $a, \SplFileInfo $b) use ($order) {
  73977. return $order * ($a->getMTime() - $b->getMTime());
  73978. };
  73979. } elseif (self::SORT_BY_NONE === $sort) {
  73980. $this->sort = $order;
  73981. } elseif (\is_callable($sort)) {
  73982. $this->sort = $reverseOrder ? static function (\SplFileInfo $a, \SplFileInfo $b) use ($sort) { return -$sort($a, $b); } : $sort;
  73983. } else {
  73984. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  73985. }
  73986. }
  73987. #[\ReturnTypeWillChange]
  73988. public function getIterator()
  73989. {
  73990. if (1 === $this->sort) {
  73991. return $this->iterator;
  73992. }
  73993. $array = iterator_to_array($this->iterator, true);
  73994. if (-1 === $this->sort) {
  73995. $array = array_reverse($array);
  73996. } else {
  73997. uasort($array, $this->sort);
  73998. }
  73999. return new \ArrayIterator($array);
  74000. }
  74001. }
  74002. <?php
  74003. namespace Symfony\Component\Finder\Iterator;
  74004. use Symfony\Component\Finder\Gitignore;
  74005. final class VcsIgnoredFilterIterator extends \FilterIterator
  74006. {
  74007. private $baseDir;
  74008. private $gitignoreFilesCache = [];
  74009. private $ignoredPathsCache = [];
  74010. public function __construct(\Iterator $iterator, string $baseDir)
  74011. {
  74012. $this->baseDir = $this->normalizePath($baseDir);
  74013. parent::__construct($iterator);
  74014. }
  74015. public function accept(): bool
  74016. {
  74017. $file = $this->current();
  74018. $fileRealPath = $this->normalizePath($file->getRealPath());
  74019. return !$this->isIgnored($fileRealPath);
  74020. }
  74021. private function isIgnored(string $fileRealPath): bool
  74022. {
  74023. if (is_dir($fileRealPath) && !str_ends_with($fileRealPath, '/')) {
  74024. $fileRealPath .= '/';
  74025. }
  74026. if (isset($this->ignoredPathsCache[$fileRealPath])) {
  74027. return $this->ignoredPathsCache[$fileRealPath];
  74028. }
  74029. $ignored = false;
  74030. foreach ($this->parentsDirectoryDownward($fileRealPath) as $parentDirectory) {
  74031. if ($this->isIgnored($parentDirectory)) {
  74032. break;
  74033. }
  74034. $fileRelativePath = substr($fileRealPath, \strlen($parentDirectory) + 1);
  74035. if (null === $regexps = $this->readGitignoreFile("{$parentDirectory}/.gitignore")) {
  74036. continue;
  74037. }
  74038. [$exclusionRegex, $inclusionRegex] = $regexps;
  74039. if (preg_match($exclusionRegex, $fileRelativePath)) {
  74040. $ignored = true;
  74041. continue;
  74042. }
  74043. if (preg_match($inclusionRegex, $fileRelativePath)) {
  74044. $ignored = false;
  74045. }
  74046. }
  74047. return $this->ignoredPathsCache[$fileRealPath] = $ignored;
  74048. }
  74049. private function parentsDirectoryDownward(string $fileRealPath): array
  74050. {
  74051. $parentDirectories = [];
  74052. $parentDirectory = $fileRealPath;
  74053. while (true) {
  74054. $newParentDirectory = \dirname($parentDirectory);
  74055. if ($newParentDirectory === $parentDirectory) {
  74056. break;
  74057. }
  74058. $parentDirectory = $newParentDirectory;
  74059. if (0 !== strpos($parentDirectory, $this->baseDir)) {
  74060. break;
  74061. }
  74062. $parentDirectories[] = $parentDirectory;
  74063. }
  74064. return array_reverse($parentDirectories);
  74065. }
  74066. private function readGitignoreFile(string $path): ?array
  74067. {
  74068. if (\array_key_exists($path, $this->gitignoreFilesCache)) {
  74069. return $this->gitignoreFilesCache[$path];
  74070. }
  74071. if (!file_exists($path)) {
  74072. return $this->gitignoreFilesCache[$path] = null;
  74073. }
  74074. if (!is_file($path) || !is_readable($path)) {
  74075. throw new \RuntimeException("The \"ignoreVCSIgnored\" option cannot be used by the Finder as the \"{$path}\" file is not readable.");
  74076. }
  74077. $gitignoreFileContent = file_get_contents($path);
  74078. return $this->gitignoreFilesCache[$path] = [
  74079. Gitignore::toRegex($gitignoreFileContent),
  74080. Gitignore::toRegexMatchingNegatedPatterns($gitignoreFileContent),
  74081. ];
  74082. }
  74083. private function normalizePath(string $path): string
  74084. {
  74085. if ('\\' === \DIRECTORY_SEPARATOR) {
  74086. return str_replace('\\', '/', $path);
  74087. }
  74088. return $path;
  74089. }
  74090. }
  74091. Copyright (c) 2004-present Fabien Potencier
  74092. Permission is hereby granted, free of charge, to any person obtaining a copy
  74093. of this software and associated documentation files (the "Software"), to deal
  74094. in the Software without restriction, including without limitation the rights
  74095. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  74096. copies of the Software, and to permit persons to whom the Software is furnished
  74097. to do so, subject to the following conditions:
  74098. The above copyright notice and this permission notice shall be included in all
  74099. copies or substantial portions of the Software.
  74100. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  74101. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  74102. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  74103. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  74104. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  74105. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  74106. THE SOFTWARE.
  74107. <?php
  74108. namespace Symfony\Component\Finder;
  74109. class SplFileInfo extends \SplFileInfo
  74110. {
  74111. private $relativePath;
  74112. private $relativePathname;
  74113. public function __construct(string $file, string $relativePath, string $relativePathname)
  74114. {
  74115. parent::__construct($file);
  74116. $this->relativePath = $relativePath;
  74117. $this->relativePathname = $relativePathname;
  74118. }
  74119. public function getRelativePath()
  74120. {
  74121. return $this->relativePath;
  74122. }
  74123. public function getRelativePathname()
  74124. {
  74125. return $this->relativePathname;
  74126. }
  74127. public function getFilenameWithoutExtension(): string
  74128. {
  74129. $filename = $this->getFilename();
  74130. return pathinfo($filename, \PATHINFO_FILENAME);
  74131. }
  74132. public function getContents()
  74133. {
  74134. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  74135. try {
  74136. $content = file_get_contents($this->getPathname());
  74137. } finally {
  74138. restore_error_handler();
  74139. }
  74140. if (false === $content) {
  74141. throw new \RuntimeException($error);
  74142. }
  74143. return $content;
  74144. }
  74145. }
  74146. <?php
  74147. namespace Symfony\Polyfill\Ctype;
  74148. final class Ctype
  74149. {
  74150. public static function ctype_alnum($text)
  74151. {
  74152. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74153. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  74154. }
  74155. public static function ctype_alpha($text)
  74156. {
  74157. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74158. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  74159. }
  74160. public static function ctype_cntrl($text)
  74161. {
  74162. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74163. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  74164. }
  74165. public static function ctype_digit($text)
  74166. {
  74167. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74168. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  74169. }
  74170. public static function ctype_graph($text)
  74171. {
  74172. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74173. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  74174. }
  74175. public static function ctype_lower($text)
  74176. {
  74177. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74178. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  74179. }
  74180. public static function ctype_print($text)
  74181. {
  74182. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74183. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  74184. }
  74185. public static function ctype_punct($text)
  74186. {
  74187. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74188. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  74189. }
  74190. public static function ctype_space($text)
  74191. {
  74192. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74193. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  74194. }
  74195. public static function ctype_upper($text)
  74196. {
  74197. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74198. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  74199. }
  74200. public static function ctype_xdigit($text)
  74201. {
  74202. $text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
  74203. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  74204. }
  74205. private static function convert_int_to_char_for_ctype($int, $function)
  74206. {
  74207. if (!\is_int($int)) {
  74208. return $int;
  74209. }
  74210. if ($int < -128 || $int > 255) {
  74211. return (string) $int;
  74212. }
  74213. if (\PHP_VERSION_ID >= 80100) {
  74214. @trigger_error($function.'(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED);
  74215. }
  74216. if ($int < 0) {
  74217. $int += 256;
  74218. }
  74219. return \chr($int);
  74220. }
  74221. }
  74222. Copyright (c) 2018-present Fabien Potencier
  74223. Permission is hereby granted, free of charge, to any person obtaining a copy
  74224. of this software and associated documentation files (the "Software"), to deal
  74225. in the Software without restriction, including without limitation the rights
  74226. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  74227. copies of the Software, and to permit persons to whom the Software is furnished
  74228. to do so, subject to the following conditions:
  74229. The above copyright notice and this permission notice shall be included in all
  74230. copies or substantial portions of the Software.
  74231. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  74232. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  74233. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  74234. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  74235. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  74236. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  74237. THE SOFTWARE.
  74238. <?php
  74239. use Symfony\Polyfill\Ctype as p;
  74240. if (\PHP_VERSION_ID >= 80000) {
  74241. return require __DIR__.'/bootstrap80.php';
  74242. }
  74243. if (!function_exists('ctype_alnum')) {
  74244. function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
  74245. }
  74246. if (!function_exists('ctype_alpha')) {
  74247. function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
  74248. }
  74249. if (!function_exists('ctype_cntrl')) {
  74250. function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
  74251. }
  74252. if (!function_exists('ctype_digit')) {
  74253. function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
  74254. }
  74255. if (!function_exists('ctype_graph')) {
  74256. function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
  74257. }
  74258. if (!function_exists('ctype_lower')) {
  74259. function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
  74260. }
  74261. if (!function_exists('ctype_print')) {
  74262. function ctype_print($text) { return p\Ctype::ctype_print($text); }
  74263. }
  74264. if (!function_exists('ctype_punct')) {
  74265. function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
  74266. }
  74267. if (!function_exists('ctype_space')) {
  74268. function ctype_space($text) { return p\Ctype::ctype_space($text); }
  74269. }
  74270. if (!function_exists('ctype_upper')) {
  74271. function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
  74272. }
  74273. if (!function_exists('ctype_xdigit')) {
  74274. function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
  74275. }
  74276. <?php
  74277. use Symfony\Polyfill\Ctype as p;
  74278. if (!function_exists('ctype_alnum')) {
  74279. function ctype_alnum(mixed $text): bool { return p\Ctype::ctype_alnum($text); }
  74280. }
  74281. if (!function_exists('ctype_alpha')) {
  74282. function ctype_alpha(mixed $text): bool { return p\Ctype::ctype_alpha($text); }
  74283. }
  74284. if (!function_exists('ctype_cntrl')) {
  74285. function ctype_cntrl(mixed $text): bool { return p\Ctype::ctype_cntrl($text); }
  74286. }
  74287. if (!function_exists('ctype_digit')) {
  74288. function ctype_digit(mixed $text): bool { return p\Ctype::ctype_digit($text); }
  74289. }
  74290. if (!function_exists('ctype_graph')) {
  74291. function ctype_graph(mixed $text): bool { return p\Ctype::ctype_graph($text); }
  74292. }
  74293. if (!function_exists('ctype_lower')) {
  74294. function ctype_lower(mixed $text): bool { return p\Ctype::ctype_lower($text); }
  74295. }
  74296. if (!function_exists('ctype_print')) {
  74297. function ctype_print(mixed $text): bool { return p\Ctype::ctype_print($text); }
  74298. }
  74299. if (!function_exists('ctype_punct')) {
  74300. function ctype_punct(mixed $text): bool { return p\Ctype::ctype_punct($text); }
  74301. }
  74302. if (!function_exists('ctype_space')) {
  74303. function ctype_space(mixed $text): bool { return p\Ctype::ctype_space($text); }
  74304. }
  74305. if (!function_exists('ctype_upper')) {
  74306. function ctype_upper(mixed $text): bool { return p\Ctype::ctype_upper($text); }
  74307. }
  74308. if (!function_exists('ctype_xdigit')) {
  74309. function ctype_xdigit(mixed $text): bool { return p\Ctype::ctype_xdigit($text); }
  74310. }
  74311. <?php
  74312. namespace Symfony\Polyfill\Intl\Grapheme;
  74313. \define('SYMFONY_GRAPHEME_CLUSTER_RX', ((float) \PCRE_VERSION < 10 ? (float) \PCRE_VERSION >= 8.32 : (float) \PCRE_VERSION >= 10.39) ? '\X' : Grapheme::GRAPHEME_CLUSTER_RX);
  74314. final class Grapheme
  74315. {
  74316. 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}])';
  74317. private const CASE_FOLD = [
  74318. ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
  74319. ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'],
  74320. ];
  74321. public static function grapheme_extract($s, $size, $type = \GRAPHEME_EXTR_COUNT, $start = 0, &$next = 0)
  74322. {
  74323. if (0 > $start) {
  74324. $start = \strlen($s) + $start;
  74325. }
  74326. if (!\is_scalar($s)) {
  74327. $hasError = false;
  74328. set_error_handler(function () use (&$hasError) { $hasError = true; });
  74329. $next = substr($s, $start);
  74330. restore_error_handler();
  74331. if ($hasError) {
  74332. substr($s, $start);
  74333. $s = '';
  74334. } else {
  74335. $s = $next;
  74336. }
  74337. } else {
  74338. $s = substr($s, $start);
  74339. }
  74340. $size = (int) $size;
  74341. $type = (int) $type;
  74342. $start = (int) $start;
  74343. if (\GRAPHEME_EXTR_COUNT !== $type && \GRAPHEME_EXTR_MAXBYTES !== $type && \GRAPHEME_EXTR_MAXCHARS !== $type) {
  74344. if (80000 > \PHP_VERSION_ID) {
  74345. return false;
  74346. }
  74347. throw new \ValueError('grapheme_extract(): Argument #3 ($type) must be one of GRAPHEME_EXTR_COUNT, GRAPHEME_EXTR_MAXBYTES, or GRAPHEME_EXTR_MAXCHARS');
  74348. }
  74349. if (!isset($s[0]) || 0 > $size || 0 > $start) {
  74350. return false;
  74351. }
  74352. if (0 === $size) {
  74353. return '';
  74354. }
  74355. $next = $start;
  74356. $s = preg_split('/('.SYMFONY_GRAPHEME_CLUSTER_RX.')/u', "\r\n".$s, $size + 1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE);
  74357. if (!isset($s[1])) {
  74358. return false;
  74359. }
  74360. $i = 1;
  74361. $ret = '';
  74362. do {
  74363. if (\GRAPHEME_EXTR_COUNT === $type) {
  74364. --$size;
  74365. } elseif (\GRAPHEME_EXTR_MAXBYTES === $type) {
  74366. $size -= \strlen($s[$i]);
  74367. } else {
  74368. $size -= iconv_strlen($s[$i], 'UTF-8//IGNORE');
  74369. }
  74370. if ($size >= 0) {
  74371. $ret .= $s[$i];
  74372. }
  74373. } while (isset($s[++$i]) && $size > 0);
  74374. $next += \strlen($ret);
  74375. return $ret;
  74376. }
  74377. public static function grapheme_strlen($s)
  74378. {
  74379. preg_replace('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', '', $s, -1, $len);
  74380. return 0 === $len && '' !== $s ? null : $len;
  74381. }
  74382. public static function grapheme_substr($s, $start, $len = null)
  74383. {
  74384. if (null === $len) {
  74385. $len = 2147483647;
  74386. }
  74387. preg_match_all('/'.SYMFONY_GRAPHEME_CLUSTER_RX.'/u', $s, $s);
  74388. $slen = \count($s[0]);
  74389. $start = (int) $start;
  74390. if (0 > $start) {
  74391. $start += $slen;
  74392. }
  74393. if (0 > $start) {
  74394. if (\PHP_VERSION_ID < 80000) {
  74395. return false;
  74396. }
  74397. $start = 0;
  74398. }
  74399. if ($start >= $slen) {
  74400. return \PHP_VERSION_ID >= 80000 ? '' : false;
  74401. }
  74402. $rem = $slen - $start;
  74403. if (0 > $len) {
  74404. $len += $rem;
  74405. }
  74406. if (0 === $len) {
  74407. return '';
  74408. }
  74409. if (0 > $len) {
  74410. return \PHP_VERSION_ID >= 80000 ? '' : false;
  74411. }
  74412. if ($len > $rem) {
  74413. $len = $rem;
  74414. }
  74415. return implode('', \array_slice($s[0], $start, $len));
  74416. }
  74417. public static function grapheme_strpos($s, $needle, $offset = 0)
  74418. {
  74419. return self::grapheme_position($s, $needle, $offset, 0);
  74420. }
  74421. public static function grapheme_stripos($s, $needle, $offset = 0)
  74422. {
  74423. return self::grapheme_position($s, $needle, $offset, 1);
  74424. }
  74425. public static function grapheme_strrpos($s, $needle, $offset = 0)
  74426. {
  74427. return self::grapheme_position($s, $needle, $offset, 2);
  74428. }
  74429. public static function grapheme_strripos($s, $needle, $offset = 0)
  74430. {
  74431. return self::grapheme_position($s, $needle, $offset, 3);
  74432. }
  74433. public static function grapheme_stristr($s, $needle, $beforeNeedle = false)
  74434. {
  74435. return mb_stristr($s, $needle, $beforeNeedle, 'UTF-8');
  74436. }
  74437. public static function grapheme_strstr($s, $needle, $beforeNeedle = false)
  74438. {
  74439. return mb_strstr($s, $needle, $beforeNeedle, 'UTF-8');
  74440. }
  74441. private static function grapheme_position($s, $needle, $offset, $mode)
  74442. {
  74443. $needle = (string) $needle;
  74444. if (80000 > \PHP_VERSION_ID && !preg_match('/./us', $needle)) {
  74445. return false;
  74446. }
  74447. $s = (string) $s;
  74448. if (!preg_match('/./us', $s)) {
  74449. return false;
  74450. }
  74451. if ($offset > 0) {
  74452. $s = self::grapheme_substr($s, $offset);
  74453. } elseif ($offset < 0) {
  74454. if (2 > $mode) {
  74455. $offset += self::grapheme_strlen($s);
  74456. $s = self::grapheme_substr($s, $offset);
  74457. if (0 > $offset) {
  74458. $offset = 0;
  74459. }
  74460. } elseif (0 > $offset += self::grapheme_strlen($needle)) {
  74461. $s = self::grapheme_substr($s, 0, $offset);
  74462. $offset = 0;
  74463. } else {
  74464. $offset = 0;
  74465. }
  74466. }
  74467. $caseInsensitive = $mode & 1;
  74468. $reverse = $mode & 2;
  74469. if ($caseInsensitive) {
  74470. $mode = \defined('MB_CASE_FOLD_SIMPLE') ? \MB_CASE_FOLD_SIMPLE : \MB_CASE_LOWER;
  74471. $s = mb_convert_case($s, $mode, 'UTF-8');
  74472. $needle = mb_convert_case($needle, $mode, 'UTF-8');
  74473. if (!\defined('MB_CASE_FOLD_SIMPLE')) {
  74474. $s = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $s);
  74475. $needle = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $needle);
  74476. }
  74477. }
  74478. if ($reverse) {
  74479. $needlePos = strrpos($s, $needle);
  74480. } else {
  74481. $needlePos = strpos($s, $needle);
  74482. }
  74483. return false !== $needlePos ? self::grapheme_strlen(substr($s, 0, $needlePos)) + $offset : false;
  74484. }
  74485. }
  74486. Copyright (c) 2015-present Fabien Potencier
  74487. Permission is hereby granted, free of charge, to any person obtaining a copy
  74488. of this software and associated documentation files (the "Software"), to deal
  74489. in the Software without restriction, including without limitation the rights
  74490. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  74491. copies of the Software, and to permit persons to whom the Software is furnished
  74492. to do so, subject to the following conditions:
  74493. The above copyright notice and this permission notice shall be included in all
  74494. copies or substantial portions of the Software.
  74495. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  74496. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  74497. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  74498. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  74499. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  74500. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  74501. THE SOFTWARE.
  74502. <?php
  74503. use Symfony\Polyfill\Intl\Grapheme as p;
  74504. if (extension_loaded('intl')) {
  74505. return;
  74506. }
  74507. if (\PHP_VERSION_ID >= 80000) {
  74508. return require __DIR__.'/bootstrap80.php';
  74509. }
  74510. if (!defined('GRAPHEME_EXTR_COUNT')) {
  74511. define('GRAPHEME_EXTR_COUNT', 0);
  74512. }
  74513. if (!defined('GRAPHEME_EXTR_MAXBYTES')) {
  74514. define('GRAPHEME_EXTR_MAXBYTES', 1);
  74515. }
  74516. if (!defined('GRAPHEME_EXTR_MAXCHARS')) {
  74517. define('GRAPHEME_EXTR_MAXCHARS', 2);
  74518. }
  74519. if (!function_exists('grapheme_extract')) {
  74520. function grapheme_extract($haystack, $size, $type = 0, $start = 0, &$next = 0) { return p\Grapheme::grapheme_extract($haystack, $size, $type, $start, $next); }
  74521. }
  74522. if (!function_exists('grapheme_stripos')) {
  74523. function grapheme_stripos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_stripos($haystack, $needle, $offset); }
  74524. }
  74525. if (!function_exists('grapheme_stristr')) {
  74526. function grapheme_stristr($haystack, $needle, $beforeNeedle = false) { return p\Grapheme::grapheme_stristr($haystack, $needle, $beforeNeedle); }
  74527. }
  74528. if (!function_exists('grapheme_strlen')) {
  74529. function grapheme_strlen($input) { return p\Grapheme::grapheme_strlen($input); }
  74530. }
  74531. if (!function_exists('grapheme_strpos')) {
  74532. function grapheme_strpos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strpos($haystack, $needle, $offset); }
  74533. }
  74534. if (!function_exists('grapheme_strripos')) {
  74535. function grapheme_strripos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strripos($haystack, $needle, $offset); }
  74536. }
  74537. if (!function_exists('grapheme_strrpos')) {
  74538. function grapheme_strrpos($haystack, $needle, $offset = 0) { return p\Grapheme::grapheme_strrpos($haystack, $needle, $offset); }
  74539. }
  74540. if (!function_exists('grapheme_strstr')) {
  74541. function grapheme_strstr($haystack, $needle, $beforeNeedle = false) { return p\Grapheme::grapheme_strstr($haystack, $needle, $beforeNeedle); }
  74542. }
  74543. if (!function_exists('grapheme_substr')) {
  74544. function grapheme_substr($string, $offset, $length = null) { return p\Grapheme::grapheme_substr($string, $offset, $length); }
  74545. }
  74546. <?php
  74547. use Symfony\Polyfill\Intl\Grapheme as p;
  74548. if (!defined('GRAPHEME_EXTR_COUNT')) {
  74549. define('GRAPHEME_EXTR_COUNT', 0);
  74550. }
  74551. if (!defined('GRAPHEME_EXTR_MAXBYTES')) {
  74552. define('GRAPHEME_EXTR_MAXBYTES', 1);
  74553. }
  74554. if (!defined('GRAPHEME_EXTR_MAXCHARS')) {
  74555. define('GRAPHEME_EXTR_MAXCHARS', 2);
  74556. }
  74557. if (!function_exists('grapheme_extract')) {
  74558. 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); }
  74559. }
  74560. if (!function_exists('grapheme_stripos')) {
  74561. function grapheme_stripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_stripos((string) $haystack, (string) $needle, (int) $offset); }
  74562. }
  74563. if (!function_exists('grapheme_stristr')) {
  74564. function grapheme_stristr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_stristr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
  74565. }
  74566. if (!function_exists('grapheme_strlen')) {
  74567. function grapheme_strlen(?string $string): int|false|null { return p\Grapheme::grapheme_strlen((string) $string); }
  74568. }
  74569. if (!function_exists('grapheme_strpos')) {
  74570. function grapheme_strpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strpos((string) $haystack, (string) $needle, (int) $offset); }
  74571. }
  74572. if (!function_exists('grapheme_strripos')) {
  74573. function grapheme_strripos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strripos((string) $haystack, (string) $needle, (int) $offset); }
  74574. }
  74575. if (!function_exists('grapheme_strrpos')) {
  74576. function grapheme_strrpos(?string $haystack, ?string $needle, ?int $offset = 0): int|false { return p\Grapheme::grapheme_strrpos((string) $haystack, (string) $needle, (int) $offset); }
  74577. }
  74578. if (!function_exists('grapheme_strstr')) {
  74579. function grapheme_strstr(?string $haystack, ?string $needle, ?bool $beforeNeedle = false): string|false { return p\Grapheme::grapheme_strstr((string) $haystack, (string) $needle, (bool) $beforeNeedle); }
  74580. }
  74581. if (!function_exists('grapheme_substr')) {
  74582. function grapheme_substr(?string $string, ?int $offset, ?int $length = null): string|false { return p\Grapheme::grapheme_substr((string) $string, (int) $offset, $length); }
  74583. }
  74584. Copyright (c) 2015-present Fabien Potencier
  74585. Permission is hereby granted, free of charge, to any person obtaining a copy
  74586. of this software and associated documentation files (the "Software"), to deal
  74587. in the Software without restriction, including without limitation the rights
  74588. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  74589. copies of the Software, and to permit persons to whom the Software is furnished
  74590. to do so, subject to the following conditions:
  74591. The above copyright notice and this permission notice shall be included in all
  74592. copies or substantial portions of the Software.
  74593. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  74594. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  74595. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  74596. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  74597. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  74598. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  74599. THE SOFTWARE.
  74600. <?php
  74601. namespace Symfony\Polyfill\Intl\Normalizer;
  74602. class Normalizer
  74603. {
  74604. public const FORM_D = \Normalizer::FORM_D;
  74605. public const FORM_KD = \Normalizer::FORM_KD;
  74606. public const FORM_C = \Normalizer::FORM_C;
  74607. public const FORM_KC = \Normalizer::FORM_KC;
  74608. public const NFD = \Normalizer::NFD;
  74609. public const NFKD = \Normalizer::NFKD;
  74610. public const NFC = \Normalizer::NFC;
  74611. public const NFKC = \Normalizer::NFKC;
  74612. private static $C;
  74613. private static $D;
  74614. private static $KD;
  74615. private static $cC;
  74616. private static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
  74617. 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";
  74618. public static function isNormalized(string $s, int $form = self::FORM_C)
  74619. {
  74620. if (!\in_array($form, [self::NFD, self::NFKD, self::NFC, self::NFKC])) {
  74621. return false;
  74622. }
  74623. if (!isset($s[strspn($s, self::$ASCII)])) {
  74624. return true;
  74625. }
  74626. if (self::NFC == $form && preg_match('//u', $s) && !preg_match('/[^\x00-\x{2FF}]/u', $s)) {
  74627. return true;
  74628. }
  74629. return self::normalize($s, $form) === $s;
  74630. }
  74631. public static function normalize(string $s, int $form = self::FORM_C)
  74632. {
  74633. if (!preg_match('//u', $s)) {
  74634. return false;
  74635. }
  74636. switch ($form) {
  74637. case self::NFC: $C = true; $K = false; break;
  74638. case self::NFD: $C = false; $K = false; break;
  74639. case self::NFKC: $C = true; $K = true; break;
  74640. case self::NFKD: $C = false; $K = true; break;
  74641. default:
  74642. if (\defined('Normalizer::NONE') && \Normalizer::NONE == $form) {
  74643. return $s;
  74644. }
  74645. if (80000 > \PHP_VERSION_ID) {
  74646. return false;
  74647. }
  74648. throw new \ValueError('normalizer_normalize(): Argument #2 ($form) must be a a valid normalization form');
  74649. }
  74650. if ('' === $s) {
  74651. return '';
  74652. }
  74653. if ($K && null === self::$KD) {
  74654. self::$KD = self::getData('compatibilityDecomposition');
  74655. }
  74656. if (null === self::$D) {
  74657. self::$D = self::getData('canonicalDecomposition');
  74658. self::$cC = self::getData('combiningClass');
  74659. }
  74660. if (null !== $mbEncoding = (2 & (int) \ini_get('mbstring.func_overload')) ? mb_internal_encoding() : null) {
  74661. mb_internal_encoding('8bit');
  74662. }
  74663. $r = self::decompose($s, $K);
  74664. if ($C) {
  74665. if (null === self::$C) {
  74666. self::$C = self::getData('canonicalComposition');
  74667. }
  74668. $r = self::recompose($r);
  74669. }
  74670. if (null !== $mbEncoding) {
  74671. mb_internal_encoding($mbEncoding);
  74672. }
  74673. return $r;
  74674. }
  74675. private static function recompose($s)
  74676. {
  74677. $ASCII = self::$ASCII;
  74678. $compMap = self::$C;
  74679. $combClass = self::$cC;
  74680. $ulenMask = self::$ulenMask;
  74681. $result = $tail = '';
  74682. $i = $s[0] < "\x80" ? 1 : $ulenMask[$s[0] & "\xF0"];
  74683. $len = \strlen($s);
  74684. $lastUchr = substr($s, 0, $i);
  74685. $lastUcls = isset($combClass[$lastUchr]) ? 256 : 0;
  74686. while ($i < $len) {
  74687. if ($s[$i] < "\x80") {
  74688. if ($tail) {
  74689. $lastUchr .= $tail;
  74690. $tail = '';
  74691. }
  74692. if ($j = strspn($s, $ASCII, $i + 1)) {
  74693. $lastUchr .= substr($s, $i, $j);
  74694. $i += $j;
  74695. }
  74696. $result .= $lastUchr;
  74697. $lastUchr = $s[$i];
  74698. $lastUcls = 0;
  74699. ++$i;
  74700. continue;
  74701. }
  74702. $ulen = $ulenMask[$s[$i] & "\xF0"];
  74703. $uchr = substr($s, $i, $ulen);
  74704. if ($lastUchr < "\xE1\x84\x80" || "\xE1\x84\x92" < $lastUchr
  74705. || $uchr < "\xE1\x85\xA1" || "\xE1\x85\xB5" < $uchr
  74706. || $lastUcls) {
  74707. $ucls = $combClass[$uchr] ?? 0;
  74708. if (isset($compMap[$lastUchr.$uchr]) && (!$lastUcls || $lastUcls < $ucls)) {
  74709. $lastUchr = $compMap[$lastUchr.$uchr];
  74710. } elseif ($lastUcls = $ucls) {
  74711. $tail .= $uchr;
  74712. } else {
  74713. if ($tail) {
  74714. $lastUchr .= $tail;
  74715. $tail = '';
  74716. }
  74717. $result .= $lastUchr;
  74718. $lastUchr = $uchr;
  74719. }
  74720. } else {
  74721. $L = \ord($lastUchr[2]) - 0x80;
  74722. $V = \ord($uchr[2]) - 0xA1;
  74723. $T = 0;
  74724. $uchr = substr($s, $i + $ulen, 3);
  74725. if ("\xE1\x86\xA7" <= $uchr && $uchr <= "\xE1\x87\x82") {
  74726. $T = \ord($uchr[2]) - 0xA7;
  74727. 0 > $T && $T += 0x40;
  74728. $ulen += 3;
  74729. }
  74730. $L = 0xAC00 + ($L * 21 + $V) * 28 + $T;
  74731. $lastUchr = \chr(0xE0 | $L >> 12).\chr(0x80 | $L >> 6 & 0x3F).\chr(0x80 | $L & 0x3F);
  74732. }
  74733. $i += $ulen;
  74734. }
  74735. return $result.$lastUchr.$tail;
  74736. }
  74737. private static function decompose($s, $c)
  74738. {
  74739. $result = '';
  74740. $ASCII = self::$ASCII;
  74741. $decompMap = self::$D;
  74742. $combClass = self::$cC;
  74743. $ulenMask = self::$ulenMask;
  74744. if ($c) {
  74745. $compatMap = self::$KD;
  74746. }
  74747. $c = [];
  74748. $i = 0;
  74749. $len = \strlen($s);
  74750. while ($i < $len) {
  74751. if ($s[$i] < "\x80") {
  74752. if ($c) {
  74753. ksort($c);
  74754. $result .= implode('', $c);
  74755. $c = [];
  74756. }
  74757. $j = 1 + strspn($s, $ASCII, $i + 1);
  74758. $result .= substr($s, $i, $j);
  74759. $i += $j;
  74760. continue;
  74761. }
  74762. $ulen = $ulenMask[$s[$i] & "\xF0"];
  74763. $uchr = substr($s, $i, $ulen);
  74764. $i += $ulen;
  74765. if ($uchr < "\xEA\xB0\x80" || "\xED\x9E\xA3" < $uchr) {
  74766. if ($uchr !== $j = $compatMap[$uchr] ?? ($decompMap[$uchr] ?? $uchr)) {
  74767. $uchr = $j;
  74768. $j = \strlen($uchr);
  74769. $ulen = $uchr[0] < "\x80" ? 1 : $ulenMask[$uchr[0] & "\xF0"];
  74770. if ($ulen != $j) {
  74771. $j -= $ulen;
  74772. $i -= $j;
  74773. if (0 > $i) {
  74774. $s = str_repeat(' ', -$i).$s;
  74775. $len -= $i;
  74776. $i = 0;
  74777. }
  74778. while ($j--) {
  74779. $s[$i + $j] = $uchr[$ulen + $j];
  74780. }
  74781. $uchr = substr($uchr, 0, $ulen);
  74782. }
  74783. }
  74784. if (isset($combClass[$uchr])) {
  74785. if (!isset($c[$combClass[$uchr]])) {
  74786. $c[$combClass[$uchr]] = '';
  74787. }
  74788. $c[$combClass[$uchr]] .= $uchr;
  74789. continue;
  74790. }
  74791. } else {
  74792. $uchr = unpack('C*', $uchr);
  74793. $j = (($uchr[1] - 224) << 12) + (($uchr[2] - 128) << 6) + $uchr[3] - 0xAC80;
  74794. $uchr = "\xE1\x84".\chr(0x80 + (int) ($j / 588))
  74795. ."\xE1\x85".\chr(0xA1 + (int) (($j % 588) / 28));
  74796. if ($j %= 28) {
  74797. $uchr .= $j < 25
  74798. ? ("\xE1\x86".\chr(0xA7 + $j))
  74799. : ("\xE1\x87".\chr(0x67 + $j));
  74800. }
  74801. }
  74802. if ($c) {
  74803. ksort($c);
  74804. $result .= implode('', $c);
  74805. $c = [];
  74806. }
  74807. $result .= $uchr;
  74808. }
  74809. if ($c) {
  74810. ksort($c);
  74811. $result .= implode('', $c);
  74812. }
  74813. return $result;
  74814. }
  74815. private static function getData($file)
  74816. {
  74817. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  74818. return require $file;
  74819. }
  74820. return false;
  74821. }
  74822. }
  74823. <?php
  74824. class Normalizer extends Symfony\Polyfill\Intl\Normalizer\Normalizer
  74825. {
  74826. public const NONE = 2;
  74827. public const FORM_D = 4;
  74828. public const FORM_KD = 8;
  74829. public const FORM_C = 16;
  74830. public const FORM_KC = 32;
  74831. public const NFD = 4;
  74832. public const NFKD = 8;
  74833. public const NFC = 16;
  74834. public const NFKC = 32;
  74835. }
  74836. <?php
  74837. return array (
  74838. 'À' => 'À',
  74839. 'A�' => '�',
  74840. 'Â' => 'Â',
  74841. 'Ã' => 'Ã',
  74842. 'Ä' => 'Ä',
  74843. 'AÌŠ' => 'Ã…',
  74844. 'Ç' => 'Ç',
  74845. 'È' => 'È',
  74846. 'E�' => 'É',
  74847. 'Ê' => 'Ê',
  74848. 'Ë' => 'Ë',
  74849. 'Ì' => 'Ì',
  74850. 'I�' => '�',
  74851. 'IÌ‚' => 'ÃŽ',
  74852. 'Ï' => '�',
  74853. 'Ñ' => 'Ñ',
  74854. 'OÌ€' => 'Ã’',
  74855. 'O�' => 'Ó',
  74856. 'Ô' => 'Ô',
  74857. 'Õ' => 'Õ',
  74858. 'Ö' => 'Ö',
  74859. 'Ù' => 'Ù',
  74860. 'U�' => 'Ú',
  74861. 'Û' => 'Û',
  74862. 'Ü' => 'Ü',
  74863. 'Y�' => '�',
  74864. 'à' => 'à',
  74865. 'a�' => 'á',
  74866. 'â' => 'â',
  74867. 'ã' => 'ã',
  74868. 'ä' => 'ä',
  74869. 'aÌŠ' => 'Ã¥',
  74870. 'ç' => 'ç',
  74871. 'è' => 'è',
  74872. 'e�' => 'é',
  74873. 'ê' => 'ê',
  74874. 'ë' => 'ë',
  74875. 'ì' => 'ì',
  74876. 'i�' => 'í',
  74877. 'î' => 'î',
  74878. 'ï' => 'ï',
  74879. 'ñ' => 'ñ',
  74880. 'ò' => 'ò',
  74881. 'o�' => 'ó',
  74882. 'ô' => 'ô',
  74883. 'õ' => 'õ',
  74884. 'ö' => 'ö',
  74885. 'ù' => 'ù',
  74886. 'u�' => 'ú',
  74887. 'û' => 'û',
  74888. 'ü' => 'ü',
  74889. 'y�' => 'ý',
  74890. 'ÿ' => 'ÿ',
  74891. 'AÌ„' => 'Ä€',
  74892. 'ā' => '�',
  74893. 'Ă' => 'Ă',
  74894. 'ă' => 'ă',
  74895. 'Ą' => 'Ą',
  74896. 'ą' => 'ą',
  74897. 'C�' => 'Ć',
  74898. 'c�' => 'ć',
  74899. 'Ĉ' => 'Ĉ',
  74900. 'ĉ' => 'ĉ',
  74901. 'Ċ' => 'Ċ',
  74902. 'ċ' => 'ċ',
  74903. 'Č' => 'Č',
  74904. 'č' => '�',
  74905. 'Ď' => 'Ď',
  74906. 'ď' => '�',
  74907. 'EÌ„' => 'Ä’',
  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. 'JÌ‚' => 'Ä´',
  74937. 'ĵ' => 'ĵ',
  74938. 'Ķ' => 'Ķ',
  74939. 'ķ' => 'ķ',
  74940. 'L�' => 'Ĺ',
  74941. 'l�' => 'ĺ',
  74942. 'Ļ' => 'Ļ',
  74943. 'ļ' => 'ļ',
  74944. 'Ľ' => 'Ľ',
  74945. 'ľ' => 'ľ',
  74946. 'N�' => 'Ń',
  74947. 'n�' => 'ń',
  74948. 'Ņ' => 'Ņ',
  74949. 'ņ' => 'ņ',
  74950. 'Ň' => 'Ň',
  74951. 'ň' => 'ň',
  74952. 'Ō' => 'Ō',
  74953. 'ō' => '�',
  74954. 'Ŏ' => 'Ŏ',
  74955. 'ŏ' => '�',
  74956. 'Ő' => '�',
  74957. 'ő' => 'ő',
  74958. 'R�' => 'Ŕ',
  74959. 'r�' => 'ŕ',
  74960. 'Ŗ' => 'Ŗ',
  74961. 'ŗ' => 'ŗ',
  74962. 'Ř' => 'Ř',
  74963. 'ř' => 'ř',
  74964. 'S�' => 'Ś',
  74965. 's�' => 'ś',
  74966. 'Ŝ' => 'Ŝ',
  74967. 'ŝ' => '�',
  74968. 'Ş' => 'Ş',
  74969. 'ş' => 'ş',
  74970. 'Š' => 'Š',
  74971. 'š' => 'š',
  74972. 'Ţ' => 'Ţ',
  74973. 'ţ' => 'ţ',
  74974. 'Ť' => 'Ť',
  74975. 'ť' => 'ť',
  74976. 'Ũ' => 'Ũ',
  74977. 'ũ' => 'ũ',
  74978. 'Ū' => 'Ū',
  74979. 'ū' => 'ū',
  74980. 'Ŭ' => 'Ŭ',
  74981. 'ŭ' => 'ŭ',
  74982. 'UÌŠ' => 'Å®',
  74983. 'ů' => 'ů',
  74984. 'Ű' => 'Ű',
  74985. 'ű' => 'ű',
  74986. 'Ų' => 'Ų',
  74987. 'ų' => 'ų',
  74988. 'WÌ‚' => 'Å´',
  74989. 'ŵ' => 'ŵ',
  74990. 'Ŷ' => 'Ŷ',
  74991. 'ŷ' => 'ŷ',
  74992. 'Ÿ' => 'Ÿ',
  74993. 'Z�' => 'Ź',
  74994. 'z�' => 'ź',
  74995. 'Ż' => 'Ż',
  74996. 'ż' => 'ż',
  74997. 'Ž' => 'Ž',
  74998. 'ž' => 'ž',
  74999. 'OÌ›' => 'Æ ',
  75000. 'oÌ›' => 'Æ¡',
  75001. 'Ư' => 'Ư',
  75002. 'ư' => 'ư',
  75003. 'Ǎ' => '�',
  75004. 'ǎ' => 'ǎ',
  75005. 'Ǐ' => '�',
  75006. 'ǐ' => '�',
  75007. 'Ǒ' => 'Ǒ',
  75008. 'ǒ' => 'ǒ',
  75009. 'Ǔ' => 'Ǔ',
  75010. 'ǔ' => 'ǔ',
  75011. 'Ǖ' => 'Ǖ',
  75012. 'ǖ' => 'ǖ',
  75013. 'Ü�' => 'Ǘ',
  75014. 'ü�' => 'ǘ',
  75015. 'Ǚ' => 'Ǚ',
  75016. 'ǚ' => 'ǚ',
  75017. 'Ǜ' => 'Ǜ',
  75018. 'ǜ' => 'ǜ',
  75019. 'Ǟ' => 'Ǟ',
  75020. 'ǟ' => 'ǟ',
  75021. 'Ǡ' => 'Ǡ',
  75022. 'ǡ' => 'ǡ',
  75023. 'Ǣ' => 'Ǣ',
  75024. 'ǣ' => 'ǣ',
  75025. 'Ǧ' => 'Ǧ',
  75026. 'ǧ' => 'ǧ',
  75027. 'Ǩ' => 'Ǩ',
  75028. 'ǩ' => 'ǩ',
  75029. 'Ǫ' => 'Ǫ',
  75030. 'ǫ' => 'ǫ',
  75031. 'Ǭ' => 'Ǭ',
  75032. 'ǭ' => 'ǭ',
  75033. 'Ǯ' => 'Ǯ',
  75034. 'ǯ' => 'ǯ',
  75035. 'ǰ' => 'ǰ',
  75036. 'G�' => 'Ǵ',
  75037. 'g�' => 'ǵ',
  75038. 'Ǹ' => 'Ǹ',
  75039. 'ǹ' => 'ǹ',
  75040. 'Å�' => 'Ǻ',
  75041. 'å�' => 'ǻ',
  75042. 'Æ�' => 'Ǽ',
  75043. 'æ�' => 'ǽ',
  75044. 'Ø�' => 'Ǿ',
  75045. 'ø�' => 'ǿ',
  75046. 'A�' => 'Ȁ',
  75047. 'a�' => '�',
  75048. 'AÌ‘' => 'È‚',
  75049. 'ȃ' => 'ȃ',
  75050. 'E�' => 'Ȅ',
  75051. 'e�' => 'ȅ',
  75052. 'Ȇ' => 'Ȇ',
  75053. 'ȇ' => 'ȇ',
  75054. 'I�' => 'Ȉ',
  75055. 'i�' => 'ȉ',
  75056. 'IÌ‘' => 'ÈŠ',
  75057. 'ȋ' => 'ȋ',
  75058. 'O�' => 'Ȍ',
  75059. 'o�' => '�',
  75060. 'OÌ‘' => 'ÈŽ',
  75061. 'ȏ' => '�',
  75062. 'R�' => '�',
  75063. 'r�' => 'ȑ',
  75064. 'RÌ‘' => 'È’',
  75065. 'ȓ' => 'ȓ',
  75066. 'U�' => 'Ȕ',
  75067. 'u�' => 'ȕ',
  75068. 'UÌ‘' => 'È–',
  75069. 'ȗ' => 'ȗ',
  75070. 'Ș' => 'Ș',
  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. 'Ḃ' => 'Ḃ',
  75213. 'ḃ' => 'ḃ',
  75214. 'Ḅ' => 'Ḅ',
  75215. 'ḅ' => 'ḅ',
  75216. 'Ḇ' => 'Ḇ',
  75217. 'ḇ' => 'ḇ',
  75218. 'Ç�' => 'Ḉ',
  75219. 'ç�' => 'ḉ',
  75220. 'Ḋ' => 'Ḋ',
  75221. 'ḋ' => 'ḋ',
  75222. 'Ḍ' => 'Ḍ',
  75223. 'ḍ' => '�',
  75224. 'Ḏ' => 'Ḏ',
  75225. 'ḏ' => '�',
  75226. 'Ḑ' => '�',
  75227. 'ḑ' => 'ḑ',
  75228. 'Ḓ' => 'Ḓ',
  75229. 'ḓ' => 'ḓ',
  75230. 'Ḕ' => 'Ḕ',
  75231. 'ḕ' => 'ḕ',
  75232. 'Ē�' => 'Ḗ',
  75233. 'ē�' => 'ḗ',
  75234. 'Ḙ' => 'Ḙ',
  75235. 'ḙ' => 'ḙ',
  75236. 'Ḛ' => 'Ḛ',
  75237. 'ḛ' => 'ḛ',
  75238. 'Ḝ' => 'Ḝ',
  75239. 'ḝ' => '�',
  75240. 'Ḟ' => 'Ḟ',
  75241. 'ḟ' => 'ḟ',
  75242. 'Ḡ' => 'Ḡ',
  75243. 'ḡ' => 'ḡ',
  75244. 'Ḣ' => 'Ḣ',
  75245. 'ḣ' => 'ḣ',
  75246. 'Ḥ' => 'Ḥ',
  75247. 'ḥ' => 'ḥ',
  75248. 'Ḧ' => 'Ḧ',
  75249. 'ḧ' => 'ḧ',
  75250. 'Ḩ' => 'Ḩ',
  75251. 'ḩ' => 'ḩ',
  75252. 'Ḫ' => 'Ḫ',
  75253. 'ḫ' => 'ḫ',
  75254. 'Ḭ' => 'Ḭ',
  75255. 'ḭ' => 'ḭ',
  75256. '��' => 'Ḯ',
  75257. 'ï�' => 'ḯ',
  75258. 'K�' => 'Ḱ',
  75259. 'k�' => 'ḱ',
  75260. 'Ḳ' => 'Ḳ',
  75261. 'ḳ' => 'ḳ',
  75262. 'Ḵ' => 'Ḵ',
  75263. 'ḵ' => 'ḵ',
  75264. 'Ḷ' => 'Ḷ',
  75265. 'ḷ' => 'ḷ',
  75266. 'Ḹ' => 'Ḹ',
  75267. 'ḹ' => 'ḹ',
  75268. 'Ḻ' => 'Ḻ',
  75269. 'ḻ' => 'ḻ',
  75270. 'Ḽ' => 'Ḽ',
  75271. 'ḽ' => 'ḽ',
  75272. 'M�' => 'Ḿ',
  75273. 'm�' => 'ḿ',
  75274. 'Ṁ' => 'Ṁ',
  75275. 'ṁ' => '�',
  75276. 'Ṃ' => 'Ṃ',
  75277. 'ṃ' => 'ṃ',
  75278. 'Ṅ' => 'Ṅ',
  75279. 'ṅ' => 'ṅ',
  75280. 'Ṇ' => 'Ṇ',
  75281. 'ṇ' => 'ṇ',
  75282. 'Ṉ' => 'Ṉ',
  75283. 'ṉ' => 'ṉ',
  75284. 'Ṋ' => 'Ṋ',
  75285. 'ṋ' => 'ṋ',
  75286. 'Õ�' => 'Ṍ',
  75287. 'õ�' => '�',
  75288. 'Ṏ' => 'Ṏ',
  75289. 'ṏ' => '�',
  75290. 'Ṑ' => '�',
  75291. '�̀' => 'ṑ',
  75292. 'Ō�' => 'Ṓ',
  75293. '��' => 'ṓ',
  75294. 'P�' => 'Ṕ',
  75295. 'p�' => 'ṕ',
  75296. 'Ṗ' => 'Ṗ',
  75297. 'ṗ' => 'ṗ',
  75298. 'Ṙ' => 'Ṙ',
  75299. 'ṙ' => 'ṙ',
  75300. 'Ṛ' => 'Ṛ',
  75301. 'ṛ' => 'ṛ',
  75302. 'Ṝ' => 'Ṝ',
  75303. 'ṝ' => '�',
  75304. 'Ṟ' => 'Ṟ',
  75305. 'ṟ' => 'ṟ',
  75306. 'Ṡ' => 'Ṡ',
  75307. 'ṡ' => 'ṡ',
  75308. 'SÌ£' => 'á¹¢',
  75309. 'ṣ' => 'ṣ',
  75310. 'Ṥ' => 'Ṥ',
  75311. 'ṥ' => 'ṥ',
  75312. 'Ṧ' => 'Ṧ',
  75313. 'ṧ' => 'ṧ',
  75314. 'Ṩ' => 'Ṩ',
  75315. 'ṩ' => 'ṩ',
  75316. 'Ṫ' => 'Ṫ',
  75317. 'ṫ' => 'ṫ',
  75318. 'Ṭ' => 'Ṭ',
  75319. 'ṭ' => 'ṭ',
  75320. 'Ṯ' => 'Ṯ',
  75321. 'ṯ' => 'ṯ',
  75322. 'TÌ­' => 'á¹°',
  75323. 'tÌ­' => 'á¹±',
  75324. 'Ṳ' => 'Ṳ',
  75325. 'ṳ' => 'ṳ',
  75326. 'Ṵ' => 'Ṵ',
  75327. 'ṵ' => 'ṵ',
  75328. 'UÌ­' => 'á¹¶',
  75329. 'uÌ­' => 'á¹·',
  75330. 'Ũ�' => 'Ṹ',
  75331. 'ũ�' => 'ṹ',
  75332. 'Ṻ' => 'Ṻ',
  75333. 'ṻ' => 'ṻ',
  75334. 'Ṽ' => 'Ṽ',
  75335. 'ṽ' => 'ṽ',
  75336. 'VÌ£' => 'á¹¾',
  75337. 'ṿ' => 'ṿ',
  75338. 'Ẁ' => 'Ẁ',
  75339. 'ẁ' => '�',
  75340. 'W�' => 'Ẃ',
  75341. 'w�' => 'ẃ',
  75342. 'Ẅ' => 'Ẅ',
  75343. 'ẅ' => 'ẅ',
  75344. 'Ẇ' => 'Ẇ',
  75345. 'ẇ' => 'ẇ',
  75346. 'Ẉ' => 'Ẉ',
  75347. 'ẉ' => 'ẉ',
  75348. 'Ẋ' => 'Ẋ',
  75349. 'ẋ' => 'ẋ',
  75350. 'Ẍ' => 'Ẍ',
  75351. 'ẍ' => '�',
  75352. 'Ẏ' => 'Ẏ',
  75353. 'ẏ' => '�',
  75354. 'Ẑ' => '�',
  75355. 'ẑ' => 'ẑ',
  75356. 'Ẓ' => 'Ẓ',
  75357. 'ẓ' => 'ẓ',
  75358. 'Ẕ' => 'Ẕ',
  75359. 'ẕ' => 'ẕ',
  75360. 'ẖ' => 'ẖ',
  75361. 'ẗ' => 'ẗ',
  75362. 'ẘ' => 'ẘ',
  75363. 'ẙ' => 'ẙ',
  75364. 'ẛ' => 'ẛ',
  75365. 'Ạ' => 'Ạ',
  75366. 'ạ' => 'ạ',
  75367. 'Ả' => 'Ả',
  75368. 'ả' => 'ả',
  75369. 'Â�' => 'Ấ',
  75370. 'â�' => 'ấ',
  75371. 'Ầ' => 'Ầ',
  75372. 'ầ' => 'ầ',
  75373. 'Ẩ' => 'Ẩ',
  75374. 'ẩ' => 'ẩ',
  75375. 'Ẫ' => 'Ẫ',
  75376. 'ẫ' => 'ẫ',
  75377. 'Ậ' => 'Ậ',
  75378. 'ậ' => 'ậ',
  75379. 'Ă�' => 'Ắ',
  75380. 'ă�' => 'ắ',
  75381. 'Ằ' => 'Ằ',
  75382. 'ằ' => 'ằ',
  75383. 'Ẳ' => 'Ẳ',
  75384. 'ẳ' => 'ẳ',
  75385. 'Ẵ' => 'Ẵ',
  75386. 'ẵ' => 'ẵ',
  75387. 'Ặ' => 'Ặ',
  75388. 'ặ' => 'ặ',
  75389. 'Ẹ' => 'Ẹ',
  75390. 'ẹ' => 'ẹ',
  75391. 'Ẻ' => 'Ẻ',
  75392. 'ẻ' => 'ẻ',
  75393. 'Ẽ' => 'Ẽ',
  75394. 'ẽ' => 'ẽ',
  75395. 'Ê�' => 'Ế',
  75396. 'ê�' => 'ế',
  75397. 'Ề' => 'Ề',
  75398. 'ề' => '�',
  75399. 'Ể' => 'Ể',
  75400. 'ể' => 'ể',
  75401. 'Ễ' => 'Ễ',
  75402. 'ễ' => 'ễ',
  75403. 'Ệ' => 'Ệ',
  75404. 'ệ' => 'ệ',
  75405. 'Ỉ' => 'Ỉ',
  75406. 'ỉ' => 'ỉ',
  75407. 'Ị' => 'Ị',
  75408. 'ị' => 'ị',
  75409. 'Ọ' => 'Ọ',
  75410. 'ọ' => '�',
  75411. 'Ỏ' => 'Ỏ',
  75412. 'ỏ' => '�',
  75413. 'Ô�' => '�',
  75414. 'ô�' => 'ố',
  75415. 'Ồ' => 'Ồ',
  75416. 'ồ' => 'ồ',
  75417. 'Ổ' => 'Ổ',
  75418. 'ổ' => 'ổ',
  75419. 'Ỗ' => 'Ỗ',
  75420. 'ỗ' => 'ỗ',
  75421. 'Ộ' => 'Ộ',
  75422. '�̂' => 'ộ',
  75423. 'Ơ�' => 'Ớ',
  75424. 'ơ�' => 'ớ',
  75425. 'Ờ' => 'Ờ',
  75426. 'ờ' => '�',
  75427. 'Ở' => 'Ở',
  75428. 'ở' => 'ở',
  75429. 'Ỡ' => 'Ỡ',
  75430. 'ỡ' => 'ỡ',
  75431. 'Ợ' => 'Ợ',
  75432. 'ợ' => 'ợ',
  75433. 'Ụ' => 'Ụ',
  75434. 'ụ' => 'ụ',
  75435. 'Ủ' => 'Ủ',
  75436. 'ủ' => 'ủ',
  75437. 'Ư�' => 'Ứ',
  75438. 'ư�' => 'ứ',
  75439. 'Ừ' => 'Ừ',
  75440. 'ừ' => 'ừ',
  75441. 'Ử' => 'Ử',
  75442. 'ử' => 'ử',
  75443. 'Ữ' => 'Ữ',
  75444. 'ữ' => 'ữ',
  75445. 'Ự' => 'Ự',
  75446. 'ự' => 'ự',
  75447. 'Ỳ' => 'Ỳ',
  75448. 'ỳ' => 'ỳ',
  75449. 'YÌ£' => 'á»´',
  75450. 'ỵ' => 'ỵ',
  75451. 'Ỷ' => 'Ỷ',
  75452. 'ỷ' => 'ỷ',
  75453. 'Ỹ' => 'Ỹ',
  75454. 'ỹ' => 'ỹ',
  75455. 'ἀ' => 'ἀ',
  75456. 'ἁ' => '�',
  75457. 'ἂ' => 'ἂ',
  75458. '�̀' => 'ἃ',
  75459. 'ἀ�' => 'ἄ',
  75460. '��' => 'ἅ',
  75461. 'ἆ' => 'ἆ',
  75462. '�͂' => 'ἇ',
  75463. 'Ἀ' => 'Ἀ',
  75464. 'Ἁ' => 'Ἁ',
  75465. 'Ἂ' => 'Ἂ',
  75466. 'Ἃ' => 'Ἃ',
  75467. 'Ἀ�' => 'Ἄ',
  75468. 'Ἁ�' => '�',
  75469. 'Ἆ' => 'Ἆ',
  75470. 'Ἇ' => '�',
  75471. 'ἐ' => '�',
  75472. 'ἑ' => 'ἑ',
  75473. '�̀' => 'ἒ',
  75474. 'ἓ' => 'ἓ',
  75475. '��' => 'ἔ',
  75476. 'ἑ�' => 'ἕ',
  75477. 'Ἐ' => 'Ἐ',
  75478. 'Ἑ' => 'Ἑ',
  75479. 'Ἒ' => 'Ἒ',
  75480. 'Ἓ' => 'Ἓ',
  75481. 'Ἐ�' => 'Ἔ',
  75482. 'Ἑ�' => '�',
  75483. 'ἠ' => 'ἠ',
  75484. 'ἡ' => 'ἡ',
  75485. 'ἢ' => 'ἢ',
  75486. 'ἣ' => 'ἣ',
  75487. 'ἠ�' => 'ἤ',
  75488. 'ἡ�' => 'ἥ',
  75489. 'ἦ' => 'ἦ',
  75490. 'ἧ' => 'ἧ',
  75491. 'Ἠ' => 'Ἠ',
  75492. 'Ἡ' => 'Ἡ',
  75493. 'Ἢ' => 'Ἢ',
  75494. 'Ἣ' => 'Ἣ',
  75495. 'Ἠ�' => 'Ἤ',
  75496. 'Ἡ�' => 'Ἥ',
  75497. 'Ἦ' => 'Ἦ',
  75498. 'Ἧ' => 'Ἧ',
  75499. 'ἰ' => 'ἰ',
  75500. 'ἱ' => 'ἱ',
  75501. 'á¼°Ì€' => 'á¼²',
  75502. 'ἳ' => 'ἳ',
  75503. 'ἰ�' => 'ἴ',
  75504. 'ἱ�' => 'ἵ',
  75505. 'á¼°Í‚' => 'á¼¶',
  75506. 'ἷ' => 'ἷ',
  75507. 'Ἰ' => 'Ἰ',
  75508. 'Ἱ' => 'Ἱ',
  75509. 'Ἲ' => 'Ἲ',
  75510. 'Ἳ' => 'Ἳ',
  75511. 'Ἰ�' => 'Ἴ',
  75512. 'Ἱ�' => 'Ἵ',
  75513. 'Ἶ' => 'Ἶ',
  75514. 'Ἷ' => 'Ἷ',
  75515. 'ὀ' => 'ὀ',
  75516. 'ὁ' => '�',
  75517. 'ὂ' => 'ὂ',
  75518. '�̀' => 'ὃ',
  75519. 'ὀ�' => 'ὄ',
  75520. '��' => 'ὅ',
  75521. 'Ὀ' => 'Ὀ',
  75522. 'Ὁ' => 'Ὁ',
  75523. 'Ὂ' => 'Ὂ',
  75524. 'Ὃ' => 'Ὃ',
  75525. 'Ὀ�' => 'Ὄ',
  75526. 'Ὁ�' => '�',
  75527. 'ὐ' => '�',
  75528. 'ὑ' => 'ὑ',
  75529. '�̀' => 'ὒ',
  75530. 'ὓ' => 'ὓ',
  75531. '��' => 'ὔ',
  75532. 'ὑ�' => 'ὕ',
  75533. '�͂' => 'ὖ',
  75534. 'ὗ' => 'ὗ',
  75535. 'Ὑ' => 'Ὑ',
  75536. 'Ὓ' => 'Ὓ',
  75537. 'Ὑ�' => '�',
  75538. 'Ὗ' => 'Ὗ',
  75539. 'ὠ' => 'ὠ',
  75540. 'ὡ' => 'ὡ',
  75541. 'ὢ' => 'ὢ',
  75542. 'ὣ' => 'ὣ',
  75543. 'ὠ�' => 'ὤ',
  75544. 'ὡ�' => 'ὥ',
  75545. 'ὦ' => 'ὦ',
  75546. 'ὧ' => 'ὧ',
  75547. 'Ὠ' => 'Ὠ',
  75548. 'Ὡ' => 'Ὡ',
  75549. 'Ὢ' => 'Ὢ',
  75550. 'Ὣ' => 'Ὣ',
  75551. 'Ὠ�' => 'Ὤ',
  75552. 'Ὡ�' => 'Ὥ',
  75553. 'Ὦ' => 'Ὦ',
  75554. 'Ὧ' => 'Ὧ',
  75555. 'ὰ' => 'ὰ',
  75556. 'ὲ' => 'ὲ',
  75557. 'ὴ' => 'ὴ',
  75558. 'ὶ' => 'ὶ',
  75559. 'ὸ' => 'ὸ',
  75560. 'ὺ' => 'ὺ',
  75561. 'ὼ' => 'ὼ',
  75562. 'ᾀ' => 'ᾀ',
  75563. '�ͅ' => '�',
  75564. 'ᾂ' => 'ᾂ',
  75565. 'ᾃ' => 'ᾃ',
  75566. 'ᾄ' => 'ᾄ',
  75567. 'á¼…Í…' => 'á¾…',
  75568. 'ᾆ' => 'ᾆ',
  75569. 'ᾇ' => 'ᾇ',
  75570. 'ᾈ' => 'ᾈ',
  75571. 'ᾉ' => 'ᾉ',
  75572. 'ᾊ' => 'ᾊ',
  75573. 'ᾋ' => 'ᾋ',
  75574. 'ᾌ' => 'ᾌ',
  75575. '�ͅ' => '�',
  75576. 'ᾎ' => 'ᾎ',
  75577. '�ͅ' => '�',
  75578. 'ᾐ' => '�',
  75579. 'ᾑ' => 'ᾑ',
  75580. 'ᾒ' => 'ᾒ',
  75581. 'ᾓ' => 'ᾓ',
  75582. 'ᾔ' => 'ᾔ',
  75583. 'ᾕ' => 'ᾕ',
  75584. 'ᾖ' => 'ᾖ',
  75585. 'á¼§Í…' => 'á¾—',
  75586. 'ᾘ' => 'ᾘ',
  75587. 'ᾙ' => 'ᾙ',
  75588. 'ᾚ' => 'ᾚ',
  75589. 'ᾛ' => 'ᾛ',
  75590. 'ᾜ' => 'ᾜ',
  75591. 'ᾝ' => '�',
  75592. 'ᾞ' => 'ᾞ',
  75593. 'ᾟ' => 'ᾟ',
  75594. 'á½ Í…' => 'á¾ ',
  75595. 'ᾡ' => 'ᾡ',
  75596. 'ᾢ' => 'ᾢ',
  75597. 'ᾣ' => 'ᾣ',
  75598. 'ᾤ' => 'ᾤ',
  75599. 'ᾥ' => 'ᾥ',
  75600. 'ᾦ' => 'ᾦ',
  75601. 'á½§Í…' => 'á¾§',
  75602. 'ᾨ' => 'ᾨ',
  75603. 'ᾩ' => 'ᾩ',
  75604. 'ᾪ' => 'ᾪ',
  75605. 'ᾫ' => 'ᾫ',
  75606. 'ᾬ' => 'ᾬ',
  75607. 'á½­Í…' => 'á¾­',
  75608. 'ᾮ' => 'ᾮ',
  75609. 'ᾯ' => 'ᾯ',
  75610. 'ᾰ' => 'ᾰ',
  75611. 'ᾱ' => 'ᾱ',
  75612. 'á½°Í…' => 'á¾²',
  75613. 'ᾳ' => 'ᾳ',
  75614. 'ᾴ' => 'ᾴ',
  75615. 'ᾶ' => 'ᾶ',
  75616. 'á¾¶Í…' => 'á¾·',
  75617. 'Ᾰ' => 'Ᾰ',
  75618. 'Ᾱ' => 'Ᾱ',
  75619. 'Ὰ' => 'Ὰ',
  75620. 'ᾼ' => 'ᾼ',
  75621. '῁' => '�',
  75622. 'á½´Í…' => 'á¿‚',
  75623. 'ῃ' => 'ῃ',
  75624. 'ῄ' => 'ῄ',
  75625. 'ῆ' => 'ῆ',
  75626. 'ῇ' => 'ῇ',
  75627. 'Ὲ' => 'Ὲ',
  75628. 'Ὴ' => 'Ὴ',
  75629. 'ῌ' => 'ῌ',
  75630. '῍' => '�',
  75631. '᾿�' => '῎',
  75632. '῏' => '�',
  75633. 'ῐ' => '�',
  75634. 'ῑ' => 'ῑ',
  75635. 'ÏŠÌ€' => 'á¿’',
  75636. 'ῖ' => 'ῖ',
  75637. 'ÏŠÍ‚' => 'á¿—',
  75638. 'Ῐ' => 'Ῐ',
  75639. 'Ῑ' => 'Ῑ',
  75640. 'Ὶ' => 'Ὶ',
  75641. '῝' => '�',
  75642. '῾�' => '῞',
  75643. '῟' => '῟',
  75644. 'ῠ' => 'ῠ',
  75645. 'Ï…Ì„' => 'á¿¡',
  75646. 'ῢ' => 'ῢ',
  75647. '�̓' => 'ῤ',
  75648. '�̔' => 'ῥ',
  75649. 'ῦ' => 'ῦ',
  75650. 'ῧ' => 'ῧ',
  75651. 'Ῠ' => 'Ῠ',
  75652. 'Ῡ' => 'Ῡ',
  75653. 'Ὺ' => 'Ὺ',
  75654. 'Ῥ' => 'Ῥ',
  75655. '῭' => '῭',
  75656. 'ῲ' => 'ῲ',
  75657. 'ῳ' => 'ῳ',
  75658. 'ÏŽÍ…' => 'á¿´',
  75659. 'ῶ' => 'ῶ',
  75660. 'á¿¶Í…' => 'á¿·',
  75661. 'Ὸ' => 'Ὸ',
  75662. 'Ὼ' => 'Ὼ',
  75663. 'ῼ' => 'ῼ',
  75664. '�̸' => '↚',
  75665. '↛' => '↛',
  75666. '↮' => '↮',
  75667. '�̸' => '�',
  75668. '⇎' => '⇎',
  75669. '⇏' => '�',
  75670. '∄' => '∄',
  75671. '∉' => '∉',
  75672. '∌' => '∌',
  75673. '∤' => '∤',
  75674. '∦' => '∦',
  75675. '≁' => '�',
  75676. '≄' => '≄',
  75677. '≇' => '≇',
  75678. '≉' => '≉',
  75679. '≠' => '≠',
  75680. '≢' => '≢',
  75681. '�̸' => '≭',
  75682. '≮' => '≮',
  75683. '≯' => '≯',
  75684. '≰' => '≰',
  75685. '≱' => '≱',
  75686. '≴' => '≴',
  75687. '≵' => '≵',
  75688. '≸' => '≸',
  75689. '≹' => '≹',
  75690. '⊀' => '⊀',
  75691. '⊁' => '�',
  75692. '⊄' => '⊄',
  75693. '⊅' => '⊅',
  75694. '⊈' => '⊈',
  75695. '⊉' => '⊉',
  75696. '⊬' => '⊬',
  75697. '⊭' => '⊭',
  75698. '⊮' => '⊮',
  75699. '⊯' => '⊯',
  75700. '⋠' => '⋠',
  75701. '⋡' => '⋡',
  75702. '⋢' => '⋢',
  75703. '⋣' => '⋣',
  75704. '⋪' => '⋪',
  75705. '⋫' => '⋫',
  75706. '⋬' => '⋬',
  75707. '⋭' => '⋭',
  75708. '�゙' => '�',
  75709. '�゙' => '�',
  75710. '�゙' => '�',
  75711. '�゙' => '�',
  75712. '�゙' => '�',
  75713. '�゙' => '�',
  75714. '�゙' => '�',
  75715. '�゙' => '�',
  75716. '�゙' => '�',
  75717. '�゙' => '�',
  75718. '�゙' => '�',
  75719. '�゙' => '�',
  75720. '�゙' => '�',
  75721. '�゙' => '�',
  75722. '�゙' => '�',
  75723. '�゙' => '�',
  75724. '�゚' => '�',
  75725. '�゙' => '�',
  75726. '�゚' => '�',
  75727. '�゙' => '�',
  75728. '�゚' => '�',
  75729. '�゙' => '�',
  75730. '�゚' => '�',
  75731. '�゙' => '�',
  75732. '�゚' => '�',
  75733. '�゙' => 'ゔ',
  75734. '�゙' => 'ゞ',
  75735. 'ガ' => 'ガ',
  75736. 'ã‚­ã‚™' => 'ã‚®',
  75737. 'グ' => 'グ',
  75738. 'ゲ' => 'ゲ',
  75739. 'ゴ' => 'ゴ',
  75740. 'ザ' => 'ザ',
  75741. 'ジ' => 'ジ',
  75742. 'ズ' => 'ズ',
  75743. 'ゼ' => 'ゼ',
  75744. 'ゾ' => 'ゾ',
  75745. 'ダ' => 'ダ',
  75746. '�゙' => 'ヂ',
  75747. 'ヅ' => 'ヅ',
  75748. 'デ' => 'デ',
  75749. 'ド' => 'ド',
  75750. '�゙' => '�',
  75751. '�゚' => 'パ',
  75752. 'ビ' => 'ビ',
  75753. 'ピ' => 'ピ',
  75754. 'ブ' => 'ブ',
  75755. 'プ' => 'プ',
  75756. 'ベ' => 'ベ',
  75757. 'ペ' => 'ペ',
  75758. 'ボ' => 'ボ',
  75759. 'ポ' => '�',
  75760. 'ヴ' => 'ヴ',
  75761. 'ヷ' => 'ヷ',
  75762. 'ヸ' => 'ヸ',
  75763. 'ヹ' => 'ヹ',
  75764. 'ヺ' => 'ヺ',
  75765. 'ヾ' => 'ヾ',
  75766. '𑂚' => '𑂚',
  75767. '𑂜' => '𑂜',
  75768. '𑂫' => '𑂫',
  75769. '𑄮' => '𑄮',
  75770. '𑄯' => '𑄯',
  75771. '�𑌾' => '�',
  75772. '��' => '�',
  75773. '𑒻' => '𑒻',
  75774. '𑒼' => '𑒼',
  75775. '𑒾' => '𑒾',
  75776. '𑖺' => '𑖺',
  75777. '𑖻' => '𑖻',
  75778. '𑤸' => '𑤸',
  75779. );
  75780. <?php
  75781. return array (
  75782. 'À' => 'À',
  75783. '�' => 'A�',
  75784. 'Â' => 'Â',
  75785. 'Ã' => 'Ã',
  75786. 'Ä' => 'Ä',
  75787. 'Ã…' => 'AÌŠ',
  75788. 'Ç' => 'Ç',
  75789. 'È' => 'È',
  75790. 'É' => 'E�',
  75791. 'Ê' => 'Ê',
  75792. 'Ë' => 'Ë',
  75793. 'Ì' => 'Ì',
  75794. '�' => 'I�',
  75795. 'ÃŽ' => 'IÌ‚',
  75796. '�' => 'Ï',
  75797. 'Ñ' => 'Ñ',
  75798. 'Ã’' => 'OÌ€',
  75799. 'Ó' => 'O�',
  75800. 'Ô' => 'Ô',
  75801. 'Õ' => 'Õ',
  75802. 'Ö' => 'Ö',
  75803. 'Ù' => 'Ù',
  75804. 'Ú' => 'U�',
  75805. 'Û' => 'Û',
  75806. 'Ü' => 'Ü',
  75807. '�' => 'Y�',
  75808. 'à' => 'à',
  75809. 'á' => 'a�',
  75810. 'â' => 'â',
  75811. 'ã' => 'ã',
  75812. 'ä' => 'ä',
  75813. 'Ã¥' => 'aÌŠ',
  75814. 'ç' => 'ç',
  75815. 'è' => 'è',
  75816. 'é' => 'e�',
  75817. 'ê' => 'ê',
  75818. 'ë' => 'ë',
  75819. 'ì' => 'ì',
  75820. 'í' => 'i�',
  75821. 'î' => 'î',
  75822. 'ï' => 'ï',
  75823. 'ñ' => 'ñ',
  75824. 'ò' => 'ò',
  75825. 'ó' => 'o�',
  75826. 'ô' => 'ô',
  75827. 'õ' => 'õ',
  75828. 'ö' => 'ö',
  75829. 'ù' => 'ù',
  75830. 'ú' => 'u�',
  75831. 'û' => 'û',
  75832. 'ü' => 'ü',
  75833. 'ý' => 'y�',
  75834. 'ÿ' => 'ÿ',
  75835. 'Ä€' => 'AÌ„',
  75836. '�' => 'ā',
  75837. 'Ă' => 'Ă',
  75838. 'ă' => 'ă',
  75839. 'Ą' => 'Ą',
  75840. 'ą' => 'ą',
  75841. 'Ć' => 'C�',
  75842. 'ć' => 'c�',
  75843. 'Ĉ' => 'Ĉ',
  75844. 'ĉ' => 'ĉ',
  75845. 'Ċ' => 'Ċ',
  75846. 'ċ' => 'ċ',
  75847. 'Č' => 'Č',
  75848. '�' => 'č',
  75849. 'Ď' => 'Ď',
  75850. '�' => 'ď',
  75851. 'Ä’' => 'EÌ„',
  75852. 'ē' => 'ē',
  75853. 'Ĕ' => 'Ĕ',
  75854. 'ĕ' => 'ĕ',
  75855. 'Ė' => 'Ė',
  75856. 'ė' => 'ė',
  75857. 'Ę' => 'Ę',
  75858. 'ę' => 'ę',
  75859. 'Ě' => 'Ě',
  75860. 'ě' => 'ě',
  75861. 'Ĝ' => 'Ĝ',
  75862. '�' => 'ĝ',
  75863. 'Ğ' => 'Ğ',
  75864. 'ğ' => 'ğ',
  75865. 'Ġ' => 'Ġ',
  75866. 'ġ' => 'ġ',
  75867. 'Ģ' => 'Ģ',
  75868. 'ģ' => 'ģ',
  75869. 'Ĥ' => 'Ĥ',
  75870. 'ĥ' => 'ĥ',
  75871. 'Ĩ' => 'Ĩ',
  75872. 'ĩ' => 'ĩ',
  75873. 'Ī' => 'Ī',
  75874. 'ī' => 'ī',
  75875. 'Ĭ' => 'Ĭ',
  75876. 'ĭ' => 'ĭ',
  75877. 'Į' => 'Į',
  75878. 'į' => 'į',
  75879. 'İ' => 'İ',
  75880. 'Ä´' => 'JÌ‚',
  75881. 'ĵ' => 'ĵ',
  75882. 'Ķ' => 'Ķ',
  75883. 'ķ' => 'ķ',
  75884. 'Ĺ' => 'L�',
  75885. 'ĺ' => 'l�',
  75886. 'Ļ' => 'Ļ',
  75887. 'ļ' => 'ļ',
  75888. 'Ľ' => 'Ľ',
  75889. 'ľ' => 'ľ',
  75890. 'Ń' => 'N�',
  75891. 'ń' => 'n�',
  75892. 'Ņ' => 'Ņ',
  75893. 'ņ' => 'ņ',
  75894. 'Ň' => 'Ň',
  75895. 'ň' => 'ň',
  75896. 'Ō' => 'Ō',
  75897. '�' => 'ō',
  75898. 'Ŏ' => 'Ŏ',
  75899. '�' => 'ŏ',
  75900. '�' => 'Ő',
  75901. 'ő' => 'ő',
  75902. 'Ŕ' => 'R�',
  75903. 'ŕ' => 'r�',
  75904. 'Ŗ' => 'Ŗ',
  75905. 'ŗ' => 'ŗ',
  75906. 'Ř' => 'Ř',
  75907. 'ř' => 'ř',
  75908. 'Ś' => 'S�',
  75909. 'ś' => 's�',
  75910. 'Ŝ' => 'Ŝ',
  75911. '�' => 'ŝ',
  75912. 'Ş' => 'Ş',
  75913. 'ş' => 'ş',
  75914. 'Š' => 'Š',
  75915. 'š' => 'š',
  75916. 'Ţ' => 'Ţ',
  75917. 'ţ' => 'ţ',
  75918. 'Ť' => 'Ť',
  75919. 'ť' => 'ť',
  75920. 'Ũ' => 'Ũ',
  75921. 'ũ' => 'ũ',
  75922. 'Ū' => 'Ū',
  75923. 'ū' => 'ū',
  75924. 'Ŭ' => 'Ŭ',
  75925. 'ŭ' => 'ŭ',
  75926. 'Å®' => 'UÌŠ',
  75927. 'ů' => 'ů',
  75928. 'Ű' => 'Ű',
  75929. 'ű' => 'ű',
  75930. 'Ų' => 'Ų',
  75931. 'ų' => 'ų',
  75932. 'Å´' => 'WÌ‚',
  75933. 'ŵ' => 'ŵ',
  75934. 'Ŷ' => 'Ŷ',
  75935. 'ŷ' => 'ŷ',
  75936. 'Ÿ' => 'Ÿ',
  75937. 'Ź' => 'Z�',
  75938. 'ź' => 'z�',
  75939. 'Ż' => 'Ż',
  75940. 'ż' => 'ż',
  75941. 'Ž' => 'Ž',
  75942. 'ž' => 'ž',
  75943. 'Æ ' => 'OÌ›',
  75944. 'Æ¡' => 'oÌ›',
  75945. 'Ư' => 'Ư',
  75946. 'ư' => 'ư',
  75947. '�' => 'Ǎ',
  75948. 'ǎ' => 'ǎ',
  75949. '�' => 'Ǐ',
  75950. '�' => 'ǐ',
  75951. 'Ǒ' => 'Ǒ',
  75952. 'ǒ' => 'ǒ',
  75953. 'Ǔ' => 'Ǔ',
  75954. 'ǔ' => 'ǔ',
  75955. 'Ǖ' => 'Ǖ',
  75956. 'ǖ' => 'ǖ',
  75957. 'Ǘ' => 'Ü�',
  75958. 'ǘ' => 'ü�',
  75959. 'Ǚ' => 'Ǚ',
  75960. 'ǚ' => 'ǚ',
  75961. 'Ǜ' => 'Ǜ',
  75962. 'ǜ' => 'ǜ',
  75963. 'Ǟ' => 'Ǟ',
  75964. 'ǟ' => 'ǟ',
  75965. 'Ǡ' => 'Ǡ',
  75966. 'ǡ' => 'ǡ',
  75967. 'Ǣ' => 'Ǣ',
  75968. 'ǣ' => 'ǣ',
  75969. 'Ǧ' => 'Ǧ',
  75970. 'ǧ' => 'ǧ',
  75971. 'Ǩ' => 'Ǩ',
  75972. 'ǩ' => 'ǩ',
  75973. 'Ǫ' => 'Ǫ',
  75974. 'ǫ' => 'ǫ',
  75975. 'Ǭ' => 'Ǭ',
  75976. 'ǭ' => 'ǭ',
  75977. 'Ǯ' => 'Ǯ',
  75978. 'ǯ' => 'ǯ',
  75979. 'ǰ' => 'ǰ',
  75980. 'Ǵ' => 'G�',
  75981. 'ǵ' => 'g�',
  75982. 'Ǹ' => 'Ǹ',
  75983. 'ǹ' => 'ǹ',
  75984. 'Ǻ' => 'Å�',
  75985. 'ǻ' => 'å�',
  75986. 'Ǽ' => 'Æ�',
  75987. 'ǽ' => 'æ�',
  75988. 'Ǿ' => 'Ø�',
  75989. 'ǿ' => 'ø�',
  75990. 'Ȁ' => 'A�',
  75991. '�' => 'a�',
  75992. 'È‚' => 'AÌ‘',
  75993. 'ȃ' => 'ȃ',
  75994. 'Ȅ' => 'E�',
  75995. 'ȅ' => 'e�',
  75996. 'Ȇ' => 'Ȇ',
  75997. 'ȇ' => 'ȇ',
  75998. 'Ȉ' => 'I�',
  75999. 'ȉ' => 'i�',
  76000. 'ÈŠ' => 'IÌ‘',
  76001. 'ȋ' => 'ȋ',
  76002. 'Ȍ' => 'O�',
  76003. '�' => 'o�',
  76004. 'ÈŽ' => 'OÌ‘',
  76005. '�' => 'ȏ',
  76006. '�' => 'R�',
  76007. 'ȑ' => 'r�',
  76008. 'È’' => 'RÌ‘',
  76009. 'ȓ' => 'ȓ',
  76010. 'Ȕ' => 'U�',
  76011. 'ȕ' => 'u�',
  76012. 'È–' => 'UÌ‘',
  76013. 'ȗ' => 'ȗ',
  76014. 'Ș' => 'Ș',
  76015. 'ș' => 'ș',
  76016. 'Ț' => 'Ț',
  76017. 'ț' => 'ț',
  76018. 'Ȟ' => 'Ȟ',
  76019. 'ȟ' => 'ȟ',
  76020. 'Ȧ' => 'Ȧ',
  76021. 'ȧ' => 'ȧ',
  76022. 'Ȩ' => 'Ȩ',
  76023. 'ȩ' => 'ȩ',
  76024. 'Ȫ' => 'Ȫ',
  76025. 'ȫ' => 'ȫ',
  76026. 'Ȭ' => 'Ȭ',
  76027. 'ȭ' => 'ȭ',
  76028. 'Ȯ' => 'Ȯ',
  76029. 'ȯ' => 'ȯ',
  76030. 'Ȱ' => 'Ȱ',
  76031. 'ȱ' => 'ȱ',
  76032. 'Ȳ' => 'Ȳ',
  76033. 'ȳ' => 'ȳ',
  76034. 'Í€' => 'Ì€',
  76035. '�' => '�',
  76036. '̓' => '̓',
  76037. '̈́' => '̈�',
  76038. 'ʹ' => 'ʹ',
  76039. ';' => ';',
  76040. '΅' => '¨�',
  76041. 'Ά' => 'Α�',
  76042. '·' => '·',
  76043. 'Έ' => 'Ε�',
  76044. 'Ή' => 'Η�',
  76045. 'Ί' => 'Ι�',
  76046. 'Ό' => 'Ο�',
  76047. 'Ύ' => 'Υ�',
  76048. '�' => 'Ω�',
  76049. '�' => 'ϊ�',
  76050. 'Ϊ' => 'Ϊ',
  76051. 'Ϋ' => 'Ϋ',
  76052. 'ά' => 'α�',
  76053. 'έ' => 'ε�',
  76054. 'ή' => 'η�',
  76055. 'ί' => 'ι�',
  76056. 'ΰ' => 'ϋ�',
  76057. 'ϊ' => 'ϊ',
  76058. 'ϋ' => 'ϋ',
  76059. 'ό' => 'ο�',
  76060. '�' => 'υ�',
  76061. 'ώ' => 'ω�',
  76062. 'ϓ' => 'ϒ�',
  76063. 'ϔ' => 'ϔ',
  76064. 'Ѐ' => 'Ѐ',
  76065. '�' => 'Ё',
  76066. 'Ѓ' => 'Г�',
  76067. 'Ї' => 'Ї',
  76068. 'Ќ' => 'К�',
  76069. '�' => 'Ѝ',
  76070. 'Ў' => 'Ў',
  76071. 'Й' => 'Й',
  76072. 'й' => 'й',
  76073. '�' => 'ѐ',
  76074. 'ё' => 'ё',
  76075. 'ѓ' => 'г�',
  76076. 'ї' => 'ї',
  76077. 'ќ' => 'к�',
  76078. '�' => 'ѝ',
  76079. 'ў' => 'ў',
  76080. 'Ѷ' => 'Ѵ�',
  76081. 'ѷ' => 'ѵ�',
  76082. '�' => 'Ӂ',
  76083. 'ӂ' => 'ӂ',
  76084. '�' => '�̆',
  76085. 'ӑ' => 'ӑ',
  76086. 'Ӓ' => '�̈',
  76087. 'ӓ' => 'ӓ',
  76088. 'Ӗ' => 'Ӗ',
  76089. 'ӗ' => 'ӗ',
  76090. 'Ӛ' => 'Ӛ',
  76091. 'ӛ' => 'ӛ',
  76092. 'Ӝ' => 'Ӝ',
  76093. '�' => 'ӝ',
  76094. 'Ӟ' => 'Ӟ',
  76095. 'ӟ' => 'ӟ',
  76096. 'Ӣ' => 'Ӣ',
  76097. 'ӣ' => 'ӣ',
  76098. 'Ӥ' => 'Ӥ',
  76099. 'ӥ' => 'ӥ',
  76100. 'Ӧ' => 'Ӧ',
  76101. 'ӧ' => 'ӧ',
  76102. 'Ӫ' => 'Ӫ',
  76103. 'ӫ' => 'ӫ',
  76104. 'Ӭ' => 'Ӭ',
  76105. 'ӭ' => '�̈',
  76106. 'Ӯ' => 'Ӯ',
  76107. 'ӯ' => 'ӯ',
  76108. 'Ӱ' => 'Ӱ',
  76109. 'ӱ' => 'ӱ',
  76110. 'Ӳ' => 'Ӳ',
  76111. 'ӳ' => 'ӳ',
  76112. 'Ӵ' => 'Ӵ',
  76113. 'ӵ' => 'ӵ',
  76114. 'Ӹ' => 'Ӹ',
  76115. 'ӹ' => 'ӹ',
  76116. 'آ' => 'آ',
  76117. 'أ' => 'أ',
  76118. 'ؤ' => 'ؤ',
  76119. 'إ' => 'إ',
  76120. 'ئ' => 'ئ',
  76121. 'Û€' => 'Û•Ù”',
  76122. 'Û‚' => 'Û�Ù”',
  76123. 'Û“' => 'Û’Ù”',
  76124. 'ऩ' => 'ऩ',
  76125. 'ऱ' => 'ऱ',
  76126. 'ऴ' => 'ऴ',
  76127. 'क़' => 'क़',
  76128. 'ख़' => 'ख़',
  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. 'ḉ' => 'ç�',
  76207. 'Ḋ' => 'Ḋ',
  76208. 'ḋ' => 'ḋ',
  76209. 'Ḍ' => 'Ḍ',
  76210. '�' => 'ḍ',
  76211. 'Ḏ' => 'Ḏ',
  76212. '�' => 'ḏ',
  76213. '�' => 'Ḑ',
  76214. 'ḑ' => 'ḑ',
  76215. 'Ḓ' => 'Ḓ',
  76216. 'ḓ' => 'ḓ',
  76217. 'Ḕ' => 'Ḕ',
  76218. 'ḕ' => 'ḕ',
  76219. 'Ḗ' => 'Ē�',
  76220. 'ḗ' => 'ē�',
  76221. 'Ḙ' => 'Ḙ',
  76222. 'ḙ' => 'ḙ',
  76223. 'Ḛ' => 'Ḛ',
  76224. 'ḛ' => 'ḛ',
  76225. 'Ḝ' => 'Ḝ',
  76226. '�' => 'ḝ',
  76227. 'Ḟ' => 'Ḟ',
  76228. 'ḟ' => 'ḟ',
  76229. 'Ḡ' => 'Ḡ',
  76230. 'ḡ' => 'ḡ',
  76231. 'Ḣ' => 'Ḣ',
  76232. 'ḣ' => 'ḣ',
  76233. 'Ḥ' => 'Ḥ',
  76234. 'ḥ' => 'ḥ',
  76235. 'Ḧ' => 'Ḧ',
  76236. 'ḧ' => 'ḧ',
  76237. 'Ḩ' => 'Ḩ',
  76238. 'ḩ' => 'ḩ',
  76239. 'Ḫ' => 'Ḫ',
  76240. 'ḫ' => 'ḫ',
  76241. 'Ḭ' => 'Ḭ',
  76242. 'ḭ' => 'ḭ',
  76243. 'Ḯ' => 'Ï�',
  76244. 'ḯ' => 'ï�',
  76245. 'Ḱ' => 'K�',
  76246. 'ḱ' => 'k�',
  76247. 'Ḳ' => 'Ḳ',
  76248. 'ḳ' => 'ḳ',
  76249. 'Ḵ' => 'Ḵ',
  76250. 'ḵ' => 'ḵ',
  76251. 'Ḷ' => 'Ḷ',
  76252. 'ḷ' => 'ḷ',
  76253. 'Ḹ' => 'Ḹ',
  76254. 'ḹ' => 'ḹ',
  76255. 'Ḻ' => 'Ḻ',
  76256. 'ḻ' => 'ḻ',
  76257. 'Ḽ' => 'Ḽ',
  76258. 'ḽ' => 'ḽ',
  76259. 'Ḿ' => 'M�',
  76260. 'ḿ' => 'm�',
  76261. 'Ṁ' => 'Ṁ',
  76262. '�' => 'ṁ',
  76263. 'Ṃ' => 'Ṃ',
  76264. 'ṃ' => 'ṃ',
  76265. 'Ṅ' => 'Ṅ',
  76266. 'ṅ' => 'ṅ',
  76267. 'Ṇ' => 'Ṇ',
  76268. 'ṇ' => 'ṇ',
  76269. 'Ṉ' => 'Ṉ',
  76270. 'ṉ' => 'ṉ',
  76271. 'Ṋ' => 'Ṋ',
  76272. 'ṋ' => 'ṋ',
  76273. 'Ṍ' => 'Õ�',
  76274. '�' => 'õ�',
  76275. 'Ṏ' => 'Ṏ',
  76276. '�' => 'ṏ',
  76277. '�' => 'Ṑ',
  76278. 'ṑ' => 'ṑ',
  76279. 'Ṓ' => 'Ō�',
  76280. 'ṓ' => 'ō�',
  76281. 'Ṕ' => 'P�',
  76282. 'ṕ' => 'p�',
  76283. 'Ṗ' => 'Ṗ',
  76284. 'ṗ' => 'ṗ',
  76285. 'Ṙ' => 'Ṙ',
  76286. 'ṙ' => 'ṙ',
  76287. 'Ṛ' => 'Ṛ',
  76288. 'ṛ' => 'ṛ',
  76289. 'Ṝ' => 'Ṝ',
  76290. '�' => 'ṝ',
  76291. 'Ṟ' => 'Ṟ',
  76292. 'ṟ' => 'ṟ',
  76293. 'Ṡ' => 'Ṡ',
  76294. 'ṡ' => 'ṡ',
  76295. 'á¹¢' => 'SÌ£',
  76296. 'ṣ' => 'ṣ',
  76297. 'Ṥ' => 'S�̇',
  76298. 'ṥ' => 's�̇',
  76299. 'Ṧ' => 'Ṧ',
  76300. 'ṧ' => 'ṧ',
  76301. 'Ṩ' => 'Ṩ',
  76302. 'ṩ' => 'ṩ',
  76303. 'Ṫ' => 'Ṫ',
  76304. 'ṫ' => 'ṫ',
  76305. 'Ṭ' => 'Ṭ',
  76306. 'ṭ' => 'ṭ',
  76307. 'Ṯ' => 'Ṯ',
  76308. 'ṯ' => 'ṯ',
  76309. 'á¹°' => 'TÌ­',
  76310. 'á¹±' => 'tÌ­',
  76311. 'Ṳ' => 'Ṳ',
  76312. 'ṳ' => 'ṳ',
  76313. 'Ṵ' => 'Ṵ',
  76314. 'ṵ' => 'ṵ',
  76315. 'á¹¶' => 'UÌ­',
  76316. 'á¹·' => 'uÌ­',
  76317. 'Ṹ' => 'Ũ�',
  76318. 'ṹ' => 'ũ�',
  76319. 'Ṻ' => 'Ṻ',
  76320. 'ṻ' => 'ṻ',
  76321. 'Ṽ' => 'Ṽ',
  76322. 'ṽ' => 'ṽ',
  76323. 'á¹¾' => 'VÌ£',
  76324. 'ṿ' => 'ṿ',
  76325. 'Ẁ' => 'Ẁ',
  76326. '�' => 'ẁ',
  76327. 'Ẃ' => 'W�',
  76328. 'ẃ' => 'w�',
  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. 'Ẹ' => 'Ẹ',
  76377. 'ẹ' => 'ẹ',
  76378. 'Ẻ' => 'Ẻ',
  76379. 'ẻ' => 'ẻ',
  76380. 'Ẽ' => 'Ẽ',
  76381. 'ẽ' => 'ẽ',
  76382. 'Ế' => 'Ê�',
  76383. 'ế' => 'ê�',
  76384. 'Ề' => 'Ề',
  76385. '�' => 'ề',
  76386. 'Ể' => 'Ể',
  76387. 'ể' => 'ể',
  76388. 'Ễ' => 'Ễ',
  76389. 'ễ' => 'ễ',
  76390. 'Ệ' => 'Ệ',
  76391. 'ệ' => 'ệ',
  76392. 'Ỉ' => 'Ỉ',
  76393. 'ỉ' => 'ỉ',
  76394. 'Ị' => 'Ị',
  76395. 'ị' => 'ị',
  76396. 'Ọ' => 'Ọ',
  76397. '�' => 'ọ',
  76398. 'Ỏ' => 'Ỏ',
  76399. '�' => 'ỏ',
  76400. '�' => 'Ô�',
  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. 'á»´' => 'YÌ£',
  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. 'K' => 'K',
  76675. 'â„«' => 'AÌŠ',
  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. '墨' => '墨',
  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. '呈' => '呈',
  77364. '周' => '周',
  77365. '咢' => '咢',
  77366. '�' => '哶',
  77367. '唐' => '�',
  77368. '啓' => '啓',
  77369. '啣' => '啣',
  77370. '善' => '善',
  77371. '善' => '善',
  77372. '喙' => '喙',
  77373. '喫' => '喫',
  77374. '喳' => '喳',
  77375. '嗂' => '嗂',
  77376. '圖' => '圖',
  77377. '嘆' => '嘆',
  77378. '�' => '圗',
  77379. '噑' => '噑',
  77380. '�' => '噴',
  77381. '�' => '切',
  77382. '壮' => '壮',
  77383. '城' => '城',
  77384. '埴' => '埴',
  77385. '堍' => '�',
  77386. '型' => '型',
  77387. '堲' => '堲',
  77388. '報' => '報',
  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. '瘐' => '�',
  77616. '𤾡' => '𤾡',
  77617. '𤾸' => '𤾸',
  77618. '𥁄' => '�',
  77619. '㿼' => '㿼',
  77620. '䀈' => '䀈',
  77621. '直' => '直',
  77622. '�' => '𥃳',
  77623. '𥃲' => '𥃲',
  77624. '𥄙' => '𥄙',
  77625. '𥄳' => '𥄳',
  77626. '眞' => '眞',
  77627. '真' => '真',
  77628. '真' => '真',
  77629. '睊' => '�',
  77630. '䀹' => '䀹',
  77631. '瞋' => '瞋',
  77632. '䁆' => '�',
  77633. '䂖' => '䂖',
  77634. '�' => '�',
  77635. '硎' => '硎',
  77636. '�' => '碌',
  77637. '�' => '磌',
  77638. '䃣' => '䃣',
  77639. '𥘦' => '𥘦',
  77640. '祖' => '祖',
  77641. '𥚚' => '𥚚',
  77642. '𥛅' => '𥛅',
  77643. '福' => '�',
  77644. '秫' => '秫',
  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. '�' => '芋',
  77702. '芝' => '�',
  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. '虩' => '虩',
  77740. '蚩' => '蚩',
  77741. '蚈' => '蚈',
  77742. '蜎' => '蜎',
  77743. '蛢' => '蛢',
  77744. '蝹' => '�',
  77745. '蜨' => '蜨',
  77746. '蝫' => '�',
  77747. '螆' => '螆',
  77748. '䗗' => '䗗',
  77749. '蟡' => '蟡',
  77750. '�' => '�',
  77751. '䗹' => '䗹',
  77752. '衠' => '衠',
  77753. '衣' => '衣',
  77754. '𧙧' => '𧙧',
  77755. '裗' => '裗',
  77756. '裞' => '裞',
  77757. '䘵' => '䘵',
  77758. '裺' => '裺',
  77759. '㒻' => '㒻',
  77760. '𧢮' => '𧢮',
  77761. '𧥦' => '𧥦',
  77762. '�' => '䚾',
  77763. '䛇' => '䛇',
  77764. '�' => '誠',
  77765. '�' => '諭',
  77766. '變' => '變',
  77767. '豕' => '豕',
  77768. '𧲨' => '𧲨',
  77769. '貫' => '貫',
  77770. '賁' => '�',
  77771. '贛' => '贛',
  77772. '起' => '起',
  77773. '𧼯' => '𧼯',
  77774. '𠠄' => '𠠄',
  77775. '跋' => '跋',
  77776. '趼' => '趼',
  77777. '跰' => '跰',
  77778. '�' => '𠣞',
  77779. '軔' => '軔',
  77780. '輸' => '輸',
  77781. '𨗒' => '𨗒',
  77782. '𨗭' => '𨗭',
  77783. '邔' => '邔',
  77784. '郱' => '郱',
  77785. '鄑' => '鄑',
  77786. '𨜮' => '𨜮',
  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. <?php
  77845. return array (
  77846. 'Ì€' => 230,
  77847. '�' => 230,
  77848. 'Ì‚' => 230,
  77849. '̃' => 230,
  77850. 'Ì„' => 230,
  77851. 'Ì…' => 230,
  77852. '̆' => 230,
  77853. '̇' => 230,
  77854. '̈' => 230,
  77855. '̉' => 230,
  77856. 'ÌŠ' => 230,
  77857. 'Ì‹' => 230,
  77858. '̌' => 230,
  77859. '�' => 230,
  77860. 'ÌŽ' => 230,
  77861. '�' => 230,
  77862. '�' => 230,
  77863. 'Ì‘' => 230,
  77864. 'Ì’' => 230,
  77865. 'Ì“' => 230,
  77866. 'Ì”' => 230,
  77867. 'Ì•' => 232,
  77868. 'Ì–' => 220,
  77869. 'Ì—' => 220,
  77870. '̘' => 220,
  77871. 'Ì™' => 220,
  77872. 'Ìš' => 232,
  77873. 'Ì›' => 216,
  77874. '̜' => 220,
  77875. '�' => 220,
  77876. 'Ìž' => 220,
  77877. 'ÌŸ' => 220,
  77878. 'Ì ' => 220,
  77879. 'Ì¡' => 202,
  77880. 'Ì¢' => 202,
  77881. 'Ì£' => 220,
  77882. '̤' => 220,
  77883. 'Ì¥' => 220,
  77884. '̦' => 220,
  77885. '̧' => 202,
  77886. '̨' => 202,
  77887. 'Ì©' => 220,
  77888. '̪' => 220,
  77889. 'Ì«' => 220,
  77890. '̬' => 220,
  77891. 'Ì­' => 220,
  77892. 'Ì®' => 220,
  77893. '̯' => 220,
  77894. '̰' => 220,
  77895. '̱' => 220,
  77896. '̲' => 220,
  77897. '̳' => 220,
  77898. 'Ì´' => 1,
  77899. '̵' => 1,
  77900. '̶' => 1,
  77901. 'Ì·' => 1,
  77902. '̸' => 1,
  77903. '̹' => 220,
  77904. '̺' => 220,
  77905. 'Ì»' => 220,
  77906. '̼' => 220,
  77907. '̽' => 230,
  77908. '̾' => 230,
  77909. 'Ì¿' => 230,
  77910. 'Í€' => 230,
  77911. '�' => 230,
  77912. 'Í‚' => 230,
  77913. '̓' => 230,
  77914. 'Í„' => 230,
  77915. 'Í…' => 240,
  77916. '͆' => 230,
  77917. '͇' => 220,
  77918. '͈' => 220,
  77919. '͉' => 220,
  77920. 'ÍŠ' => 230,
  77921. 'Í‹' => 230,
  77922. '͌' => 230,
  77923. '�' => 220,
  77924. 'ÍŽ' => 220,
  77925. '�' => 230,
  77926. 'Í‘' => 230,
  77927. 'Í’' => 230,
  77928. 'Í“' => 220,
  77929. 'Í”' => 220,
  77930. 'Í•' => 220,
  77931. 'Í–' => 220,
  77932. 'Í—' => 230,
  77933. '͘' => 232,
  77934. 'Í™' => 220,
  77935. 'Íš' => 220,
  77936. 'Í›' => 230,
  77937. '͜' => 233,
  77938. '�' => 234,
  77939. 'Íž' => 234,
  77940. 'ÍŸ' => 233,
  77941. 'Í ' => 234,
  77942. 'Í¡' => 234,
  77943. 'Í¢' => 233,
  77944. 'Í£' => 230,
  77945. 'ͤ' => 230,
  77946. 'Í¥' => 230,
  77947. 'ͦ' => 230,
  77948. 'ͧ' => 230,
  77949. 'ͨ' => 230,
  77950. 'Í©' => 230,
  77951. 'ͪ' => 230,
  77952. 'Í«' => 230,
  77953. 'ͬ' => 230,
  77954. 'Í­' => 230,
  77955. 'Í®' => 230,
  77956. 'ͯ' => 230,
  77957. 'Òƒ' => 230,
  77958. 'Ò„' => 230,
  77959. 'Ò…' => 230,
  77960. 'Ò†' => 230,
  77961. 'Ò‡' => 230,
  77962. 'Ö‘' => 220,
  77963. 'Ö’' => 230,
  77964. 'Ö“' => 230,
  77965. 'Ö”' => 230,
  77966. 'Ö•' => 230,
  77967. 'Ö–' => 220,
  77968. 'Ö—' => 230,
  77969. 'Ö˜' => 230,
  77970. 'Ö™' => 230,
  77971. 'Öš' => 222,
  77972. 'Ö›' => 220,
  77973. '֜' => 230,
  77974. 'Ö�' => 230,
  77975. 'Öž' => 230,
  77976. 'ÖŸ' => 230,
  77977. 'Ö ' => 230,
  77978. 'Ö¡' => 230,
  77979. 'Ö¢' => 220,
  77980. 'Ö£' => 220,
  77981. 'Ö¤' => 220,
  77982. 'Ö¥' => 220,
  77983. 'Ö¦' => 220,
  77984. 'Ö§' => 220,
  77985. 'Ö¨' => 230,
  77986. 'Ö©' => 230,
  77987. 'Öª' => 220,
  77988. 'Ö«' => 230,
  77989. 'Ö¬' => 230,
  77990. 'Ö­' => 222,
  77991. 'Ö®' => 228,
  77992. 'Ö¯' => 230,
  77993. 'Ö°' => 10,
  77994. 'Ö±' => 11,
  77995. 'Ö²' => 12,
  77996. 'Ö³' => 13,
  77997. 'Ö´' => 14,
  77998. 'Öµ' => 15,
  77999. 'Ö¶' => 16,
  78000. 'Ö·' => 17,
  78001. 'Ö¸' => 18,
  78002. 'Ö¹' => 19,
  78003. 'Öº' => 19,
  78004. 'Ö»' => 20,
  78005. 'Ö¼' => 21,
  78006. 'Ö½' => 22,
  78007. 'Ö¿' => 23,
  78008. '�' => 24,
  78009. 'ׂ' => 25,
  78010. 'ׄ' => 230,
  78011. '×…' => 220,
  78012. 'ׇ' => 18,
  78013. '�' => 230,
  78014. 'Ø‘' => 230,
  78015. 'Ø’' => 230,
  78016. 'Ø“' => 230,
  78017. 'Ø”' => 230,
  78018. 'Ø•' => 230,
  78019. 'Ø–' => 230,
  78020. 'Ø—' => 230,
  78021. 'ؘ' => 30,
  78022. 'Ø™' => 31,
  78023. 'Øš' => 32,
  78024. 'Ù‹' => 27,
  78025. 'ٌ' => 28,
  78026. 'Ù�' => 29,
  78027. 'ÙŽ' => 30,
  78028. 'Ù�' => 31,
  78029. 'Ù�' => 32,
  78030. 'Ù‘' => 33,
  78031. 'Ù’' => 34,
  78032. 'Ù“' => 230,
  78033. 'Ù”' => 230,
  78034. 'Ù•' => 220,
  78035. 'Ù–' => 220,
  78036. 'Ù—' => 230,
  78037. 'Ù˜' => 230,
  78038. 'Ù™' => 230,
  78039. 'Ùš' => 230,
  78040. 'Ù›' => 230,
  78041. 'ٜ' => 220,
  78042. 'Ù�' => 230,
  78043. 'Ùž' => 230,
  78044. 'ÙŸ' => 220,
  78045. 'Ù°' => 35,
  78046. 'Û–' => 230,
  78047. 'Û—' => 230,
  78048. 'Û˜' => 230,
  78049. 'Û™' => 230,
  78050. 'Ûš' => 230,
  78051. 'Û›' => 230,
  78052. 'ۜ' => 230,
  78053. 'ÛŸ' => 230,
  78054. 'Û ' => 230,
  78055. 'Û¡' => 230,
  78056. 'Û¢' => 230,
  78057. 'Û£' => 220,
  78058. 'Û¤' => 230,
  78059. 'Û§' => 230,
  78060. 'Û¨' => 230,
  78061. 'Ûª' => 220,
  78062. 'Û«' => 230,
  78063. 'Û¬' => 230,
  78064. 'Û­' => 220,
  78065. 'Ü‘' => 36,
  78066. 'ܰ' => 230,
  78067. 'ܱ' => 220,
  78068. 'ܲ' => 230,
  78069. 'ܳ' => 230,
  78070. 'Ü´' => 220,
  78071. 'ܵ' => 230,
  78072. 'ܶ' => 230,
  78073. 'Ü·' => 220,
  78074. 'ܸ' => 220,
  78075. 'ܹ' => 220,
  78076. 'ܺ' => 230,
  78077. 'Ü»' => 220,
  78078. 'ܼ' => 220,
  78079. 'ܽ' => 230,
  78080. 'ܾ' => 220,
  78081. 'Ü¿' => 230,
  78082. 'Ý€' => 230,
  78083. '�' => 230,
  78084. 'Ý‚' => 220,
  78085. '݃' => 230,
  78086. 'Ý„' => 220,
  78087. 'Ý…' => 230,
  78088. '݆' => 220,
  78089. '݇' => 230,
  78090. '݈' => 220,
  78091. '݉' => 230,
  78092. 'ÝŠ' => 230,
  78093. 'ß«' => 230,
  78094. '߬' => 230,
  78095. 'ß­' => 230,
  78096. 'ß®' => 230,
  78097. '߯' => 230,
  78098. 'ß°' => 230,
  78099. 'ß±' => 230,
  78100. 'ß²' => 220,
  78101. 'ß³' => 230,
  78102. 'ß½' => 220,
  78103. 'à –' => 230,
  78104. 'à —' => 230,
  78105. 'à ˜' => 230,
  78106. 'à ™' => 230,
  78107. 'à ›' => 230,
  78108. 'ࠜ' => 230,
  78109. 'à �' => 230,
  78110. 'à ž' => 230,
  78111. 'à Ÿ' => 230,
  78112. 'à  ' => 230,
  78113. 'à ¡' => 230,
  78114. 'à ¢' => 230,
  78115. 'à £' => 230,
  78116. 'à ¥' => 230,
  78117. 'à ¦' => 230,
  78118. 'à §' => 230,
  78119. 'à ©' => 230,
  78120. 'à ª' => 230,
  78121. 'à «' => 230,
  78122. 'à ¬' => 230,
  78123. 'à ­' => 230,
  78124. 'à¡™' => 220,
  78125. '࡚' => 220,
  78126. 'à¡›' => 220,
  78127. '࣓' => 220,
  78128. 'ࣔ' => 230,
  78129. 'ࣕ' => 230,
  78130. 'ࣖ' => 230,
  78131. 'ࣗ' => 230,
  78132. 'ࣘ' => 230,
  78133. 'ࣙ' => 230,
  78134. 'ࣚ' => 230,
  78135. 'ࣛ' => 230,
  78136. 'ࣜ' => 230,
  78137. '�' => 230,
  78138. 'ࣞ' => 230,
  78139. 'ࣟ' => 230,
  78140. '࣠' => 230,
  78141. '࣡' => 230,
  78142. 'ࣣ' => 220,
  78143. 'ࣤ' => 230,
  78144. 'ࣥ' => 230,
  78145. 'ࣦ' => 220,
  78146. 'ࣧ' => 230,
  78147. 'ࣨ' => 230,
  78148. 'ࣩ' => 220,
  78149. '࣪' => 230,
  78150. '࣫' => 230,
  78151. '࣬' => 230,
  78152. '࣭' => 220,
  78153. '࣮' => 220,
  78154. '࣯' => 220,
  78155. 'ࣰ' => 27,
  78156. 'ࣱ' => 28,
  78157. 'ࣲ' => 29,
  78158. 'ࣳ' => 230,
  78159. 'ࣴ' => 230,
  78160. 'ࣵ' => 230,
  78161. 'ࣶ' => 220,
  78162. 'ࣷ' => 230,
  78163. 'ࣸ' => 230,
  78164. 'ࣹ' => 220,
  78165. 'ࣺ' => 220,
  78166. 'ࣻ' => 230,
  78167. 'ࣼ' => 230,
  78168. 'ࣽ' => 230,
  78169. 'ࣾ' => 230,
  78170. 'ࣿ' => 230,
  78171. '़' => 7,
  78172. '�' => 9,
  78173. '॑' => 230,
  78174. '॒' => 220,
  78175. '॓' => 230,
  78176. '॔' => 230,
  78177. '়' => 7,
  78178. '�' => 9,
  78179. 'à§¾' => 230,
  78180. '਼' => 7,
  78181. '�' => 9,
  78182. '઼' => 7,
  78183. '�' => 9,
  78184. '଼' => 7,
  78185. 'à­�' => 9,
  78186. '�' => 9,
  78187. '�' => 9,
  78188. 'ౕ' => 84,
  78189. 'à±–' => 91,
  78190. '಼' => 7,
  78191. '�' => 9,
  78192. 'à´»' => 9,
  78193. 'à´¼' => 9,
  78194. '�' => 9,
  78195. 'à·Š' => 9,
  78196. 'ุ' => 103,
  78197. 'ู' => 103,
  78198. 'ฺ' => 9,
  78199. '่' => 107,
  78200. '้' => 107,
  78201. '๊' => 107,
  78202. '๋' => 107,
  78203. 'ຸ' => 118,
  78204. 'ູ' => 118,
  78205. '຺' => 9,
  78206. '່' => 122,
  78207. '້' => 122,
  78208. '໊' => 122,
  78209. '໋' => 122,
  78210. '༘' => 220,
  78211. '༙' => 220,
  78212. '༵' => 220,
  78213. '༷' => 220,
  78214. '༹' => 216,
  78215. 'ཱ' => 129,
  78216. 'ི' => 130,
  78217. 'ུ' => 132,
  78218. 'ེ' => 130,
  78219. 'ཻ' => 130,
  78220. 'ོ' => 130,
  78221. 'ཽ' => 130,
  78222. 'ྀ' => 130,
  78223. 'ྂ' => 230,
  78224. 'ྃ' => 230,
  78225. '྄' => 9,
  78226. '྆' => 230,
  78227. '྇' => 230,
  78228. '࿆' => 220,
  78229. '့' => 7,
  78230. '္' => 9,
  78231. '်' => 9,
  78232. '�' => 220,
  78233. '�' => 230,
  78234. '�' => 230,
  78235. '�' => 230,
  78236. '᜔' => 9,
  78237. '᜴' => 9,
  78238. '្' => 9,
  78239. '�' => 230,
  78240. 'ᢩ' => 228,
  78241. '᤹' => 222,
  78242. '᤺' => 230,
  78243. '᤻' => 220,
  78244. 'ᨗ' => 230,
  78245. 'ᨘ' => 220,
  78246. 'á© ' => 9,
  78247. '᩵' => 230,
  78248. 'á©¶' => 230,
  78249. 'á©·' => 230,
  78250. '᩸' => 230,
  78251. '᩹' => 230,
  78252. '᩺' => 230,
  78253. 'á©»' => 230,
  78254. '᩼' => 230,
  78255. 'á©¿' => 220,
  78256. '᪰' => 230,
  78257. '᪱' => 230,
  78258. '᪲' => 230,
  78259. '᪳' => 230,
  78260. '᪴' => 230,
  78261. '᪵' => 220,
  78262. '᪶' => 220,
  78263. '᪷' => 220,
  78264. '᪸' => 220,
  78265. '᪹' => 220,
  78266. '᪺' => 220,
  78267. '᪻' => 230,
  78268. '᪼' => 230,
  78269. '᪽' => 220,
  78270. 'ᪿ' => 220,
  78271. 'á«€' => 220,
  78272. '᬴' => 7,
  78273. 'á­„' => 9,
  78274. 'á­«' => 230,
  78275. 'á­¬' => 220,
  78276. 'á­­' => 230,
  78277. 'á­®' => 230,
  78278. 'á­¯' => 230,
  78279. 'á­°' => 230,
  78280. 'á­±' => 230,
  78281. 'á­²' => 230,
  78282. 'á­³' => 230,
  78283. '᮪' => 9,
  78284. '᮫' => 9,
  78285. '᯦' => 7,
  78286. '᯲' => 9,
  78287. '᯳' => 9,
  78288. 'á°·' => 7,
  78289. '�' => 230,
  78290. '᳑' => 230,
  78291. 'á³’' => 230,
  78292. 'á³”' => 1,
  78293. '᳕' => 220,
  78294. 'á³–' => 220,
  78295. 'á³—' => 220,
  78296. '᳘' => 220,
  78297. 'á³™' => 220,
  78298. '᳚' => 230,
  78299. 'á³›' => 230,
  78300. '᳜' => 220,
  78301. '�' => 220,
  78302. '᳞' => 220,
  78303. '᳟' => 220,
  78304. 'á³ ' => 230,
  78305. 'á³¢' => 1,
  78306. 'á³£' => 1,
  78307. '᳤' => 1,
  78308. 'á³¥' => 1,
  78309. '᳦' => 1,
  78310. 'á³§' => 1,
  78311. '᳨' => 1,
  78312. 'á³­' => 220,
  78313. 'á³´' => 230,
  78314. '᳸' => 230,
  78315. 'á³¹' => 230,
  78316. 'á·€' => 230,
  78317. 'á·�' => 230,
  78318. 'á·‚' => 220,
  78319. 'á·ƒ' => 230,
  78320. 'á·„' => 230,
  78321. 'á·…' => 230,
  78322. 'á·†' => 230,
  78323. 'á·‡' => 230,
  78324. 'á·ˆ' => 230,
  78325. 'á·‰' => 230,
  78326. 'á·Š' => 220,
  78327. 'á·‹' => 230,
  78328. '᷌' => 230,
  78329. 'á·�' => 234,
  78330. 'á·Ž' => 214,
  78331. 'á·�' => 220,
  78332. 'á·�' => 202,
  78333. 'á·‘' => 230,
  78334. 'á·’' => 230,
  78335. 'á·“' => 230,
  78336. 'á·”' => 230,
  78337. 'á·•' => 230,
  78338. 'á·–' => 230,
  78339. 'á·—' => 230,
  78340. 'á·˜' => 230,
  78341. 'á·™' => 230,
  78342. 'á·š' => 230,
  78343. 'á·›' => 230,
  78344. 'ᷜ' => 230,
  78345. 'á·�' => 230,
  78346. 'á·ž' => 230,
  78347. 'á·Ÿ' => 230,
  78348. 'á· ' => 230,
  78349. 'á·¡' => 230,
  78350. 'á·¢' => 230,
  78351. 'á·£' => 230,
  78352. 'á·¤' => 230,
  78353. 'á·¥' => 230,
  78354. 'á·¦' => 230,
  78355. 'á·§' => 230,
  78356. 'á·¨' => 230,
  78357. 'á·©' => 230,
  78358. 'á·ª' => 230,
  78359. 'á·«' => 230,
  78360. 'á·¬' => 230,
  78361. 'á·­' => 230,
  78362. 'á·®' => 230,
  78363. 'á·¯' => 230,
  78364. 'á·°' => 230,
  78365. 'á·±' => 230,
  78366. 'á·²' => 230,
  78367. 'á·³' => 230,
  78368. 'á·´' => 230,
  78369. 'á·µ' => 230,
  78370. 'á·¶' => 232,
  78371. 'á··' => 228,
  78372. 'á·¸' => 228,
  78373. 'á·¹' => 220,
  78374. 'á·»' => 230,
  78375. 'á·¼' => 233,
  78376. 'á·½' => 220,
  78377. 'á·¾' => 230,
  78378. 'á·¿' => 220,
  78379. '�' => 230,
  78380. '⃑' => 230,
  78381. '⃒' => 1,
  78382. '⃓' => 1,
  78383. '⃔' => 230,
  78384. '⃕' => 230,
  78385. '⃖' => 230,
  78386. '⃗' => 230,
  78387. '⃘' => 1,
  78388. '⃙' => 1,
  78389. '⃚' => 1,
  78390. '⃛' => 230,
  78391. '⃜' => 230,
  78392. '⃡' => 230,
  78393. '⃥' => 1,
  78394. '⃦' => 1,
  78395. '⃧' => 230,
  78396. '⃨' => 220,
  78397. '⃩' => 230,
  78398. '⃪' => 1,
  78399. '⃫' => 1,
  78400. '⃬' => 220,
  78401. '⃭' => 220,
  78402. '⃮' => 220,
  78403. '⃯' => 220,
  78404. '⃰' => 230,
  78405. '⳯' => 230,
  78406. 'â³°' => 230,
  78407. 'â³±' => 230,
  78408. '⵿' => 9,
  78409. 'â· ' => 230,
  78410. 'â·¡' => 230,
  78411. 'â·¢' => 230,
  78412. 'â·£' => 230,
  78413. 'â·¤' => 230,
  78414. 'â·¥' => 230,
  78415. 'â·¦' => 230,
  78416. 'â·§' => 230,
  78417. 'â·¨' => 230,
  78418. 'â·©' => 230,
  78419. 'â·ª' => 230,
  78420. 'â·«' => 230,
  78421. 'â·¬' => 230,
  78422. 'â·­' => 230,
  78423. 'â·®' => 230,
  78424. 'â·¯' => 230,
  78425. 'â·°' => 230,
  78426. 'â·±' => 230,
  78427. 'â·²' => 230,
  78428. 'â·³' => 230,
  78429. 'â·´' => 230,
  78430. 'â·µ' => 230,
  78431. 'â·¶' => 230,
  78432. 'â··' => 230,
  78433. 'â·¸' => 230,
  78434. 'â·¹' => 230,
  78435. 'â·º' => 230,
  78436. 'â·»' => 230,
  78437. 'â·¼' => 230,
  78438. 'â·½' => 230,
  78439. 'â·¾' => 230,
  78440. 'â·¿' => 230,
  78441. '〪' => 218,
  78442. '〫' => 228,
  78443. '〬' => 232,
  78444. '〭' => 222,
  78445. '〮' => 224,
  78446. '〯' => 224,
  78447. 'ã‚™' => 8,
  78448. '゚' => 8,
  78449. '꙯' => 230,
  78450. 'ê™´' => 230,
  78451. 'ꙵ' => 230,
  78452. 'ê™¶' => 230,
  78453. 'ê™·' => 230,
  78454. 'ꙸ' => 230,
  78455. 'ꙹ' => 230,
  78456. 'ꙺ' => 230,
  78457. 'ê™»' => 230,
  78458. '꙼' => 230,
  78459. '꙽' => 230,
  78460. 'êšž' => 230,
  78461. 'ꚟ' => 230,
  78462. 'ê›°' => 230,
  78463. 'ê›±' => 230,
  78464. 'ê †' => 9,
  78465. 'ê ¬' => 9,
  78466. '꣄' => 9,
  78467. '꣠' => 230,
  78468. '꣡' => 230,
  78469. '꣢' => 230,
  78470. '꣣' => 230,
  78471. '꣤' => 230,
  78472. '꣥' => 230,
  78473. '꣦' => 230,
  78474. '꣧' => 230,
  78475. '꣨' => 230,
  78476. '꣩' => 230,
  78477. '꣪' => 230,
  78478. '꣫' => 230,
  78479. '꣬' => 230,
  78480. '꣭' => 230,
  78481. '꣮' => 230,
  78482. '꣯' => 230,
  78483. '꣰' => 230,
  78484. '꣱' => 230,
  78485. '꤫' => 220,
  78486. '꤬' => 220,
  78487. '꤭' => 220,
  78488. '꥓' => 9,
  78489. '꦳' => 7,
  78490. 'ê§€' => 9,
  78491. 'ꪰ' => 230,
  78492. 'ꪲ' => 230,
  78493. 'ꪳ' => 230,
  78494. 'ꪴ' => 220,
  78495. 'ꪷ' => 230,
  78496. 'ꪸ' => 230,
  78497. 'ꪾ' => 230,
  78498. '꪿' => 230,
  78499. '�' => 230,
  78500. 'ê«¶' => 9,
  78501. '꯭' => 9,
  78502. 'ﬞ' => 26,
  78503. '︠' => 230,
  78504. '︡' => 230,
  78505. '︢' => 230,
  78506. '︣' => 230,
  78507. '︤' => 230,
  78508. '︥' => 230,
  78509. '︦' => 230,
  78510. '︧' => 220,
  78511. '︨' => 220,
  78512. '︩' => 220,
  78513. '︪' => 220,
  78514. '︫' => 220,
  78515. '︬' => 220,
  78516. '︭' => 220,
  78517. '︮' => 230,
  78518. '︯' => 230,
  78519. '�' => 220,
  78520. '�' => 220,
  78521. '�' => 230,
  78522. '�' => 230,
  78523. '�' => 230,
  78524. '�' => 230,
  78525. '�' => 230,
  78526. '�' => 220,
  78527. '�' => 230,
  78528. '�' => 230,
  78529. '�' => 1,
  78530. '�' => 220,
  78531. '�' => 9,
  78532. '�' => 230,
  78533. '�' => 220,
  78534. '�' => 230,
  78535. '�' => 230,
  78536. '�' => 230,
  78537. '�' => 230,
  78538. '�' => 230,
  78539. '�' => 230,
  78540. '�' => 220,
  78541. '�' => 220,
  78542. '�' => 230,
  78543. '�' => 230,
  78544. '�' => 230,
  78545. '�' => 220,
  78546. '�' => 230,
  78547. '�' => 220,
  78548. '�' => 220,
  78549. '�' => 220,
  78550. '�' => 220,
  78551. '�' => 9,
  78552. '�' => 9,
  78553. 'ð‘‚¹' => 9,
  78554. '𑂺' => 7,
  78555. 'ð‘„€' => 230,
  78556. '�' => 230,
  78557. 'ð‘„‚' => 230,
  78558. 'ð‘„³' => 9,
  78559. 'ð‘„´' => 9,
  78560. 'ð‘…³' => 7,
  78561. '𑇀' => 9,
  78562. '𑇊' => 7,
  78563. '𑈵' => 9,
  78564. '𑈶' => 7,
  78565. 'ð‘‹©' => 7,
  78566. '𑋪' => 9,
  78567. '𑌻' => 7,
  78568. '𑌼' => 7,
  78569. '�' => 9,
  78570. '�' => 230,
  78571. '�' => 230,
  78572. '�' => 230,
  78573. '�' => 230,
  78574. '�' => 230,
  78575. '�' => 230,
  78576. '�' => 230,
  78577. '�' => 230,
  78578. '�' => 230,
  78579. '�' => 230,
  78580. '�' => 230,
  78581. '�' => 230,
  78582. 'ð‘‘‚' => 9,
  78583. '𑑆' => 7,
  78584. 'ð‘‘ž' => 230,
  78585. 'ð‘“‚' => 9,
  78586. '𑓃' => 7,
  78587. 'ð‘–¿' => 9,
  78588. 'ð‘—€' => 7,
  78589. '𑘿' => 9,
  78590. '𑚶' => 9,
  78591. '𑚷' => 7,
  78592. '𑜫' => 9,
  78593. 'ð‘ ¹' => 9,
  78594. 'ð‘ º' => 7,
  78595. '𑤽' => 9,
  78596. '𑤾' => 9,
  78597. '𑥃' => 7,
  78598. 'ð‘§ ' => 9,
  78599. '𑨴' => 9,
  78600. '𑩇' => 9,
  78601. '𑪙' => 9,
  78602. 'ð‘°¿' => 9,
  78603. '𑵂' => 7,
  78604. '𑵄' => 9,
  78605. '𑵅' => 9,
  78606. 'ð‘¶—' => 9,
  78607. 'ð–«°' => 1,
  78608. 'ð–«±' => 1,
  78609. 'ð–«²' => 1,
  78610. 'ð–«³' => 1,
  78611. 'ð–«´' => 1,
  78612. 'ð–¬°' => 230,
  78613. '𖬱' => 230,
  78614. '𖬲' => 230,
  78615. '𖬳' => 230,
  78616. 'ð–¬´' => 230,
  78617. '𖬵' => 230,
  78618. '𖬶' => 230,
  78619. 'ð–¿°' => 6,
  78620. 'ð–¿±' => 6,
  78621. '𛲞' => 1,
  78622. '�' => 216,
  78623. '�' => 216,
  78624. '�' => 1,
  78625. '�' => 1,
  78626. '�' => 1,
  78627. '�' => 226,
  78628. '�' => 216,
  78629. '�' => 216,
  78630. '�' => 216,
  78631. '�' => 216,
  78632. '�' => 216,
  78633. '�' => 220,
  78634. '�' => 220,
  78635. '�' => 220,
  78636. '�' => 220,
  78637. '�' => 220,
  78638. '�' => 220,
  78639. '�' => 220,
  78640. '�' => 220,
  78641. '�' => 230,
  78642. '�' => 230,
  78643. '�' => 230,
  78644. '�' => 230,
  78645. '�' => 230,
  78646. '�' => 220,
  78647. '�' => 220,
  78648. '�' => 230,
  78649. '�' => 230,
  78650. '�' => 230,
  78651. '�' => 230,
  78652. '�' => 230,
  78653. '�' => 230,
  78654. '�' => 230,
  78655. '𞀀' => 230,
  78656. '�' => 230,
  78657. '𞀂' => 230,
  78658. '𞀃' => 230,
  78659. '𞀄' => 230,
  78660. '𞀅' => 230,
  78661. '𞀆' => 230,
  78662. '𞀈' => 230,
  78663. '𞀉' => 230,
  78664. '𞀊' => 230,
  78665. '𞀋' => 230,
  78666. '𞀌' => 230,
  78667. '�' => 230,
  78668. '𞀎' => 230,
  78669. '�' => 230,
  78670. '�' => 230,
  78671. '𞀑' => 230,
  78672. '𞀒' => 230,
  78673. '𞀓' => 230,
  78674. '𞀔' => 230,
  78675. '𞀕' => 230,
  78676. '𞀖' => 230,
  78677. '𞀗' => 230,
  78678. '𞀘' => 230,
  78679. '𞀛' => 230,
  78680. '𞀜' => 230,
  78681. '�' => 230,
  78682. '𞀞' => 230,
  78683. '𞀟' => 230,
  78684. '𞀠' => 230,
  78685. '𞀡' => 230,
  78686. '𞀣' => 230,
  78687. '𞀤' => 230,
  78688. '𞀦' => 230,
  78689. '𞀧' => 230,
  78690. '𞀨' => 230,
  78691. '𞀩' => 230,
  78692. '𞀪' => 230,
  78693. 'ðž„°' => 230,
  78694. '𞄱' => 230,
  78695. '𞄲' => 230,
  78696. '𞄳' => 230,
  78697. 'ðž„´' => 230,
  78698. '𞄵' => 230,
  78699. 'ðž„¶' => 230,
  78700. '𞋬' => 230,
  78701. 'ðž‹­' => 230,
  78702. 'ðž‹®' => 230,
  78703. '𞋯' => 230,
  78704. '�' => 220,
  78705. '𞣑' => 220,
  78706. '𞣒' => 220,
  78707. '𞣓' => 220,
  78708. '𞣔' => 220,
  78709. '𞣕' => 220,
  78710. '𞣖' => 220,
  78711. '𞥄' => 230,
  78712. '𞥅' => 230,
  78713. '𞥆' => 230,
  78714. '𞥇' => 230,
  78715. '𞥈' => 230,
  78716. '𞥉' => 230,
  78717. '𞥊' => 7,
  78718. );
  78719. <?php
  78720. return array (
  78721. ' ' => ' ',
  78722. '¨' => ' ̈',
  78723. 'ª' => 'a',
  78724. '¯' => ' ̄',
  78725. '²' => '2',
  78726. '³' => '3',
  78727. '´' => ' �',
  78728. 'µ' => 'μ',
  78729. '¸' => ' ̧',
  78730. '¹' => '1',
  78731. 'º' => 'o',
  78732. '¼' => '1�4',
  78733. '½' => '1�2',
  78734. '¾' => '3�4',
  78735. 'IJ' => 'IJ',
  78736. 'ij' => 'ij',
  78737. 'Ŀ' => 'L·',
  78738. 'ŀ' => 'l·',
  78739. 'ʼn' => 'ʼn',
  78740. 'Å¿' => 's',
  78741. 'DŽ' => 'DŽ',
  78742. 'Dž' => 'Dž',
  78743. 'dž' => 'dž',
  78744. 'LJ' => 'LJ',
  78745. 'Lj' => 'Lj',
  78746. 'lj' => 'lj',
  78747. 'ÇŠ' => 'NJ',
  78748. 'Ç‹' => 'Nj',
  78749. 'nj' => 'nj',
  78750. 'DZ' => 'DZ',
  78751. 'Dz' => 'Dz',
  78752. 'dz' => 'dz',
  78753. 'ʰ' => 'h',
  78754. 'ʱ' => 'ɦ',
  78755. 'ʲ' => 'j',
  78756. 'ʳ' => 'r',
  78757. 'ʴ' => 'ɹ',
  78758. 'ʵ' => 'ɻ',
  78759. 'ʶ' => '�',
  78760. 'Ê·' => 'w',
  78761. 'ʸ' => 'y',
  78762. '˘' => ' ̆',
  78763. '˙' => ' ̇',
  78764. 'Ëš' => ' ÌŠ',
  78765. '˛' => ' ̨',
  78766. '˜' => ' ̃',
  78767. '�' => ' ̋',
  78768. 'Ë ' => 'É£',
  78769. 'Ë¡' => 'l',
  78770. 'Ë¢' => 's',
  78771. 'Ë£' => 'x',
  78772. 'ˤ' => 'ʕ',
  78773. 'ͺ' => ' ͅ',
  78774. '΄' => ' �',
  78775. '΅' => ' ̈�',
  78776. '�' => 'β',
  78777. 'ϑ' => 'θ',
  78778. 'Ï’' => 'Î¥',
  78779. 'ϓ' => 'Υ�',
  78780. 'ϔ' => 'Ϋ',
  78781. 'ϕ' => 'φ',
  78782. 'Ï–' => 'Ï€',
  78783. 'ϰ' => 'κ',
  78784. 'ϱ' => '�',
  78785. 'ϲ' => 'ς',
  78786. 'ϴ' => 'Θ',
  78787. 'ϵ' => 'ε',
  78788. 'Ϲ' => 'Σ',
  78789. 'Ö‡' => 'Õ¥Ö‚',
  78790. 'ٵ' => 'اٴ',
  78791. 'ٶ' => 'وٴ',
  78792. 'Ù·' => 'Û‡Ù´',
  78793. 'ٸ' => 'يٴ',
  78794. 'ำ' => '�า',
  78795. 'ຳ' => '�າ',
  78796. 'ໜ' => 'ຫນ',
  78797. '�' => 'ຫມ',
  78798. '༌' => '་',
  78799. 'ཷ' => 'ྲཱྀ',
  78800. 'ཹ' => 'ླཱྀ',
  78801. 'ჼ' => 'ნ',
  78802. 'á´¬' => 'A',
  78803. 'ᴭ' => 'Æ',
  78804. 'á´®' => 'B',
  78805. 'á´°' => 'D',
  78806. 'á´±' => 'E',
  78807. 'á´²' => 'ÆŽ',
  78808. 'á´³' => 'G',
  78809. 'á´´' => 'H',
  78810. 'á´µ' => 'I',
  78811. 'á´¶' => 'J',
  78812. 'á´·' => 'K',
  78813. 'á´¸' => 'L',
  78814. 'á´¹' => 'M',
  78815. 'á´º' => 'N',
  78816. 'á´¼' => 'O',
  78817. 'á´½' => 'È¢',
  78818. 'á´¾' => 'P',
  78819. 'á´¿' => 'R',
  78820. 'áµ€' => 'T',
  78821. '�' => 'U',
  78822. 'ᵂ' => 'W',
  78823. 'ᵃ' => 'a',
  78824. 'ᵄ' => '�',
  78825. 'áµ…' => 'É‘',
  78826. 'ᵆ' => 'ᴂ',
  78827. 'ᵇ' => 'b',
  78828. 'ᵈ' => 'd',
  78829. 'ᵉ' => 'e',
  78830. 'ᵊ' => 'ə',
  78831. 'ᵋ' => 'ɛ',
  78832. 'ᵌ' => 'ɜ',
  78833. '�' => 'g',
  78834. '�' => 'k',
  78835. '�' => 'm',
  78836. 'ᵑ' => 'ŋ',
  78837. 'áµ’' => 'o',
  78838. 'ᵓ' => 'ɔ',
  78839. 'áµ”' => 'á´–',
  78840. 'ᵕ' => 'ᴗ',
  78841. 'áµ–' => 'p',
  78842. 'áµ—' => 't',
  78843. 'ᵘ' => 'u',
  78844. 'áµ™' => 'á´�',
  78845. 'ᵚ' => 'ɯ',
  78846. 'áµ›' => 'v',
  78847. 'ᵜ' => 'ᴥ',
  78848. '�' => 'β',
  78849. 'ᵞ' => 'γ',
  78850. 'ᵟ' => 'δ',
  78851. 'ᵠ' => 'φ',
  78852. 'ᵡ' => 'χ',
  78853. 'áµ¢' => 'i',
  78854. 'áµ£' => 'r',
  78855. 'ᵤ' => 'u',
  78856. 'áµ¥' => 'v',
  78857. 'ᵦ' => 'β',
  78858. 'ᵧ' => 'γ',
  78859. 'ᵨ' => '�',
  78860. 'ᵩ' => 'φ',
  78861. 'ᵪ' => 'χ',
  78862. 'ᵸ' => 'н',
  78863. 'á¶›' => 'É’',
  78864. 'ᶜ' => 'c',
  78865. '�' => 'ɕ',
  78866. 'ᶞ' => 'ð',
  78867. 'ᶟ' => 'ɜ',
  78868. 'á¶ ' => 'f',
  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. 'á¶»' => 'z',
  78896. 'ᶼ' => '�',
  78897. 'á¶½' => 'Ê‘',
  78898. 'á¶¾' => 'Ê’',
  78899. 'ᶿ' => 'θ',
  78900. 'ẚ' => 'aʾ',
  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. '�' => '0',
  78945. '�' => 'i',
  78946. '�' => '4',
  78947. '�' => '5',
  78948. '�' => '6',
  78949. '�' => '7',
  78950. '�' => '8',
  78951. '�' => '9',
  78952. '�' => '+',
  78953. '�' => '−',
  78954. '�' => '=',
  78955. '�' => '(',
  78956. '�' => ')',
  78957. '�' => 'n',
  78958. 'â‚€' => '0',
  78959. '�' => '1',
  78960. 'â‚‚' => '2',
  78961. '₃' => '3',
  78962. 'â‚„' => '4',
  78963. 'â‚…' => '5',
  78964. '₆' => '6',
  78965. '₇' => '7',
  78966. '₈' => '8',
  78967. '₉' => '9',
  78968. '₊' => '+',
  78969. '₋' => '−',
  78970. '₌' => '=',
  78971. '�' => '(',
  78972. '₎' => ')',
  78973. '�' => 'a',
  78974. 'â‚‘' => 'e',
  78975. 'â‚’' => 'o',
  78976. 'â‚“' => 'x',
  78977. 'â‚”' => 'É™',
  78978. 'â‚•' => 'h',
  78979. 'â‚–' => 'k',
  78980. 'â‚—' => 'l',
  78981. 'ₘ' => 'm',
  78982. 'â‚™' => 'n',
  78983. 'ₚ' => 'p',
  78984. 'â‚›' => 's',
  78985. 'ₜ' => 't',
  78986. '₨' => 'Rs',
  78987. 'â„€' => 'a/c',
  78988. '�' => 'a/s',
  78989. 'â„‚' => 'C',
  78990. '℃' => '°C',
  78991. 'â„…' => 'c/o',
  78992. '℆' => 'c/u',
  78993. 'ℇ' => '�',
  78994. '℉' => '°F',
  78995. 'ℊ' => 'g',
  78996. 'â„‹' => 'H',
  78997. 'ℌ' => 'H',
  78998. '�' => 'H',
  78999. 'ℎ' => 'h',
  79000. '�' => 'ħ',
  79001. '�' => 'I',
  79002. 'â„‘' => 'I',
  79003. 'â„’' => 'L',
  79004. 'â„“' => 'l',
  79005. 'â„•' => 'N',
  79006. 'â„–' => 'No',
  79007. 'â„™' => 'P',
  79008. 'ℚ' => 'Q',
  79009. 'â„›' => 'R',
  79010. 'ℜ' => 'R',
  79011. '�' => 'R',
  79012. 'â„ ' => 'SM',
  79013. 'â„¡' => 'TEL',
  79014. 'â„¢' => 'TM',
  79015. 'ℤ' => 'Z',
  79016. 'ℨ' => 'Z',
  79017. 'ℬ' => 'B',
  79018. 'â„­' => 'C',
  79019. 'ℯ' => 'e',
  79020. 'â„°' => 'E',
  79021. 'ℱ' => 'F',
  79022. 'ℳ' => 'M',
  79023. 'â„´' => 'o',
  79024. 'ℵ' => '�',
  79025. 'ℶ' => 'ב',
  79026. 'â„·' => '×’',
  79027. 'ℸ' => 'ד',
  79028. 'ℹ' => 'i',
  79029. 'â„»' => 'FAX',
  79030. 'ℼ' => 'π',
  79031. 'ℽ' => 'γ',
  79032. 'ℾ' => 'Γ',
  79033. 'ℿ' => 'Π',
  79034. '⅀' => '∑',
  79035. 'â……' => 'D',
  79036. 'â…†' => 'd',
  79037. 'â…‡' => 'e',
  79038. 'â…ˆ' => 'i',
  79039. 'â…‰' => 'j',
  79040. '�' => '1�7',
  79041. '⅑' => '1�9',
  79042. '⅒' => '1�10',
  79043. '⅓' => '1�3',
  79044. '⅔' => '2�3',
  79045. '⅕' => '1�5',
  79046. '⅖' => '2�5',
  79047. '⅗' => '3�5',
  79048. '⅘' => '4�5',
  79049. '⅙' => '1�6',
  79050. '⅚' => '5�6',
  79051. '⅛' => '1�8',
  79052. '⅜' => '3�8',
  79053. '�' => '5�8',
  79054. '⅞' => '7�8',
  79055. '⅟' => '1�',
  79056. 'â… ' => 'I',
  79057. 'â…¡' => 'II',
  79058. 'â…¢' => 'III',
  79059. 'â…£' => 'IV',
  79060. 'â…¤' => 'V',
  79061. 'â…¥' => 'VI',
  79062. 'â…¦' => 'VII',
  79063. 'â…§' => 'VIII',
  79064. 'â…¨' => 'IX',
  79065. 'â…©' => 'X',
  79066. 'â…ª' => 'XI',
  79067. 'â…«' => 'XII',
  79068. 'â…¬' => 'L',
  79069. 'â…­' => 'C',
  79070. 'â…®' => 'D',
  79071. 'â…¯' => 'M',
  79072. 'â…°' => 'i',
  79073. 'â…±' => 'ii',
  79074. 'â…²' => 'iii',
  79075. 'â…³' => 'iv',
  79076. 'â…´' => 'v',
  79077. 'â…µ' => 'vi',
  79078. 'â…¶' => 'vii',
  79079. 'â…·' => 'viii',
  79080. 'â…¸' => 'ix',
  79081. 'â…¹' => 'x',
  79082. 'â…º' => 'xi',
  79083. 'â…»' => 'xii',
  79084. 'â…¼' => 'l',
  79085. 'â…½' => 'c',
  79086. 'â…¾' => 'd',
  79087. 'â…¿' => 'm',
  79088. '↉' => '0�3',
  79089. '∬' => '∫∫',
  79090. '∭' => '∫∫∫',
  79091. '∯' => '∮∮',
  79092. '∰' => '∮∮∮',
  79093. 'â‘ ' => '1',
  79094. 'â‘¡' => '2',
  79095. 'â‘¢' => '3',
  79096. 'â‘£' => '4',
  79097. '⑤' => '5',
  79098. 'â‘¥' => '6',
  79099. '⑦' => '7',
  79100. 'â‘§' => '8',
  79101. '⑨' => '9',
  79102. 'â‘©' => '10',
  79103. '⑪' => '11',
  79104. 'â‘«' => '12',
  79105. '⑬' => '13',
  79106. 'â‘­' => '14',
  79107. 'â‘®' => '15',
  79108. '⑯' => '16',
  79109. 'â‘°' => '17',
  79110. '⑱' => '18',
  79111. '⑲' => '19',
  79112. '⑳' => '20',
  79113. 'â‘´' => '(1)',
  79114. '⑵' => '(2)',
  79115. 'â‘¶' => '(3)',
  79116. 'â‘·' => '(4)',
  79117. '⑸' => '(5)',
  79118. '⑹' => '(6)',
  79119. '⑺' => '(7)',
  79120. 'â‘»' => '(8)',
  79121. '⑼' => '(9)',
  79122. '⑽' => '(10)',
  79123. '⑾' => '(11)',
  79124. 'â‘¿' => '(12)',
  79125. 'â’€' => '(13)',
  79126. 'â’�' => '(14)',
  79127. 'â’‚' => '(15)',
  79128. 'â’ƒ' => '(16)',
  79129. 'â’„' => '(17)',
  79130. 'â’…' => '(18)',
  79131. 'â’†' => '(19)',
  79132. 'â’‡' => '(20)',
  79133. 'â’ˆ' => '1.',
  79134. 'â’‰' => '2.',
  79135. 'â’Š' => '3.',
  79136. 'â’‹' => '4.',
  79137. '⒌' => '5.',
  79138. 'â’�' => '6.',
  79139. 'â’Ž' => '7.',
  79140. 'â’�' => '8.',
  79141. 'â’�' => '9.',
  79142. 'â’‘' => '10.',
  79143. 'â’’' => '11.',
  79144. 'â’“' => '12.',
  79145. 'â’”' => '13.',
  79146. 'â’•' => '14.',
  79147. 'â’–' => '15.',
  79148. 'â’—' => '16.',
  79149. 'â’˜' => '17.',
  79150. 'â’™' => '18.',
  79151. 'â’š' => '19.',
  79152. 'â’›' => '20.',
  79153. '⒜' => '(a)',
  79154. 'â’�' => '(b)',
  79155. 'â’ž' => '(c)',
  79156. 'â’Ÿ' => '(d)',
  79157. 'â’ ' => '(e)',
  79158. 'â’¡' => '(f)',
  79159. 'â’¢' => '(g)',
  79160. 'â’£' => '(h)',
  79161. 'â’¤' => '(i)',
  79162. 'â’¥' => '(j)',
  79163. 'â’¦' => '(k)',
  79164. 'â’§' => '(l)',
  79165. 'â’¨' => '(m)',
  79166. 'â’©' => '(n)',
  79167. 'â’ª' => '(o)',
  79168. 'â’«' => '(p)',
  79169. 'â’¬' => '(q)',
  79170. 'â’­' => '(r)',
  79171. 'â’®' => '(s)',
  79172. 'â’¯' => '(t)',
  79173. 'â’°' => '(u)',
  79174. 'â’±' => '(v)',
  79175. 'â’²' => '(w)',
  79176. 'â’³' => '(x)',
  79177. 'â’´' => '(y)',
  79178. 'â’µ' => '(z)',
  79179. 'â’¶' => 'A',
  79180. 'â’·' => 'B',
  79181. 'â’¸' => 'C',
  79182. 'â’¹' => 'D',
  79183. 'â’º' => 'E',
  79184. 'â’»' => 'F',
  79185. 'â’¼' => 'G',
  79186. 'â’½' => 'H',
  79187. 'â’¾' => 'I',
  79188. 'â’¿' => 'J',
  79189. 'â“€' => 'K',
  79190. '�' => 'L',
  79191. 'â“‚' => 'M',
  79192. 'Ⓝ' => 'N',
  79193. 'â“„' => 'O',
  79194. 'â“…' => 'P',
  79195. 'Ⓠ' => 'Q',
  79196. 'Ⓡ' => 'R',
  79197. 'Ⓢ' => 'S',
  79198. 'Ⓣ' => 'T',
  79199. 'Ⓤ' => 'U',
  79200. 'â“‹' => 'V',
  79201. 'Ⓦ' => 'W',
  79202. '�' => 'X',
  79203. 'Ⓨ' => 'Y',
  79204. '�' => 'Z',
  79205. '�' => 'a',
  79206. 'â“‘' => 'b',
  79207. 'â“’' => 'c',
  79208. 'â““' => 'd',
  79209. 'â“”' => 'e',
  79210. 'â“•' => 'f',
  79211. 'â“–' => 'g',
  79212. 'â“—' => 'h',
  79213. 'ⓘ' => 'i',
  79214. 'â“™' => 'j',
  79215. 'ⓚ' => 'k',
  79216. 'â“›' => 'l',
  79217. 'ⓜ' => 'm',
  79218. '�' => 'n',
  79219. 'ⓞ' => 'o',
  79220. 'ⓟ' => 'p',
  79221. 'â“ ' => 'q',
  79222. 'â“¡' => 'r',
  79223. 'â“¢' => 's',
  79224. 'â“£' => 't',
  79225. 'ⓤ' => 'u',
  79226. 'â“¥' => 'v',
  79227. 'ⓦ' => 'w',
  79228. 'â“§' => 'x',
  79229. 'ⓨ' => 'y',
  79230. 'â“©' => 'z',
  79231. '⓪' => '0',
  79232. '⨌' => '∫∫∫∫',
  79233. 'â©´' => '::=',
  79234. '⩵' => '==',
  79235. 'â©¶' => '===',
  79236. 'â±¼' => 'j',
  79237. 'â±½' => 'V',
  79238. 'ⵯ' => 'ⵡ',
  79239. '⺟' => '�',
  79240. '⻳' => '龟',
  79241. '⼀' => '一',
  79242. '�' => '丨',
  79243. '⼂' => '丶',
  79244. '⼃' => '丿',
  79245. '⼄' => '乙',
  79246. '⼅' => '亅',
  79247. '⼆' => '二',
  79248. '⼇' => '亠',
  79249. '⼈' => '人',
  79250. '⼉' => '儿',
  79251. '⼊' => '入',
  79252. '⼋' => '八',
  79253. '⼌' => '冂',
  79254. '�' => '冖',
  79255. '⼎' => '冫',
  79256. '�' => '几',
  79257. '�' => '凵',
  79258. '⼑' => '刀',
  79259. '⼒' => '力',
  79260. '⼓' => '勹',
  79261. '⼔' => '匕',
  79262. '⼕' => '匚',
  79263. '⼖' => '匸',
  79264. '⼗' => '�',
  79265. '⼘' => '�',
  79266. '⼙' => '�',
  79267. '⼚' => '厂',
  79268. '⼛' => '厶',
  79269. '⼜' => '�',
  79270. '�' => '�',
  79271. '⼞' => '囗',
  79272. '⼟' => '土',
  79273. '⼠' => '士',
  79274. '⼡' => '夂',
  79275. '⼢' => '夊',
  79276. '⼣' => '夕',
  79277. '⼤' => '大',
  79278. '⼥' => '女',
  79279. '⼦' => '�',
  79280. '⼧' => '宀',
  79281. '⼨' => '寸',
  79282. '⼩' => '�',
  79283. '⼪' => '尢',
  79284. '⼫' => '尸',
  79285. '⼬' => '屮',
  79286. 'â¼­' => 'å±±',
  79287. 'â¼®' => 'å·›',
  79288. '⼯' => '工',
  79289. 'â¼°' => 'å·±',
  79290. 'â¼±' => 'å·¾',
  79291. 'â¼²' => 'å¹²',
  79292. '⼳' => '幺',
  79293. '⼴' => '广',
  79294. 'â¼µ' => 'å»´',
  79295. '⼶' => '廾',
  79296. '⼷' => '弋',
  79297. '⼸' => '弓',
  79298. '⼹' => '�',
  79299. '⼺' => '彡',
  79300. 'â¼»' => 'å½³',
  79301. '⼼' => '心',
  79302. '⼽' => '戈',
  79303. '⼾' => '戶',
  79304. '⼿' => '手',
  79305. '⽀' => '支',
  79306. '�' => '攴',
  79307. '⽂' => '文',
  79308. '⽃' => '斗',
  79309. '⽄' => '斤',
  79310. 'â½…' => 'æ–¹',
  79311. '⽆' => '无',
  79312. '⽇' => '日',
  79313. '⽈' => '曰',
  79314. '⽉' => '月',
  79315. '⽊' => '木',
  79316. '⽋' => '欠',
  79317. '⽌' => '止',
  79318. '�' => '歹',
  79319. '⽎' => '殳',
  79320. '�' => '毋',
  79321. '�' => '比',
  79322. '⽑' => '毛',
  79323. 'â½’' => 'æ°�',
  79324. '⽓' => '气',
  79325. 'â½”' => 'æ°´',
  79326. '⽕' => '�',
  79327. '⽖' => '爪',
  79328. '⽗' => '父',
  79329. '⽘' => '爻',
  79330. '⽙' => '爿',
  79331. '⽚' => '片',
  79332. '⽛' => '牙',
  79333. '⽜' => '牛',
  79334. '�' => '犬',
  79335. '⽞' => '玄',
  79336. '⽟' => '玉',
  79337. '⽠' => '瓜',
  79338. '⽡' => '瓦',
  79339. '⽢' => '甘',
  79340. '⽣' => '生',
  79341. '⽤' => '用',
  79342. 'â½¥' => 'ç”°',
  79343. '⽦' => '疋',
  79344. 'â½§' => 'ç–’',
  79345. '⽨' => '癶',
  79346. '⽩' => '白',
  79347. '⽪' => '皮',
  79348. '⽫' => '皿',
  79349. '⽬' => '目',
  79350. '⽭' => '矛',
  79351. '⽮' => '矢',
  79352. '⽯' => '石',
  79353. '⽰' => '示',
  79354. '⽱' => '禸',
  79355. '⽲' => '禾',
  79356. 'â½³' => 'ç©´',
  79357. 'â½´' => 'ç«‹',
  79358. '⽵' => '竹',
  79359. 'â½¶' => 'ç±³',
  79360. '⽷' => '糸',
  79361. '⽸' => '缶',
  79362. '⽹' => '网',
  79363. '⽺' => '羊',
  79364. 'â½»' => 'ç¾½',
  79365. '⽼' => '�',
  79366. '⽽' => '而',
  79367. '⽾' => '耒',
  79368. '⽿' => '耳',
  79369. '⾀' => '�',
  79370. '�' => '肉',
  79371. '⾂' => '臣',
  79372. '⾃' => '自',
  79373. '⾄' => '至',
  79374. '⾅' => '臼',
  79375. '⾆' => '舌',
  79376. '⾇' => '舛',
  79377. '⾈' => '舟',
  79378. '⾉' => '艮',
  79379. '⾊' => '色',
  79380. '⾋' => '艸',
  79381. '⾌' => '�',
  79382. '�' => '虫',
  79383. '⾎' => '血',
  79384. '�' => '行',
  79385. '�' => '衣',
  79386. '⾑' => '襾',
  79387. '⾒' => '見',
  79388. '⾓' => '角',
  79389. '⾔' => '言',
  79390. '⾕' => '谷',
  79391. '⾖' => '豆',
  79392. '⾗' => '豕',
  79393. '⾘' => '豸',
  79394. '⾙' => '�',
  79395. '⾚' => '赤',
  79396. 'â¾›' => 'èµ°',
  79397. '⾜' => '足',
  79398. '�' => '身',
  79399. '⾞' => '車',
  79400. '⾟' => '辛',
  79401. 'â¾ ' => 'è¾°',
  79402. '⾡' => '辵',
  79403. 'â¾¢' => 'é‚‘',
  79404. 'â¾£' => 'é…‰',
  79405. '⾤' => '釆',
  79406. '⾥' => '里',
  79407. '⾦' => '金',
  79408. 'â¾§' => 'é•·',
  79409. '⾨' => '門',
  79410. '⾩' => '阜',
  79411. '⾪' => '隶',
  79412. '⾫' => '隹',
  79413. '⾬' => '雨',
  79414. '⾭' => '�',
  79415. '⾮' => '�',
  79416. '⾯' => '�',
  79417. '⾰' => '�',
  79418. '⾱' => '韋',
  79419. '⾲' => '韭',
  79420. '⾳' => '音',
  79421. 'â¾´' => 'é �',
  79422. '⾵' => '風',
  79423. '⾶' => '飛',
  79424. '⾷' => '食',
  79425. '⾸' => '首',
  79426. '⾹' => '香',
  79427. '⾺' => '馬',
  79428. '⾻' => '骨',
  79429. '⾼' => '高',
  79430. '⾽' => '髟',
  79431. '⾾' => '鬥',
  79432. '⾿' => '鬯',
  79433. '⿀' => '鬲',
  79434. '�' => '鬼',
  79435. 'â¿‚' => 'é­š',
  79436. '⿃' => '鳥',
  79437. 'â¿„' => 'é¹µ',
  79438. '⿅' => '鹿',
  79439. '⿆' => '麥',
  79440. '⿇' => '麻',
  79441. '⿈' => '黃',
  79442. '⿉' => '�',
  79443. '⿊' => '黑',
  79444. '⿋' => '黹',
  79445. '⿌' => '黽',
  79446. '�' => '鼎',
  79447. '⿎' => '鼓',
  79448. '�' => '鼠',
  79449. '�' => '鼻',
  79450. '⿑' => '齊',
  79451. 'â¿’' => 'é½’',
  79452. '⿓' => '�',
  79453. '⿔' => '龜',
  79454. 'â¿•' => 'é¾ ',
  79455. ' ' => ' ',
  79456. '〶' => '〒',
  79457. '〸' => '�',
  79458. '〹' => '�',
  79459. '〺' => '�',
  79460. 'ã‚›' => ' ã‚™',
  79461. '゜' => ' ゚',
  79462. 'ゟ' => 'より',
  79463. 'ヿ' => 'コト',
  79464. 'ㄱ' => 'ᄀ',
  79465. 'ㄲ' => '�',
  79466. 'ㄳ' => 'ᆪ',
  79467. 'ã„´' => 'á„‚',
  79468. 'ㄵ' => 'ᆬ',
  79469. 'ㄶ' => 'ᆭ',
  79470. 'ㄷ' => 'ᄃ',
  79471. 'ㄸ' => 'ᄄ',
  79472. 'ㄹ' => 'ᄅ',
  79473. 'ㄺ' => 'ᆰ',
  79474. 'ㄻ' => 'ᆱ',
  79475. 'ㄼ' => 'ᆲ',
  79476. 'ㄽ' => 'ᆳ',
  79477. 'ㄾ' => 'ᆴ',
  79478. 'ㄿ' => 'ᆵ',
  79479. 'ㅀ' => 'ᄚ',
  79480. '�' => 'ᄆ',
  79481. 'ㅂ' => 'ᄇ',
  79482. 'ㅃ' => 'ᄈ',
  79483. 'ã…„' => 'á„¡',
  79484. 'ㅅ' => 'ᄉ',
  79485. 'ㅆ' => 'ᄊ',
  79486. 'ã…‡' => 'á„‹',
  79487. 'ㅈ' => 'ᄌ',
  79488. 'ㅉ' => '�',
  79489. 'ㅊ' => 'ᄎ',
  79490. 'ㅋ' => '�',
  79491. 'ㅌ' => '�',
  79492. 'ã…�' => 'á„‘',
  79493. 'ã…Ž' => 'á„’',
  79494. 'ã…�' => 'á…¡',
  79495. 'ã…�' => 'á…¢',
  79496. 'ã…‘' => 'á…£',
  79497. 'ã…’' => 'á…¤',
  79498. 'ã…“' => 'á…¥',
  79499. 'ã…”' => 'á…¦',
  79500. 'ã…•' => 'á…§',
  79501. 'ã…–' => 'á…¨',
  79502. 'ã…—' => 'á…©',
  79503. 'ã…˜' => 'á…ª',
  79504. 'ã…™' => 'á…«',
  79505. 'ã…š' => 'á…¬',
  79506. 'ã…›' => 'á…­',
  79507. 'ㅜ' => 'ᅮ',
  79508. 'ã…�' => 'á…¯',
  79509. 'ã…ž' => 'á…°',
  79510. 'ã…Ÿ' => 'á…±',
  79511. 'ã… ' => 'á…²',
  79512. 'ã…¡' => 'á…³',
  79513. 'ã…¢' => 'á…´',
  79514. 'ã…£' => 'á…µ',
  79515. 'ã…¤' => 'á… ',
  79516. 'ã…¥' => 'á„”',
  79517. 'ã…¦' => 'á„•',
  79518. 'ㅧ' => 'ᇇ',
  79519. 'ㅨ' => 'ᇈ',
  79520. 'ㅩ' => 'ᇌ',
  79521. 'ㅪ' => 'ᇎ',
  79522. 'ㅫ' => 'ᇓ',
  79523. 'ㅬ' => 'ᇗ',
  79524. 'ㅭ' => 'ᇙ',
  79525. 'ㅮ' => 'ᄜ',
  79526. 'ㅯ' => '�',
  79527. 'ㅰ' => 'ᇟ',
  79528. 'ㅱ' => '�',
  79529. 'ㅲ' => 'ᄞ',
  79530. 'ã…³' => 'á„ ',
  79531. 'ã…´' => 'á„¢',
  79532. 'ã…µ' => 'á„£',
  79533. 'ã…¶' => 'á„§',
  79534. 'ã…·' => 'á„©',
  79535. 'ã…¸' => 'á„«',
  79536. 'ㅹ' => 'ᄬ',
  79537. 'ã…º' => 'á„­',
  79538. 'ã…»' => 'á„®',
  79539. 'ㅼ' => 'ᄯ',
  79540. 'ㅽ' => 'ᄲ',
  79541. 'ã…¾' => 'á„¶',
  79542. 'ã…¿' => 'á…€',
  79543. 'ㆀ' => 'ᅇ',
  79544. '�' => 'ᅌ',
  79545. 'ㆂ' => 'ᇱ',
  79546. 'ㆃ' => 'ᇲ',
  79547. 'ㆄ' => 'ᅗ',
  79548. 'ㆅ' => 'ᅘ',
  79549. 'ㆆ' => 'ᅙ',
  79550. 'ㆇ' => 'ᆄ',
  79551. 'ㆈ' => 'ᆅ',
  79552. 'ㆉ' => 'ᆈ',
  79553. 'ㆊ' => 'ᆑ',
  79554. 'ㆋ' => 'ᆒ',
  79555. 'ㆌ' => 'ᆔ',
  79556. '�' => 'ᆞ',
  79557. 'ㆎ' => 'ᆡ',
  79558. '㆒' => '一',
  79559. '㆓' => '二',
  79560. '㆔' => '三',
  79561. '㆕' => '四',
  79562. '㆖' => '上',
  79563. '㆗' => '中',
  79564. '㆘' => '下',
  79565. '㆙' => '甲',
  79566. '㆚' => '乙',
  79567. '㆛' => '丙',
  79568. '㆜' => '�',
  79569. '�' => '天',
  79570. '㆞' => '地',
  79571. '㆟' => '人',
  79572. '㈀' => '(ᄀ)',
  79573. '�' => '(ᄂ)',
  79574. '㈂' => '(ᄃ)',
  79575. '㈃' => '(ᄅ)',
  79576. '㈄' => '(ᄆ)',
  79577. '㈅' => '(ᄇ)',
  79578. '㈆' => '(ᄉ)',
  79579. '㈇' => '(ᄋ)',
  79580. '㈈' => '(ᄌ)',
  79581. '㈉' => '(ᄎ)',
  79582. '㈊' => '(�)',
  79583. '㈋' => '(�)',
  79584. '㈌' => '(ᄑ)',
  79585. '�' => '(ᄒ)',
  79586. '㈎' => '(가)',
  79587. '�' => '(나)',
  79588. '�' => '(다)',
  79589. '㈑' => '(라)',
  79590. '㈒' => '(마)',
  79591. '㈓' => '(바)',
  79592. '㈔' => '(사)',
  79593. '㈕' => '(아)',
  79594. '㈖' => '(자)',
  79595. '㈗' => '(차)',
  79596. '㈘' => '(�ᅡ)',
  79597. '㈙' => '(�ᅡ)',
  79598. '㈚' => '(파)',
  79599. '㈛' => '(하)',
  79600. '㈜' => '(주)',
  79601. '�' => '(오전)',
  79602. '㈞' => '(오후)',
  79603. '㈠' => '(一)',
  79604. '㈡' => '(二)',
  79605. '㈢' => '(三)',
  79606. '㈣' => '(四)',
  79607. '㈤' => '(五)',
  79608. '㈥' => '(六)',
  79609. '㈦' => '(七)',
  79610. '㈧' => '(八)',
  79611. '㈨' => '(�)',
  79612. '㈩' => '(�)',
  79613. '㈪' => '(月)',
  79614. '㈫' => '(�)',
  79615. '㈬' => '(水)',
  79616. '㈭' => '(木)',
  79617. '㈮' => '(金)',
  79618. '㈯' => '(土)',
  79619. '㈰' => '(日)',
  79620. '㈱' => '(株)',
  79621. '㈲' => '(有)',
  79622. '㈳' => '(社)',
  79623. '㈴' => '(�)',
  79624. '㈵' => '(特)',
  79625. '㈶' => '(財)',
  79626. '㈷' => '(�)',
  79627. '㈸' => '(労)',
  79628. '㈹' => '(代)',
  79629. '㈺' => '(呼)',
  79630. '㈻' => '(学)',
  79631. '㈼' => '(監)',
  79632. '㈽' => '(�)',
  79633. '㈾' => '(資)',
  79634. '㈿' => '(�)',
  79635. '㉀' => '(祭)',
  79636. '�' => '(休)',
  79637. '㉂' => '(自)',
  79638. '㉃' => '(至)',
  79639. '㉄' => '�',
  79640. '㉅' => '幼',
  79641. '㉆' => '文',
  79642. '㉇' => '�',
  79643. '�' => 'PTE',
  79644. '㉑' => '21',
  79645. '㉒' => '22',
  79646. '㉓' => '23',
  79647. '㉔' => '24',
  79648. '㉕' => '25',
  79649. '㉖' => '26',
  79650. '㉗' => '27',
  79651. '㉘' => '28',
  79652. '㉙' => '29',
  79653. '㉚' => '30',
  79654. '㉛' => '31',
  79655. '㉜' => '32',
  79656. '�' => '33',
  79657. '㉞' => '34',
  79658. '㉟' => '35',
  79659. '㉠' => 'ᄀ',
  79660. '㉡' => 'ᄂ',
  79661. '㉢' => 'ᄃ',
  79662. '㉣' => 'ᄅ',
  79663. '㉤' => 'ᄆ',
  79664. '㉥' => 'ᄇ',
  79665. '㉦' => 'ᄉ',
  79666. '㉧' => 'ᄋ',
  79667. '㉨' => 'ᄌ',
  79668. '㉩' => 'ᄎ',
  79669. '㉪' => '�',
  79670. '㉫' => '�',
  79671. '㉬' => 'ᄑ',
  79672. '㉭' => 'ᄒ',
  79673. '㉮' => '가',
  79674. '㉯' => '나',
  79675. '㉰' => '다',
  79676. '㉱' => '라',
  79677. '㉲' => '마',
  79678. '㉳' => '바',
  79679. '㉴' => '사',
  79680. '㉵' => '아',
  79681. '㉶' => '자',
  79682. '㉷' => '차',
  79683. '㉸' => '�ᅡ',
  79684. '㉹' => '�ᅡ',
  79685. '㉺' => '파',
  79686. '㉻' => '하',
  79687. '㉼' => '참고',
  79688. '㉽' => '주의',
  79689. '㉾' => '우',
  79690. '㊀' => '一',
  79691. '�' => '二',
  79692. '㊂' => '三',
  79693. '㊃' => '四',
  79694. '㊄' => '五',
  79695. '㊅' => '六',
  79696. '㊆' => '七',
  79697. '㊇' => '八',
  79698. '㊈' => '�',
  79699. '㊉' => '�',
  79700. '㊊' => '月',
  79701. '㊋' => '�',
  79702. '㊌' => '水',
  79703. '�' => '木',
  79704. '㊎' => '金',
  79705. '�' => '土',
  79706. '�' => '日',
  79707. '㊑' => '株',
  79708. '㊒' => '有',
  79709. '㊓' => '社',
  79710. '㊔' => '�',
  79711. '㊕' => '特',
  79712. '㊖' => '財',
  79713. '㊗' => '�',
  79714. '㊘' => '労',
  79715. '㊙' => '秘',
  79716. '㊚' => '男',
  79717. '㊛' => '女',
  79718. '㊜' => '�',
  79719. '�' => '優',
  79720. '㊞' => '�',
  79721. '㊟' => '注',
  79722. '㊠' => '項',
  79723. '㊡' => '休',
  79724. '㊢' => '写',
  79725. '㊣' => '正',
  79726. '㊤' => '上',
  79727. '㊥' => '中',
  79728. '㊦' => '下',
  79729. '㊧' => '左',
  79730. '㊨' => '�',
  79731. '㊩' => '医',
  79732. '㊪' => '宗',
  79733. '㊫' => '学',
  79734. '㊬' => '監',
  79735. '㊭' => '�',
  79736. '㊮' => '資',
  79737. '㊯' => '�',
  79738. '㊰' => '夜',
  79739. '㊱' => '36',
  79740. '㊲' => '37',
  79741. '㊳' => '38',
  79742. '㊴' => '39',
  79743. '㊵' => '40',
  79744. '㊶' => '41',
  79745. '㊷' => '42',
  79746. '㊸' => '43',
  79747. '㊹' => '44',
  79748. '㊺' => '45',
  79749. '㊻' => '46',
  79750. '㊼' => '47',
  79751. '㊽' => '48',
  79752. '㊾' => '49',
  79753. '㊿' => '50',
  79754. '㋀' => '1月',
  79755. '�' => '2月',
  79756. '㋂' => '3月',
  79757. '㋃' => '4月',
  79758. '㋄' => '5月',
  79759. '㋅' => '6月',
  79760. '㋆' => '7月',
  79761. '㋇' => '8月',
  79762. '㋈' => '9月',
  79763. '㋉' => '10月',
  79764. '㋊' => '11月',
  79765. '㋋' => '12月',
  79766. '㋌' => 'Hg',
  79767. '�' => 'erg',
  79768. '㋎' => 'eV',
  79769. '�' => 'LTD',
  79770. '�' => 'ア',
  79771. '㋑' => 'イ',
  79772. '㋒' => 'ウ',
  79773. '㋓' => 'エ',
  79774. '㋔' => 'オ',
  79775. 'ã‹•' => 'ã‚«',
  79776. 'ã‹–' => 'ã‚­',
  79777. '㋗' => 'ク',
  79778. '㋘' => 'ケ',
  79779. '㋙' => 'コ',
  79780. '㋚' => 'サ',
  79781. 'ã‹›' => 'ã‚·',
  79782. '㋜' => 'ス',
  79783. '�' => 'セ',
  79784. '㋞' => 'ソ',
  79785. '㋟' => 'タ',
  79786. '㋠' => '�',
  79787. '㋡' => 'ツ',
  79788. '㋢' => 'テ',
  79789. '㋣' => 'ト',
  79790. '㋤' => 'ナ',
  79791. '㋥' => 'ニ',
  79792. '㋦' => 'ヌ',
  79793. '㋧' => '�',
  79794. '㋨' => 'ノ',
  79795. '㋩' => '�',
  79796. '㋪' => 'ヒ',
  79797. '㋫' => 'フ',
  79798. '㋬' => 'ヘ',
  79799. '㋭' => 'ホ',
  79800. '㋮' => 'マ',
  79801. '㋯' => 'ミ',
  79802. '㋰' => 'ム',
  79803. '㋱' => 'メ',
  79804. '㋲' => 'モ',
  79805. '㋳' => 'ヤ',
  79806. '㋴' => 'ユ',
  79807. '㋵' => 'ヨ',
  79808. '㋶' => 'ラ',
  79809. '㋷' => 'リ',
  79810. '㋸' => 'ル',
  79811. '㋹' => 'レ',
  79812. '㋺' => 'ロ',
  79813. '㋻' => 'ワ',
  79814. '㋼' => 'ヰ',
  79815. '㋽' => 'ヱ',
  79816. '㋾' => 'ヲ',
  79817. '㋿' => '令和',
  79818. '㌀' => 'ア�゚ート',
  79819. '�' => 'アルファ',
  79820. '㌂' => 'アンペア',
  79821. '㌃' => 'アール',
  79822. '㌄' => 'イニング',
  79823. '㌅' => 'イン�',
  79824. '㌆' => 'ウォン',
  79825. '㌇' => 'エスクード',
  79826. '㌈' => 'エーカー',
  79827. '㌉' => 'オンス',
  79828. '㌊' => 'オーム',
  79829. '㌋' => 'カイリ',
  79830. '㌌' => 'カラット',
  79831. '�' => 'カロリー',
  79832. '㌎' => 'ガロン',
  79833. '�' => 'ガンマ',
  79834. '�' => 'ギガ',
  79835. '㌑' => 'ギニー',
  79836. '㌒' => 'キュリー',
  79837. '㌓' => 'ギルダー',
  79838. '㌔' => 'キロ',
  79839. '㌕' => 'キログラム',
  79840. '㌖' => 'キロメートル',
  79841. '㌗' => 'キロワット',
  79842. '㌘' => 'グラム',
  79843. '㌙' => 'グラムトン',
  79844. '㌚' => 'クルゼイロ',
  79845. '㌛' => 'クロー�',
  79846. '㌜' => 'ケース',
  79847. '�' => 'コルナ',
  79848. '㌞' => 'コーポ',
  79849. '㌟' => 'サイクル',
  79850. '㌠' => 'サン�ーム',
  79851. '㌡' => 'シリング',
  79852. '㌢' => 'セン�',
  79853. '㌣' => 'セント',
  79854. '㌤' => 'ダース',
  79855. '㌥' => 'デシ',
  79856. '㌦' => 'ドル',
  79857. '㌧' => 'トン',
  79858. '㌨' => 'ナノ',
  79859. '㌩' => 'ノット',
  79860. '㌪' => '�イツ',
  79861. '㌫' => '�゚ーセント',
  79862. '㌬' => '�゚ーツ',
  79863. '㌭' => '�゙ーレル',
  79864. '㌮' => 'ピアストル',
  79865. '㌯' => 'ピクル',
  79866. '㌰' => 'ピコ',
  79867. '㌱' => 'ビル',
  79868. '㌲' => 'ファラッド',
  79869. '㌳' => 'フィート',
  79870. '㌴' => 'ブッシェル',
  79871. '㌵' => 'フラン',
  79872. '㌶' => 'ヘクタール',
  79873. '㌷' => 'ペソ',
  79874. '㌸' => 'ペニヒ',
  79875. '㌹' => 'ヘルツ',
  79876. '㌺' => 'ペンス',
  79877. '㌻' => 'ページ',
  79878. '㌼' => 'ベータ',
  79879. '㌽' => 'ポイント',
  79880. '㌾' => 'ボルト',
  79881. '㌿' => 'ホン',
  79882. '�' => 'ポンド',
  79883. '�' => 'ホール',
  79884. '�' => 'ホーン',
  79885. '�' => 'マイクロ',
  79886. '�' => 'マイル',
  79887. '�' => 'マッ�',
  79888. '�' => 'マルク',
  79889. '�' => 'マンション',
  79890. '�' => 'ミクロン',
  79891. '�' => 'ミリ',
  79892. '�' => 'ミリ�゙ール',
  79893. '�' => 'メガ',
  79894. '�' => 'メガトン',
  79895. '�' => 'メートル',
  79896. '�' => 'ヤード',
  79897. '�' => 'ヤール',
  79898. '�' => 'ユアン',
  79899. '�' => 'リットル',
  79900. '�' => 'リラ',
  79901. '�' => 'ルピー',
  79902. '�' => 'ルーブル',
  79903. '�' => 'レム',
  79904. '�' => 'レントゲン',
  79905. '�' => 'ワット',
  79906. '�' => '0点',
  79907. '�' => '1点',
  79908. '�' => '2点',
  79909. '�' => '3点',
  79910. '�' => '4点',
  79911. '�' => '5点',
  79912. '�' => '6点',
  79913. '�' => '7点',
  79914. '�' => '8点',
  79915. '�' => '9点',
  79916. '�' => '10点',
  79917. '�' => '11点',
  79918. '�' => '12点',
  79919. '�' => '13点',
  79920. '�' => '14点',
  79921. '�' => '15点',
  79922. '�' => '16点',
  79923. '�' => '17点',
  79924. '�' => '18点',
  79925. '�' => '19点',
  79926. '�' => '20点',
  79927. '�' => '21点',
  79928. '�' => '22点',
  79929. '�' => '23点',
  79930. '�' => '24点',
  79931. '�' => 'hPa',
  79932. '�' => 'da',
  79933. '�' => 'AU',
  79934. '�' => 'bar',
  79935. '�' => 'oV',
  79936. '�' => 'pc',
  79937. '�' => 'dm',
  79938. '�' => 'dm2',
  79939. '�' => 'dm3',
  79940. '�' => 'IU',
  79941. '�' => '平�',
  79942. '�' => '昭和',
  79943. '�' => '大正',
  79944. '�' => '明治',
  79945. '�' => '株�会社',
  79946. '㎀' => 'pA',
  79947. '�' => 'nA',
  79948. '㎂' => 'μA',
  79949. '㎃' => 'mA',
  79950. '㎄' => 'kA',
  79951. '㎅' => 'KB',
  79952. '㎆' => 'MB',
  79953. '㎇' => 'GB',
  79954. '㎈' => 'cal',
  79955. '㎉' => 'kcal',
  79956. '㎊' => 'pF',
  79957. '㎋' => 'nF',
  79958. '㎌' => 'μF',
  79959. '�' => 'μg',
  79960. '㎎' => 'mg',
  79961. '�' => 'kg',
  79962. '�' => 'Hz',
  79963. '㎑' => 'kHz',
  79964. '㎒' => 'MHz',
  79965. '㎓' => 'GHz',
  79966. '㎔' => 'THz',
  79967. '㎕' => 'μl',
  79968. '㎖' => 'ml',
  79969. '㎗' => 'dl',
  79970. '㎘' => 'kl',
  79971. '㎙' => 'fm',
  79972. '㎚' => 'nm',
  79973. '㎛' => 'μm',
  79974. '㎜' => 'mm',
  79975. '�' => 'cm',
  79976. '㎞' => 'km',
  79977. '㎟' => 'mm2',
  79978. '㎠' => 'cm2',
  79979. '㎡' => 'm2',
  79980. '㎢' => 'km2',
  79981. '㎣' => 'mm3',
  79982. '㎤' => 'cm3',
  79983. '㎥' => 'm3',
  79984. '㎦' => 'km3',
  79985. '㎧' => 'm∕s',
  79986. '㎨' => 'm∕s2',
  79987. '㎩' => 'Pa',
  79988. '㎪' => 'kPa',
  79989. '㎫' => 'MPa',
  79990. '㎬' => 'GPa',
  79991. '㎭' => 'rad',
  79992. '㎮' => 'rad∕s',
  79993. '㎯' => 'rad∕s2',
  79994. '㎰' => 'ps',
  79995. '㎱' => 'ns',
  79996. '㎲' => 'μs',
  79997. '㎳' => 'ms',
  79998. '㎴' => 'pV',
  79999. '㎵' => 'nV',
  80000. '㎶' => 'μV',
  80001. '㎷' => 'mV',
  80002. '㎸' => 'kV',
  80003. '㎹' => 'MV',
  80004. '㎺' => 'pW',
  80005. '㎻' => 'nW',
  80006. '㎼' => 'μW',
  80007. '㎽' => 'mW',
  80008. '㎾' => 'kW',
  80009. '㎿' => 'MW',
  80010. '�' => 'kΩ',
  80011. '�' => 'MΩ',
  80012. '�' => 'a.m.',
  80013. '�' => 'Bq',
  80014. '�' => 'cc',
  80015. '�' => 'cd',
  80016. '�' => 'C∕kg',
  80017. '�' => 'Co.',
  80018. '�' => 'dB',
  80019. '�' => 'Gy',
  80020. '�' => 'ha',
  80021. '�' => 'HP',
  80022. '�' => 'in',
  80023. '�' => 'KK',
  80024. '�' => 'KM',
  80025. '�' => 'kt',
  80026. '�' => 'lm',
  80027. '�' => 'ln',
  80028. '�' => 'log',
  80029. '�' => 'lx',
  80030. '�' => 'mb',
  80031. '�' => 'mil',
  80032. '�' => 'mol',
  80033. '�' => 'PH',
  80034. '�' => 'p.m.',
  80035. '�' => 'PPM',
  80036. '�' => 'PR',
  80037. '�' => 'sr',
  80038. '�' => 'Sv',
  80039. '�' => 'Wb',
  80040. '�' => 'V∕m',
  80041. '�' => 'A∕m',
  80042. '�' => '1日',
  80043. '�' => '2日',
  80044. '�' => '3日',
  80045. '�' => '4日',
  80046. '�' => '5日',
  80047. '�' => '6日',
  80048. '�' => '7日',
  80049. '�' => '8日',
  80050. '�' => '9日',
  80051. '�' => '10日',
  80052. '�' => '11日',
  80053. '�' => '12日',
  80054. '�' => '13日',
  80055. '�' => '14日',
  80056. '�' => '15日',
  80057. '�' => '16日',
  80058. '�' => '17日',
  80059. '�' => '18日',
  80060. '�' => '19日',
  80061. '�' => '20日',
  80062. '�' => '21日',
  80063. '�' => '22日',
  80064. '�' => '23日',
  80065. '�' => '24日',
  80066. '�' => '25日',
  80067. '�' => '26日',
  80068. '�' => '27日',
  80069. '�' => '28日',
  80070. '�' => '29日',
  80071. '�' => '30日',
  80072. '�' => '31日',
  80073. '�' => 'gal',
  80074. 'ꚜ' => 'ъ',
  80075. '�' => 'ь',
  80076. '�' => '�',
  80077. 'ꟸ' => 'Ħ',
  80078. 'ꟹ' => 'œ',
  80079. 'ꭜ' => 'ꜧ',
  80080. '�' => 'ꬷ',
  80081. 'ê­ž' => 'É«',
  80082. 'ê­Ÿ' => 'ê­’',
  80083. 'ꭩ' => '�',
  80084. 'ff' => 'ff',
  80085. '�' => 'fi',
  80086. 'fl' => 'fl',
  80087. 'ffi' => 'ffi',
  80088. 'ffl' => 'ffl',
  80089. 'ſt' => 'st',
  80090. 'st' => 'st',
  80091. 'ﬓ' => 'մն',
  80092. 'ﬔ' => 'մե',
  80093. 'ﬕ' => 'մի',
  80094. 'ﬖ' => 'վն',
  80095. 'ﬗ' => 'մխ',
  80096. 'ﬠ' => 'ע',
  80097. 'ﬡ' => '�',
  80098. 'ﬢ' => 'ד',
  80099. 'ﬣ' => 'ה',
  80100. 'ﬤ' => 'כ',
  80101. 'ﬥ' => 'ל',
  80102. 'ﬦ' => '�',
  80103. 'ﬧ' => 'ר',
  80104. 'ﬨ' => 'ת',
  80105. '﬩' => '+',
  80106. '�' => '�ל',
  80107. 'ï­�' => 'Ù±',
  80108. 'ï­‘' => 'Ù±',
  80109. 'ï­’' => 'Ù»',
  80110. 'ï­“' => 'Ù»',
  80111. 'ï­”' => 'Ù»',
  80112. 'ï­•' => 'Ù»',
  80113. 'ï­–' => 'Ù¾',
  80114. 'ï­—' => 'Ù¾',
  80115. 'ï­˜' => 'Ù¾',
  80116. 'ï­™' => 'Ù¾',
  80117. 'ï­š' => 'Ú€',
  80118. 'ï­›' => 'Ú€',
  80119. 'ﭜ' => 'ڀ',
  80120. 'ï­�' => 'Ú€',
  80121. 'ï­ž' => 'Ùº',
  80122. 'ï­Ÿ' => 'Ùº',
  80123. 'ï­ ' => 'Ùº',
  80124. 'ï­¡' => 'Ùº',
  80125. 'ï­¢' => 'Ù¿',
  80126. 'ï­£' => 'Ù¿',
  80127. 'ï­¤' => 'Ù¿',
  80128. 'ï­¥' => 'Ù¿',
  80129. 'ï­¦' => 'Ù¹',
  80130. 'ï­§' => 'Ù¹',
  80131. 'ï­¨' => 'Ù¹',
  80132. 'ï­©' => 'Ù¹',
  80133. 'ï­ª' => 'Ú¤',
  80134. 'ï­«' => 'Ú¤',
  80135. 'ï­¬' => 'Ú¤',
  80136. 'ï­­' => 'Ú¤',
  80137. 'ï­®' => 'Ú¦',
  80138. 'ï­¯' => 'Ú¦',
  80139. 'ï­°' => 'Ú¦',
  80140. 'ï­±' => 'Ú¦',
  80141. 'ï­²' => 'Ú„',
  80142. 'ï­³' => 'Ú„',
  80143. 'ï­´' => 'Ú„',
  80144. 'ï­µ' => 'Ú„',
  80145. 'ï­¶' => 'Úƒ',
  80146. 'ï­·' => 'Úƒ',
  80147. 'ï­¸' => 'Úƒ',
  80148. 'ï­¹' => 'Úƒ',
  80149. 'ï­º' => 'Ú†',
  80150. 'ï­»' => 'Ú†',
  80151. 'ï­¼' => 'Ú†',
  80152. 'ï­½' => 'Ú†',
  80153. 'ï­¾' => 'Ú‡',
  80154. 'ï­¿' => 'Ú‡',
  80155. 'ﮀ' => 'ڇ',
  80156. '�' => 'ڇ',
  80157. 'ﮂ' => '�',
  80158. 'ﮃ' => '�',
  80159. 'ﮄ' => 'ڌ',
  80160. 'ﮅ' => 'ڌ',
  80161. 'ﮆ' => 'ڎ',
  80162. 'ﮇ' => 'ڎ',
  80163. 'ﮈ' => 'ڈ',
  80164. 'ﮉ' => 'ڈ',
  80165. 'ﮊ' => 'ژ',
  80166. 'ﮋ' => 'ژ',
  80167. 'ﮌ' => 'ڑ',
  80168. '�' => 'ڑ',
  80169. 'ﮎ' => 'ک',
  80170. '�' => 'ک',
  80171. '�' => 'ک',
  80172. 'ﮑ' => 'ک',
  80173. 'ï®’' => 'Ú¯',
  80174. 'ﮓ' => 'گ',
  80175. 'ï®”' => 'Ú¯',
  80176. 'ﮕ' => 'گ',
  80177. 'ï®–' => 'Ú³',
  80178. 'ï®—' => 'Ú³',
  80179. 'ﮘ' => 'ڳ',
  80180. 'ï®™' => 'Ú³',
  80181. 'ﮚ' => 'ڱ',
  80182. 'ï®›' => 'Ú±',
  80183. 'ﮜ' => 'ڱ',
  80184. '�' => 'ڱ',
  80185. 'ﮞ' => 'ں',
  80186. 'ﮟ' => 'ں',
  80187. 'ï® ' => 'Ú»',
  80188. 'ﮡ' => 'ڻ',
  80189. 'ﮢ' => 'ڻ',
  80190. 'ﮣ' => 'ڻ',
  80191. 'ﮤ' => 'ۀ',
  80192. 'ﮥ' => 'ۀ',
  80193. 'ﮦ' => '�',
  80194. 'ï®§' => 'Û�',
  80195. 'ﮨ' => '�',
  80196. 'ﮩ' => '�',
  80197. 'ﮪ' => 'ھ',
  80198. 'ﮫ' => 'ھ',
  80199. 'ﮬ' => 'ھ',
  80200. 'ï®­' => 'Ú¾',
  80201. 'ï®®' => 'Û’',
  80202. 'ﮯ' => 'ے',
  80203. 'ï®°' => 'Û’Ù”',
  80204. 'ï®±' => 'Û’Ù”',
  80205. 'ﯓ' => 'ڭ',
  80206. 'ﯔ' => 'ڭ',
  80207. 'ﯕ' => 'ڭ',
  80208. 'ﯖ' => 'ڭ',
  80209. 'ﯗ' => 'ۇ',
  80210. 'ﯘ' => 'ۇ',
  80211. 'ﯙ' => 'ۆ',
  80212. 'ﯚ' => 'ۆ',
  80213. 'ﯛ' => 'ۈ',
  80214. 'ﯜ' => 'ۈ',
  80215. '�' => 'ۇٴ',
  80216. 'ﯞ' => 'ۋ',
  80217. 'ﯟ' => 'ۋ',
  80218. 'ﯠ' => 'ۅ',
  80219. 'ﯡ' => 'ۅ',
  80220. 'ﯢ' => 'ۉ',
  80221. 'ﯣ' => 'ۉ',
  80222. 'ﯤ' => '�',
  80223. 'ﯥ' => '�',
  80224. 'ﯦ' => '�',
  80225. 'ﯧ' => '�',
  80226. 'ﯨ' => 'ى',
  80227. 'ﯩ' => 'ى',
  80228. 'ﯪ' => 'ئا',
  80229. 'ﯫ' => 'ئا',
  80230. 'ﯬ' => 'ئە',
  80231. 'ﯭ' => 'ئە',
  80232. 'ﯮ' => 'ئو',
  80233. 'ﯯ' => 'ئو',
  80234. 'ﯰ' => 'ئۇ',
  80235. 'ﯱ' => 'ئۇ',
  80236. 'ﯲ' => 'ئۆ',
  80237. 'ﯳ' => 'ئۆ',
  80238. 'ﯴ' => 'ئۈ',
  80239. 'ﯵ' => 'ئۈ',
  80240. 'ﯶ' => 'ئ�',
  80241. 'ﯷ' => 'ئ�',
  80242. 'ﯸ' => 'ئ�',
  80243. 'ﯹ' => 'ئى',
  80244. 'ﯺ' => 'ئى',
  80245. 'ﯻ' => 'ئى',
  80246. 'ﯼ' => 'ی',
  80247. 'ﯽ' => 'ی',
  80248. 'ﯾ' => 'ی',
  80249. 'ﯿ' => 'ی',
  80250. 'ﰀ' => 'ئج',
  80251. '�' => 'ئح',
  80252. 'ï°‚' => 'ÙŠÙ”Ù…',
  80253. 'ï°ƒ' => 'ÙŠÙ”Ù‰',
  80254. 'ï°„' => 'ÙŠÙ”ÙŠ',
  80255. 'ﰅ' => 'بج',
  80256. 'ﰆ' => 'بح',
  80257. 'ﰇ' => 'بخ',
  80258. 'ﰈ' => 'بم',
  80259. 'ﰉ' => 'بى',
  80260. 'ﰊ' => 'بي',
  80261. 'ﰋ' => 'تج',
  80262. 'ﰌ' => 'تح',
  80263. '�' => 'تخ',
  80264. 'ﰎ' => 'تم',
  80265. '�' => 'تى',
  80266. '�' => 'تي',
  80267. 'ﰑ' => 'ثج',
  80268. 'ﰒ' => 'ثم',
  80269. 'ﰓ' => 'ثى',
  80270. 'ﰔ' => 'ثي',
  80271. 'ﰕ' => 'جح',
  80272. 'ﰖ' => 'جم',
  80273. 'ﰗ' => 'حج',
  80274. 'ﰘ' => 'حم',
  80275. 'ﰙ' => 'خج',
  80276. 'ﰚ' => 'خح',
  80277. 'ﰛ' => 'خم',
  80278. 'ﰜ' => 'سج',
  80279. '�' => 'سح',
  80280. 'ﰞ' => 'سخ',
  80281. 'ﰟ' => 'سم',
  80282. 'ﰠ' => 'صح',
  80283. 'ﰡ' => 'صم',
  80284. 'ﰢ' => 'ضج',
  80285. 'ﰣ' => 'ضح',
  80286. 'ﰤ' => 'ضخ',
  80287. 'ﰥ' => 'ضم',
  80288. 'ﰦ' => 'طح',
  80289. 'ﰧ' => 'طم',
  80290. 'ﰨ' => 'ظم',
  80291. 'ﰩ' => 'عج',
  80292. 'ﰪ' => 'عم',
  80293. 'ﰫ' => 'غج',
  80294. 'ﰬ' => 'غم',
  80295. 'ﰭ' => '�ج',
  80296. 'ﰮ' => '�ح',
  80297. 'ﰯ' => '�خ',
  80298. 'ﰰ' => '�م',
  80299. 'ﰱ' => '�ى',
  80300. 'ﰲ' => '�ي',
  80301. 'ﰳ' => 'قح',
  80302. 'ﰴ' => 'قم',
  80303. 'ﰵ' => 'قى',
  80304. 'ﰶ' => 'قي',
  80305. 'ﰷ' => 'كا',
  80306. 'ﰸ' => 'كج',
  80307. 'ﰹ' => 'كح',
  80308. 'ﰺ' => 'كخ',
  80309. 'ﰻ' => 'كل',
  80310. 'ﰼ' => 'كم',
  80311. 'ﰽ' => 'كى',
  80312. 'ﰾ' => 'كي',
  80313. 'ﰿ' => 'لج',
  80314. 'ﱀ' => 'لح',
  80315. '�' => 'لخ',
  80316. 'ﱂ' => 'لم',
  80317. 'ﱃ' => 'لى',
  80318. 'ﱄ' => 'لي',
  80319. 'ﱅ' => 'مج',
  80320. 'ﱆ' => 'مح',
  80321. 'ﱇ' => 'مخ',
  80322. 'ﱈ' => 'مم',
  80323. 'ﱉ' => 'مى',
  80324. 'ﱊ' => 'مي',
  80325. 'ﱋ' => 'نج',
  80326. 'ﱌ' => 'نح',
  80327. '�' => 'نخ',
  80328. 'ﱎ' => 'نم',
  80329. '�' => 'نى',
  80330. '�' => 'ني',
  80331. 'ﱑ' => 'هج',
  80332. 'ﱒ' => 'هم',
  80333. 'ﱓ' => 'هى',
  80334. 'ﱔ' => 'هي',
  80335. 'ﱕ' => 'يج',
  80336. 'ﱖ' => 'يح',
  80337. 'ﱗ' => 'يخ',
  80338. 'ﱘ' => 'يم',
  80339. 'ﱙ' => 'يى',
  80340. 'ﱚ' => 'يي',
  80341. 'ﱛ' => 'ذٰ',
  80342. 'ﱜ' => 'رٰ',
  80343. '�' => 'ىٰ',
  80344. 'ﱞ' => ' ٌّ',
  80345. 'ﱟ' => ' �ّ',
  80346. 'ï± ' => ' ÙŽÙ‘',
  80347. 'ﱡ' => ' �ّ',
  80348. 'ﱢ' => ' �ّ',
  80349. 'ﱣ' => ' ّٰ',
  80350. 'ﱤ' => 'ئر',
  80351. 'ﱥ' => 'ئز',
  80352. 'ﱦ' => 'ئم',
  80353. 'ï±§' => 'ÙŠÙ”Ù†',
  80354. 'ﱨ' => 'ئى',
  80355. 'ﱩ' => 'ئي',
  80356. 'ﱪ' => 'بر',
  80357. 'ﱫ' => 'بز',
  80358. 'ﱬ' => 'بم',
  80359. 'ﱭ' => 'بن',
  80360. 'ﱮ' => 'بى',
  80361. 'ﱯ' => 'بي',
  80362. 'ﱰ' => 'تر',
  80363. 'ﱱ' => 'تز',
  80364. 'ﱲ' => 'تم',
  80365. 'ﱳ' => 'تن',
  80366. 'ﱴ' => 'تى',
  80367. 'ﱵ' => 'تي',
  80368. 'ﱶ' => 'ثر',
  80369. 'ﱷ' => 'ثز',
  80370. 'ﱸ' => 'ثم',
  80371. 'ﱹ' => 'ثن',
  80372. 'ﱺ' => 'ثى',
  80373. 'ﱻ' => 'ثي',
  80374. 'ﱼ' => '�ى',
  80375. 'ﱽ' => '�ي',
  80376. 'ﱾ' => 'قى',
  80377. 'ﱿ' => 'قي',
  80378. 'ﲀ' => 'كا',
  80379. '�' => 'كل',
  80380. 'ﲂ' => 'كم',
  80381. 'ﲃ' => 'كى',
  80382. 'ﲄ' => 'كي',
  80383. 'ﲅ' => 'لم',
  80384. 'ﲆ' => 'لى',
  80385. 'ﲇ' => 'لي',
  80386. 'ﲈ' => 'ما',
  80387. 'ﲉ' => 'مم',
  80388. 'ﲊ' => 'نر',
  80389. 'ﲋ' => 'نز',
  80390. 'ﲌ' => 'نم',
  80391. '�' => 'نن',
  80392. 'ﲎ' => 'نى',
  80393. '�' => 'ني',
  80394. '�' => 'ىٰ',
  80395. 'ﲑ' => 'ير',
  80396. 'ﲒ' => 'يز',
  80397. 'ﲓ' => 'يم',
  80398. 'ﲔ' => 'ين',
  80399. 'ﲕ' => 'يى',
  80400. 'ﲖ' => 'يي',
  80401. 'ﲗ' => 'ئج',
  80402. 'ﲘ' => 'ئح',
  80403. 'ﲙ' => 'ئخ',
  80404. 'ﲚ' => 'ئم',
  80405. 'ï²›' => 'ÙŠÙ”Ù‡',
  80406. 'ﲜ' => 'بج',
  80407. '�' => 'بح',
  80408. 'ﲞ' => 'بخ',
  80409. 'ﲟ' => 'بم',
  80410. 'ﲠ' => 'به',
  80411. 'ﲡ' => 'تج',
  80412. 'ﲢ' => 'تح',
  80413. 'ﲣ' => 'تخ',
  80414. 'ﲤ' => 'تم',
  80415. 'ﲥ' => 'ته',
  80416. 'ﲦ' => 'ثم',
  80417. 'ﲧ' => 'جح',
  80418. 'ﲨ' => 'جم',
  80419. 'ﲩ' => 'حج',
  80420. 'ﲪ' => 'حم',
  80421. 'ﲫ' => 'خج',
  80422. 'ﲬ' => 'خم',
  80423. 'ﲭ' => 'سج',
  80424. 'ﲮ' => 'سح',
  80425. 'ﲯ' => 'سخ',
  80426. 'ﲰ' => 'سم',
  80427. 'ﲱ' => 'صح',
  80428. 'ﲲ' => 'صخ',
  80429. 'ﲳ' => 'صم',
  80430. 'ﲴ' => 'ضج',
  80431. 'ﲵ' => 'ضح',
  80432. 'ﲶ' => 'ضخ',
  80433. 'ﲷ' => 'ضم',
  80434. 'ﲸ' => 'طح',
  80435. 'ﲹ' => 'ظم',
  80436. 'ﲺ' => 'عج',
  80437. 'ﲻ' => 'عم',
  80438. 'ﲼ' => 'غج',
  80439. 'ﲽ' => 'غم',
  80440. 'ﲾ' => '�ج',
  80441. 'ﲿ' => '�ح',
  80442. 'ﳀ' => '�خ',
  80443. '�' => '�م',
  80444. 'ﳂ' => 'قح',
  80445. 'ﳃ' => 'قم',
  80446. 'ﳄ' => 'كج',
  80447. 'ﳅ' => 'كح',
  80448. 'ﳆ' => 'كخ',
  80449. 'ﳇ' => 'كل',
  80450. 'ﳈ' => 'كم',
  80451. 'ﳉ' => 'لج',
  80452. 'ﳊ' => 'لح',
  80453. 'ﳋ' => 'لخ',
  80454. 'ﳌ' => 'لم',
  80455. '�' => 'له',
  80456. 'ﳎ' => 'مج',
  80457. '�' => 'مح',
  80458. '�' => 'مخ',
  80459. 'ﳑ' => 'مم',
  80460. 'ﳒ' => 'نج',
  80461. 'ﳓ' => 'نح',
  80462. 'ﳔ' => 'نخ',
  80463. 'ﳕ' => 'نم',
  80464. 'ﳖ' => 'نه',
  80465. 'ﳗ' => 'هج',
  80466. 'ﳘ' => 'هم',
  80467. 'ﳙ' => 'هٰ',
  80468. 'ﳚ' => 'يج',
  80469. 'ﳛ' => 'يح',
  80470. 'ﳜ' => 'يخ',
  80471. '�' => 'يم',
  80472. 'ﳞ' => 'يه',
  80473. 'ﳟ' => 'ئم',
  80474. 'ï³ ' => 'ÙŠÙ”Ù‡',
  80475. 'ﳡ' => 'بم',
  80476. 'ﳢ' => 'به',
  80477. 'ﳣ' => 'تم',
  80478. 'ﳤ' => 'ته',
  80479. 'ﳥ' => 'ثم',
  80480. 'ﳦ' => 'ثه',
  80481. 'ﳧ' => 'سم',
  80482. 'ﳨ' => 'سه',
  80483. 'ﳩ' => 'شم',
  80484. 'ﳪ' => 'شه',
  80485. 'ﳫ' => 'كل',
  80486. 'ﳬ' => 'كم',
  80487. 'ﳭ' => 'لم',
  80488. 'ﳮ' => 'نم',
  80489. 'ﳯ' => 'نه',
  80490. 'ﳰ' => 'يم',
  80491. 'ﳱ' => 'يه',
  80492. 'ï³²' => 'Ù€ÙŽÙ‘',
  80493. 'ﳳ' => 'ـ�ّ',
  80494. 'ﳴ' => 'ـ�ّ',
  80495. 'ﳵ' => 'طى',
  80496. 'ﳶ' => 'طي',
  80497. 'ﳷ' => 'عى',
  80498. 'ﳸ' => 'عي',
  80499. 'ﳹ' => 'غى',
  80500. 'ﳺ' => 'غي',
  80501. 'ﳻ' => 'سى',
  80502. 'ﳼ' => 'سي',
  80503. 'ﳽ' => 'شى',
  80504. 'ﳾ' => 'شي',
  80505. 'ﳿ' => 'حى',
  80506. 'ﴀ' => 'حي',
  80507. '�' => 'جى',
  80508. 'ﴂ' => 'جي',
  80509. 'ﴃ' => 'خى',
  80510. 'ﴄ' => 'خي',
  80511. 'ﴅ' => 'صى',
  80512. 'ﴆ' => 'صي',
  80513. 'ﴇ' => 'ضى',
  80514. 'ﴈ' => 'ضي',
  80515. 'ﴉ' => 'شج',
  80516. 'ﴊ' => 'شح',
  80517. 'ﴋ' => 'شخ',
  80518. 'ﴌ' => 'شم',
  80519. '�' => 'شر',
  80520. 'ﴎ' => 'سر',
  80521. '�' => 'صر',
  80522. '�' => 'ضر',
  80523. 'ﴑ' => 'طى',
  80524. 'ﴒ' => 'طي',
  80525. 'ﴓ' => 'عى',
  80526. 'ﴔ' => 'عي',
  80527. 'ﴕ' => 'غى',
  80528. 'ﴖ' => 'غي',
  80529. 'ﴗ' => 'سى',
  80530. 'ﴘ' => 'سي',
  80531. 'ﴙ' => 'شى',
  80532. 'ﴚ' => 'شي',
  80533. 'ﴛ' => 'حى',
  80534. 'ﴜ' => 'حي',
  80535. '�' => 'جى',
  80536. 'ﴞ' => 'جي',
  80537. 'ﴟ' => 'خى',
  80538. 'ﴠ' => 'خي',
  80539. 'ﴡ' => 'صى',
  80540. 'ﴢ' => 'صي',
  80541. 'ﴣ' => 'ضى',
  80542. 'ﴤ' => 'ضي',
  80543. 'ﴥ' => 'شج',
  80544. 'ﴦ' => 'شح',
  80545. 'ﴧ' => 'شخ',
  80546. 'ﴨ' => 'شم',
  80547. 'ﴩ' => 'شر',
  80548. 'ﴪ' => 'سر',
  80549. 'ﴫ' => 'صر',
  80550. 'ﴬ' => 'ضر',
  80551. 'ﴭ' => 'شج',
  80552. 'ﴮ' => 'شح',
  80553. 'ﴯ' => 'شخ',
  80554. 'ﴰ' => 'شم',
  80555. 'ﴱ' => 'سه',
  80556. 'ﴲ' => 'شه',
  80557. 'ﴳ' => 'طم',
  80558. 'ﴴ' => 'سج',
  80559. 'ﴵ' => 'سح',
  80560. 'ﴶ' => 'سخ',
  80561. 'ﴷ' => 'شج',
  80562. 'ﴸ' => 'شح',
  80563. 'ﴹ' => 'شخ',
  80564. 'ﴺ' => 'طم',
  80565. 'ﴻ' => 'ظم',
  80566. 'ﴼ' => 'اً',
  80567. 'ﴽ' => 'اً',
  80568. '�' => 'تجم',
  80569. 'ﵑ' => 'تحج',
  80570. 'ﵒ' => 'تحج',
  80571. 'ﵓ' => 'تحم',
  80572. 'ﵔ' => 'تخم',
  80573. 'ﵕ' => 'تمج',
  80574. 'ﵖ' => 'تمح',
  80575. 'ﵗ' => 'تمخ',
  80576. 'ﵘ' => 'جمح',
  80577. 'ﵙ' => 'جمح',
  80578. 'ﵚ' => 'حمي',
  80579. 'ﵛ' => 'حمى',
  80580. 'ﵜ' => 'سحج',
  80581. '�' => 'سجح',
  80582. 'ﵞ' => 'سجى',
  80583. 'ﵟ' => 'سمح',
  80584. 'ﵠ' => 'سمح',
  80585. 'ﵡ' => 'سمج',
  80586. 'ﵢ' => 'سمم',
  80587. 'ﵣ' => 'سمم',
  80588. 'ﵤ' => 'صحح',
  80589. 'ﵥ' => 'صحح',
  80590. 'ﵦ' => 'صمم',
  80591. 'ﵧ' => 'شحم',
  80592. 'ﵨ' => 'شحم',
  80593. 'ﵩ' => 'شجي',
  80594. 'ﵪ' => 'شمخ',
  80595. 'ﵫ' => 'شمخ',
  80596. 'ﵬ' => 'شمم',
  80597. 'ﵭ' => 'شمم',
  80598. 'ﵮ' => 'ضحى',
  80599. 'ﵯ' => 'ضخم',
  80600. 'ﵰ' => 'ضخم',
  80601. 'ﵱ' => 'طمح',
  80602. 'ﵲ' => 'طمح',
  80603. 'ﵳ' => 'طمم',
  80604. 'ﵴ' => 'طمي',
  80605. 'ﵵ' => 'عجم',
  80606. 'ﵶ' => 'عمم',
  80607. 'ﵷ' => 'عمم',
  80608. 'ﵸ' => 'عمى',
  80609. 'ﵹ' => 'غمم',
  80610. 'ﵺ' => 'غمي',
  80611. 'ﵻ' => 'غمى',
  80612. 'ﵼ' => '�خم',
  80613. 'ﵽ' => '�خم',
  80614. 'ﵾ' => 'قمح',
  80615. 'ﵿ' => 'قمم',
  80616. 'ﶀ' => 'لحم',
  80617. '�' => 'لحي',
  80618. 'ﶂ' => 'لحى',
  80619. 'ﶃ' => 'لجج',
  80620. 'ﶄ' => 'لجج',
  80621. 'ﶅ' => 'لخم',
  80622. 'ﶆ' => 'لخم',
  80623. 'ﶇ' => 'لمح',
  80624. 'ﶈ' => 'لمح',
  80625. 'ﶉ' => 'محج',
  80626. 'ﶊ' => 'محم',
  80627. 'ﶋ' => 'محي',
  80628. 'ﶌ' => 'مجح',
  80629. '�' => 'مجم',
  80630. 'ﶎ' => 'مخج',
  80631. '�' => 'مخم',
  80632. 'ﶒ' => 'مجخ',
  80633. 'ﶓ' => 'همج',
  80634. 'ﶔ' => 'همم',
  80635. 'ﶕ' => 'نحم',
  80636. 'ﶖ' => 'نحى',
  80637. 'ﶗ' => 'نجم',
  80638. 'ﶘ' => 'نجم',
  80639. 'ﶙ' => 'نجى',
  80640. 'ﶚ' => 'نمي',
  80641. 'ﶛ' => 'نمى',
  80642. 'ﶜ' => 'يمم',
  80643. '�' => 'يمم',
  80644. 'ﶞ' => 'بخي',
  80645. 'ﶟ' => 'تجي',
  80646. 'ﶠ' => 'تجى',
  80647. 'ﶡ' => 'تخي',
  80648. 'ﶢ' => 'تخى',
  80649. 'ﶣ' => 'تمي',
  80650. 'ﶤ' => 'تمى',
  80651. 'ﶥ' => 'جمي',
  80652. 'ﶦ' => 'جحى',
  80653. 'ﶧ' => 'جمى',
  80654. 'ﶨ' => 'سخى',
  80655. 'ﶩ' => 'صحي',
  80656. 'ﶪ' => 'شحي',
  80657. 'ﶫ' => 'ضحي',
  80658. 'ﶬ' => 'لجي',
  80659. 'ﶭ' => 'لمي',
  80660. 'ﶮ' => 'يحي',
  80661. 'ﶯ' => 'يجي',
  80662. 'ﶰ' => 'يمي',
  80663. 'ﶱ' => 'ممي',
  80664. 'ﶲ' => 'قمي',
  80665. 'ﶳ' => 'نحي',
  80666. 'ﶴ' => 'قمح',
  80667. 'ﶵ' => 'لحم',
  80668. 'ﶶ' => 'عمي',
  80669. 'ﶷ' => 'كمي',
  80670. 'ﶸ' => 'نجح',
  80671. 'ﶹ' => 'مخي',
  80672. 'ﶺ' => 'لجم',
  80673. 'ﶻ' => 'كمم',
  80674. 'ﶼ' => 'لجم',
  80675. 'ﶽ' => 'نجح',
  80676. 'ﶾ' => 'جحي',
  80677. 'ﶿ' => 'حجي',
  80678. 'ﷀ' => 'مجي',
  80679. '�' => '�مي',
  80680. 'ﷂ' => 'بحي',
  80681. 'ﷃ' => 'كمم',
  80682. 'ﷄ' => 'عجم',
  80683. 'ﷅ' => 'صمم',
  80684. 'ﷆ' => 'سخي',
  80685. 'ﷇ' => 'نجي',
  80686. 'ﷰ' => 'صلے',
  80687. 'ﷱ' => 'قلے',
  80688. 'ﷲ' => 'الله',
  80689. 'ﷳ' => 'اكبر',
  80690. 'ﷴ' => 'محمد',
  80691. 'ﷵ' => 'صلعم',
  80692. 'ﷶ' => 'رسول',
  80693. 'ﷷ' => 'عليه',
  80694. 'ﷸ' => 'وسلم',
  80695. 'ﷹ' => 'صلى',
  80696. 'ﷺ' => 'صلى الله عليه وسلم',
  80697. 'ﷻ' => 'جل جلاله',
  80698. '﷼' => 'ریال',
  80699. '�' => ',',
  80700. '︑' => '�',
  80701. '︒' => '。',
  80702. '︓' => ':',
  80703. '︔' => ';',
  80704. '︕' => '!',
  80705. '︖' => '?',
  80706. '︗' => '〖',
  80707. '︘' => '〗',
  80708. '︙' => '...',
  80709. '︰' => '..',
  80710. '︱' => '—',
  80711. '︲' => '–',
  80712. '︳' => '_',
  80713. '︴' => '_',
  80714. '︵' => '(',
  80715. '︶' => ')',
  80716. '︷' => '{',
  80717. '︸' => '}',
  80718. '︹' => '〔',
  80719. '︺' => '〕',
  80720. '︻' => '�',
  80721. '︼' => '】',
  80722. '︽' => '《',
  80723. '︾' => '》',
  80724. '︿' => '〈',
  80725. '﹀' => '〉',
  80726. '�' => '「',
  80727. '﹂' => '�',
  80728. '﹃' => '『',
  80729. '﹄' => '�',
  80730. '﹇' => '[',
  80731. '﹈' => ']',
  80732. '﹉' => ' ̅',
  80733. '﹊' => ' ̅',
  80734. '﹋' => ' ̅',
  80735. '﹌' => ' ̅',
  80736. '�' => '_',
  80737. '﹎' => '_',
  80738. '�' => '_',
  80739. '�' => ',',
  80740. '﹑' => '�',
  80741. 'ï¹’' => '.',
  80742. 'ï¹”' => ';',
  80743. '﹕' => ':',
  80744. 'ï¹–' => '?',
  80745. 'ï¹—' => '!',
  80746. '﹘' => '—',
  80747. 'ï¹™' => '(',
  80748. '﹚' => ')',
  80749. 'ï¹›' => '{',
  80750. '﹜' => '}',
  80751. '�' => '〔',
  80752. '﹞' => '〕',
  80753. '﹟' => '#',
  80754. 'ï¹ ' => '&',
  80755. '﹡' => '*',
  80756. 'ï¹¢' => '+',
  80757. 'ï¹£' => '-',
  80758. '﹤' => '<',
  80759. 'ï¹¥' => '>',
  80760. '﹦' => '=',
  80761. '﹨' => '\\',
  80762. '﹩' => '$',
  80763. '﹪' => '%',
  80764. '﹫' => '@',
  80765. 'ï¹°' => ' Ù‹',
  80766. 'ﹱ' => 'ـً',
  80767. 'ﹲ' => ' ٌ',
  80768. 'ï¹´' => ' Ù�',
  80769. 'ï¹¶' => ' ÙŽ',
  80770. 'ï¹·' => 'Ù€ÙŽ',
  80771. 'ﹸ' => ' �',
  80772. 'ﹹ' => 'ـ�',
  80773. 'ﹺ' => ' �',
  80774. 'ﹻ' => 'ـ�',
  80775. 'ï¹¼' => ' Ù‘',
  80776. 'ﹽ' => 'ـّ',
  80777. 'ï¹¾' => ' Ù’',
  80778. 'ﹿ' => 'ـْ',
  80779. 'ﺀ' => 'ء',
  80780. '�' => 'آ',
  80781. 'ﺂ' => 'آ',
  80782. 'ﺃ' => 'أ',
  80783. 'ﺄ' => 'أ',
  80784. 'ﺅ' => 'ؤ',
  80785. 'ﺆ' => 'ؤ',
  80786. 'ﺇ' => 'إ',
  80787. 'ﺈ' => 'إ',
  80788. 'ﺉ' => 'ئ',
  80789. 'ﺊ' => 'ئ',
  80790. 'ﺋ' => 'ئ',
  80791. 'ﺌ' => 'ئ',
  80792. '�' => 'ا',
  80793. 'ﺎ' => 'ا',
  80794. '�' => 'ب',
  80795. '�' => 'ب',
  80796. 'ﺑ' => 'ب',
  80797. 'ﺒ' => 'ب',
  80798. 'ﺓ' => 'ة',
  80799. 'ﺔ' => 'ة',
  80800. 'ﺕ' => 'ت',
  80801. 'ﺖ' => 'ت',
  80802. 'ﺗ' => 'ت',
  80803. 'ﺘ' => 'ت',
  80804. 'ﺙ' => 'ث',
  80805. 'ﺚ' => 'ث',
  80806. 'ﺛ' => 'ث',
  80807. 'ﺜ' => 'ث',
  80808. '�' => 'ج',
  80809. 'ﺞ' => 'ج',
  80810. 'ﺟ' => 'ج',
  80811. 'ﺠ' => 'ج',
  80812. 'ﺡ' => 'ح',
  80813. 'ﺢ' => 'ح',
  80814. 'ﺣ' => 'ح',
  80815. 'ﺤ' => 'ح',
  80816. 'ﺥ' => 'خ',
  80817. 'ﺦ' => 'خ',
  80818. 'ﺧ' => 'خ',
  80819. 'ﺨ' => 'خ',
  80820. 'ﺩ' => 'د',
  80821. 'ﺪ' => 'د',
  80822. 'ﺫ' => 'ذ',
  80823. 'ﺬ' => 'ذ',
  80824. 'ﺭ' => 'ر',
  80825. 'ﺮ' => 'ر',
  80826. 'ﺯ' => 'ز',
  80827. 'ﺰ' => 'ز',
  80828. 'ﺱ' => 'س',
  80829. 'ﺲ' => 'س',
  80830. 'ﺳ' => 'س',
  80831. 'ﺴ' => 'س',
  80832. 'ﺵ' => 'ش',
  80833. 'ﺶ' => 'ش',
  80834. 'ﺷ' => 'ش',
  80835. 'ﺸ' => 'ش',
  80836. 'ﺹ' => 'ص',
  80837. 'ﺺ' => 'ص',
  80838. 'ﺻ' => 'ص',
  80839. 'ﺼ' => 'ص',
  80840. 'ﺽ' => 'ض',
  80841. 'ﺾ' => 'ض',
  80842. 'ﺿ' => 'ض',
  80843. 'ﻀ' => 'ض',
  80844. '�' => 'ط',
  80845. 'ﻂ' => 'ط',
  80846. 'ﻃ' => 'ط',
  80847. 'ﻄ' => 'ط',
  80848. 'ﻅ' => 'ظ',
  80849. 'ﻆ' => 'ظ',
  80850. 'ﻇ' => 'ظ',
  80851. 'ﻈ' => 'ظ',
  80852. 'ﻉ' => 'ع',
  80853. 'ﻊ' => 'ع',
  80854. 'ﻋ' => 'ع',
  80855. 'ﻌ' => 'ع',
  80856. '�' => 'غ',
  80857. 'ﻎ' => 'غ',
  80858. '�' => 'غ',
  80859. '�' => 'غ',
  80860. 'ﻑ' => '�',
  80861. 'ï»’' => 'Ù�',
  80862. 'ﻓ' => '�',
  80863. 'ï»”' => 'Ù�',
  80864. 'ﻕ' => 'ق',
  80865. 'ï»–' => 'Ù‚',
  80866. 'ï»—' => 'Ù‚',
  80867. 'ﻘ' => 'ق',
  80868. 'ï»™' => 'Ùƒ',
  80869. 'ﻚ' => 'ك',
  80870. 'ï»›' => 'Ùƒ',
  80871. 'ﻜ' => 'ك',
  80872. '�' => 'ل',
  80873. 'ﻞ' => 'ل',
  80874. 'ﻟ' => 'ل',
  80875. 'ï» ' => 'Ù„',
  80876. 'ﻡ' => 'م',
  80877. 'ﻢ' => 'م',
  80878. 'ﻣ' => 'م',
  80879. 'ﻤ' => 'م',
  80880. 'ﻥ' => 'ن',
  80881. 'ﻦ' => 'ن',
  80882. 'ï»§' => 'Ù†',
  80883. 'ﻨ' => 'ن',
  80884. 'ﻩ' => 'ه',
  80885. 'ﻪ' => 'ه',
  80886. 'ﻫ' => 'ه',
  80887. 'ﻬ' => 'ه',
  80888. 'ï»­' => 'Ùˆ',
  80889. 'ï»®' => 'Ùˆ',
  80890. 'ﻯ' => 'ى',
  80891. 'ï»°' => 'Ù‰',
  80892. 'ï»±' => 'ÙŠ',
  80893. 'ﻲ' => 'ي',
  80894. 'ﻳ' => 'ي',
  80895. 'ï»´' => 'ÙŠ',
  80896. 'ﻵ' => 'لآ',
  80897. 'ﻶ' => 'لآ',
  80898. 'ﻷ' => 'لأ',
  80899. 'ﻸ' => 'لأ',
  80900. 'ﻹ' => 'لإ',
  80901. 'ﻺ' => 'لإ',
  80902. 'ﻻ' => 'لا',
  80903. 'ﻼ' => 'لا',
  80904. '�' => '!',
  80905. '"' => '"',
  80906. '#' => '#',
  80907. '$' => '$',
  80908. 'ï¼…' => '%',
  80909. '&' => '&',
  80910. ''' => '\'',
  80911. '(' => '(',
  80912. ')' => ')',
  80913. '*' => '*',
  80914. '+' => '+',
  80915. ',' => ',',
  80916. '�' => '-',
  80917. '.' => '.',
  80918. '�' => '/',
  80919. '�' => '0',
  80920. '1' => '1',
  80921. 'ï¼’' => '2',
  80922. '3' => '3',
  80923. 'ï¼”' => '4',
  80924. '5' => '5',
  80925. 'ï¼–' => '6',
  80926. 'ï¼—' => '7',
  80927. '8' => '8',
  80928. 'ï¼™' => '9',
  80929. ':' => ':',
  80930. 'ï¼›' => ';',
  80931. '<' => '<',
  80932. '�' => '=',
  80933. '>' => '>',
  80934. '?' => '?',
  80935. 'ï¼ ' => '@',
  80936. 'A' => 'A',
  80937. 'ï¼¢' => 'B',
  80938. 'ï¼£' => 'C',
  80939. 'D' => 'D',
  80940. 'ï¼¥' => 'E',
  80941. 'F' => 'F',
  80942. 'ï¼§' => 'G',
  80943. 'H' => 'H',
  80944. 'I' => 'I',
  80945. 'J' => 'J',
  80946. 'K' => 'K',
  80947. 'L' => 'L',
  80948. 'ï¼­' => 'M',
  80949. 'ï¼®' => 'N',
  80950. 'O' => 'O',
  80951. 'ï¼°' => 'P',
  80952. 'ï¼±' => 'Q',
  80953. 'ï¼²' => 'R',
  80954. 'ï¼³' => 'S',
  80955. 'ï¼´' => 'T',
  80956. 'ï¼µ' => 'U',
  80957. 'ï¼¶' => 'V',
  80958. 'ï¼·' => 'W',
  80959. 'X' => 'X',
  80960. 'ï¼¹' => 'Y',
  80961. 'Z' => 'Z',
  80962. 'ï¼»' => '[',
  80963. 'ï¼¼' => '\\',
  80964. 'ï¼½' => ']',
  80965. 'ï¼¾' => '^',
  80966. '_' => '_',
  80967. 'ï½€' => '`',
  80968. '�' => 'a',
  80969. 'b' => 'b',
  80970. 'c' => 'c',
  80971. 'd' => 'd',
  80972. 'ï½…' => 'e',
  80973. 'f' => 'f',
  80974. 'g' => 'g',
  80975. 'h' => 'h',
  80976. 'i' => 'i',
  80977. 'j' => 'j',
  80978. 'k' => 'k',
  80979. 'l' => 'l',
  80980. '�' => 'm',
  80981. 'n' => 'n',
  80982. '�' => 'o',
  80983. '�' => 'p',
  80984. 'q' => 'q',
  80985. 'ï½’' => 'r',
  80986. 's' => 's',
  80987. 'ï½”' => 't',
  80988. 'u' => 'u',
  80989. 'ï½–' => 'v',
  80990. 'ï½—' => 'w',
  80991. 'x' => 'x',
  80992. 'ï½™' => 'y',
  80993. 'z' => 'z',
  80994. 'ï½›' => '{',
  80995. '|' => '|',
  80996. '�' => '}',
  80997. '~' => '~',
  80998. '⦅' => '⦅',
  80999. '⦆' => '⦆',
  81000. '。' => '。',
  81001. '「' => '「',
  81002. '」' => '�',
  81003. '、' => '�',
  81004. '・' => '・',
  81005. 'ヲ' => 'ヲ',
  81006. 'ï½§' => 'ã‚¡',
  81007. 'ィ' => 'ィ',
  81008. 'ゥ' => 'ゥ',
  81009. 'ェ' => 'ェ',
  81010. 'ォ' => 'ォ',
  81011. 'ャ' => 'ャ',
  81012. 'ュ' => 'ュ',
  81013. 'ョ' => 'ョ',
  81014. 'ッ' => 'ッ',
  81015. 'ー' => 'ー',
  81016. 'ï½±' => 'ã‚¢',
  81017. 'イ' => 'イ',
  81018. 'ウ' => 'ウ',
  81019. 'エ' => 'エ',
  81020. 'オ' => 'オ',
  81021. 'ï½¶' => 'ã‚«',
  81022. 'ï½·' => 'ã‚­',
  81023. 'ク' => 'ク',
  81024. 'ケ' => 'ケ',
  81025. 'コ' => 'コ',
  81026. 'サ' => 'サ',
  81027. 'ï½¼' => 'ã‚·',
  81028. 'ス' => 'ス',
  81029. 'ï½¾' => 'ã‚»',
  81030. 'ソ' => 'ソ',
  81031. 'ï¾€' => 'ã‚¿',
  81032. '�' => '�',
  81033. 'ツ' => 'ツ',
  81034. 'テ' => 'テ',
  81035. 'ト' => 'ト',
  81036. 'ナ' => 'ナ',
  81037. 'ニ' => 'ニ',
  81038. 'ヌ' => 'ヌ',
  81039. 'ネ' => '�',
  81040. 'ノ' => 'ノ',
  81041. 'ハ' => '�',
  81042. 'ヒ' => 'ヒ',
  81043. 'フ' => 'フ',
  81044. '�' => 'ヘ',
  81045. 'ホ' => 'ホ',
  81046. '�' => 'マ',
  81047. '�' => 'ミ',
  81048. 'ム' => 'ム',
  81049. 'メ' => 'メ',
  81050. 'モ' => 'モ',
  81051. 'ヤ' => 'ヤ',
  81052. 'ユ' => 'ユ',
  81053. 'ヨ' => 'ヨ',
  81054. 'ラ' => 'ラ',
  81055. 'リ' => 'リ',
  81056. 'ル' => 'ル',
  81057. 'レ' => 'レ',
  81058. 'ロ' => 'ロ',
  81059. 'ワ' => 'ワ',
  81060. '�' => 'ン',
  81061. '゙' => '゙',
  81062. '゚' => '゚',
  81063. 'ï¾ ' => 'á… ',
  81064. 'ᄀ' => 'ᄀ',
  81065. 'ᄁ' => '�',
  81066. 'ᆪ' => 'ᆪ',
  81067. 'ᄂ' => 'ᄂ',
  81068. 'ᆬ' => 'ᆬ',
  81069. 'ᆭ' => 'ᆭ',
  81070. 'ᄃ' => 'ᄃ',
  81071. 'ᄄ' => 'ᄄ',
  81072. 'ᄅ' => 'ᄅ',
  81073. 'ᆰ' => 'ᆰ',
  81074. 'ᆱ' => 'ᆱ',
  81075. 'ᆲ' => 'ᆲ',
  81076. 'ᆳ' => 'ᆳ',
  81077. 'ᆴ' => 'ᆴ',
  81078. 'ᆵ' => 'ᆵ',
  81079. 'ᄚ' => 'ᄚ',
  81080. 'ᄆ' => 'ᄆ',
  81081. 'ᄇ' => 'ᄇ',
  81082. 'ᄈ' => 'ᄈ',
  81083. 'ï¾´' => 'á„¡',
  81084. 'ᄉ' => 'ᄉ',
  81085. 'ᄊ' => 'ᄊ',
  81086. 'ï¾·' => 'á„‹',
  81087. 'ᄌ' => 'ᄌ',
  81088. 'ᄍ' => '�',
  81089. 'ᄎ' => 'ᄎ',
  81090. 'ᄏ' => '�',
  81091. 'ᄐ' => '�',
  81092. 'ï¾½' => 'á„‘',
  81093. 'ï¾¾' => 'á„’',
  81094. 'ï¿‚' => 'á…¡',
  81095. 'ᅢ' => 'ᅢ',
  81096. 'ï¿„' => 'á…£',
  81097. 'ï¿…' => 'á…¤',
  81098. 'ᅥ' => 'ᅥ',
  81099. 'ᅦ' => 'ᅦ',
  81100. 'ᅧ' => 'ᅧ',
  81101. 'ï¿‹' => 'á…¨',
  81102. 'ᅩ' => 'ᅩ',
  81103. '�' => 'ᅪ',
  81104. 'ᅫ' => 'ᅫ',
  81105. '�' => 'ᅬ',
  81106. 'ï¿’' => 'á…­',
  81107. 'ï¿“' => 'á…®',
  81108. 'ï¿”' => 'á…¯',
  81109. 'ï¿•' => 'á…°',
  81110. 'ï¿–' => 'á…±',
  81111. 'ï¿—' => 'á…²',
  81112. 'ᅳ' => 'ᅳ',
  81113. 'ï¿›' => 'á…´',
  81114. 'ᅵ' => 'ᅵ',
  81115. '¢' => '¢',
  81116. '£' => '£',
  81117. '¬' => '¬',
  81118. 'ï¿£' => ' Ì„',
  81119. '¦' => '¦',
  81120. 'ï¿¥' => 'Â¥',
  81121. '₩' => '₩',
  81122. '│' => '│',
  81123. '←' => '�',
  81124. '↑' => '↑',
  81125. '→' => '→',
  81126. '↓' => '↓',
  81127. 'ï¿­' => 'â– ',
  81128. 'ï¿®' => 'â—‹',
  81129. '�' => 'A',
  81130. '�' => 'B',
  81131. '�' => 'C',
  81132. '�' => 'D',
  81133. '�' => 'E',
  81134. '�' => 'F',
  81135. '�' => 'G',
  81136. '�' => 'H',
  81137. '�' => 'I',
  81138. '�' => 'J',
  81139. '�' => 'K',
  81140. '�' => 'L',
  81141. '�' => 'M',
  81142. '�' => 'N',
  81143. '�' => 'O',
  81144. '�' => 'P',
  81145. '�' => 'Q',
  81146. '�' => 'R',
  81147. '�' => 'S',
  81148. '�' => 'T',
  81149. '�' => 'U',
  81150. '�' => 'V',
  81151. '�' => 'W',
  81152. '�' => 'X',
  81153. '�' => 'Y',
  81154. '�' => 'Z',
  81155. '�' => 'a',
  81156. '�' => 'b',
  81157. '�' => 'c',
  81158. '�' => 'd',
  81159. '�' => 'e',
  81160. '�' => 'f',
  81161. '�' => 'g',
  81162. '�' => 'h',
  81163. '�' => 'i',
  81164. '�' => 'j',
  81165. '�' => 'k',
  81166. '�' => 'l',
  81167. '�' => 'm',
  81168. '�' => 'n',
  81169. '�' => 'o',
  81170. '�' => 'p',
  81171. '�' => 'q',
  81172. '�' => 'r',
  81173. '�' => 's',
  81174. '�' => 't',
  81175. '�' => 'u',
  81176. '�' => 'v',
  81177. '�' => 'w',
  81178. '�' => 'x',
  81179. '�' => 'y',
  81180. '�' => 'z',
  81181. '�' => 'A',
  81182. '�' => 'B',
  81183. '�' => 'C',
  81184. '�' => 'D',
  81185. '�' => 'E',
  81186. '�' => 'F',
  81187. '�' => 'G',
  81188. '�' => 'H',
  81189. '�' => 'I',
  81190. '�' => 'J',
  81191. '�' => 'K',
  81192. '�' => 'L',
  81193. '�' => 'M',
  81194. '�' => 'N',
  81195. '�' => 'O',
  81196. '�' => 'P',
  81197. '�' => 'Q',
  81198. '�' => 'R',
  81199. '�' => 'S',
  81200. '�' => 'T',
  81201. '�' => 'U',
  81202. '�' => 'V',
  81203. '�' => 'W',
  81204. '�' => 'X',
  81205. '�' => 'Y',
  81206. '�' => 'Z',
  81207. '�' => 'a',
  81208. '�' => 'b',
  81209. '�' => 'c',
  81210. '�' => 'd',
  81211. '�' => 'e',
  81212. '�' => 'f',
  81213. '�' => 'g',
  81214. '�' => 'i',
  81215. '�' => 'j',
  81216. '�' => 'k',
  81217. '�' => 'l',
  81218. '�' => 'm',
  81219. '�' => 'n',
  81220. '�' => 'o',
  81221. '�' => 'p',
  81222. '�' => 'q',
  81223. '�' => 'r',
  81224. '�' => 's',
  81225. '�' => 't',
  81226. '�' => 'u',
  81227. '�' => 'v',
  81228. '�' => 'w',
  81229. '�' => 'x',
  81230. '�' => 'y',
  81231. '�' => 'z',
  81232. '�' => 'A',
  81233. '�' => 'B',
  81234. '�' => 'C',
  81235. '�' => 'D',
  81236. '�' => 'E',
  81237. '�' => 'F',
  81238. '�' => 'G',
  81239. '�' => 'H',
  81240. '�' => 'I',
  81241. '�' => 'J',
  81242. '�' => 'K',
  81243. '�' => 'L',
  81244. '�' => 'M',
  81245. '�' => 'N',
  81246. '�' => 'O',
  81247. '�' => 'P',
  81248. '�' => 'Q',
  81249. '�' => 'R',
  81250. '�' => 'S',
  81251. '�' => 'T',
  81252. '�' => 'U',
  81253. '�' => 'V',
  81254. '�' => 'W',
  81255. '�' => 'X',
  81256. '�' => 'Y',
  81257. '�' => 'Z',
  81258. '�' => 'a',
  81259. '�' => 'b',
  81260. '�' => 'c',
  81261. '�' => 'd',
  81262. '�' => 'e',
  81263. '�' => 'f',
  81264. '�' => 'g',
  81265. '�' => 'h',
  81266. '�' => 'i',
  81267. '�' => 'j',
  81268. '�' => 'k',
  81269. '�' => 'l',
  81270. '�' => 'm',
  81271. '�' => 'n',
  81272. '�' => 'o',
  81273. '�' => 'p',
  81274. '�' => 'q',
  81275. '�' => 'r',
  81276. '�' => 's',
  81277. '�' => 't',
  81278. '�' => 'u',
  81279. '�' => 'v',
  81280. '�' => 'w',
  81281. '�' => 'x',
  81282. '�' => 'y',
  81283. '�' => 'z',
  81284. '�' => 'A',
  81285. '�' => 'C',
  81286. '�' => 'D',
  81287. '�' => 'G',
  81288. '�' => 'J',
  81289. '�' => 'K',
  81290. '�' => 'N',
  81291. '�' => 'O',
  81292. '�' => 'P',
  81293. '�' => 'Q',
  81294. '�' => 'S',
  81295. '�' => 'T',
  81296. '�' => 'U',
  81297. '�' => 'V',
  81298. '�' => 'W',
  81299. '�' => 'X',
  81300. '�' => 'Y',
  81301. '�' => 'Z',
  81302. '�' => 'a',
  81303. '�' => 'b',
  81304. '�' => 'c',
  81305. '�' => 'd',
  81306. '�' => 'f',
  81307. '�' => 'h',
  81308. '�' => 'i',
  81309. '�' => 'j',
  81310. '�' => 'k',
  81311. '�' => 'l',
  81312. '�' => 'm',
  81313. '�' => 'n',
  81314. '�' => 'p',
  81315. '�' => 'q',
  81316. '�' => 'r',
  81317. '�' => 's',
  81318. '�' => 't',
  81319. '�' => 'u',
  81320. '�' => 'v',
  81321. '�' => 'w',
  81322. '�' => 'x',
  81323. '�' => 'y',
  81324. '�' => 'z',
  81325. '�' => 'A',
  81326. '�' => 'B',
  81327. '�' => 'C',
  81328. '�' => 'D',
  81329. '�' => 'E',
  81330. '�' => 'F',
  81331. '�' => 'G',
  81332. '�' => 'H',
  81333. '�' => 'I',
  81334. '�' => 'J',
  81335. '�' => 'K',
  81336. '�' => 'L',
  81337. '�' => 'M',
  81338. '�' => 'N',
  81339. '�' => 'O',
  81340. '�' => 'P',
  81341. '�' => 'Q',
  81342. '�' => 'R',
  81343. '�' => 'S',
  81344. '�' => 'T',
  81345. '�' => 'U',
  81346. '�' => 'V',
  81347. '�' => 'W',
  81348. '�' => 'X',
  81349. '�' => 'Y',
  81350. '�' => 'Z',
  81351. '�' => 'a',
  81352. '�' => 'b',
  81353. '�' => 'c',
  81354. '�' => 'd',
  81355. '�' => 'e',
  81356. '�' => 'f',
  81357. '�' => 'g',
  81358. '�' => 'h',
  81359. '�' => 'i',
  81360. '�' => 'j',
  81361. '�' => 'k',
  81362. '�' => 'l',
  81363. '�' => 'm',
  81364. '�' => 'n',
  81365. '�' => 'o',
  81366. '�' => 'p',
  81367. '�' => 'q',
  81368. '�' => 'r',
  81369. '�' => 's',
  81370. '�' => 't',
  81371. '�' => 'u',
  81372. '�' => 'v',
  81373. '�' => 'w',
  81374. '�' => 'x',
  81375. '�' => 'y',
  81376. '�' => 'z',
  81377. '�' => 'A',
  81378. '�' => 'B',
  81379. '�' => 'D',
  81380. '�' => 'E',
  81381. '�' => 'F',
  81382. '�' => 'G',
  81383. '�' => 'J',
  81384. '�' => 'K',
  81385. '�' => 'L',
  81386. '�' => 'M',
  81387. '�' => 'N',
  81388. '�' => 'O',
  81389. '�' => 'P',
  81390. '�' => 'Q',
  81391. '�' => 'S',
  81392. '�' => 'T',
  81393. '�' => 'U',
  81394. '�' => 'V',
  81395. '�' => 'W',
  81396. '�' => 'X',
  81397. '�' => 'Y',
  81398. '�' => 'a',
  81399. '�' => 'b',
  81400. '�' => 'c',
  81401. '�' => 'd',
  81402. '�' => 'e',
  81403. '�' => 'f',
  81404. '�' => 'g',
  81405. '�' => 'h',
  81406. '�' => 'i',
  81407. '�' => 'j',
  81408. '�' => 'k',
  81409. '�' => 'l',
  81410. '�' => 'm',
  81411. '�' => 'n',
  81412. '�' => 'o',
  81413. '�' => 'p',
  81414. '�' => 'q',
  81415. '�' => 'r',
  81416. '�' => 's',
  81417. '�' => 't',
  81418. '�' => 'u',
  81419. '�' => 'v',
  81420. '�' => 'w',
  81421. '�' => 'x',
  81422. '�' => 'y',
  81423. '�' => 'z',
  81424. '�' => 'A',
  81425. '�' => 'B',
  81426. '�' => 'D',
  81427. '�' => 'E',
  81428. '�' => 'F',
  81429. '�' => 'G',
  81430. '�' => 'I',
  81431. '�' => 'J',
  81432. '�' => 'K',
  81433. '�' => 'L',
  81434. '�' => 'M',
  81435. '�' => 'O',
  81436. '�' => 'S',
  81437. '�' => 'T',
  81438. '�' => 'U',
  81439. '�' => 'V',
  81440. '�' => 'W',
  81441. '�' => 'X',
  81442. '�' => 'Y',
  81443. '�' => 'a',
  81444. '�' => 'b',
  81445. '�' => 'c',
  81446. '�' => 'd',
  81447. '�' => 'e',
  81448. '�' => 'f',
  81449. '�' => 'g',
  81450. '�' => 'h',
  81451. '�' => 'i',
  81452. '�' => 'j',
  81453. '�' => 'k',
  81454. '�' => 'l',
  81455. '�' => 'm',
  81456. '�' => 'n',
  81457. '�' => 'o',
  81458. '�' => 'p',
  81459. '�' => 'q',
  81460. '�' => 'r',
  81461. '�' => 's',
  81462. '�' => 't',
  81463. '�' => 'u',
  81464. '�' => 'v',
  81465. '�' => 'w',
  81466. '�' => 'x',
  81467. '�' => 'y',
  81468. '�' => 'z',
  81469. '�' => 'A',
  81470. '�' => 'B',
  81471. '�' => 'C',
  81472. '�' => 'D',
  81473. '�' => 'E',
  81474. '�' => 'F',
  81475. '�' => 'G',
  81476. '�' => 'H',
  81477. '�' => 'I',
  81478. '�' => 'J',
  81479. '�' => 'K',
  81480. '�' => 'L',
  81481. '�' => 'M',
  81482. '�' => 'N',
  81483. '�' => 'O',
  81484. '�' => 'P',
  81485. '�' => 'Q',
  81486. '�' => 'R',
  81487. '�' => 'S',
  81488. '�' => 'T',
  81489. '�' => 'U',
  81490. '�' => 'V',
  81491. '�' => 'W',
  81492. '�' => 'X',
  81493. '�' => 'Y',
  81494. '�' => 'Z',
  81495. '�' => 'a',
  81496. '�' => 'b',
  81497. '�' => 'c',
  81498. '�' => 'd',
  81499. '�' => 'e',
  81500. '�' => 'f',
  81501. '�' => 'g',
  81502. '�' => 'h',
  81503. '�' => 'i',
  81504. '�' => 'j',
  81505. '�' => 'k',
  81506. '�' => 'l',
  81507. '�' => 'm',
  81508. '�' => 'n',
  81509. '�' => 'o',
  81510. '�' => 'p',
  81511. '�' => 'q',
  81512. '�' => 'r',
  81513. '�' => 's',
  81514. '�' => 't',
  81515. '�' => 'u',
  81516. '�' => 'v',
  81517. '�' => 'w',
  81518. '�' => 'x',
  81519. '�' => 'y',
  81520. '�' => 'z',
  81521. '�' => 'A',
  81522. '�' => 'B',
  81523. '�' => 'C',
  81524. '�' => 'D',
  81525. '�' => 'E',
  81526. '�' => 'F',
  81527. '�' => 'G',
  81528. '�' => 'H',
  81529. '�' => 'I',
  81530. '�' => 'J',
  81531. '�' => 'K',
  81532. '�' => 'L',
  81533. '�' => 'M',
  81534. '�' => 'N',
  81535. '�' => 'O',
  81536. '�' => 'P',
  81537. '�' => 'Q',
  81538. '�' => 'R',
  81539. '�' => 'S',
  81540. '�' => 'T',
  81541. '�' => 'U',
  81542. '�' => 'V',
  81543. '�' => 'W',
  81544. '�' => 'X',
  81545. '�' => 'Y',
  81546. '�' => 'Z',
  81547. '�' => 'a',
  81548. '�' => 'b',
  81549. '�' => 'c',
  81550. '�' => 'd',
  81551. '�' => 'e',
  81552. '�' => 'f',
  81553. '�' => 'g',
  81554. '�' => 'h',
  81555. '�' => 'i',
  81556. '�' => 'j',
  81557. '�' => 'k',
  81558. '�' => 'l',
  81559. '�' => 'm',
  81560. '�' => 'n',
  81561. '�' => 'o',
  81562. '�' => 'p',
  81563. '�' => 'q',
  81564. '�' => 'r',
  81565. '�' => 's',
  81566. '�' => 't',
  81567. '�' => 'u',
  81568. '�' => 'v',
  81569. '�' => 'w',
  81570. '�' => 'x',
  81571. '�' => 'y',
  81572. '�' => 'z',
  81573. '�' => 'A',
  81574. '�' => 'B',
  81575. '�' => 'C',
  81576. '�' => 'D',
  81577. '�' => 'E',
  81578. '�' => 'F',
  81579. '�' => 'G',
  81580. '�' => 'H',
  81581. '�' => 'I',
  81582. '�' => 'J',
  81583. '�' => 'K',
  81584. '�' => 'L',
  81585. '�' => 'M',
  81586. '�' => 'N',
  81587. '�' => 'O',
  81588. '�' => 'P',
  81589. '�' => 'Q',
  81590. '�' => 'R',
  81591. '�' => 'S',
  81592. '�' => 'T',
  81593. '�' => 'U',
  81594. '�' => 'V',
  81595. '�' => 'W',
  81596. '�' => 'X',
  81597. '�' => 'Y',
  81598. '�' => 'Z',
  81599. '�' => 'a',
  81600. '�' => 'b',
  81601. '�' => 'c',
  81602. '�' => 'd',
  81603. '�' => 'e',
  81604. '�' => 'f',
  81605. '�' => 'g',
  81606. '�' => 'h',
  81607. '�' => 'i',
  81608. '�' => 'j',
  81609. '�' => 'k',
  81610. '�' => 'l',
  81611. '�' => 'm',
  81612. '�' => 'n',
  81613. '�' => 'o',
  81614. '�' => 'p',
  81615. '�' => 'q',
  81616. '�' => 'r',
  81617. '�' => 's',
  81618. '�' => 't',
  81619. '�' => 'u',
  81620. '�' => 'v',
  81621. '�' => 'w',
  81622. '�' => 'x',
  81623. '�' => 'y',
  81624. '�' => 'z',
  81625. '�' => 'A',
  81626. '�' => 'B',
  81627. '�' => 'C',
  81628. '�' => 'D',
  81629. '�' => 'E',
  81630. '�' => 'F',
  81631. '�' => 'G',
  81632. '�' => 'H',
  81633. '�' => 'I',
  81634. '�' => 'J',
  81635. '�' => 'K',
  81636. '�' => 'L',
  81637. '�' => 'M',
  81638. '�' => 'N',
  81639. '�' => 'O',
  81640. '�' => 'P',
  81641. '�' => 'Q',
  81642. '�' => 'R',
  81643. '�' => 'S',
  81644. '�' => 'T',
  81645. '�' => 'U',
  81646. '�' => 'V',
  81647. '�' => 'W',
  81648. '�' => 'X',
  81649. '�' => 'Y',
  81650. '�' => 'Z',
  81651. '�' => 'a',
  81652. '�' => 'b',
  81653. '�' => 'c',
  81654. '�' => 'd',
  81655. '�' => 'e',
  81656. '�' => 'f',
  81657. '�' => 'g',
  81658. '�' => 'h',
  81659. '�' => 'i',
  81660. '�' => 'j',
  81661. '�' => 'k',
  81662. '�' => 'l',
  81663. '�' => 'm',
  81664. '�' => 'n',
  81665. '�' => 'o',
  81666. '�' => 'p',
  81667. '�' => 'q',
  81668. '�' => 'r',
  81669. '�' => 's',
  81670. '�' => 't',
  81671. '�' => 'u',
  81672. '�' => 'v',
  81673. '�' => 'w',
  81674. '�' => 'x',
  81675. '�' => 'y',
  81676. '�' => 'z',
  81677. '�' => 'A',
  81678. '�' => 'B',
  81679. '�' => 'C',
  81680. '�' => 'D',
  81681. '�' => 'E',
  81682. '�' => 'F',
  81683. '�' => 'G',
  81684. '�' => 'H',
  81685. '�' => 'I',
  81686. '�' => 'J',
  81687. '�' => 'K',
  81688. '�' => 'L',
  81689. '�' => 'M',
  81690. '�' => 'N',
  81691. '�' => 'O',
  81692. '�' => 'P',
  81693. '�' => 'Q',
  81694. '�' => 'R',
  81695. '�' => 'S',
  81696. '�' => 'T',
  81697. '�' => 'U',
  81698. '�' => 'V',
  81699. '�' => 'W',
  81700. '�' => 'X',
  81701. '�' => 'Y',
  81702. '�' => 'Z',
  81703. '�' => 'a',
  81704. '�' => 'b',
  81705. '�' => 'c',
  81706. '�' => 'd',
  81707. '�' => 'e',
  81708. '�' => 'f',
  81709. '�' => 'g',
  81710. '�' => 'h',
  81711. '�' => 'i',
  81712. '�' => 'j',
  81713. '�' => 'k',
  81714. '�' => 'l',
  81715. '�' => 'm',
  81716. '�' => 'n',
  81717. '�' => 'o',
  81718. '�' => 'p',
  81719. '�' => 'q',
  81720. '�' => 'r',
  81721. '�' => 's',
  81722. '�' => 't',
  81723. '�' => 'u',
  81724. '�' => 'v',
  81725. '�' => 'w',
  81726. '�' => 'x',
  81727. '�' => 'y',
  81728. '�' => 'z',
  81729. '�' => 'A',
  81730. '�' => 'B',
  81731. '�' => 'C',
  81732. '�' => 'D',
  81733. '�' => 'E',
  81734. '�' => 'F',
  81735. '�' => 'G',
  81736. '�' => 'H',
  81737. '�' => 'I',
  81738. '�' => 'J',
  81739. '�' => 'K',
  81740. '�' => 'L',
  81741. '�' => 'M',
  81742. '�' => 'N',
  81743. '�' => 'O',
  81744. '�' => 'P',
  81745. '�' => 'Q',
  81746. '�' => 'R',
  81747. '�' => 'S',
  81748. '�' => 'T',
  81749. '�' => 'U',
  81750. '�' => 'V',
  81751. '�' => 'W',
  81752. '�' => 'X',
  81753. '�' => 'Y',
  81754. '�' => 'Z',
  81755. '�' => 'a',
  81756. '�' => 'b',
  81757. '�' => 'c',
  81758. '�' => 'd',
  81759. '�' => 'e',
  81760. '�' => 'f',
  81761. '�' => 'g',
  81762. '�' => 'h',
  81763. '�' => 'i',
  81764. '�' => 'j',
  81765. '�' => 'k',
  81766. '�' => 'l',
  81767. '�' => 'm',
  81768. '�' => 'n',
  81769. '�' => 'o',
  81770. '�' => 'p',
  81771. '�' => 'q',
  81772. '�' => 'r',
  81773. '�' => 's',
  81774. '�' => 't',
  81775. '�' => 'u',
  81776. '�' => 'v',
  81777. '�' => 'w',
  81778. '�' => 'x',
  81779. '�' => 'y',
  81780. '�' => 'z',
  81781. '�' => 'ı',
  81782. '�' => 'ȷ',
  81783. '�' => 'Α',
  81784. '�' => 'Β',
  81785. '�' => 'Γ',
  81786. '�' => 'Δ',
  81787. '�' => 'Ε',
  81788. '�' => 'Ζ',
  81789. '�' => 'Η',
  81790. '�' => 'Θ',
  81791. '�' => 'Ι',
  81792. '�' => 'Κ',
  81793. '�' => 'Λ',
  81794. '�' => 'Μ',
  81795. '�' => '�',
  81796. '�' => 'Ξ',
  81797. '�' => 'Ο',
  81798. '�' => 'Π',
  81799. '�' => 'Ρ',
  81800. '�' => 'Θ',
  81801. '�' => 'Σ',
  81802. '�' => 'Τ',
  81803. '�' => 'Υ',
  81804. '�' => 'Φ',
  81805. '�' => 'Χ',
  81806. '�' => 'Ψ',
  81807. '�' => 'Ω',
  81808. '�' => '∇',
  81809. '�' => 'α',
  81810. '�' => 'β',
  81811. '�' => 'γ',
  81812. '�' => 'δ',
  81813. '�' => 'ε',
  81814. '�' => 'ζ',
  81815. '�' => 'η',
  81816. '�' => 'θ',
  81817. '�' => 'ι',
  81818. '�' => 'κ',
  81819. '�' => 'λ',
  81820. '�' => 'μ',
  81821. '�' => 'ν',
  81822. '�' => 'ξ',
  81823. '�' => 'ο',
  81824. '�' => 'π',
  81825. '�' => '�',
  81826. '�' => 'ς',
  81827. '�' => 'σ',
  81828. '�' => 'τ',
  81829. '�' => 'υ',
  81830. '�' => 'φ',
  81831. '�' => 'χ',
  81832. '�' => 'ψ',
  81833. '�' => 'ω',
  81834. '�' => '∂',
  81835. '�' => 'ε',
  81836. '�' => 'θ',
  81837. '�' => 'κ',
  81838. '�' => 'φ',
  81839. '�' => '�',
  81840. '�' => 'π',
  81841. '�' => 'Α',
  81842. '�' => 'Β',
  81843. '�' => 'Γ',
  81844. '�' => 'Δ',
  81845. '�' => 'Ε',
  81846. '�' => 'Ζ',
  81847. '�' => 'Η',
  81848. '�' => 'Θ',
  81849. '�' => 'Ι',
  81850. '�' => 'Κ',
  81851. '�' => 'Λ',
  81852. '�' => 'Μ',
  81853. '�' => '�',
  81854. '�' => 'Ξ',
  81855. '�' => 'Ο',
  81856. '�' => 'Π',
  81857. '�' => 'Ρ',
  81858. '�' => 'Θ',
  81859. '�' => 'Σ',
  81860. '�' => 'Τ',
  81861. '�' => 'Υ',
  81862. '�' => 'Φ',
  81863. '�' => 'Χ',
  81864. '�' => 'Ψ',
  81865. '�' => 'Ω',
  81866. '�' => '∇',
  81867. '�' => 'α',
  81868. '�' => 'β',
  81869. '�' => 'γ',
  81870. '�' => 'δ',
  81871. '�' => 'ε',
  81872. '�' => 'ζ',
  81873. '�' => 'η',
  81874. '�' => 'θ',
  81875. '�' => 'ι',
  81876. '�' => 'κ',
  81877. '�' => 'λ',
  81878. '�' => 'μ',
  81879. '�' => 'ν',
  81880. '�' => 'ξ',
  81881. '�' => 'ο',
  81882. '�' => 'π',
  81883. '�' => '�',
  81884. '�' => 'ς',
  81885. '�' => 'σ',
  81886. '�' => 'τ',
  81887. '�' => 'υ',
  81888. '�' => 'φ',
  81889. '�' => 'χ',
  81890. '�' => 'ψ',
  81891. '�' => 'ω',
  81892. '�' => '∂',
  81893. '�' => 'ε',
  81894. '�' => 'θ',
  81895. '�' => 'κ',
  81896. '�' => 'φ',
  81897. '�' => '�',
  81898. '�' => 'π',
  81899. '�' => 'Α',
  81900. '�' => 'Β',
  81901. '�' => 'Γ',
  81902. '�' => 'Δ',
  81903. '�' => 'Ε',
  81904. '�' => 'Ζ',
  81905. '�' => 'Η',
  81906. '�' => 'Θ',
  81907. '�' => 'Ι',
  81908. '�' => 'Κ',
  81909. '�' => 'Λ',
  81910. '�' => 'Μ',
  81911. '�' => '�',
  81912. '�' => 'Ξ',
  81913. '�' => 'Ο',
  81914. '�' => 'Π',
  81915. '�' => 'Ρ',
  81916. '�' => 'Θ',
  81917. '�' => 'Σ',
  81918. '�' => 'Τ',
  81919. '�' => 'Υ',
  81920. '�' => 'Φ',
  81921. '�' => 'Χ',
  81922. '�' => 'Ψ',
  81923. '�' => 'Ω',
  81924. '�' => '∇',
  81925. '�' => 'α',
  81926. '�' => 'β',
  81927. '�' => 'γ',
  81928. '�' => 'δ',
  81929. '�' => 'ε',
  81930. '�' => 'ζ',
  81931. '�' => 'η',
  81932. '�' => 'θ',
  81933. '�' => 'ι',
  81934. '�' => 'κ',
  81935. '�' => 'λ',
  81936. '�' => 'μ',
  81937. '�' => 'ν',
  81938. '�' => 'ξ',
  81939. '�' => 'ο',
  81940. '�' => 'π',
  81941. '�' => '�',
  81942. '�' => 'ς',
  81943. '�' => 'σ',
  81944. '�' => 'τ',
  81945. '�' => 'υ',
  81946. '�' => 'φ',
  81947. '�' => 'χ',
  81948. '�' => 'ψ',
  81949. '�' => 'ω',
  81950. '�' => '∂',
  81951. '�' => 'ε',
  81952. '�' => 'θ',
  81953. '�' => 'κ',
  81954. '�' => 'φ',
  81955. '�' => '�',
  81956. '�' => 'π',
  81957. '�' => 'Α',
  81958. '�' => 'Β',
  81959. '�' => 'Γ',
  81960. '�' => 'Δ',
  81961. '�' => 'Ε',
  81962. '�' => 'Ζ',
  81963. '�' => 'Η',
  81964. '�' => 'Θ',
  81965. '�' => 'Ι',
  81966. '�' => 'Κ',
  81967. '�' => 'Λ',
  81968. '�' => 'Μ',
  81969. '�' => '�',
  81970. '�' => 'Ξ',
  81971. '�' => 'Ο',
  81972. '�' => 'Π',
  81973. '�' => 'Ρ',
  81974. '�' => 'Θ',
  81975. '�' => 'Σ',
  81976. '�' => 'Τ',
  81977. '�' => 'Υ',
  81978. '�' => 'Φ',
  81979. '�' => 'Χ',
  81980. '�' => 'Ψ',
  81981. '�' => 'Ω',
  81982. '�' => '∇',
  81983. '�' => 'α',
  81984. '�' => 'β',
  81985. '�' => 'γ',
  81986. '�' => 'δ',
  81987. '�' => 'ε',
  81988. '�' => 'ζ',
  81989. '�' => 'η',
  81990. '�' => 'θ',
  81991. '�' => 'ι',
  81992. '�' => 'κ',
  81993. '�' => 'λ',
  81994. '�' => 'μ',
  81995. '�' => 'ν',
  81996. '�' => 'ξ',
  81997. '�' => 'ο',
  81998. '�' => 'π',
  81999. '�' => '�',
  82000. '�' => 'ς',
  82001. '�' => 'σ',
  82002. '�' => 'τ',
  82003. '�' => 'υ',
  82004. '�' => 'φ',
  82005. '�' => 'χ',
  82006. '�' => 'ψ',
  82007. '�' => 'ω',
  82008. '�' => '∂',
  82009. '�' => 'ε',
  82010. '�' => 'θ',
  82011. '�' => 'κ',
  82012. '�' => 'φ',
  82013. '�' => '�',
  82014. '�' => 'π',
  82015. '�' => 'Α',
  82016. '�' => 'Β',
  82017. '�' => 'Γ',
  82018. '�' => 'Δ',
  82019. '�' => 'Ε',
  82020. '�' => 'Ζ',
  82021. '�' => 'Η',
  82022. '�' => 'Θ',
  82023. '�' => 'Ι',
  82024. '�' => 'Κ',
  82025. '�' => 'Λ',
  82026. '�' => 'Μ',
  82027. '�' => '�',
  82028. '�' => 'Ξ',
  82029. '�' => 'Ο',
  82030. '�' => 'Π',
  82031. '�' => 'Ρ',
  82032. '�' => 'Θ',
  82033. '�' => 'Σ',
  82034. '�' => 'Τ',
  82035. '�' => 'Υ',
  82036. '�' => 'Φ',
  82037. '�' => 'Χ',
  82038. '�' => 'Ψ',
  82039. '�' => 'Ω',
  82040. '�' => '∇',
  82041. '�' => 'α',
  82042. '�' => 'β',
  82043. '�' => 'γ',
  82044. '�' => 'δ',
  82045. '�' => 'ε',
  82046. '�' => 'ζ',
  82047. '�' => 'η',
  82048. '�' => 'θ',
  82049. '�' => 'ι',
  82050. '�' => 'κ',
  82051. '�' => 'λ',
  82052. '�' => 'μ',
  82053. '�' => 'ν',
  82054. '�' => 'ξ',
  82055. '�' => 'ο',
  82056. '�' => 'π',
  82057. '�' => '�',
  82058. '�' => 'ς',
  82059. '�' => 'σ',
  82060. '�' => 'τ',
  82061. '�' => 'υ',
  82062. '�' => 'φ',
  82063. '�' => 'χ',
  82064. '�' => 'ψ',
  82065. '�' => 'ω',
  82066. '�' => '∂',
  82067. '�' => 'ε',
  82068. '�' => 'θ',
  82069. '�' => 'κ',
  82070. '�' => 'φ',
  82071. '�' => '�',
  82072. '�' => 'π',
  82073. '�' => 'Ϝ',
  82074. '�' => '�',
  82075. '�' => '0',
  82076. '�' => '1',
  82077. '�' => '2',
  82078. '�' => '3',
  82079. '�' => '4',
  82080. '�' => '5',
  82081. '�' => '6',
  82082. '�' => '7',
  82083. '�' => '8',
  82084. '�' => '9',
  82085. '�' => '0',
  82086. '�' => '1',
  82087. '�' => '2',
  82088. '�' => '3',
  82089. '�' => '4',
  82090. '�' => '5',
  82091. '�' => '6',
  82092. '�' => '7',
  82093. '�' => '8',
  82094. '�' => '9',
  82095. '�' => '0',
  82096. '�' => '1',
  82097. '�' => '2',
  82098. '�' => '3',
  82099. '�' => '4',
  82100. '�' => '5',
  82101. '�' => '6',
  82102. '�' => '7',
  82103. '�' => '8',
  82104. '�' => '9',
  82105. '�' => '0',
  82106. '�' => '1',
  82107. '�' => '2',
  82108. '�' => '3',
  82109. '�' => '4',
  82110. '�' => '5',
  82111. '�' => '6',
  82112. '�' => '7',
  82113. '�' => '8',
  82114. '�' => '9',
  82115. '�' => '0',
  82116. '�' => '1',
  82117. '�' => '2',
  82118. '�' => '3',
  82119. '�' => '4',
  82120. '�' => '5',
  82121. '�' => '6',
  82122. '�' => '7',
  82123. '�' => '8',
  82124. '�' => '9',
  82125. '𞸀' => 'ا',
  82126. '�' => 'ب',
  82127. '𞸂' => 'ج',
  82128. '𞸃' => 'د',
  82129. '𞸅' => 'و',
  82130. '𞸆' => 'ز',
  82131. '𞸇' => 'ح',
  82132. '𞸈' => 'ط',
  82133. '𞸉' => 'ي',
  82134. '𞸊' => 'ك',
  82135. '𞸋' => 'ل',
  82136. '𞸌' => 'م',
  82137. '�' => 'ن',
  82138. '𞸎' => 'س',
  82139. '�' => 'ع',
  82140. '�' => '�',
  82141. '𞸑' => 'ص',
  82142. '𞸒' => 'ق',
  82143. '𞸓' => 'ر',
  82144. '𞸔' => 'ش',
  82145. '𞸕' => 'ت',
  82146. '𞸖' => 'ث',
  82147. '𞸗' => 'خ',
  82148. '𞸘' => 'ذ',
  82149. '𞸙' => 'ض',
  82150. '𞸚' => 'ظ',
  82151. '𞸛' => 'غ',
  82152. '𞸜' => 'ٮ',
  82153. '�' => 'ں',
  82154. '𞸞' => 'ڡ',
  82155. '𞸟' => 'ٯ',
  82156. '𞸡' => 'ب',
  82157. '𞸢' => 'ج',
  82158. '𞸤' => 'ه',
  82159. '𞸧' => 'ح',
  82160. '𞸩' => 'ي',
  82161. '𞸪' => 'ك',
  82162. '𞸫' => 'ل',
  82163. '𞸬' => 'م',
  82164. '𞸭' => 'ن',
  82165. '𞸮' => 'س',
  82166. '𞸯' => 'ع',
  82167. '𞸰' => '�',
  82168. '𞸱' => 'ص',
  82169. '𞸲' => 'ق',
  82170. '𞸴' => 'ش',
  82171. '𞸵' => 'ت',
  82172. '𞸶' => 'ث',
  82173. '𞸷' => 'خ',
  82174. '𞸹' => 'ض',
  82175. '𞸻' => 'غ',
  82176. '𞹂' => 'ج',
  82177. '𞹇' => 'ح',
  82178. '𞹉' => 'ي',
  82179. '𞹋' => 'ل',
  82180. '�' => 'ن',
  82181. '𞹎' => 'س',
  82182. '�' => 'ع',
  82183. '𞹑' => 'ص',
  82184. 'ðž¹’' => 'Ù‚',
  82185. 'ðž¹”' => 'Ø´',
  82186. 'ðž¹—' => 'Ø®',
  82187. '𞹙' => 'ض',
  82188. '𞹛' => 'غ',
  82189. '�' => 'ں',
  82190. '𞹟' => 'ٯ',
  82191. '𞹡' => 'ب',
  82192. '𞹢' => 'ج',
  82193. '𞹤' => 'ه',
  82194. 'ðž¹§' => 'Ø­',
  82195. '𞹨' => 'ط',
  82196. '𞹩' => 'ي',
  82197. '𞹪' => 'ك',
  82198. '𞹬' => 'م',
  82199. 'ðž¹­' => 'Ù†',
  82200. '𞹮' => 'س',
  82201. '𞹯' => 'ع',
  82202. 'ðž¹°' => 'Ù�',
  82203. '𞹱' => 'ص',
  82204. 'ðž¹²' => 'Ù‚',
  82205. 'ðž¹´' => 'Ø´',
  82206. '𞹵' => 'ت',
  82207. 'ðž¹¶' => 'Ø«',
  82208. 'ðž¹·' => 'Ø®',
  82209. '𞹹' => 'ض',
  82210. '𞹺' => 'ظ',
  82211. '𞹻' => 'غ',
  82212. 'ðž¹¼' => 'Ù®',
  82213. 'ðž¹¾' => 'Ú¡',
  82214. '𞺀' => 'ا',
  82215. '�' => 'ب',
  82216. '𞺂' => 'ج',
  82217. '𞺃' => 'د',
  82218. '𞺄' => 'ه',
  82219. '𞺅' => 'و',
  82220. '𞺆' => 'ز',
  82221. '𞺇' => 'ح',
  82222. '𞺈' => 'ط',
  82223. '𞺉' => 'ي',
  82224. '𞺋' => 'ل',
  82225. '𞺌' => 'م',
  82226. '�' => 'ن',
  82227. '𞺎' => 'س',
  82228. '�' => 'ع',
  82229. '�' => '�',
  82230. '𞺑' => 'ص',
  82231. '𞺒' => 'ق',
  82232. '𞺓' => 'ر',
  82233. '𞺔' => 'ش',
  82234. '𞺕' => 'ت',
  82235. '𞺖' => 'ث',
  82236. '𞺗' => 'خ',
  82237. '𞺘' => 'ذ',
  82238. '𞺙' => 'ض',
  82239. '𞺚' => 'ظ',
  82240. '𞺛' => 'غ',
  82241. '𞺡' => 'ب',
  82242. '𞺢' => 'ج',
  82243. '𞺣' => 'د',
  82244. '𞺥' => 'و',
  82245. '𞺦' => 'ز',
  82246. '𞺧' => 'ح',
  82247. '𞺨' => 'ط',
  82248. '𞺩' => 'ي',
  82249. '𞺫' => 'ل',
  82250. '𞺬' => 'م',
  82251. '𞺭' => 'ن',
  82252. '𞺮' => 'س',
  82253. '𞺯' => 'ع',
  82254. '𞺰' => '�',
  82255. '𞺱' => 'ص',
  82256. '𞺲' => 'ق',
  82257. '𞺳' => 'ر',
  82258. '𞺴' => 'ش',
  82259. '𞺵' => 'ت',
  82260. '𞺶' => 'ث',
  82261. '𞺷' => 'خ',
  82262. '𞺸' => 'ذ',
  82263. '𞺹' => 'ض',
  82264. '𞺺' => 'ظ',
  82265. '𞺻' => 'غ',
  82266. '🄀' => '0.',
  82267. '�' => '0,',
  82268. '🄂' => '1,',
  82269. '🄃' => '2,',
  82270. '🄄' => '3,',
  82271. '🄅' => '4,',
  82272. '🄆' => '5,',
  82273. '🄇' => '6,',
  82274. '🄈' => '7,',
  82275. '🄉' => '8,',
  82276. '🄊' => '9,',
  82277. '�' => '(A)',
  82278. '🄑' => '(B)',
  82279. '🄒' => '(C)',
  82280. '🄓' => '(D)',
  82281. '🄔' => '(E)',
  82282. '🄕' => '(F)',
  82283. '🄖' => '(G)',
  82284. '🄗' => '(H)',
  82285. '🄘' => '(I)',
  82286. '🄙' => '(J)',
  82287. '🄚' => '(K)',
  82288. '🄛' => '(L)',
  82289. '🄜' => '(M)',
  82290. '�' => '(N)',
  82291. '🄞' => '(O)',
  82292. '🄟' => '(P)',
  82293. '🄠' => '(Q)',
  82294. '🄡' => '(R)',
  82295. '🄢' => '(S)',
  82296. '🄣' => '(T)',
  82297. '🄤' => '(U)',
  82298. '🄥' => '(V)',
  82299. '🄦' => '(W)',
  82300. '🄧' => '(X)',
  82301. '🄨' => '(Y)',
  82302. '🄩' => '(Z)',
  82303. '🄪' => '〔S〕',
  82304. '🄫' => 'C',
  82305. '🄬' => 'R',
  82306. '🄭' => 'CD',
  82307. '🄮' => 'WZ',
  82308. '🄰' => 'A',
  82309. '🄱' => 'B',
  82310. '🄲' => 'C',
  82311. '🄳' => 'D',
  82312. '🄴' => 'E',
  82313. '🄵' => 'F',
  82314. '🄶' => 'G',
  82315. '🄷' => 'H',
  82316. '🄸' => 'I',
  82317. '🄹' => 'J',
  82318. '🄺' => 'K',
  82319. '🄻' => 'L',
  82320. '🄼' => 'M',
  82321. '🄽' => 'N',
  82322. '🄾' => 'O',
  82323. '🄿' => 'P',
  82324. '🅀' => 'Q',
  82325. '�' => 'R',
  82326. '🅂' => 'S',
  82327. '🅃' => 'T',
  82328. '🅄' => 'U',
  82329. '🅅' => 'V',
  82330. '🅆' => 'W',
  82331. '🅇' => 'X',
  82332. '🅈' => 'Y',
  82333. '🅉' => 'Z',
  82334. '🅊' => 'HV',
  82335. '🅋' => 'MV',
  82336. '🅌' => 'SD',
  82337. '�' => 'SS',
  82338. '🅎' => 'PPV',
  82339. '�' => 'WC',
  82340. '🅪' => 'MC',
  82341. '🅫' => 'MD',
  82342. '🅬' => 'MR',
  82343. '�' => 'DJ',
  82344. '🈀' => '��',
  82345. '�' => 'ココ',
  82346. '🈂' => 'サ',
  82347. '�' => '手',
  82348. '🈑' => '字',
  82349. '🈒' => '�',
  82350. '🈓' => 'デ',
  82351. '🈔' => '二',
  82352. '🈕' => '多',
  82353. '🈖' => '解',
  82354. '🈗' => '天',
  82355. '🈘' => '交',
  82356. '🈙' => '映',
  82357. '🈚' => '無',
  82358. '🈛' => '料',
  82359. '🈜' => '�',
  82360. '�' => '後',
  82361. '🈞' => '�',
  82362. '🈟' => '新',
  82363. '🈠' => '�',
  82364. '🈡' => '終',
  82365. '🈢' => '生',
  82366. '🈣' => '販',
  82367. '🈤' => '声',
  82368. '🈥' => '�',
  82369. '🈦' => '演',
  82370. '🈧' => '投',
  82371. '🈨' => '�',
  82372. '🈩' => '一',
  82373. '🈪' => '三',
  82374. '🈫' => '�',
  82375. '🈬' => '左',
  82376. '🈭' => '中',
  82377. '🈮' => '�',
  82378. '🈯' => '指',
  82379. '🈰' => '走',
  82380. '🈱' => '打',
  82381. '🈲' => '�',
  82382. '🈳' => '空',
  82383. '🈴' => '�',
  82384. '🈵' => '満',
  82385. '🈶' => '有',
  82386. '🈷' => '月',
  82387. '🈸' => '申',
  82388. '🈹' => '割',
  82389. '🈺' => '営',
  82390. '🈻' => '�',
  82391. '🉀' => '〔本〕',
  82392. '�' => '〔三〕',
  82393. '🉂' => '〔二〕',
  82394. '🉃' => '〔安〕',
  82395. '🉄' => '〔点〕',
  82396. '🉅' => '〔打〕',
  82397. '🉆' => '〔盗〕',
  82398. '🉇' => '〔�〕',
  82399. '🉈' => '〔敗〕',
  82400. '�' => '得',
  82401. '🉑' => '�',
  82402. '🯰' => '0',
  82403. '🯱' => '1',
  82404. '🯲' => '2',
  82405. '🯳' => '3',
  82406. '🯴' => '4',
  82407. '🯵' => '5',
  82408. '🯶' => '6',
  82409. '🯷' => '7',
  82410. '🯸' => '8',
  82411. '🯹' => '9',
  82412. );
  82413. <?php
  82414. use Symfony\Polyfill\Intl\Normalizer as p;
  82415. if (\PHP_VERSION_ID >= 80000) {
  82416. return require __DIR__.'/bootstrap80.php';
  82417. }
  82418. if (!function_exists('normalizer_is_normalized')) {
  82419. function normalizer_is_normalized($string, $form = p\Normalizer::FORM_C) { return p\Normalizer::isNormalized($string, $form); }
  82420. }
  82421. if (!function_exists('normalizer_normalize')) {
  82422. function normalizer_normalize($string, $form = p\Normalizer::FORM_C) { return p\Normalizer::normalize($string, $form); }
  82423. }
  82424. <?php
  82425. use Symfony\Polyfill\Intl\Normalizer as p;
  82426. if (!function_exists('normalizer_is_normalized')) {
  82427. function normalizer_is_normalized(?string $string, ?int $form = p\Normalizer::FORM_C): bool { return p\Normalizer::isNormalized((string) $string, (int) $form); }
  82428. }
  82429. if (!function_exists('normalizer_normalize')) {
  82430. function normalizer_normalize(?string $string, ?int $form = p\Normalizer::FORM_C): string|false { return p\Normalizer::normalize((string) $string, (int) $form); }
  82431. }
  82432. Copyright (c) 2015-present Fabien Potencier
  82433. Permission is hereby granted, free of charge, to any person obtaining a copy
  82434. of this software and associated documentation files (the "Software"), to deal
  82435. in the Software without restriction, including without limitation the rights
  82436. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  82437. copies of the Software, and to permit persons to whom the Software is furnished
  82438. to do so, subject to the following conditions:
  82439. The above copyright notice and this permission notice shall be included in all
  82440. copies or substantial portions of the Software.
  82441. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  82442. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  82443. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  82444. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  82445. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  82446. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  82447. THE SOFTWARE.
  82448. <?php
  82449. namespace Symfony\Polyfill\Mbstring;
  82450. final class Mbstring
  82451. {
  82452. public const MB_CASE_FOLD = \PHP_INT_MAX;
  82453. private const SIMPLE_CASE_FOLD = [
  82454. ['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
  82455. ['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'],
  82456. ];
  82457. private static $encodingList = ['ASCII', 'UTF-8'];
  82458. private static $language = 'neutral';
  82459. private static $internalEncoding = 'UTF-8';
  82460. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  82461. {
  82462. if (\is_array($s)) {
  82463. $r = [];
  82464. foreach ($s as $str) {
  82465. $r[] = self::mb_convert_encoding($str, $toEncoding, $fromEncoding);
  82466. }
  82467. return $r;
  82468. }
  82469. if (\is_array($fromEncoding) || (null !== $fromEncoding && false !== strpos($fromEncoding, ','))) {
  82470. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  82471. } else {
  82472. $fromEncoding = self::getEncoding($fromEncoding);
  82473. }
  82474. $toEncoding = self::getEncoding($toEncoding);
  82475. if ('BASE64' === $fromEncoding) {
  82476. $s = base64_decode($s);
  82477. $fromEncoding = $toEncoding;
  82478. }
  82479. if ('BASE64' === $toEncoding) {
  82480. return base64_encode($s);
  82481. }
  82482. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  82483. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  82484. $fromEncoding = 'Windows-1252';
  82485. }
  82486. if ('UTF-8' !== $fromEncoding) {
  82487. $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  82488. }
  82489. return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
  82490. }
  82491. if ('HTML-ENTITIES' === $fromEncoding) {
  82492. $s = html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
  82493. $fromEncoding = 'UTF-8';
  82494. }
  82495. return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  82496. }
  82497. public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
  82498. {
  82499. $ok = true;
  82500. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  82501. if (false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  82502. $ok = false;
  82503. }
  82504. });
  82505. return $ok ? $fromEncoding : false;
  82506. }
  82507. public static function mb_decode_mimeheader($s)
  82508. {
  82509. return iconv_mime_decode($s, 2, self::$internalEncoding);
  82510. }
  82511. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  82512. {
  82513. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
  82514. }
  82515. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  82516. {
  82517. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
  82518. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  82519. return null;
  82520. }
  82521. if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
  82522. return false;
  82523. }
  82524. if (null !== $encoding && !\is_scalar($encoding)) {
  82525. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  82526. return '';
  82527. }
  82528. $s = (string) $s;
  82529. if ('' === $s) {
  82530. return '';
  82531. }
  82532. $encoding = self::getEncoding($encoding);
  82533. if ('UTF-8' === $encoding) {
  82534. $encoding = null;
  82535. if (!preg_match('//u', $s)) {
  82536. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  82537. }
  82538. } else {
  82539. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  82540. }
  82541. $cnt = floor(\count($convmap) / 4) * 4;
  82542. for ($i = 0; $i < $cnt; $i += 4) {
  82543. $convmap[$i] += $convmap[$i + 2];
  82544. $convmap[$i + 1] += $convmap[$i + 2];
  82545. }
  82546. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  82547. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  82548. for ($i = 0; $i < $cnt; $i += 4) {
  82549. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  82550. return self::mb_chr($c - $convmap[$i + 2]);
  82551. }
  82552. }
  82553. return $m[0];
  82554. }, $s);
  82555. if (null === $encoding) {
  82556. return $s;
  82557. }
  82558. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  82559. }
  82560. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  82561. {
  82562. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
  82563. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  82564. return null;
  82565. }
  82566. if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
  82567. return false;
  82568. }
  82569. if (null !== $encoding && !\is_scalar($encoding)) {
  82570. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
  82571. return null;
  82572. }
  82573. if (null !== $is_hex && !\is_scalar($is_hex)) {
  82574. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', \E_USER_WARNING);
  82575. return null;
  82576. }
  82577. $s = (string) $s;
  82578. if ('' === $s) {
  82579. return '';
  82580. }
  82581. $encoding = self::getEncoding($encoding);
  82582. if ('UTF-8' === $encoding) {
  82583. $encoding = null;
  82584. if (!preg_match('//u', $s)) {
  82585. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  82586. }
  82587. } else {
  82588. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  82589. }
  82590. static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
  82591. $cnt = floor(\count($convmap) / 4) * 4;
  82592. $i = 0;
  82593. $len = \strlen($s);
  82594. $result = '';
  82595. while ($i < $len) {
  82596. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  82597. $uchr = substr($s, $i, $ulen);
  82598. $i += $ulen;
  82599. $c = self::mb_ord($uchr);
  82600. for ($j = 0; $j < $cnt; $j += 4) {
  82601. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  82602. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  82603. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  82604. continue 2;
  82605. }
  82606. }
  82607. $result .= $uchr;
  82608. }
  82609. if (null === $encoding) {
  82610. return $result;
  82611. }
  82612. return iconv('UTF-8', $encoding.'//IGNORE', $result);
  82613. }
  82614. public static function mb_convert_case($s, $mode, $encoding = null)
  82615. {
  82616. $s = (string) $s;
  82617. if ('' === $s) {
  82618. return '';
  82619. }
  82620. $encoding = self::getEncoding($encoding);
  82621. if ('UTF-8' === $encoding) {
  82622. $encoding = null;
  82623. if (!preg_match('//u', $s)) {
  82624. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  82625. }
  82626. } else {
  82627. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  82628. }
  82629. if (\MB_CASE_TITLE == $mode) {
  82630. static $titleRegexp = null;
  82631. if (null === $titleRegexp) {
  82632. $titleRegexp = self::getData('titleCaseRegexp');
  82633. }
  82634. $s = preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s);
  82635. } else {
  82636. if (\MB_CASE_UPPER == $mode) {
  82637. static $upper = null;
  82638. if (null === $upper) {
  82639. $upper = self::getData('upperCase');
  82640. }
  82641. $map = $upper;
  82642. } else {
  82643. if (self::MB_CASE_FOLD === $mode) {
  82644. static $caseFolding = null;
  82645. if (null === $caseFolding) {
  82646. $caseFolding = self::getData('caseFolding');
  82647. }
  82648. $s = strtr($s, $caseFolding);
  82649. }
  82650. static $lower = null;
  82651. if (null === $lower) {
  82652. $lower = self::getData('lowerCase');
  82653. }
  82654. $map = $lower;
  82655. }
  82656. static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
  82657. $i = 0;
  82658. $len = \strlen($s);
  82659. while ($i < $len) {
  82660. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  82661. $uchr = substr($s, $i, $ulen);
  82662. $i += $ulen;
  82663. if (isset($map[$uchr])) {
  82664. $uchr = $map[$uchr];
  82665. $nlen = \strlen($uchr);
  82666. if ($nlen == $ulen) {
  82667. $nlen = $i;
  82668. do {
  82669. $s[--$nlen] = $uchr[--$ulen];
  82670. } while ($ulen);
  82671. } else {
  82672. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  82673. $len += $nlen - $ulen;
  82674. $i += $nlen - $ulen;
  82675. }
  82676. }
  82677. }
  82678. }
  82679. if (null === $encoding) {
  82680. return $s;
  82681. }
  82682. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  82683. }
  82684. public static function mb_internal_encoding($encoding = null)
  82685. {
  82686. if (null === $encoding) {
  82687. return self::$internalEncoding;
  82688. }
  82689. $normalizedEncoding = self::getEncoding($encoding);
  82690. if ('UTF-8' === $normalizedEncoding || false !== @iconv($normalizedEncoding, $normalizedEncoding, ' ')) {
  82691. self::$internalEncoding = $normalizedEncoding;
  82692. return true;
  82693. }
  82694. if (80000 > \PHP_VERSION_ID) {
  82695. return false;
  82696. }
  82697. throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
  82698. }
  82699. public static function mb_language($lang = null)
  82700. {
  82701. if (null === $lang) {
  82702. return self::$language;
  82703. }
  82704. switch ($normalizedLang = strtolower($lang)) {
  82705. case 'uni':
  82706. case 'neutral':
  82707. self::$language = $normalizedLang;
  82708. return true;
  82709. }
  82710. if (80000 > \PHP_VERSION_ID) {
  82711. return false;
  82712. }
  82713. throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
  82714. }
  82715. public static function mb_list_encodings()
  82716. {
  82717. return ['UTF-8'];
  82718. }
  82719. public static function mb_encoding_aliases($encoding)
  82720. {
  82721. switch (strtoupper($encoding)) {
  82722. case 'UTF8':
  82723. case 'UTF-8':
  82724. return ['utf8'];
  82725. }
  82726. return false;
  82727. }
  82728. public static function mb_check_encoding($var = null, $encoding = null)
  82729. {
  82730. if (null === $encoding) {
  82731. if (null === $var) {
  82732. return false;
  82733. }
  82734. $encoding = self::$internalEncoding;
  82735. }
  82736. if (!\is_array($var)) {
  82737. return self::mb_detect_encoding($var, [$encoding]) || false !== @iconv($encoding, $encoding, $var);
  82738. }
  82739. foreach ($var as $key => $value) {
  82740. if (!self::mb_check_encoding($key, $encoding)) {
  82741. return false;
  82742. }
  82743. if (!self::mb_check_encoding($value, $encoding)) {
  82744. return false;
  82745. }
  82746. }
  82747. return true;
  82748. }
  82749. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  82750. {
  82751. if (null === $encodingList) {
  82752. $encodingList = self::$encodingList;
  82753. } else {
  82754. if (!\is_array($encodingList)) {
  82755. $encodingList = array_map('trim', explode(',', $encodingList));
  82756. }
  82757. $encodingList = array_map('strtoupper', $encodingList);
  82758. }
  82759. foreach ($encodingList as $enc) {
  82760. switch ($enc) {
  82761. case 'ASCII':
  82762. if (!preg_match('/[\x80-\xFF]/', $str)) {
  82763. return $enc;
  82764. }
  82765. break;
  82766. case 'UTF8':
  82767. case 'UTF-8':
  82768. if (preg_match('//u', $str)) {
  82769. return 'UTF-8';
  82770. }
  82771. break;
  82772. default:
  82773. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  82774. return $enc;
  82775. }
  82776. }
  82777. }
  82778. return false;
  82779. }
  82780. public static function mb_detect_order($encodingList = null)
  82781. {
  82782. if (null === $encodingList) {
  82783. return self::$encodingList;
  82784. }
  82785. if (!\is_array($encodingList)) {
  82786. $encodingList = array_map('trim', explode(',', $encodingList));
  82787. }
  82788. $encodingList = array_map('strtoupper', $encodingList);
  82789. foreach ($encodingList as $enc) {
  82790. switch ($enc) {
  82791. default:
  82792. if (strncmp($enc, 'ISO-8859-', 9)) {
  82793. return false;
  82794. }
  82795. case 'ASCII':
  82796. case 'UTF8':
  82797. case 'UTF-8':
  82798. }
  82799. }
  82800. self::$encodingList = $encodingList;
  82801. return true;
  82802. }
  82803. public static function mb_strlen($s, $encoding = null)
  82804. {
  82805. $encoding = self::getEncoding($encoding);
  82806. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  82807. return \strlen($s);
  82808. }
  82809. return @iconv_strlen($s, $encoding);
  82810. }
  82811. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  82812. {
  82813. $encoding = self::getEncoding($encoding);
  82814. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  82815. return strpos($haystack, $needle, $offset);
  82816. }
  82817. $needle = (string) $needle;
  82818. if ('' === $needle) {
  82819. if (80000 > \PHP_VERSION_ID) {
  82820. trigger_error(__METHOD__.': Empty delimiter', \E_USER_WARNING);
  82821. return false;
  82822. }
  82823. return 0;
  82824. }
  82825. return iconv_strpos($haystack, $needle, $offset, $encoding);
  82826. }
  82827. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  82828. {
  82829. $encoding = self::getEncoding($encoding);
  82830. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  82831. return strrpos($haystack, $needle, $offset);
  82832. }
  82833. if ($offset != (int) $offset) {
  82834. $offset = 0;
  82835. } elseif ($offset = (int) $offset) {
  82836. if ($offset < 0) {
  82837. if (0 > $offset += self::mb_strlen($needle)) {
  82838. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  82839. }
  82840. $offset = 0;
  82841. } else {
  82842. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  82843. }
  82844. }
  82845. $pos = '' !== $needle || 80000 > \PHP_VERSION_ID
  82846. ? iconv_strrpos($haystack, $needle, $encoding)
  82847. : self::mb_strlen($haystack, $encoding);
  82848. return false !== $pos ? $offset + $pos : false;
  82849. }
  82850. public static function mb_str_split($string, $split_length = 1, $encoding = null)
  82851. {
  82852. if (null !== $string && !\is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) {
  82853. trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING);
  82854. return null;
  82855. }
  82856. if (1 > $split_length = (int) $split_length) {
  82857. if (80000 > \PHP_VERSION_ID) {
  82858. trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING);
  82859. return false;
  82860. }
  82861. throw new \ValueError('Argument #2 ($length) must be greater than 0');
  82862. }
  82863. if (null === $encoding) {
  82864. $encoding = mb_internal_encoding();
  82865. }
  82866. if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
  82867. $rx = '/(';
  82868. while (65535 < $split_length) {
  82869. $rx .= '.{65535}';
  82870. $split_length -= 65535;
  82871. }
  82872. $rx .= '.{'.$split_length.'})/us';
  82873. return preg_split($rx, $string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
  82874. }
  82875. $result = [];
  82876. $length = mb_strlen($string, $encoding);
  82877. for ($i = 0; $i < $length; $i += $split_length) {
  82878. $result[] = mb_substr($string, $i, $split_length, $encoding);
  82879. }
  82880. return $result;
  82881. }
  82882. public static function mb_strtolower($s, $encoding = null)
  82883. {
  82884. return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding);
  82885. }
  82886. public static function mb_strtoupper($s, $encoding = null)
  82887. {
  82888. return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding);
  82889. }
  82890. public static function mb_substitute_character($c = null)
  82891. {
  82892. if (null === $c) {
  82893. return 'none';
  82894. }
  82895. if (0 === strcasecmp($c, 'none')) {
  82896. return true;
  82897. }
  82898. if (80000 > \PHP_VERSION_ID) {
  82899. return false;
  82900. }
  82901. if (\is_int($c) || 'long' === $c || 'entity' === $c) {
  82902. return false;
  82903. }
  82904. throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint');
  82905. }
  82906. public static function mb_substr($s, $start, $length = null, $encoding = null)
  82907. {
  82908. $encoding = self::getEncoding($encoding);
  82909. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  82910. return (string) substr($s, $start, null === $length ? 2147483647 : $length);
  82911. }
  82912. if ($start < 0) {
  82913. $start = iconv_strlen($s, $encoding) + $start;
  82914. if ($start < 0) {
  82915. $start = 0;
  82916. }
  82917. }
  82918. if (null === $length) {
  82919. $length = 2147483647;
  82920. } elseif ($length < 0) {
  82921. $length = iconv_strlen($s, $encoding) + $length - $start;
  82922. if ($length < 0) {
  82923. return '';
  82924. }
  82925. }
  82926. return (string) iconv_substr($s, $start, $length, $encoding);
  82927. }
  82928. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  82929. {
  82930. [$haystack, $needle] = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], [
  82931. self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding),
  82932. self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding),
  82933. ]);
  82934. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  82935. }
  82936. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  82937. {
  82938. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  82939. return self::getSubpart($pos, $part, $haystack, $encoding);
  82940. }
  82941. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  82942. {
  82943. $encoding = self::getEncoding($encoding);
  82944. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  82945. $pos = strrpos($haystack, $needle);
  82946. } else {
  82947. $needle = self::mb_substr($needle, 0, 1, $encoding);
  82948. $pos = iconv_strrpos($haystack, $needle, $encoding);
  82949. }
  82950. return self::getSubpart($pos, $part, $haystack, $encoding);
  82951. }
  82952. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  82953. {
  82954. $needle = self::mb_substr($needle, 0, 1, $encoding);
  82955. $pos = self::mb_strripos($haystack, $needle, $encoding);
  82956. return self::getSubpart($pos, $part, $haystack, $encoding);
  82957. }
  82958. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  82959. {
  82960. $haystack = self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding);
  82961. $needle = self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding);
  82962. $haystack = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $haystack);
  82963. $needle = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $needle);
  82964. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  82965. }
  82966. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  82967. {
  82968. $pos = strpos($haystack, $needle);
  82969. if (false === $pos) {
  82970. return false;
  82971. }
  82972. if ($part) {
  82973. return substr($haystack, 0, $pos);
  82974. }
  82975. return substr($haystack, $pos);
  82976. }
  82977. public static function mb_get_info($type = 'all')
  82978. {
  82979. $info = [
  82980. 'internal_encoding' => self::$internalEncoding,
  82981. 'http_output' => 'pass',
  82982. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  82983. 'func_overload' => 0,
  82984. 'func_overload_list' => 'no overload',
  82985. 'mail_charset' => 'UTF-8',
  82986. 'mail_header_encoding' => 'BASE64',
  82987. 'mail_body_encoding' => 'BASE64',
  82988. 'illegal_chars' => 0,
  82989. 'encoding_translation' => 'Off',
  82990. 'language' => self::$language,
  82991. 'detect_order' => self::$encodingList,
  82992. 'substitute_character' => 'none',
  82993. 'strict_detection' => 'Off',
  82994. ];
  82995. if ('all' === $type) {
  82996. return $info;
  82997. }
  82998. if (isset($info[$type])) {
  82999. return $info[$type];
  83000. }
  83001. return false;
  83002. }
  83003. public static function mb_http_input($type = '')
  83004. {
  83005. return false;
  83006. }
  83007. public static function mb_http_output($encoding = null)
  83008. {
  83009. return null !== $encoding ? 'pass' === $encoding : 'pass';
  83010. }
  83011. public static function mb_strwidth($s, $encoding = null)
  83012. {
  83013. $encoding = self::getEncoding($encoding);
  83014. if ('UTF-8' !== $encoding) {
  83015. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  83016. }
  83017. $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);
  83018. return ($wide << 1) + iconv_strlen($s, 'UTF-8');
  83019. }
  83020. public static function mb_substr_count($haystack, $needle, $encoding = null)
  83021. {
  83022. return substr_count($haystack, $needle);
  83023. }
  83024. public static function mb_output_handler($contents, $status)
  83025. {
  83026. return $contents;
  83027. }
  83028. public static function mb_chr($code, $encoding = null)
  83029. {
  83030. if (0x80 > $code %= 0x200000) {
  83031. $s = \chr($code);
  83032. } elseif (0x800 > $code) {
  83033. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  83034. } elseif (0x10000 > $code) {
  83035. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  83036. } else {
  83037. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  83038. }
  83039. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  83040. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  83041. }
  83042. return $s;
  83043. }
  83044. public static function mb_ord($s, $encoding = null)
  83045. {
  83046. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  83047. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  83048. }
  83049. if (1 === \strlen($s)) {
  83050. return \ord($s);
  83051. }
  83052. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  83053. if (0xF0 <= $code) {
  83054. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  83055. }
  83056. if (0xE0 <= $code) {
  83057. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  83058. }
  83059. if (0xC0 <= $code) {
  83060. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  83061. }
  83062. return $code;
  83063. }
  83064. public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, ?string $encoding = null): string
  83065. {
  83066. if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], true)) {
  83067. throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH');
  83068. }
  83069. if (null === $encoding) {
  83070. $encoding = self::mb_internal_encoding();
  83071. } else {
  83072. self::assertEncoding($encoding, 'mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given');
  83073. }
  83074. if (self::mb_strlen($pad_string, $encoding) <= 0) {
  83075. throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string');
  83076. }
  83077. $paddingRequired = $length - self::mb_strlen($string, $encoding);
  83078. if ($paddingRequired < 1) {
  83079. return $string;
  83080. }
  83081. switch ($pad_type) {
  83082. case \STR_PAD_LEFT:
  83083. return self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding).$string;
  83084. case \STR_PAD_RIGHT:
  83085. return $string.self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding);
  83086. default:
  83087. $leftPaddingLength = floor($paddingRequired / 2);
  83088. $rightPaddingLength = $paddingRequired - $leftPaddingLength;
  83089. return self::mb_substr(str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding).$string.self::mb_substr(str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding);
  83090. }
  83091. }
  83092. public static function mb_ucfirst(string $string, ?string $encoding = null): string
  83093. {
  83094. if (null === $encoding) {
  83095. $encoding = self::mb_internal_encoding();
  83096. } else {
  83097. self::assertEncoding($encoding, 'mb_ucfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given');
  83098. }
  83099. $firstChar = mb_substr($string, 0, 1, $encoding);
  83100. $firstChar = mb_convert_case($firstChar, \MB_CASE_TITLE, $encoding);
  83101. return $firstChar.mb_substr($string, 1, null, $encoding);
  83102. }
  83103. public static function mb_lcfirst(string $string, ?string $encoding = null): string
  83104. {
  83105. if (null === $encoding) {
  83106. $encoding = self::mb_internal_encoding();
  83107. } else {
  83108. self::assertEncoding($encoding, 'mb_lcfirst(): Argument #2 ($encoding) must be a valid encoding, "%s" given');
  83109. }
  83110. $firstChar = mb_substr($string, 0, 1, $encoding);
  83111. $firstChar = mb_convert_case($firstChar, \MB_CASE_LOWER, $encoding);
  83112. return $firstChar.mb_substr($string, 1, null, $encoding);
  83113. }
  83114. private static function getSubpart($pos, $part, $haystack, $encoding)
  83115. {
  83116. if (false === $pos) {
  83117. return false;
  83118. }
  83119. if ($part) {
  83120. return self::mb_substr($haystack, 0, $pos, $encoding);
  83121. }
  83122. return self::mb_substr($haystack, $pos, null, $encoding);
  83123. }
  83124. private static function html_encoding_callback(array $m)
  83125. {
  83126. $i = 1;
  83127. $entities = '';
  83128. $m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8'));
  83129. while (isset($m[$i])) {
  83130. if (0x80 > $m[$i]) {
  83131. $entities .= \chr($m[$i++]);
  83132. continue;
  83133. }
  83134. if (0xF0 <= $m[$i]) {
  83135. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  83136. } elseif (0xE0 <= $m[$i]) {
  83137. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  83138. } else {
  83139. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  83140. }
  83141. $entities .= '&#'.$c.';';
  83142. }
  83143. return $entities;
  83144. }
  83145. private static function title_case(array $s)
  83146. {
  83147. return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8');
  83148. }
  83149. private static function getData($file)
  83150. {
  83151. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  83152. return require $file;
  83153. }
  83154. return false;
  83155. }
  83156. private static function getEncoding($encoding)
  83157. {
  83158. if (null === $encoding) {
  83159. return self::$internalEncoding;
  83160. }
  83161. if ('UTF-8' === $encoding) {
  83162. return 'UTF-8';
  83163. }
  83164. $encoding = strtoupper($encoding);
  83165. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  83166. return 'CP850';
  83167. }
  83168. if ('UTF8' === $encoding) {
  83169. return 'UTF-8';
  83170. }
  83171. return $encoding;
  83172. }
  83173. public static function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string
  83174. {
  83175. return self::mb_internal_trim('{^[%s]+|[%1$s]+$}Du', $string, $characters, $encoding, __FUNCTION__);
  83176. }
  83177. public static function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string
  83178. {
  83179. return self::mb_internal_trim('{^[%s]+}Du', $string, $characters, $encoding, __FUNCTION__);
  83180. }
  83181. public static function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string
  83182. {
  83183. return self::mb_internal_trim('{[%s]+$}D', $string, $characters, $encoding, __FUNCTION__);
  83184. }
  83185. private static function mb_internal_trim(string $regex, string $string, ?string $characters, ?string $encoding, string $function): string
  83186. {
  83187. if (null === $encoding) {
  83188. $encoding = self::mb_internal_encoding();
  83189. } else {
  83190. self::assertEncoding($encoding, $function.'(): Argument #3 ($encoding) must be a valid encoding, "%s" given');
  83191. }
  83192. if ('' === $characters) {
  83193. return null === $encoding ? $string : self::mb_convert_encoding($string, $encoding);
  83194. }
  83195. if ('UTF-8' === $encoding) {
  83196. $encoding = null;
  83197. if (!preg_match('//u', $string)) {
  83198. $string = @iconv('UTF-8', 'UTF-8//IGNORE', $string);
  83199. }
  83200. if (null !== $characters && !preg_match('//u', $characters)) {
  83201. $characters = @iconv('UTF-8', 'UTF-8//IGNORE', $characters);
  83202. }
  83203. } else {
  83204. $string = iconv($encoding, 'UTF-8//IGNORE', $string);
  83205. if (null !== $characters) {
  83206. $characters = iconv($encoding, 'UTF-8//IGNORE', $characters);
  83207. }
  83208. }
  83209. if (null === $characters) {
  83210. $characters = "\\0 \f\n\r\t\v\u{00A0}\u{1680}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200A}\u{2028}\u{2029}\u{202F}\u{205F}\u{3000}\u{0085}\u{180E}";
  83211. } else {
  83212. $characters = preg_quote($characters);
  83213. }
  83214. $string = preg_replace(sprintf($regex, $characters), '', $string);
  83215. if (null === $encoding) {
  83216. return $string;
  83217. }
  83218. return iconv('UTF-8', $encoding.'//IGNORE', $string);
  83219. }
  83220. private static function assertEncoding(string $encoding, string $errorFormat): void
  83221. {
  83222. try {
  83223. $validEncoding = @self::mb_check_encoding('', $encoding);
  83224. } catch (\ValueError $e) {
  83225. throw new \ValueError(sprintf($errorFormat, $encoding));
  83226. }
  83227. if (!$validEncoding) {
  83228. throw new \ValueError(sprintf($errorFormat, $encoding));
  83229. }
  83230. }
  83231. }
  83232. <?php
  83233. return [
  83234. 'İ' => 'i̇',
  83235. 'µ' => 'μ',
  83236. 'Å¿' => 's',
  83237. 'ͅ' => 'ι',
  83238. 'ς' => 'σ',
  83239. '�' => 'β',
  83240. 'ϑ' => 'θ',
  83241. 'ϕ' => 'φ',
  83242. 'Ï–' => 'Ï€',
  83243. 'ϰ' => 'κ',
  83244. 'ϱ' => '�',
  83245. 'ϵ' => 'ε',
  83246. 'ẛ' => 'ṡ',
  83247. 'ι' => 'ι',
  83248. 'ß' => 'ss',
  83249. 'ʼn' => 'ʼn',
  83250. 'ǰ' => 'ǰ',
  83251. '�' => '�',
  83252. 'ΰ' => 'ΰ',
  83253. 'Ö‡' => 'Õ¥Ö‚',
  83254. 'ẖ' => 'ẖ',
  83255. 'ẗ' => 'ẗ',
  83256. 'ẘ' => 'ẘ',
  83257. 'ẙ' => 'ẙ',
  83258. 'ẚ' => 'aʾ',
  83259. 'ẞ' => 'ss',
  83260. '�' => '�',
  83261. 'á½’' => 'á½’',
  83262. 'á½”' => 'á½”',
  83263. 'á½–' => 'á½–',
  83264. 'ᾀ' => 'ἀι',
  83265. '�' => '�ι',
  83266. 'ᾂ' => 'ἂι',
  83267. 'ᾃ' => 'ἃι',
  83268. 'ᾄ' => 'ἄι',
  83269. 'ᾅ' => 'ἅι',
  83270. 'ᾆ' => 'ἆι',
  83271. 'ᾇ' => 'ἇι',
  83272. 'ᾈ' => 'ἀι',
  83273. 'ᾉ' => '�ι',
  83274. 'ᾊ' => 'ἂι',
  83275. 'ᾋ' => 'ἃι',
  83276. 'ᾌ' => 'ἄι',
  83277. '�' => 'ἅι',
  83278. 'ᾎ' => 'ἆι',
  83279. '�' => 'ἇι',
  83280. '�' => 'ἠι',
  83281. 'ᾑ' => 'ἡι',
  83282. 'ᾒ' => 'ἢι',
  83283. 'ᾓ' => 'ἣι',
  83284. 'ᾔ' => 'ἤι',
  83285. 'ᾕ' => 'ἥι',
  83286. 'ᾖ' => 'ἦι',
  83287. 'ᾗ' => 'ἧι',
  83288. 'ᾘ' => 'ἠι',
  83289. 'ᾙ' => 'ἡι',
  83290. 'ᾚ' => 'ἢι',
  83291. 'ᾛ' => 'ἣι',
  83292. 'ᾜ' => 'ἤι',
  83293. '�' => 'ἥι',
  83294. 'ᾞ' => 'ἦι',
  83295. 'ᾟ' => 'ἧι',
  83296. 'ᾠ' => 'ὠι',
  83297. 'ᾡ' => 'ὡι',
  83298. 'ᾢ' => 'ὢι',
  83299. 'ᾣ' => 'ὣι',
  83300. 'ᾤ' => 'ὤι',
  83301. 'ᾥ' => 'ὥι',
  83302. 'ᾦ' => 'ὦι',
  83303. 'ᾧ' => 'ὧι',
  83304. 'ᾨ' => 'ὠι',
  83305. 'ᾩ' => 'ὡι',
  83306. 'ᾪ' => 'ὢι',
  83307. 'ᾫ' => 'ὣι',
  83308. 'ᾬ' => 'ὤι',
  83309. 'ᾭ' => 'ὥι',
  83310. 'ᾮ' => 'ὦι',
  83311. 'ᾯ' => 'ὧι',
  83312. 'ᾲ' => 'ὰι',
  83313. 'ᾳ' => 'αι',
  83314. 'ᾴ' => 'άι',
  83315. 'á¾¶' => 'á¾¶',
  83316. 'ᾷ' => 'ᾶι',
  83317. 'ᾼ' => 'αι',
  83318. 'ῂ' => 'ὴι',
  83319. 'ῃ' => 'ηι',
  83320. 'ῄ' => 'ήι',
  83321. 'ῆ' => 'ῆ',
  83322. 'ῇ' => 'ῆι',
  83323. 'ῌ' => 'ηι',
  83324. 'á¿’' => 'á¿’',
  83325. 'á¿–' => 'á¿–',
  83326. 'á¿—' => 'á¿—',
  83327. 'á¿¢' => 'á¿¢',
  83328. 'ῤ' => 'ῤ',
  83329. 'ῦ' => 'ῦ',
  83330. 'á¿§' => 'á¿§',
  83331. 'ῲ' => 'ὼι',
  83332. 'ῳ' => 'ωι',
  83333. 'ῴ' => 'ώι',
  83334. 'á¿¶' => 'á¿¶',
  83335. 'ῷ' => 'ῶι',
  83336. 'ῼ' => 'ωι',
  83337. 'ff' => 'ff',
  83338. '�' => 'fi',
  83339. 'fl' => 'fl',
  83340. 'ffi' => 'ffi',
  83341. 'ffl' => 'ffl',
  83342. 'ſt' => 'st',
  83343. 'st' => 'st',
  83344. 'ﬓ' => 'մն',
  83345. 'ﬔ' => 'մե',
  83346. 'ﬕ' => 'մի',
  83347. 'ﬖ' => 'վն',
  83348. 'ﬗ' => 'մխ',
  83349. ];
  83350. <?php
  83351. return array (
  83352. 'A' => 'a',
  83353. 'B' => 'b',
  83354. 'C' => 'c',
  83355. 'D' => 'd',
  83356. 'E' => 'e',
  83357. 'F' => 'f',
  83358. 'G' => 'g',
  83359. 'H' => 'h',
  83360. 'I' => 'i',
  83361. 'J' => 'j',
  83362. 'K' => 'k',
  83363. 'L' => 'l',
  83364. 'M' => 'm',
  83365. 'N' => 'n',
  83366. 'O' => 'o',
  83367. 'P' => 'p',
  83368. 'Q' => 'q',
  83369. 'R' => 'r',
  83370. 'S' => 's',
  83371. 'T' => 't',
  83372. 'U' => 'u',
  83373. 'V' => 'v',
  83374. 'W' => 'w',
  83375. 'X' => 'x',
  83376. 'Y' => 'y',
  83377. 'Z' => 'z',
  83378. 'À' => 'à',
  83379. '�' => 'á',
  83380. 'Â' => 'â',
  83381. 'Ã' => 'ã',
  83382. 'Ä' => 'ä',
  83383. 'Ã…' => 'Ã¥',
  83384. 'Æ' => 'æ',
  83385. 'Ç' => 'ç',
  83386. 'È' => 'è',
  83387. 'É' => 'é',
  83388. 'Ê' => 'ê',
  83389. 'Ë' => 'ë',
  83390. 'Ì' => 'ì',
  83391. '�' => 'í',
  83392. 'Î' => 'î',
  83393. '�' => 'ï',
  83394. '�' => 'ð',
  83395. 'Ñ' => 'ñ',
  83396. 'Ò' => 'ò',
  83397. 'Ó' => 'ó',
  83398. 'Ô' => 'ô',
  83399. 'Õ' => 'õ',
  83400. 'Ö' => 'ö',
  83401. 'Ø' => 'ø',
  83402. 'Ù' => 'ù',
  83403. 'Ú' => 'ú',
  83404. 'Û' => 'û',
  83405. 'Ü' => 'ü',
  83406. '�' => 'ý',
  83407. 'Þ' => 'þ',
  83408. 'Ā' => '�',
  83409. 'Ă' => 'ă',
  83410. 'Ä„' => 'Ä…',
  83411. 'Ć' => 'ć',
  83412. 'Ĉ' => 'ĉ',
  83413. 'ÄŠ' => 'Ä‹',
  83414. 'Č' => '�',
  83415. 'Ď' => '�',
  83416. '�' => 'đ',
  83417. 'Ä’' => 'Ä“',
  83418. 'Ä”' => 'Ä•',
  83419. 'Ä–' => 'Ä—',
  83420. 'Ę' => 'ę',
  83421. 'Äš' => 'Ä›',
  83422. 'Ĝ' => '�',
  83423. 'Äž' => 'ÄŸ',
  83424. 'Ä ' => 'Ä¡',
  83425. 'Ä¢' => 'Ä£',
  83426. 'Ĥ' => 'ĥ',
  83427. 'Ħ' => 'ħ',
  83428. 'Ĩ' => 'ĩ',
  83429. 'Ī' => 'ī',
  83430. 'Ĭ' => 'ĭ',
  83431. 'Į' => 'į',
  83432. 'İ' => 'i̇',
  83433. 'IJ' => 'ij',
  83434. 'Ĵ' => 'ĵ',
  83435. 'Ķ' => 'ķ',
  83436. 'Ĺ' => 'ĺ',
  83437. 'Ļ' => 'ļ',
  83438. 'Ľ' => 'ľ',
  83439. 'Ä¿' => 'Å€',
  83440. '�' => 'ł',
  83441. 'Ń' => 'ń',
  83442. 'Ņ' => 'ņ',
  83443. 'Ň' => 'ň',
  83444. 'ÅŠ' => 'Å‹',
  83445. 'Ō' => '�',
  83446. 'Ŏ' => '�',
  83447. '�' => 'ő',
  83448. 'Å’' => 'Å“',
  83449. 'Å”' => 'Å•',
  83450. 'Å–' => 'Å—',
  83451. 'Ř' => 'ř',
  83452. 'Åš' => 'Å›',
  83453. 'Ŝ' => '�',
  83454. 'Åž' => 'ÅŸ',
  83455. 'Å ' => 'Å¡',
  83456. 'Å¢' => 'Å£',
  83457. 'Ť' => 'ť',
  83458. 'Ŧ' => 'ŧ',
  83459. 'Ũ' => 'ũ',
  83460. 'Ū' => 'ū',
  83461. 'Ŭ' => 'ŭ',
  83462. 'Ů' => 'ů',
  83463. 'Ű' => 'ű',
  83464. 'Ų' => 'ų',
  83465. 'Ŵ' => 'ŵ',
  83466. 'Ŷ' => 'ŷ',
  83467. 'Ÿ' => 'ÿ',
  83468. 'Ź' => 'ź',
  83469. 'Ż' => 'ż',
  83470. 'Ž' => 'ž',
  83471. '�' => 'ɓ',
  83472. 'Ƃ' => 'ƃ',
  83473. 'Æ„' => 'Æ…',
  83474. 'Ɔ' => 'ɔ',
  83475. 'Ƈ' => 'ƈ',
  83476. 'Ɖ' => 'ɖ',
  83477. 'ÆŠ' => 'É—',
  83478. 'Ƌ' => 'ƌ',
  83479. 'Ǝ' => '�',
  83480. '�' => 'ə',
  83481. '�' => 'ɛ',
  83482. 'Æ‘' => 'Æ’',
  83483. 'Æ“' => 'É ',
  83484. 'Æ”' => 'É£',
  83485. 'Æ–' => 'É©',
  83486. 'Ɨ' => 'ɨ',
  83487. 'Ƙ' => 'ƙ',
  83488. 'Ɯ' => 'ɯ',
  83489. '�' => 'ɲ',
  83490. 'Ɵ' => 'ɵ',
  83491. 'Æ ' => 'Æ¡',
  83492. 'Æ¢' => 'Æ£',
  83493. 'Ƥ' => 'ƥ',
  83494. 'Ʀ' => 'ʀ',
  83495. 'Ƨ' => 'ƨ',
  83496. 'Ʃ' => 'ʃ',
  83497. 'Ƭ' => 'ƭ',
  83498. 'Ʈ' => 'ʈ',
  83499. 'Ư' => 'ư',
  83500. 'Ʊ' => 'ʊ',
  83501. 'Ʋ' => 'ʋ',
  83502. 'Ƴ' => 'ƴ',
  83503. 'Ƶ' => 'ƶ',
  83504. 'Æ·' => 'Ê’',
  83505. 'Ƹ' => 'ƹ',
  83506. 'Ƽ' => 'ƽ',
  83507. 'DŽ' => 'dž',
  83508. 'Dž' => 'dž',
  83509. 'LJ' => 'lj',
  83510. 'Lj' => 'lj',
  83511. 'NJ' => 'nj',
  83512. 'Nj' => 'nj',
  83513. '�' => 'ǎ',
  83514. '�' => '�',
  83515. 'Ç‘' => 'Ç’',
  83516. 'Ç“' => 'Ç”',
  83517. 'Ç•' => 'Ç–',
  83518. 'Ǘ' => 'ǘ',
  83519. 'Ç™' => 'Çš',
  83520. 'Ǜ' => 'ǜ',
  83521. 'Çž' => 'ÇŸ',
  83522. 'Ç ' => 'Ç¡',
  83523. 'Ç¢' => 'Ç£',
  83524. 'Ǥ' => 'ǥ',
  83525. 'Ǧ' => 'ǧ',
  83526. 'Ǩ' => 'ǩ',
  83527. 'Ǫ' => 'ǫ',
  83528. 'Ǭ' => 'ǭ',
  83529. 'Ǯ' => 'ǯ',
  83530. 'DZ' => 'dz',
  83531. 'Dz' => 'dz',
  83532. 'Ǵ' => 'ǵ',
  83533. 'Ƕ' => 'ƕ',
  83534. 'Ç·' => 'Æ¿',
  83535. 'Ǹ' => 'ǹ',
  83536. 'Ǻ' => 'ǻ',
  83537. 'Ǽ' => 'ǽ',
  83538. 'Ǿ' => 'ǿ',
  83539. 'Ȁ' => '�',
  83540. 'Ȃ' => 'ȃ',
  83541. 'È„' => 'È…',
  83542. 'Ȇ' => 'ȇ',
  83543. 'Ȉ' => 'ȉ',
  83544. 'ÈŠ' => 'È‹',
  83545. 'Ȍ' => '�',
  83546. 'Ȏ' => '�',
  83547. '�' => 'ȑ',
  83548. 'È’' => 'È“',
  83549. 'È”' => 'È•',
  83550. 'È–' => 'È—',
  83551. 'Ș' => 'ș',
  83552. 'Èš' => 'È›',
  83553. 'Ȝ' => '�',
  83554. 'Èž' => 'ÈŸ',
  83555. 'È ' => 'Æž',
  83556. 'È¢' => 'È£',
  83557. 'Ȥ' => 'ȥ',
  83558. 'Ȧ' => 'ȧ',
  83559. 'Ȩ' => 'ȩ',
  83560. 'Ȫ' => 'ȫ',
  83561. 'Ȭ' => 'ȭ',
  83562. 'Ȯ' => 'ȯ',
  83563. 'Ȱ' => 'ȱ',
  83564. 'Ȳ' => 'ȳ',
  83565. 'Ⱥ' => 'ⱥ',
  83566. 'Ȼ' => 'ȼ',
  83567. 'Ƚ' => 'ƚ',
  83568. 'Ⱦ' => 'ⱦ',
  83569. '�' => 'ɂ',
  83570. 'Ƀ' => 'ƀ',
  83571. 'Ʉ' => 'ʉ',
  83572. 'Ʌ' => 'ʌ',
  83573. 'Ɇ' => 'ɇ',
  83574. 'Ɉ' => 'ɉ',
  83575. 'ÉŠ' => 'É‹',
  83576. 'Ɍ' => '�',
  83577. 'Ɏ' => '�',
  83578. 'Ͱ' => 'ͱ',
  83579. 'Ͳ' => 'ͳ',
  83580. 'Ͷ' => 'ͷ',
  83581. 'Ϳ' => 'ϳ',
  83582. 'Ά' => 'ά',
  83583. 'Έ' => 'έ',
  83584. 'Ή' => 'ή',
  83585. 'Ί' => 'ί',
  83586. 'Ό' => 'ό',
  83587. 'Ύ' => '�',
  83588. '�' => 'ώ',
  83589. 'Α' => 'α',
  83590. 'Β' => 'β',
  83591. 'Γ' => 'γ',
  83592. 'Δ' => 'δ',
  83593. 'Ε' => 'ε',
  83594. 'Ζ' => 'ζ',
  83595. 'Η' => 'η',
  83596. 'Θ' => 'θ',
  83597. 'Ι' => 'ι',
  83598. 'Κ' => 'κ',
  83599. 'Λ' => 'λ',
  83600. 'Μ' => 'μ',
  83601. '�' => 'ν',
  83602. 'Ξ' => 'ξ',
  83603. 'Ο' => 'ο',
  83604. 'Π' => 'π',
  83605. 'Ρ' => '�',
  83606. 'Σ' => 'σ',
  83607. 'Τ' => 'τ',
  83608. 'Î¥' => 'Ï…',
  83609. 'Φ' => 'φ',
  83610. 'Χ' => 'χ',
  83611. 'Ψ' => 'ψ',
  83612. 'Ω' => 'ω',
  83613. 'Ϊ' => 'ϊ',
  83614. 'Ϋ' => 'ϋ',
  83615. '�' => 'ϗ',
  83616. 'Ϙ' => 'ϙ',
  83617. 'Ïš' => 'Ï›',
  83618. 'Ϝ' => '�',
  83619. 'Ïž' => 'ÏŸ',
  83620. 'Ï ' => 'Ï¡',
  83621. 'Ï¢' => 'Ï£',
  83622. 'Ϥ' => 'ϥ',
  83623. 'Ϧ' => 'ϧ',
  83624. 'Ϩ' => 'ϩ',
  83625. 'Ϫ' => 'ϫ',
  83626. 'Ϭ' => 'ϭ',
  83627. 'Ϯ' => 'ϯ',
  83628. 'ϴ' => 'θ',
  83629. 'Ϸ' => 'ϸ',
  83630. 'Ϲ' => 'ϲ',
  83631. 'Ϻ' => 'ϻ',
  83632. 'Ͻ' => 'ͻ',
  83633. 'Ͼ' => 'ͼ',
  83634. 'Ͽ' => 'ͽ',
  83635. 'Ѐ' => '�',
  83636. '�' => 'ё',
  83637. 'Ђ' => 'ђ',
  83638. 'Ѓ' => 'ѓ',
  83639. 'Є' => 'є',
  83640. 'Ð…' => 'Ñ•',
  83641. 'І' => 'і',
  83642. 'Ї' => 'ї',
  83643. 'Ј' => 'ј',
  83644. 'Љ' => 'љ',
  83645. 'Њ' => 'њ',
  83646. 'Ћ' => 'ћ',
  83647. 'Ќ' => 'ќ',
  83648. '�' => '�',
  83649. 'ÐŽ' => 'Ñž',
  83650. '�' => 'џ',
  83651. '�' => 'а',
  83652. 'Б' => 'б',
  83653. 'В' => 'в',
  83654. 'Г' => 'г',
  83655. 'Д' => 'д',
  83656. 'Е' => 'е',
  83657. 'Ж' => 'ж',
  83658. 'З' => 'з',
  83659. 'И' => 'и',
  83660. 'Й' => 'й',
  83661. 'К' => 'к',
  83662. 'Л' => 'л',
  83663. 'М' => 'м',
  83664. '�' => 'н',
  83665. 'О' => 'о',
  83666. 'П' => 'п',
  83667. 'Р' => 'р',
  83668. 'С' => '�',
  83669. 'Т' => 'т',
  83670. 'У' => 'у',
  83671. 'Ф' => 'ф',
  83672. 'Ð¥' => 'Ñ…',
  83673. 'Ц' => 'ц',
  83674. 'Ч' => 'ч',
  83675. 'Ш' => 'ш',
  83676. 'Щ' => 'щ',
  83677. 'Ъ' => 'ъ',
  83678. 'Ы' => 'ы',
  83679. 'Ь' => 'ь',
  83680. 'Э' => '�',
  83681. 'Ю' => 'ю',
  83682. 'Я' => '�',
  83683. 'Ñ ' => 'Ñ¡',
  83684. 'Ñ¢' => 'Ñ£',
  83685. 'Ѥ' => 'ѥ',
  83686. 'Ѧ' => 'ѧ',
  83687. 'Ѩ' => 'ѩ',
  83688. 'Ѫ' => 'ѫ',
  83689. 'Ѭ' => 'ѭ',
  83690. 'Ѯ' => 'ѯ',
  83691. 'Ѱ' => 'ѱ',
  83692. 'Ѳ' => 'ѳ',
  83693. 'Ѵ' => 'ѵ',
  83694. 'Ѷ' => 'ѷ',
  83695. 'Ѹ' => 'ѹ',
  83696. 'Ѻ' => 'ѻ',
  83697. 'Ѽ' => 'ѽ',
  83698. 'Ѿ' => 'ѿ',
  83699. 'Ò€' => 'Ò�',
  83700. 'ÒŠ' => 'Ò‹',
  83701. 'Ҍ' => '�',
  83702. 'ÒŽ' => 'Ò�',
  83703. 'Ò�' => 'Ò‘',
  83704. 'Ò’' => 'Ò“',
  83705. 'Ò”' => 'Ò•',
  83706. 'Ò–' => 'Ò—',
  83707. 'Ò˜' => 'Ò™',
  83708. 'Òš' => 'Ò›',
  83709. 'Ҝ' => '�',
  83710. 'Òž' => 'ÒŸ',
  83711. 'Ò ' => 'Ò¡',
  83712. 'Ò¢' => 'Ò£',
  83713. 'Ò¤' => 'Ò¥',
  83714. 'Ò¦' => 'Ò§',
  83715. 'Ò¨' => 'Ò©',
  83716. 'Òª' => 'Ò«',
  83717. 'Ò¬' => 'Ò­',
  83718. 'Ò®' => 'Ò¯',
  83719. 'Ò°' => 'Ò±',
  83720. 'Ò²' => 'Ò³',
  83721. 'Ò´' => 'Òµ',
  83722. 'Ò¶' => 'Ò·',
  83723. 'Ò¸' => 'Ò¹',
  83724. 'Òº' => 'Ò»',
  83725. 'Ò¼' => 'Ò½',
  83726. 'Ò¾' => 'Ò¿',
  83727. 'Ó€' => 'Ó�',
  83728. 'Ó�' => 'Ó‚',
  83729. 'Óƒ' => 'Ó„',
  83730. 'Ó…' => 'Ó†',
  83731. 'Ó‡' => 'Óˆ',
  83732. 'Ó‰' => 'ÓŠ',
  83733. 'Ӌ' => 'ӌ',
  83734. 'Ó�' => 'ÓŽ',
  83735. 'Ó�' => 'Ó‘',
  83736. 'Ó’' => 'Ó“',
  83737. 'Ó”' => 'Ó•',
  83738. 'Ó–' => 'Ó—',
  83739. 'Ó˜' => 'Ó™',
  83740. 'Óš' => 'Ó›',
  83741. 'Ӝ' => '�',
  83742. 'Óž' => 'ÓŸ',
  83743. 'Ó ' => 'Ó¡',
  83744. 'Ó¢' => 'Ó£',
  83745. 'Ó¤' => 'Ó¥',
  83746. 'Ó¦' => 'Ó§',
  83747. 'Ó¨' => 'Ó©',
  83748. 'Óª' => 'Ó«',
  83749. 'Ó¬' => 'Ó­',
  83750. 'Ó®' => 'Ó¯',
  83751. 'Ó°' => 'Ó±',
  83752. 'Ó²' => 'Ó³',
  83753. 'Ó´' => 'Óµ',
  83754. 'Ó¶' => 'Ó·',
  83755. 'Ó¸' => 'Ó¹',
  83756. 'Óº' => 'Ó»',
  83757. 'Ó¼' => 'Ó½',
  83758. 'Ó¾' => 'Ó¿',
  83759. 'Ô€' => 'Ô�',
  83760. 'Ô‚' => 'Ôƒ',
  83761. 'Ô„' => 'Ô…',
  83762. 'Ô†' => 'Ô‡',
  83763. 'Ôˆ' => 'Ô‰',
  83764. 'ÔŠ' => 'Ô‹',
  83765. 'Ԍ' => '�',
  83766. 'ÔŽ' => 'Ô�',
  83767. 'Ô�' => 'Ô‘',
  83768. 'Ô’' => 'Ô“',
  83769. 'Ô”' => 'Ô•',
  83770. 'Ô–' => 'Ô—',
  83771. 'Ô˜' => 'Ô™',
  83772. 'Ôš' => 'Ô›',
  83773. 'Ԝ' => '�',
  83774. 'Ôž' => 'ÔŸ',
  83775. 'Ô ' => 'Ô¡',
  83776. 'Ô¢' => 'Ô£',
  83777. 'Ô¤' => 'Ô¥',
  83778. 'Ô¦' => 'Ô§',
  83779. 'Ô¨' => 'Ô©',
  83780. 'Ôª' => 'Ô«',
  83781. 'Ô¬' => 'Ô­',
  83782. 'Ô®' => 'Ô¯',
  83783. 'Ô±' => 'Õ¡',
  83784. 'Ô²' => 'Õ¢',
  83785. 'Ô³' => 'Õ£',
  83786. 'Ô´' => 'Õ¤',
  83787. 'Ôµ' => 'Õ¥',
  83788. 'Ô¶' => 'Õ¦',
  83789. 'Ô·' => 'Õ§',
  83790. 'Ô¸' => 'Õ¨',
  83791. 'Ô¹' => 'Õ©',
  83792. 'Ôº' => 'Õª',
  83793. 'Ô»' => 'Õ«',
  83794. 'Ô¼' => 'Õ¬',
  83795. 'Ô½' => 'Õ­',
  83796. 'Ô¾' => 'Õ®',
  83797. 'Ô¿' => 'Õ¯',
  83798. 'Õ€' => 'Õ°',
  83799. 'Õ�' => 'Õ±',
  83800. 'Õ‚' => 'Õ²',
  83801. 'Õƒ' => 'Õ³',
  83802. 'Õ„' => 'Õ´',
  83803. 'Õ…' => 'Õµ',
  83804. 'Õ†' => 'Õ¶',
  83805. 'Õ‡' => 'Õ·',
  83806. 'Õˆ' => 'Õ¸',
  83807. 'Õ‰' => 'Õ¹',
  83808. 'ÕŠ' => 'Õº',
  83809. 'Õ‹' => 'Õ»',
  83810. 'Ռ' => 'ռ',
  83811. 'Õ�' => 'Õ½',
  83812. 'ÕŽ' => 'Õ¾',
  83813. 'Õ�' => 'Õ¿',
  83814. 'Õ�' => 'Ö€',
  83815. 'Õ‘' => 'Ö�',
  83816. 'Õ’' => 'Ö‚',
  83817. 'Õ“' => 'Öƒ',
  83818. 'Õ”' => 'Ö„',
  83819. 'Õ•' => 'Ö…',
  83820. 'Õ–' => 'Ö†',
  83821. 'á‚ ' => 'â´€',
  83822. 'á‚¡' => 'â´�',
  83823. 'á‚¢' => 'â´‚',
  83824. 'á‚£' => 'â´ƒ',
  83825. 'Ⴄ' => 'ⴄ',
  83826. 'á‚¥' => 'â´…',
  83827. 'Ⴆ' => 'ⴆ',
  83828. 'á‚§' => 'â´‡',
  83829. 'Ⴈ' => 'ⴈ',
  83830. 'á‚©' => 'â´‰',
  83831. 'Ⴊ' => 'ⴊ',
  83832. 'á‚«' => 'â´‹',
  83833. 'Ⴌ' => 'ⴌ',
  83834. 'á‚­' => 'â´�',
  83835. 'á‚®' => 'â´Ž',
  83836. 'Ⴏ' => '�',
  83837. 'á‚°' => 'â´�',
  83838. 'Ⴑ' => 'ⴑ',
  83839. 'Ⴒ' => 'ⴒ',
  83840. 'Ⴓ' => 'ⴓ',
  83841. 'á‚´' => 'â´”',
  83842. 'Ⴕ' => 'ⴕ',
  83843. 'á‚¶' => 'â´–',
  83844. 'á‚·' => 'â´—',
  83845. 'Ⴘ' => 'ⴘ',
  83846. 'Ⴙ' => 'ⴙ',
  83847. 'Ⴚ' => 'ⴚ',
  83848. 'á‚»' => 'â´›',
  83849. 'Ⴜ' => 'ⴜ',
  83850. 'Ⴝ' => '�',
  83851. 'Ⴞ' => 'ⴞ',
  83852. 'á‚¿' => 'â´Ÿ',
  83853. 'Ⴠ' => 'ⴠ',
  83854. '�' => 'ⴡ',
  83855. 'Ⴢ' => 'ⴢ',
  83856. 'Ⴣ' => 'ⴣ',
  83857. 'Ⴤ' => 'ⴤ',
  83858. 'Ⴥ' => 'ⴥ',
  83859. 'Ⴧ' => 'ⴧ',
  83860. '�' => 'ⴭ',
  83861. 'Ꭰ' => 'ꭰ',
  83862. 'Ꭱ' => 'ꭱ',
  83863. 'Ꭲ' => 'ꭲ',
  83864. 'Ꭳ' => 'ꭳ',
  83865. 'Ꭴ' => 'ꭴ',
  83866. 'Ꭵ' => 'ꭵ',
  83867. 'Ꭶ' => 'ꭶ',
  83868. 'Ꭷ' => 'ꭷ',
  83869. 'Ꭸ' => 'ꭸ',
  83870. 'Ꭹ' => 'ꭹ',
  83871. 'Ꭺ' => 'ꭺ',
  83872. 'Ꭻ' => 'ꭻ',
  83873. 'Ꭼ' => 'ꭼ',
  83874. 'Ꭽ' => 'ꭽ',
  83875. 'Ꭾ' => 'ꭾ',
  83876. 'Ꭿ' => 'ꭿ',
  83877. 'Ꮀ' => 'ꮀ',
  83878. 'Ꮁ' => '�',
  83879. 'Ꮂ' => 'ꮂ',
  83880. 'Ꮃ' => 'ꮃ',
  83881. 'Ꮄ' => 'ꮄ',
  83882. 'Ꮅ' => 'ꮅ',
  83883. 'Ꮆ' => 'ꮆ',
  83884. 'Ꮇ' => 'ꮇ',
  83885. 'Ꮈ' => 'ꮈ',
  83886. 'Ꮉ' => 'ꮉ',
  83887. 'Ꮊ' => 'ꮊ',
  83888. 'Ꮋ' => 'ꮋ',
  83889. 'Ꮌ' => 'ꮌ',
  83890. 'Ꮍ' => '�',
  83891. 'Ꮎ' => 'ꮎ',
  83892. 'Ꮏ' => '�',
  83893. '�' => '�',
  83894. '�' => 'ꮑ',
  83895. '�' => 'ꮒ',
  83896. '�' => 'ꮓ',
  83897. '�' => 'ꮔ',
  83898. '�' => 'ꮕ',
  83899. '�' => 'ꮖ',
  83900. '�' => 'ꮗ',
  83901. '�' => 'ꮘ',
  83902. '�' => 'ꮙ',
  83903. '�' => 'ꮚ',
  83904. '�' => 'ꮛ',
  83905. '�' => 'ꮜ',
  83906. '�' => '�',
  83907. '�' => 'ꮞ',
  83908. '�' => 'ꮟ',
  83909. '�' => 'ꮠ',
  83910. '�' => 'ꮡ',
  83911. '�' => 'ꮢ',
  83912. '�' => 'ꮣ',
  83913. '�' => 'ꮤ',
  83914. '�' => 'ꮥ',
  83915. '�' => 'ꮦ',
  83916. '�' => 'ꮧ',
  83917. '�' => 'ꮨ',
  83918. '�' => 'ꮩ',
  83919. '�' => 'ꮪ',
  83920. '�' => 'ꮫ',
  83921. '�' => 'ꮬ',
  83922. '�' => 'ꮭ',
  83923. '�' => 'ꮮ',
  83924. '�' => 'ꮯ',
  83925. '�' => 'ꮰ',
  83926. '�' => 'ꮱ',
  83927. '�' => 'ꮲ',
  83928. '�' => 'ꮳ',
  83929. '�' => 'ꮴ',
  83930. '�' => 'ꮵ',
  83931. '�' => 'ꮶ',
  83932. '�' => 'ꮷ',
  83933. '�' => 'ꮸ',
  83934. '�' => 'ꮹ',
  83935. '�' => 'ꮺ',
  83936. '�' => 'ꮻ',
  83937. '�' => 'ꮼ',
  83938. '�' => 'ꮽ',
  83939. '�' => 'ꮾ',
  83940. '�' => 'ꮿ',
  83941. '�' => '�',
  83942. '�' => '�',
  83943. '�' => '�',
  83944. '�' => '�',
  83945. '�' => '�',
  83946. '�' => '�',
  83947. '�' => '�',
  83948. 'Ბ' => 'ბ',
  83949. 'Გ' => 'გ',
  83950. 'Დ' => 'დ',
  83951. 'Ე' => 'ე',
  83952. 'Ვ' => 'ვ',
  83953. 'Ზ' => 'ზ',
  83954. 'Თ' => 'თ',
  83955. 'Ი' => 'ი',
  83956. 'Კ' => 'კ',
  83957. 'Ლ' => 'ლ',
  83958. 'Მ' => 'მ',
  83959. 'Ნ' => 'ნ',
  83960. '�' => '�',
  83961. 'Პ' => 'პ',
  83962. 'Ჟ' => 'ჟ',
  83963. 'Რ' => 'რ',
  83964. 'Ს' => 'ს',
  83965. 'Ტ' => 'ტ',
  83966. 'Უ' => 'უ',
  83967. 'Ფ' => 'ფ',
  83968. 'Ქ' => 'ქ',
  83969. 'Ღ' => 'ღ',
  83970. 'Ყ' => 'ყ',
  83971. 'Შ' => 'შ',
  83972. 'Ჩ' => 'ჩ',
  83973. 'Ც' => 'ც',
  83974. 'Ძ' => 'ძ',
  83975. 'Წ' => 'წ',
  83976. 'Ჭ' => 'ჭ',
  83977. 'Ხ' => 'ხ',
  83978. 'Ჯ' => 'ჯ',
  83979. 'Ჰ' => 'ჰ',
  83980. 'Ჱ' => 'ჱ',
  83981. 'Ჲ' => 'ჲ',
  83982. 'Ჳ' => 'ჳ',
  83983. 'Ჴ' => 'ჴ',
  83984. 'Ჵ' => 'ჵ',
  83985. 'Ჶ' => 'ჶ',
  83986. 'Ჷ' => 'ჷ',
  83987. 'Ჸ' => 'ჸ',
  83988. 'Ჹ' => 'ჹ',
  83989. 'Ჺ' => 'ჺ',
  83990. 'Ჽ' => 'ჽ',
  83991. 'Ჾ' => 'ჾ',
  83992. 'Ჿ' => 'ჿ',
  83993. 'Ḁ' => '�',
  83994. 'Ḃ' => 'ḃ',
  83995. 'Ḅ' => 'ḅ',
  83996. 'Ḇ' => 'ḇ',
  83997. 'Ḉ' => 'ḉ',
  83998. 'Ḋ' => 'ḋ',
  83999. 'Ḍ' => '�',
  84000. 'Ḏ' => '�',
  84001. '�' => 'ḑ',
  84002. 'Ḓ' => 'ḓ',
  84003. 'Ḕ' => 'ḕ',
  84004. 'Ḗ' => 'ḗ',
  84005. 'Ḙ' => 'ḙ',
  84006. 'Ḛ' => 'ḛ',
  84007. 'Ḝ' => '�',
  84008. 'Ḟ' => 'ḟ',
  84009. 'Ḡ' => 'ḡ',
  84010. 'Ḣ' => 'ḣ',
  84011. 'Ḥ' => 'ḥ',
  84012. 'Ḧ' => 'ḧ',
  84013. 'Ḩ' => 'ḩ',
  84014. 'Ḫ' => 'ḫ',
  84015. 'Ḭ' => 'ḭ',
  84016. 'Ḯ' => 'ḯ',
  84017. 'Ḱ' => 'ḱ',
  84018. 'Ḳ' => 'ḳ',
  84019. 'Ḵ' => 'ḵ',
  84020. 'Ḷ' => 'ḷ',
  84021. 'Ḹ' => 'ḹ',
  84022. 'Ḻ' => 'ḻ',
  84023. 'Ḽ' => 'ḽ',
  84024. 'Ḿ' => 'ḿ',
  84025. 'Ṁ' => '�',
  84026. 'Ṃ' => 'ṃ',
  84027. 'Ṅ' => 'ṅ',
  84028. 'Ṇ' => 'ṇ',
  84029. 'Ṉ' => 'ṉ',
  84030. 'Ṋ' => 'ṋ',
  84031. 'Ṍ' => '�',
  84032. 'Ṏ' => '�',
  84033. '�' => 'ṑ',
  84034. 'Ṓ' => 'ṓ',
  84035. 'Ṕ' => 'ṕ',
  84036. 'á¹–' => 'á¹—',
  84037. 'Ṙ' => 'ṙ',
  84038. 'Ṛ' => 'ṛ',
  84039. 'Ṝ' => '�',
  84040. 'Ṟ' => 'ṟ',
  84041. 'Ṡ' => 'ṡ',
  84042. 'á¹¢' => 'á¹£',
  84043. 'Ṥ' => 'ṥ',
  84044. 'Ṧ' => 'ṧ',
  84045. 'Ṩ' => 'ṩ',
  84046. 'Ṫ' => 'ṫ',
  84047. 'Ṭ' => 'ṭ',
  84048. 'Ṯ' => 'ṯ',
  84049. 'á¹°' => 'á¹±',
  84050. 'á¹²' => 'á¹³',
  84051. 'á¹´' => 'á¹µ',
  84052. 'á¹¶' => 'á¹·',
  84053. 'Ṹ' => 'ṹ',
  84054. 'Ṻ' => 'ṻ',
  84055. 'á¹¼' => 'á¹½',
  84056. 'Ṿ' => 'ṿ',
  84057. 'Ẁ' => '�',
  84058. 'Ẃ' => 'ẃ',
  84059. 'Ẅ' => 'ẅ',
  84060. 'Ẇ' => 'ẇ',
  84061. 'Ẉ' => 'ẉ',
  84062. 'Ẋ' => 'ẋ',
  84063. 'Ẍ' => '�',
  84064. 'Ẏ' => '�',
  84065. '�' => 'ẑ',
  84066. 'Ẓ' => 'ẓ',
  84067. 'Ẕ' => 'ẕ',
  84068. 'ẞ' => 'ß',
  84069. 'Ạ' => 'ạ',
  84070. 'Ả' => 'ả',
  84071. 'Ấ' => 'ấ',
  84072. 'Ầ' => 'ầ',
  84073. 'Ẩ' => 'ẩ',
  84074. 'Ẫ' => 'ẫ',
  84075. 'Ậ' => 'ậ',
  84076. 'Ắ' => 'ắ',
  84077. 'Ằ' => 'ằ',
  84078. 'Ẳ' => 'ẳ',
  84079. 'Ẵ' => 'ẵ',
  84080. 'Ặ' => 'ặ',
  84081. 'Ẹ' => 'ẹ',
  84082. 'Ẻ' => 'ẻ',
  84083. 'Ẽ' => 'ẽ',
  84084. 'Ế' => 'ế',
  84085. 'Ề' => '�',
  84086. 'Ể' => 'ể',
  84087. 'Ễ' => 'ễ',
  84088. 'Ệ' => 'ệ',
  84089. 'Ỉ' => 'ỉ',
  84090. 'Ị' => 'ị',
  84091. 'Ọ' => '�',
  84092. 'Ỏ' => '�',
  84093. '�' => 'ố',
  84094. 'Ồ' => 'ồ',
  84095. 'Ổ' => 'ổ',
  84096. 'á»–' => 'á»—',
  84097. 'Ộ' => 'ộ',
  84098. 'Ớ' => 'ớ',
  84099. 'Ờ' => '�',
  84100. 'Ở' => 'ở',
  84101. 'Ỡ' => 'ỡ',
  84102. 'Ợ' => 'ợ',
  84103. 'Ụ' => 'ụ',
  84104. 'Ủ' => 'ủ',
  84105. 'Ứ' => 'ứ',
  84106. 'Ừ' => 'ừ',
  84107. 'Ử' => 'ử',
  84108. 'Ữ' => 'ữ',
  84109. 'á»°' => 'á»±',
  84110. 'Ỳ' => 'ỳ',
  84111. 'Ỵ' => 'ỵ',
  84112. 'á»¶' => 'á»·',
  84113. 'Ỹ' => 'ỹ',
  84114. 'Ỻ' => 'ỻ',
  84115. 'Ỽ' => 'ỽ',
  84116. 'Ỿ' => 'ỿ',
  84117. 'Ἀ' => 'ἀ',
  84118. 'Ἁ' => '�',
  84119. 'Ἂ' => 'ἂ',
  84120. 'Ἃ' => 'ἃ',
  84121. 'Ἄ' => 'ἄ',
  84122. '�' => 'ἅ',
  84123. 'Ἆ' => 'ἆ',
  84124. '�' => 'ἇ',
  84125. 'Ἐ' => '�',
  84126. 'Ἑ' => 'ἑ',
  84127. 'Ἒ' => 'ἒ',
  84128. 'Ἓ' => 'ἓ',
  84129. 'Ἔ' => 'ἔ',
  84130. '�' => 'ἕ',
  84131. 'Ἠ' => 'ἠ',
  84132. 'Ἡ' => 'ἡ',
  84133. 'Ἢ' => 'ἢ',
  84134. 'Ἣ' => 'ἣ',
  84135. 'Ἤ' => 'ἤ',
  84136. 'á¼­' => 'á¼¥',
  84137. 'Ἦ' => 'ἦ',
  84138. 'Ἧ' => 'ἧ',
  84139. 'Ἰ' => 'ἰ',
  84140. 'á¼¹' => 'á¼±',
  84141. 'Ἲ' => 'ἲ',
  84142. 'á¼»' => 'á¼³',
  84143. 'á¼¼' => 'á¼´',
  84144. 'á¼½' => 'á¼µ',
  84145. 'á¼¾' => 'á¼¶',
  84146. 'Ἷ' => 'ἷ',
  84147. 'Ὀ' => 'ὀ',
  84148. 'Ὁ' => '�',
  84149. 'Ὂ' => 'ὂ',
  84150. 'Ὃ' => 'ὃ',
  84151. 'Ὄ' => 'ὄ',
  84152. '�' => 'ὅ',
  84153. 'Ὑ' => 'ὑ',
  84154. 'Ὓ' => 'ὓ',
  84155. '�' => 'ὕ',
  84156. 'Ὗ' => 'ὗ',
  84157. 'Ὠ' => 'ὠ',
  84158. 'Ὡ' => 'ὡ',
  84159. 'Ὢ' => 'ὢ',
  84160. 'Ὣ' => 'ὣ',
  84161. 'Ὤ' => 'ὤ',
  84162. 'á½­' => 'á½¥',
  84163. 'Ὦ' => 'ὦ',
  84164. 'Ὧ' => 'ὧ',
  84165. 'ᾈ' => 'ᾀ',
  84166. 'ᾉ' => '�',
  84167. 'ᾊ' => 'ᾂ',
  84168. 'ᾋ' => 'ᾃ',
  84169. 'ᾌ' => 'ᾄ',
  84170. '�' => 'ᾅ',
  84171. 'ᾎ' => 'ᾆ',
  84172. '�' => 'ᾇ',
  84173. 'ᾘ' => '�',
  84174. 'ᾙ' => 'ᾑ',
  84175. 'ᾚ' => 'ᾒ',
  84176. 'ᾛ' => 'ᾓ',
  84177. 'ᾜ' => 'ᾔ',
  84178. '�' => 'ᾕ',
  84179. 'ᾞ' => 'ᾖ',
  84180. 'ᾟ' => 'ᾗ',
  84181. 'ᾨ' => 'ᾠ',
  84182. 'ᾩ' => 'ᾡ',
  84183. 'ᾪ' => 'ᾢ',
  84184. 'ᾫ' => 'ᾣ',
  84185. 'ᾬ' => 'ᾤ',
  84186. 'á¾­' => 'á¾¥',
  84187. 'ᾮ' => 'ᾦ',
  84188. 'ᾯ' => 'ᾧ',
  84189. 'Ᾰ' => 'ᾰ',
  84190. 'á¾¹' => 'á¾±',
  84191. 'Ὰ' => 'ὰ',
  84192. 'á¾»' => 'á½±',
  84193. 'á¾¼' => 'á¾³',
  84194. 'Ὲ' => 'ὲ',
  84195. 'Έ' => 'έ',
  84196. 'Ὴ' => 'ὴ',
  84197. 'á¿‹' => 'á½µ',
  84198. 'ῌ' => 'ῃ',
  84199. 'Ῐ' => '�',
  84200. 'á¿™' => 'á¿‘',
  84201. 'Ὶ' => 'ὶ',
  84202. 'á¿›' => 'á½·',
  84203. 'Ῠ' => 'ῠ',
  84204. 'á¿©' => 'á¿¡',
  84205. 'Ὺ' => 'ὺ',
  84206. 'á¿«' => 'á½»',
  84207. 'Ῥ' => 'ῥ',
  84208. 'Ὸ' => 'ὸ',
  84209. 'Ό' => 'ό',
  84210. 'Ὼ' => 'ὼ',
  84211. 'á¿»' => 'á½½',
  84212. 'ῼ' => 'ῳ',
  84213. 'Ω' => 'ω',
  84214. 'K' => 'k',
  84215. 'â„«' => 'Ã¥',
  84216. 'Ⅎ' => 'ⅎ',
  84217. 'â… ' => 'â…°',
  84218. 'â…¡' => 'â…±',
  84219. 'â…¢' => 'â…²',
  84220. 'â…£' => 'â…³',
  84221. 'â…¤' => 'â…´',
  84222. 'â…¥' => 'â…µ',
  84223. 'â…¦' => 'â…¶',
  84224. 'â…§' => 'â…·',
  84225. 'â…¨' => 'â…¸',
  84226. 'â…©' => 'â…¹',
  84227. 'â…ª' => 'â…º',
  84228. 'â…«' => 'â…»',
  84229. 'â…¬' => 'â…¼',
  84230. 'â…­' => 'â…½',
  84231. 'â…®' => 'â…¾',
  84232. 'â…¯' => 'â…¿',
  84233. 'Ↄ' => 'ↄ',
  84234. 'Ⓐ' => '�',
  84235. 'â’·' => 'â“‘',
  84236. 'â’¸' => 'â“’',
  84237. 'â’¹' => 'â““',
  84238. 'â’º' => 'â“”',
  84239. 'â’»' => 'â“•',
  84240. 'â’¼' => 'â“–',
  84241. 'â’½' => 'â“—',
  84242. 'Ⓘ' => 'ⓘ',
  84243. 'â’¿' => 'â“™',
  84244. 'Ⓚ' => 'ⓚ',
  84245. '�' => 'ⓛ',
  84246. 'Ⓜ' => 'ⓜ',
  84247. 'Ⓝ' => '�',
  84248. 'Ⓞ' => 'ⓞ',
  84249. 'Ⓟ' => 'ⓟ',
  84250. 'Ⓠ' => 'ⓠ',
  84251. 'Ⓡ' => 'ⓡ',
  84252. 'Ⓢ' => 'ⓢ',
  84253. 'Ⓣ' => 'ⓣ',
  84254. 'Ⓤ' => 'ⓤ',
  84255. 'â“‹' => 'â“¥',
  84256. 'Ⓦ' => 'ⓦ',
  84257. '�' => 'ⓧ',
  84258. 'Ⓨ' => 'ⓨ',
  84259. '�' => 'ⓩ',
  84260. 'â°€' => 'â°°',
  84261. 'â°�' => 'â°±',
  84262. 'â°‚' => 'â°²',
  84263. 'â°ƒ' => 'â°³',
  84264. 'â°„' => 'â°´',
  84265. 'â°…' => 'â°µ',
  84266. 'â°†' => 'â°¶',
  84267. 'â°‡' => 'â°·',
  84268. 'â°ˆ' => 'â°¸',
  84269. 'â°‰' => 'â°¹',
  84270. 'â°Š' => 'â°º',
  84271. 'â°‹' => 'â°»',
  84272. 'Ⰼ' => 'ⰼ',
  84273. 'â°�' => 'â°½',
  84274. 'â°Ž' => 'â°¾',
  84275. 'â°�' => 'â°¿',
  84276. 'â°�' => 'â±€',
  84277. 'Ⱁ' => '�',
  84278. 'Ⱂ' => 'ⱂ',
  84279. 'Ⱃ' => 'ⱃ',
  84280. 'Ⱄ' => 'ⱄ',
  84281. 'â°•' => 'â±…',
  84282. 'Ⱆ' => 'ⱆ',
  84283. 'Ⱇ' => 'ⱇ',
  84284. 'Ⱈ' => 'ⱈ',
  84285. 'Ⱉ' => 'ⱉ',
  84286. 'Ⱊ' => 'ⱊ',
  84287. 'Ⱋ' => 'ⱋ',
  84288. 'Ⱌ' => 'ⱌ',
  84289. '�' => '�',
  84290. 'Ⱎ' => 'ⱎ',
  84291. 'Ⱏ' => '�',
  84292. 'Ⱐ' => '�',
  84293. 'Ⱑ' => 'ⱑ',
  84294. 'â°¢' => 'â±’',
  84295. 'Ⱓ' => 'ⱓ',
  84296. 'â°¤' => 'â±”',
  84297. 'Ⱕ' => 'ⱕ',
  84298. 'â°¦' => 'â±–',
  84299. 'â°§' => 'â±—',
  84300. 'Ⱘ' => 'ⱘ',
  84301. 'â°©' => 'â±™',
  84302. 'Ⱚ' => 'ⱚ',
  84303. 'â°«' => 'â±›',
  84304. 'Ⱜ' => 'ⱜ',
  84305. 'Ⱝ' => '�',
  84306. 'Ⱞ' => 'ⱞ',
  84307. 'Ⱡ' => 'ⱡ',
  84308. 'â±¢' => 'É«',
  84309. 'â±£' => 'áµ½',
  84310. 'Ɽ' => 'ɽ',
  84311. 'Ⱨ' => 'ⱨ',
  84312. 'Ⱪ' => 'ⱪ',
  84313. 'Ⱬ' => 'ⱬ',
  84314. 'â±­' => 'É‘',
  84315. 'Ɱ' => 'ɱ',
  84316. 'Ɐ' => '�',
  84317. 'â±°' => 'É’',
  84318. 'â±²' => 'â±³',
  84319. 'â±µ' => 'â±¶',
  84320. 'â±¾' => 'È¿',
  84321. 'Ɀ' => 'ɀ',
  84322. 'Ⲁ' => '�',
  84323. 'Ⲃ' => 'ⲃ',
  84324. 'Ⲅ' => 'ⲅ',
  84325. 'Ⲇ' => 'ⲇ',
  84326. 'Ⲉ' => 'ⲉ',
  84327. 'Ⲋ' => 'ⲋ',
  84328. 'Ⲍ' => '�',
  84329. 'Ⲏ' => '�',
  84330. '�' => 'ⲑ',
  84331. 'Ⲓ' => 'ⲓ',
  84332. 'Ⲕ' => 'ⲕ',
  84333. 'â²–' => 'â²—',
  84334. 'Ⲙ' => 'ⲙ',
  84335. 'Ⲛ' => 'ⲛ',
  84336. 'Ⲝ' => '�',
  84337. 'Ⲟ' => 'ⲟ',
  84338. 'Ⲡ' => 'ⲡ',
  84339. 'â²¢' => 'â²£',
  84340. 'Ⲥ' => 'ⲥ',
  84341. 'Ⲧ' => 'ⲧ',
  84342. 'Ⲩ' => 'ⲩ',
  84343. 'Ⲫ' => 'ⲫ',
  84344. 'Ⲭ' => 'ⲭ',
  84345. 'Ⲯ' => 'ⲯ',
  84346. 'â²°' => 'â²±',
  84347. 'â²²' => 'â²³',
  84348. 'â²´' => 'â²µ',
  84349. 'â²¶' => 'â²·',
  84350. 'Ⲹ' => 'ⲹ',
  84351. 'Ⲻ' => 'ⲻ',
  84352. 'â²¼' => 'â²½',
  84353. 'Ⲿ' => 'ⲿ',
  84354. 'Ⳁ' => '�',
  84355. 'Ⳃ' => 'ⳃ',
  84356. 'Ⳅ' => 'ⳅ',
  84357. 'Ⳇ' => 'ⳇ',
  84358. 'Ⳉ' => 'ⳉ',
  84359. 'Ⳋ' => 'ⳋ',
  84360. 'Ⳍ' => '�',
  84361. 'Ⳏ' => '�',
  84362. '�' => 'ⳑ',
  84363. 'Ⳓ' => 'ⳓ',
  84364. 'Ⳕ' => 'ⳕ',
  84365. 'â³–' => 'â³—',
  84366. 'Ⳙ' => 'ⳙ',
  84367. 'Ⳛ' => 'ⳛ',
  84368. 'Ⳝ' => '�',
  84369. 'Ⳟ' => 'ⳟ',
  84370. 'Ⳡ' => 'ⳡ',
  84371. 'â³¢' => 'â³£',
  84372. 'Ⳬ' => 'ⳬ',
  84373. 'â³­' => 'â³®',
  84374. 'â³²' => 'â³³',
  84375. 'Ꙁ' => '�',
  84376. 'Ꙃ' => 'ꙃ',
  84377. 'Ꙅ' => 'ꙅ',
  84378. 'Ꙇ' => 'ꙇ',
  84379. 'Ꙉ' => 'ꙉ',
  84380. 'Ꙋ' => 'ꙋ',
  84381. 'Ꙍ' => '�',
  84382. 'Ꙏ' => '�',
  84383. '�' => 'ꙑ',
  84384. 'Ꙓ' => 'ꙓ',
  84385. 'Ꙕ' => 'ꙕ',
  84386. 'ê™–' => 'ê™—',
  84387. 'Ꙙ' => 'ꙙ',
  84388. 'Ꙛ' => 'ꙛ',
  84389. 'Ꙝ' => '�',
  84390. 'Ꙟ' => 'ꙟ',
  84391. 'Ꙡ' => 'ꙡ',
  84392. 'Ꙣ' => 'ꙣ',
  84393. 'Ꙥ' => 'ꙥ',
  84394. 'Ꙧ' => 'ꙧ',
  84395. 'Ꙩ' => 'ꙩ',
  84396. 'Ꙫ' => 'ꙫ',
  84397. 'Ꙭ' => 'ꙭ',
  84398. 'Ꚁ' => '�',
  84399. 'Ꚃ' => 'ꚃ',
  84400. 'êš„' => 'êš…',
  84401. 'Ꚇ' => 'ꚇ',
  84402. 'Ꚉ' => 'ꚉ',
  84403. 'Ꚋ' => 'ꚋ',
  84404. 'Ꚍ' => '�',
  84405. 'Ꚏ' => '�',
  84406. '�' => 'ꚑ',
  84407. 'êš’' => 'êš“',
  84408. 'êš”' => 'êš•',
  84409. 'êš–' => 'êš—',
  84410. 'Ꚙ' => 'ꚙ',
  84411. 'êšš' => 'êš›',
  84412. 'Ꜣ' => 'ꜣ',
  84413. 'Ꜥ' => 'ꜥ',
  84414. 'Ꜧ' => 'ꜧ',
  84415. 'Ꜩ' => 'ꜩ',
  84416. 'Ꜫ' => 'ꜫ',
  84417. 'Ꜭ' => 'ꜭ',
  84418. 'Ꜯ' => 'ꜯ',
  84419. 'Ꜳ' => 'ꜳ',
  84420. 'Ꜵ' => 'ꜵ',
  84421. 'Ꜷ' => 'ꜷ',
  84422. 'Ꜹ' => 'ꜹ',
  84423. 'Ꜻ' => 'ꜻ',
  84424. 'Ꜽ' => 'ꜽ',
  84425. 'Ꜿ' => 'ꜿ',
  84426. '�' => '�',
  84427. '�' => '�',
  84428. '�' => '�',
  84429. '�' => '�',
  84430. '�' => '�',
  84431. '�' => '�',
  84432. '�' => '�',
  84433. '�' => '�',
  84434. '�' => '�',
  84435. '�' => '�',
  84436. '�' => '�',
  84437. '�' => '�',
  84438. '�' => '�',
  84439. '�' => '�',
  84440. '�' => '�',
  84441. '�' => '�',
  84442. '�' => '�',
  84443. '�' => '�',
  84444. '�' => '�',
  84445. '�' => '�',
  84446. '�' => '�',
  84447. '�' => '�',
  84448. '�' => '�',
  84449. '�' => '�',
  84450. '�' => '�',
  84451. '�' => '�',
  84452. '�' => 'ᵹ',
  84453. '�' => '�',
  84454. 'Ꞁ' => '�',
  84455. 'Ꞃ' => 'ꞃ',
  84456. 'êž„' => 'êž…',
  84457. 'Ꞇ' => 'ꞇ',
  84458. 'Ꞌ' => 'ꞌ',
  84459. '�' => 'ɥ',
  84460. '�' => 'ꞑ',
  84461. 'êž’' => 'êž“',
  84462. 'êž–' => 'êž—',
  84463. 'Ꞙ' => 'ꞙ',
  84464. 'êžš' => 'êž›',
  84465. 'Ꞝ' => '�',
  84466. 'Ꞟ' => 'ꞟ',
  84467. 'êž ' => 'êž¡',
  84468. 'Ꞣ' => 'ꞣ',
  84469. 'Ꞥ' => 'ꞥ',
  84470. 'Ꞧ' => 'ꞧ',
  84471. 'Ꞩ' => 'ꞩ',
  84472. 'Ɦ' => 'ɦ',
  84473. 'Ɜ' => 'ɜ',
  84474. 'Ɡ' => 'ɡ',
  84475. 'Ɬ' => 'ɬ',
  84476. 'Ɪ' => 'ɪ',
  84477. 'êž°' => 'Êž',
  84478. 'Ʇ' => 'ʇ',
  84479. 'Ʝ' => '�',
  84480. 'êž³' => 'ê­“',
  84481. 'êž´' => 'êžµ',
  84482. 'êž¶' => 'êž·',
  84483. 'Ꞹ' => 'ꞹ',
  84484. 'Ꞻ' => 'ꞻ',
  84485. 'êž¼' => 'êž½',
  84486. 'êž¾' => 'êž¿',
  84487. 'Ꟃ' => 'ꟃ',
  84488. 'Ꞔ' => 'ꞔ',
  84489. 'Ʂ' => 'ʂ',
  84490. 'Ᶎ' => 'ᶎ',
  84491. 'Ꟈ' => 'ꟈ',
  84492. 'Ꟊ' => 'ꟊ',
  84493. 'Ꟶ' => 'ꟶ',
  84494. 'A' => '�',
  84495. 'B' => 'b',
  84496. 'C' => 'c',
  84497. 'D' => 'd',
  84498. 'ï¼¥' => 'ï½…',
  84499. 'F' => 'f',
  84500. 'G' => 'g',
  84501. 'H' => 'h',
  84502. 'I' => 'i',
  84503. 'J' => 'j',
  84504. 'K' => 'k',
  84505. 'L' => 'l',
  84506. 'M' => '�',
  84507. 'N' => 'n',
  84508. 'O' => '�',
  84509. 'P' => '�',
  84510. 'Q' => 'q',
  84511. 'ï¼²' => 'ï½’',
  84512. 'S' => 's',
  84513. 'ï¼´' => 'ï½”',
  84514. 'U' => 'u',
  84515. 'ï¼¶' => 'ï½–',
  84516. 'ï¼·' => 'ï½—',
  84517. 'X' => 'x',
  84518. 'ï¼¹' => 'ï½™',
  84519. 'Z' => 'z',
  84520. '�' => '�',
  84521. '�' => '�',
  84522. '�' => '�',
  84523. '�' => '�',
  84524. '�' => '�',
  84525. '�' => '�',
  84526. '�' => '�',
  84527. '�' => '�',
  84528. '�' => '�',
  84529. '�' => '�',
  84530. '�' => '�',
  84531. '�' => '�',
  84532. '�' => '�',
  84533. '�' => '�',
  84534. '�' => '�',
  84535. '�' => '�',
  84536. '�' => '�',
  84537. '�' => '�',
  84538. '�' => '�',
  84539. '�' => '�',
  84540. '�' => '�',
  84541. '�' => '�',
  84542. '�' => '�',
  84543. '�' => '�',
  84544. '�' => '�',
  84545. '�' => '�',
  84546. '�' => '�',
  84547. '�' => '�',
  84548. '�' => '�',
  84549. '�' => '�',
  84550. '�' => '�',
  84551. '�' => '�',
  84552. '�' => '�',
  84553. '�' => '�',
  84554. '�' => '�',
  84555. '�' => '�',
  84556. '�' => '�',
  84557. '�' => '�',
  84558. '�' => '�',
  84559. '�' => '�',
  84560. '�' => '�',
  84561. '�' => '�',
  84562. '�' => '�',
  84563. '�' => '�',
  84564. '�' => '�',
  84565. '�' => '�',
  84566. '�' => '�',
  84567. '�' => '�',
  84568. '�' => '�',
  84569. '�' => '�',
  84570. '�' => '�',
  84571. '�' => '�',
  84572. '�' => '�',
  84573. '�' => '�',
  84574. '�' => '�',
  84575. '�' => '�',
  84576. '�' => '�',
  84577. '�' => '�',
  84578. '�' => '�',
  84579. '�' => '�',
  84580. '�' => '�',
  84581. '�' => '�',
  84582. '�' => '�',
  84583. '�' => '�',
  84584. '�' => '�',
  84585. '�' => '�',
  84586. '�' => '�',
  84587. '�' => '�',
  84588. '�' => '�',
  84589. '�' => '�',
  84590. '�' => '�',
  84591. '�' => '�',
  84592. '�' => '�',
  84593. '�' => '�',
  84594. '�' => '�',
  84595. '�' => '�',
  84596. '�' => '�',
  84597. '�' => '�',
  84598. '�' => '�',
  84599. '�' => '�',
  84600. '�' => '�',
  84601. '�' => '�',
  84602. '�' => '�',
  84603. '�' => '�',
  84604. '�' => '�',
  84605. '�' => '�',
  84606. '�' => '�',
  84607. '�' => '�',
  84608. '�' => '�',
  84609. '�' => '�',
  84610. '�' => '�',
  84611. '�' => '�',
  84612. '�' => '�',
  84613. '�' => '�',
  84614. '�' => '�',
  84615. '�' => '�',
  84616. '�' => '�',
  84617. '�' => '�',
  84618. '�' => '�',
  84619. '�' => '�',
  84620. '�' => '�',
  84621. '�' => '�',
  84622. '�' => '�',
  84623. '�' => '�',
  84624. '�' => '�',
  84625. '�' => '�',
  84626. '�' => '�',
  84627. '�' => '�',
  84628. '�' => '�',
  84629. '�' => '�',
  84630. '�' => '�',
  84631. '�' => '�',
  84632. '�' => '�',
  84633. '�' => '�',
  84634. '�' => '�',
  84635. '�' => '�',
  84636. '�' => '�',
  84637. '�' => '�',
  84638. '�' => '�',
  84639. '�' => '�',
  84640. '�' => '�',
  84641. '�' => '�',
  84642. '�' => '�',
  84643. '�' => '�',
  84644. '�' => '�',
  84645. '�' => '�',
  84646. '�' => '�',
  84647. 'ð‘¢ ' => 'ð‘£€',
  84648. '𑢡' => '�',
  84649. '𑢢' => '𑣂',
  84650. '𑢣' => '𑣃',
  84651. '𑢤' => '𑣄',
  84652. 'ð‘¢¥' => 'ð‘£…',
  84653. '𑢦' => '𑣆',
  84654. '𑢧' => '𑣇',
  84655. '𑢨' => '𑣈',
  84656. '𑢩' => '𑣉',
  84657. '𑢪' => '𑣊',
  84658. '𑢫' => '𑣋',
  84659. '𑢬' => '𑣌',
  84660. '𑢭' => '�',
  84661. '𑢮' => '𑣎',
  84662. '𑢯' => '�',
  84663. '𑢰' => '�',
  84664. '𑢱' => '𑣑',
  84665. 'ð‘¢²' => 'ð‘£’',
  84666. '𑢳' => '𑣓',
  84667. 'ð‘¢´' => 'ð‘£”',
  84668. '𑢵' => '𑣕',
  84669. 'ð‘¢¶' => 'ð‘£–',
  84670. 'ð‘¢·' => 'ð‘£—',
  84671. '𑢸' => '𑣘',
  84672. 'ð‘¢¹' => 'ð‘£™',
  84673. '𑢺' => '𑣚',
  84674. 'ð‘¢»' => 'ð‘£›',
  84675. '𑢼' => '𑣜',
  84676. '𑢽' => '�',
  84677. '𑢾' => '𑣞',
  84678. '𑢿' => '𑣟',
  84679. 'ð–¹€' => 'ð–¹ ',
  84680. '�' => '𖹡',
  84681. '𖹂' => '𖹢',
  84682. '𖹃' => '𖹣',
  84683. '𖹄' => '𖹤',
  84684. 'ð–¹…' => 'ð–¹¥',
  84685. '𖹆' => '𖹦',
  84686. '𖹇' => '𖹧',
  84687. '𖹈' => '𖹨',
  84688. '𖹉' => '𖹩',
  84689. '𖹊' => '𖹪',
  84690. '𖹋' => '𖹫',
  84691. '𖹌' => '𖹬',
  84692. '�' => '𖹭',
  84693. '𖹎' => '𖹮',
  84694. '�' => '𖹯',
  84695. '�' => '𖹰',
  84696. '𖹑' => '𖹱',
  84697. 'ð–¹’' => 'ð–¹²',
  84698. '𖹓' => '𖹳',
  84699. 'ð–¹”' => 'ð–¹´',
  84700. '𖹕' => '𖹵',
  84701. 'ð–¹–' => 'ð–¹¶',
  84702. 'ð–¹—' => 'ð–¹·',
  84703. '𖹘' => '𖹸',
  84704. 'ð–¹™' => 'ð–¹¹',
  84705. '𖹚' => '𖹺',
  84706. 'ð–¹›' => 'ð–¹»',
  84707. '𖹜' => '𖹼',
  84708. '�' => '𖹽',
  84709. '𖹞' => '𖹾',
  84710. '𖹟' => '𖹿',
  84711. '𞤀' => '𞤢',
  84712. '�' => '𞤣',
  84713. '𞤂' => '𞤤',
  84714. '𞤃' => '𞤥',
  84715. '𞤄' => '𞤦',
  84716. '𞤅' => '𞤧',
  84717. '𞤆' => '𞤨',
  84718. '𞤇' => '𞤩',
  84719. '𞤈' => '𞤪',
  84720. '𞤉' => '𞤫',
  84721. '𞤊' => '𞤬',
  84722. '𞤋' => '𞤭',
  84723. '𞤌' => '𞤮',
  84724. '�' => '𞤯',
  84725. '𞤎' => '𞤰',
  84726. '�' => '𞤱',
  84727. '�' => '𞤲',
  84728. '𞤑' => '𞤳',
  84729. '𞤒' => '𞤴',
  84730. '𞤓' => '𞤵',
  84731. '𞤔' => '𞤶',
  84732. '𞤕' => '𞤷',
  84733. '𞤖' => '𞤸',
  84734. '𞤗' => '𞤹',
  84735. '𞤘' => '𞤺',
  84736. '𞤙' => '𞤻',
  84737. '𞤚' => '𞤼',
  84738. '𞤛' => '𞤽',
  84739. '𞤜' => '𞤾',
  84740. '�' => '𞤿',
  84741. '𞤞' => '𞥀',
  84742. '𞤟' => '�',
  84743. '𞤠' => '𞥂',
  84744. '𞤡' => '𞥃',
  84745. );
  84746. <?php
  84747. 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';
  84748. <?php
  84749. return array (
  84750. 'a' => 'A',
  84751. 'b' => 'B',
  84752. 'c' => 'C',
  84753. 'd' => 'D',
  84754. 'e' => 'E',
  84755. 'f' => 'F',
  84756. 'g' => 'G',
  84757. 'h' => 'H',
  84758. 'i' => 'I',
  84759. 'j' => 'J',
  84760. 'k' => 'K',
  84761. 'l' => 'L',
  84762. 'm' => 'M',
  84763. 'n' => 'N',
  84764. 'o' => 'O',
  84765. 'p' => 'P',
  84766. 'q' => 'Q',
  84767. 'r' => 'R',
  84768. 's' => 'S',
  84769. 't' => 'T',
  84770. 'u' => 'U',
  84771. 'v' => 'V',
  84772. 'w' => 'W',
  84773. 'x' => 'X',
  84774. 'y' => 'Y',
  84775. 'z' => 'Z',
  84776. 'µ' => 'Μ',
  84777. 'à' => 'À',
  84778. 'á' => '�',
  84779. 'â' => 'Â',
  84780. 'ã' => 'Ã',
  84781. 'ä' => 'Ä',
  84782. 'Ã¥' => 'Ã…',
  84783. 'æ' => 'Æ',
  84784. 'ç' => 'Ç',
  84785. 'è' => 'È',
  84786. 'é' => 'É',
  84787. 'ê' => 'Ê',
  84788. 'ë' => 'Ë',
  84789. 'ì' => 'Ì',
  84790. 'í' => '�',
  84791. 'î' => 'Î',
  84792. 'ï' => '�',
  84793. 'ð' => '�',
  84794. 'ñ' => 'Ñ',
  84795. 'ò' => 'Ò',
  84796. 'ó' => 'Ó',
  84797. 'ô' => 'Ô',
  84798. 'õ' => 'Õ',
  84799. 'ö' => 'Ö',
  84800. 'ø' => 'Ø',
  84801. 'ù' => 'Ù',
  84802. 'ú' => 'Ú',
  84803. 'û' => 'Û',
  84804. 'ü' => 'Ü',
  84805. 'ý' => '�',
  84806. 'þ' => 'Þ',
  84807. 'ÿ' => 'Ÿ',
  84808. '�' => 'Ā',
  84809. 'ă' => 'Ă',
  84810. 'Ä…' => 'Ä„',
  84811. 'ć' => 'Ć',
  84812. 'ĉ' => 'Ĉ',
  84813. 'Ä‹' => 'ÄŠ',
  84814. '�' => 'Č',
  84815. '�' => 'Ď',
  84816. 'đ' => '�',
  84817. 'Ä“' => 'Ä’',
  84818. 'Ä•' => 'Ä”',
  84819. 'Ä—' => 'Ä–',
  84820. 'ę' => 'Ę',
  84821. 'Ä›' => 'Äš',
  84822. '�' => 'Ĝ',
  84823. 'ÄŸ' => 'Äž',
  84824. 'Ä¡' => 'Ä ',
  84825. 'Ä£' => 'Ä¢',
  84826. 'ĥ' => 'Ĥ',
  84827. 'ħ' => 'Ħ',
  84828. 'ĩ' => 'Ĩ',
  84829. 'ī' => 'Ī',
  84830. 'ĭ' => 'Ĭ',
  84831. 'į' => 'Į',
  84832. 'ı' => 'I',
  84833. 'ij' => 'IJ',
  84834. 'ĵ' => 'Ĵ',
  84835. 'ķ' => 'Ķ',
  84836. 'ĺ' => 'Ĺ',
  84837. 'ļ' => 'Ļ',
  84838. 'ľ' => 'Ľ',
  84839. 'Å€' => 'Ä¿',
  84840. 'ł' => '�',
  84841. 'ń' => 'Ń',
  84842. 'ņ' => 'Ņ',
  84843. 'ň' => 'Ň',
  84844. 'Å‹' => 'ÅŠ',
  84845. '�' => 'Ō',
  84846. '�' => 'Ŏ',
  84847. 'ő' => '�',
  84848. 'Å“' => 'Å’',
  84849. 'Å•' => 'Å”',
  84850. 'Å—' => 'Å–',
  84851. 'ř' => 'Ř',
  84852. 'Å›' => 'Åš',
  84853. '�' => 'Ŝ',
  84854. 'ÅŸ' => 'Åž',
  84855. 'Å¡' => 'Å ',
  84856. 'Å£' => 'Å¢',
  84857. 'ť' => 'Ť',
  84858. 'ŧ' => 'Ŧ',
  84859. 'ũ' => 'Ũ',
  84860. 'ū' => 'Ū',
  84861. 'ŭ' => 'Ŭ',
  84862. 'ů' => 'Ů',
  84863. 'ű' => 'Ű',
  84864. 'ų' => 'Ų',
  84865. 'ŵ' => 'Ŵ',
  84866. 'ŷ' => 'Ŷ',
  84867. 'ź' => 'Ź',
  84868. 'ż' => 'Ż',
  84869. 'ž' => 'Ž',
  84870. 'Å¿' => 'S',
  84871. 'ƀ' => 'Ƀ',
  84872. 'ƃ' => 'Ƃ',
  84873. 'Æ…' => 'Æ„',
  84874. 'ƈ' => 'Ƈ',
  84875. 'ƌ' => 'Ƌ',
  84876. 'Æ’' => 'Æ‘',
  84877. 'ƕ' => 'Ƕ',
  84878. 'ƙ' => 'Ƙ',
  84879. 'ƚ' => 'Ƚ',
  84880. 'Æž' => 'È ',
  84881. 'Æ¡' => 'Æ ',
  84882. 'Æ£' => 'Æ¢',
  84883. 'ƥ' => 'Ƥ',
  84884. 'ƨ' => 'Ƨ',
  84885. 'ƭ' => 'Ƭ',
  84886. 'ư' => 'Ư',
  84887. 'ƴ' => 'Ƴ',
  84888. 'ƶ' => 'Ƶ',
  84889. 'ƹ' => 'Ƹ',
  84890. 'ƽ' => 'Ƽ',
  84891. 'Æ¿' => 'Ç·',
  84892. 'Ç…' => 'Ç„',
  84893. 'dž' => 'DŽ',
  84894. 'Lj' => 'LJ',
  84895. 'lj' => 'LJ',
  84896. 'Ç‹' => 'ÇŠ',
  84897. 'nj' => 'NJ',
  84898. 'ǎ' => '�',
  84899. '�' => '�',
  84900. 'Ç’' => 'Ç‘',
  84901. 'Ç”' => 'Ç“',
  84902. 'Ç–' => 'Ç•',
  84903. 'ǘ' => 'Ǘ',
  84904. 'Çš' => 'Ç™',
  84905. 'ǜ' => 'Ǜ',
  84906. '�' => 'Ǝ',
  84907. 'ÇŸ' => 'Çž',
  84908. 'Ç¡' => 'Ç ',
  84909. 'Ç£' => 'Ç¢',
  84910. 'ǥ' => 'Ǥ',
  84911. 'ǧ' => 'Ǧ',
  84912. 'ǩ' => 'Ǩ',
  84913. 'ǫ' => 'Ǫ',
  84914. 'ǭ' => 'Ǭ',
  84915. 'ǯ' => 'Ǯ',
  84916. 'Dz' => 'DZ',
  84917. 'dz' => 'DZ',
  84918. 'ǵ' => 'Ǵ',
  84919. 'ǹ' => 'Ǹ',
  84920. 'ǻ' => 'Ǻ',
  84921. 'ǽ' => 'Ǽ',
  84922. 'ǿ' => 'Ǿ',
  84923. '�' => 'Ȁ',
  84924. 'ȃ' => 'Ȃ',
  84925. 'È…' => 'È„',
  84926. 'ȇ' => 'Ȇ',
  84927. 'ȉ' => 'Ȉ',
  84928. 'È‹' => 'ÈŠ',
  84929. '�' => 'Ȍ',
  84930. '�' => 'Ȏ',
  84931. 'ȑ' => '�',
  84932. 'È“' => 'È’',
  84933. 'È•' => 'È”',
  84934. 'È—' => 'È–',
  84935. 'ș' => 'Ș',
  84936. 'È›' => 'Èš',
  84937. '�' => 'Ȝ',
  84938. 'ÈŸ' => 'Èž',
  84939. 'È£' => 'È¢',
  84940. 'ȥ' => 'Ȥ',
  84941. 'ȧ' => 'Ȧ',
  84942. 'ȩ' => 'Ȩ',
  84943. 'ȫ' => 'Ȫ',
  84944. 'ȭ' => 'Ȭ',
  84945. 'ȯ' => 'Ȯ',
  84946. 'ȱ' => 'Ȱ',
  84947. 'ȳ' => 'Ȳ',
  84948. 'ȼ' => 'Ȼ',
  84949. 'È¿' => 'â±¾',
  84950. 'ɀ' => 'Ɀ',
  84951. 'ɂ' => '�',
  84952. 'ɇ' => 'Ɇ',
  84953. 'ɉ' => 'Ɉ',
  84954. 'É‹' => 'ÉŠ',
  84955. '�' => 'Ɍ',
  84956. '�' => 'Ɏ',
  84957. '�' => 'Ɐ',
  84958. 'É‘' => 'â±­',
  84959. 'É’' => 'â±°',
  84960. 'ɓ' => '�',
  84961. 'ɔ' => 'Ɔ',
  84962. 'ɖ' => 'Ɖ',
  84963. 'É—' => 'ÆŠ',
  84964. 'ə' => '�',
  84965. 'ɛ' => '�',
  84966. 'ɜ' => 'Ɜ',
  84967. 'É ' => 'Æ“',
  84968. 'ɡ' => 'Ɡ',
  84969. 'É£' => 'Æ”',
  84970. 'ɥ' => '�',
  84971. 'ɦ' => 'Ɦ',
  84972. 'ɨ' => 'Ɨ',
  84973. 'É©' => 'Æ–',
  84974. 'ɪ' => 'Ɪ',
  84975. 'É«' => 'â±¢',
  84976. 'ɬ' => 'Ɬ',
  84977. 'ɯ' => 'Ɯ',
  84978. 'ɱ' => 'Ɱ',
  84979. 'ɲ' => '�',
  84980. 'ɵ' => 'Ɵ',
  84981. 'ɽ' => 'Ɽ',
  84982. 'ʀ' => 'Ʀ',
  84983. 'ʂ' => 'Ʂ',
  84984. 'ʃ' => 'Ʃ',
  84985. 'ʇ' => 'Ʇ',
  84986. 'ʈ' => 'Ʈ',
  84987. 'ʉ' => 'Ʉ',
  84988. 'ʊ' => 'Ʊ',
  84989. 'ʋ' => 'Ʋ',
  84990. 'ʌ' => 'Ʌ',
  84991. 'Ê’' => 'Æ·',
  84992. '�' => 'Ʝ',
  84993. 'Êž' => 'êž°',
  84994. 'ͅ' => 'Ι',
  84995. 'ͱ' => 'Ͱ',
  84996. 'ͳ' => 'Ͳ',
  84997. 'ͷ' => 'Ͷ',
  84998. 'ͻ' => 'Ͻ',
  84999. 'ͼ' => 'Ͼ',
  85000. 'ͽ' => 'Ͽ',
  85001. 'ά' => 'Ά',
  85002. 'έ' => 'Έ',
  85003. 'ή' => 'Ή',
  85004. 'ί' => 'Ί',
  85005. 'α' => 'Α',
  85006. 'β' => 'Β',
  85007. 'γ' => 'Γ',
  85008. 'δ' => 'Δ',
  85009. 'ε' => 'Ε',
  85010. 'ζ' => 'Ζ',
  85011. 'η' => 'Η',
  85012. 'θ' => 'Θ',
  85013. 'ι' => 'Ι',
  85014. 'κ' => 'Κ',
  85015. 'λ' => 'Λ',
  85016. 'μ' => 'Μ',
  85017. 'ν' => '�',
  85018. 'ξ' => 'Ξ',
  85019. 'ο' => 'Ο',
  85020. 'π' => 'Π',
  85021. '�' => 'Ρ',
  85022. 'ς' => 'Σ',
  85023. 'σ' => 'Σ',
  85024. 'τ' => 'Τ',
  85025. 'Ï…' => 'Î¥',
  85026. 'φ' => 'Φ',
  85027. 'χ' => 'Χ',
  85028. 'ψ' => 'Ψ',
  85029. 'ω' => 'Ω',
  85030. 'ϊ' => 'Ϊ',
  85031. 'ϋ' => 'Ϋ',
  85032. 'ό' => 'Ό',
  85033. '�' => 'Ύ',
  85034. 'ώ' => '�',
  85035. '�' => 'Β',
  85036. 'ϑ' => 'Θ',
  85037. 'ϕ' => 'Φ',
  85038. 'ϖ' => 'Π',
  85039. 'ϗ' => '�',
  85040. 'ϙ' => 'Ϙ',
  85041. 'Ï›' => 'Ïš',
  85042. '�' => 'Ϝ',
  85043. 'ÏŸ' => 'Ïž',
  85044. 'Ï¡' => 'Ï ',
  85045. 'Ï£' => 'Ï¢',
  85046. 'ϥ' => 'Ϥ',
  85047. 'ϧ' => 'Ϧ',
  85048. 'ϩ' => 'Ϩ',
  85049. 'ϫ' => 'Ϫ',
  85050. 'ϭ' => 'Ϭ',
  85051. 'ϯ' => 'Ϯ',
  85052. 'ϰ' => 'Κ',
  85053. 'ϱ' => 'Ρ',
  85054. 'ϲ' => 'Ϲ',
  85055. 'ϳ' => 'Ϳ',
  85056. 'ϵ' => 'Ε',
  85057. 'ϸ' => 'Ϸ',
  85058. 'ϻ' => 'Ϻ',
  85059. 'а' => '�',
  85060. 'б' => 'Б',
  85061. 'в' => 'В',
  85062. 'г' => 'Г',
  85063. 'д' => 'Д',
  85064. 'е' => 'Е',
  85065. 'ж' => 'Ж',
  85066. 'з' => 'З',
  85067. 'и' => 'И',
  85068. 'й' => 'Й',
  85069. 'к' => 'К',
  85070. 'л' => 'Л',
  85071. 'м' => 'М',
  85072. 'н' => '�',
  85073. 'о' => 'О',
  85074. 'п' => 'П',
  85075. 'р' => 'Р',
  85076. '�' => 'С',
  85077. 'т' => 'Т',
  85078. 'у' => 'У',
  85079. 'ф' => 'Ф',
  85080. 'Ñ…' => 'Ð¥',
  85081. 'ц' => 'Ц',
  85082. 'ч' => 'Ч',
  85083. 'ш' => 'Ш',
  85084. 'щ' => 'Щ',
  85085. 'ъ' => 'Ъ',
  85086. 'ы' => 'Ы',
  85087. 'ь' => 'Ь',
  85088. '�' => 'Э',
  85089. 'ю' => 'Ю',
  85090. '�' => 'Я',
  85091. '�' => 'Ѐ',
  85092. 'ё' => '�',
  85093. 'ђ' => 'Ђ',
  85094. 'ѓ' => 'Ѓ',
  85095. 'є' => 'Є',
  85096. 'Ñ•' => 'Ð…',
  85097. 'і' => 'І',
  85098. 'ї' => 'Ї',
  85099. 'ј' => 'Ј',
  85100. 'љ' => 'Љ',
  85101. 'њ' => 'Њ',
  85102. 'ћ' => 'Ћ',
  85103. 'ќ' => 'Ќ',
  85104. '�' => '�',
  85105. 'Ñž' => 'ÐŽ',
  85106. 'џ' => '�',
  85107. 'Ñ¡' => 'Ñ ',
  85108. 'Ñ£' => 'Ñ¢',
  85109. 'ѥ' => 'Ѥ',
  85110. 'ѧ' => 'Ѧ',
  85111. 'ѩ' => 'Ѩ',
  85112. 'ѫ' => 'Ѫ',
  85113. 'ѭ' => 'Ѭ',
  85114. 'ѯ' => 'Ѯ',
  85115. 'ѱ' => 'Ѱ',
  85116. 'ѳ' => 'Ѳ',
  85117. 'ѵ' => 'Ѵ',
  85118. 'ѷ' => 'Ѷ',
  85119. 'ѹ' => 'Ѹ',
  85120. 'ѻ' => 'Ѻ',
  85121. 'ѽ' => 'Ѽ',
  85122. 'ѿ' => 'Ѿ',
  85123. 'Ò�' => 'Ò€',
  85124. 'Ò‹' => 'ÒŠ',
  85125. '�' => 'Ҍ',
  85126. 'Ò�' => 'ÒŽ',
  85127. 'Ò‘' => 'Ò�',
  85128. 'Ò“' => 'Ò’',
  85129. 'Ò•' => 'Ò”',
  85130. 'Ò—' => 'Ò–',
  85131. 'Ò™' => 'Ò˜',
  85132. 'Ò›' => 'Òš',
  85133. '�' => 'Ҝ',
  85134. 'ÒŸ' => 'Òž',
  85135. 'Ò¡' => 'Ò ',
  85136. 'Ò£' => 'Ò¢',
  85137. 'Ò¥' => 'Ò¤',
  85138. 'Ò§' => 'Ò¦',
  85139. 'Ò©' => 'Ò¨',
  85140. 'Ò«' => 'Òª',
  85141. 'Ò­' => 'Ò¬',
  85142. 'Ò¯' => 'Ò®',
  85143. 'Ò±' => 'Ò°',
  85144. 'Ò³' => 'Ò²',
  85145. 'Òµ' => 'Ò´',
  85146. 'Ò·' => 'Ò¶',
  85147. 'Ò¹' => 'Ò¸',
  85148. 'Ò»' => 'Òº',
  85149. 'Ò½' => 'Ò¼',
  85150. 'Ò¿' => 'Ò¾',
  85151. 'Ó‚' => 'Ó�',
  85152. 'Ó„' => 'Óƒ',
  85153. 'Ó†' => 'Ó…',
  85154. 'Óˆ' => 'Ó‡',
  85155. 'ÓŠ' => 'Ó‰',
  85156. 'ӌ' => 'Ӌ',
  85157. 'ÓŽ' => 'Ó�',
  85158. 'Ó�' => 'Ó€',
  85159. 'Ó‘' => 'Ó�',
  85160. 'Ó“' => 'Ó’',
  85161. 'Ó•' => 'Ó”',
  85162. 'Ó—' => 'Ó–',
  85163. 'Ó™' => 'Ó˜',
  85164. 'Ó›' => 'Óš',
  85165. '�' => 'Ӝ',
  85166. 'ÓŸ' => 'Óž',
  85167. 'Ó¡' => 'Ó ',
  85168. 'Ó£' => 'Ó¢',
  85169. 'Ó¥' => 'Ó¤',
  85170. 'Ó§' => 'Ó¦',
  85171. 'Ó©' => 'Ó¨',
  85172. 'Ó«' => 'Óª',
  85173. 'Ó­' => 'Ó¬',
  85174. 'Ó¯' => 'Ó®',
  85175. 'Ó±' => 'Ó°',
  85176. 'Ó³' => 'Ó²',
  85177. 'Óµ' => 'Ó´',
  85178. 'Ó·' => 'Ó¶',
  85179. 'Ó¹' => 'Ó¸',
  85180. 'Ó»' => 'Óº',
  85181. 'Ó½' => 'Ó¼',
  85182. 'Ó¿' => 'Ó¾',
  85183. 'Ô�' => 'Ô€',
  85184. 'Ôƒ' => 'Ô‚',
  85185. 'Ô…' => 'Ô„',
  85186. 'Ô‡' => 'Ô†',
  85187. 'Ô‰' => 'Ôˆ',
  85188. 'Ô‹' => 'ÔŠ',
  85189. '�' => 'Ԍ',
  85190. 'Ô�' => 'ÔŽ',
  85191. 'Ô‘' => 'Ô�',
  85192. 'Ô“' => 'Ô’',
  85193. 'Ô•' => 'Ô”',
  85194. 'Ô—' => 'Ô–',
  85195. 'Ô™' => 'Ô˜',
  85196. 'Ô›' => 'Ôš',
  85197. '�' => 'Ԝ',
  85198. 'ÔŸ' => 'Ôž',
  85199. 'Ô¡' => 'Ô ',
  85200. 'Ô£' => 'Ô¢',
  85201. 'Ô¥' => 'Ô¤',
  85202. 'Ô§' => 'Ô¦',
  85203. 'Ô©' => 'Ô¨',
  85204. 'Ô«' => 'Ôª',
  85205. 'Ô­' => 'Ô¬',
  85206. 'Ô¯' => 'Ô®',
  85207. 'Õ¡' => 'Ô±',
  85208. 'Õ¢' => 'Ô²',
  85209. 'Õ£' => 'Ô³',
  85210. 'Õ¤' => 'Ô´',
  85211. 'Õ¥' => 'Ôµ',
  85212. 'Õ¦' => 'Ô¶',
  85213. 'Õ§' => 'Ô·',
  85214. 'Õ¨' => 'Ô¸',
  85215. 'Õ©' => 'Ô¹',
  85216. 'Õª' => 'Ôº',
  85217. 'Õ«' => 'Ô»',
  85218. 'Õ¬' => 'Ô¼',
  85219. 'Õ­' => 'Ô½',
  85220. 'Õ®' => 'Ô¾',
  85221. 'Õ¯' => 'Ô¿',
  85222. 'Õ°' => 'Õ€',
  85223. 'Õ±' => 'Õ�',
  85224. 'Õ²' => 'Õ‚',
  85225. 'Õ³' => 'Õƒ',
  85226. 'Õ´' => 'Õ„',
  85227. 'Õµ' => 'Õ…',
  85228. 'Õ¶' => 'Õ†',
  85229. 'Õ·' => 'Õ‡',
  85230. 'Õ¸' => 'Õˆ',
  85231. 'Õ¹' => 'Õ‰',
  85232. 'Õº' => 'ÕŠ',
  85233. 'Õ»' => 'Õ‹',
  85234. 'ռ' => 'Ռ',
  85235. 'Õ½' => 'Õ�',
  85236. 'Õ¾' => 'ÕŽ',
  85237. 'Õ¿' => 'Õ�',
  85238. 'Ö€' => 'Õ�',
  85239. 'Ö�' => 'Õ‘',
  85240. 'Ö‚' => 'Õ’',
  85241. 'Öƒ' => 'Õ“',
  85242. 'Ö„' => 'Õ”',
  85243. 'Ö…' => 'Õ•',
  85244. 'Ö†' => 'Õ–',
  85245. '�' => '�',
  85246. 'ბ' => 'Ბ',
  85247. 'გ' => 'Გ',
  85248. 'დ' => 'Დ',
  85249. 'ე' => 'Ე',
  85250. 'ვ' => 'Ვ',
  85251. 'ზ' => 'Ზ',
  85252. 'თ' => 'Თ',
  85253. 'ი' => 'Ი',
  85254. 'კ' => 'Კ',
  85255. 'ლ' => 'Ლ',
  85256. 'მ' => 'Მ',
  85257. 'ნ' => 'Ნ',
  85258. '�' => '�',
  85259. 'პ' => 'Პ',
  85260. 'ჟ' => 'Ჟ',
  85261. 'რ' => 'Რ',
  85262. 'ს' => 'Ს',
  85263. 'ტ' => 'Ტ',
  85264. 'უ' => 'Უ',
  85265. 'ფ' => 'Ფ',
  85266. 'ქ' => 'Ქ',
  85267. 'ღ' => 'Ღ',
  85268. 'ყ' => 'Ყ',
  85269. 'შ' => 'Შ',
  85270. 'ჩ' => 'Ჩ',
  85271. 'ც' => 'Ც',
  85272. 'ძ' => 'Ძ',
  85273. 'წ' => 'Წ',
  85274. 'ჭ' => 'Ჭ',
  85275. 'ხ' => 'Ხ',
  85276. 'ჯ' => 'Ჯ',
  85277. 'ჰ' => 'Ჰ',
  85278. 'ჱ' => 'Ჱ',
  85279. 'ჲ' => 'Ჲ',
  85280. 'ჳ' => 'Ჳ',
  85281. 'ჴ' => 'Ჴ',
  85282. 'ჵ' => 'Ჵ',
  85283. 'ჶ' => 'Ჶ',
  85284. 'ჷ' => 'Ჷ',
  85285. 'ჸ' => 'Ჸ',
  85286. 'ჹ' => 'Ჹ',
  85287. 'ჺ' => 'Ჺ',
  85288. 'ჽ' => 'Ჽ',
  85289. 'ჾ' => 'Ჾ',
  85290. 'ჿ' => 'Ჿ',
  85291. '�' => '�',
  85292. '�' => '�',
  85293. '�' => '�',
  85294. '�' => '�',
  85295. '�' => '�',
  85296. '�' => '�',
  85297. 'á²€' => 'Ð’',
  85298. '�' => 'Д',
  85299. 'ᲂ' => 'О',
  85300. 'ᲃ' => 'С',
  85301. 'ᲄ' => 'Т',
  85302. 'ᲅ' => 'Т',
  85303. 'ᲆ' => 'Ъ',
  85304. 'ᲇ' => 'Ѣ',
  85305. 'ᲈ' => 'Ꙋ',
  85306. 'ᵹ' => '�',
  85307. 'áµ½' => 'â±£',
  85308. 'ᶎ' => 'Ᶎ',
  85309. '�' => 'Ḁ',
  85310. 'ḃ' => 'Ḃ',
  85311. 'ḅ' => 'Ḅ',
  85312. 'ḇ' => 'Ḇ',
  85313. 'ḉ' => 'Ḉ',
  85314. 'ḋ' => 'Ḋ',
  85315. '�' => 'Ḍ',
  85316. '�' => 'Ḏ',
  85317. 'ḑ' => '�',
  85318. 'ḓ' => 'Ḓ',
  85319. 'ḕ' => 'Ḕ',
  85320. 'ḗ' => 'Ḗ',
  85321. 'ḙ' => 'Ḙ',
  85322. 'ḛ' => 'Ḛ',
  85323. '�' => 'Ḝ',
  85324. 'ḟ' => 'Ḟ',
  85325. 'ḡ' => 'Ḡ',
  85326. 'ḣ' => 'Ḣ',
  85327. 'ḥ' => 'Ḥ',
  85328. 'ḧ' => 'Ḧ',
  85329. 'ḩ' => 'Ḩ',
  85330. 'ḫ' => 'Ḫ',
  85331. 'ḭ' => 'Ḭ',
  85332. 'ḯ' => 'Ḯ',
  85333. 'ḱ' => 'Ḱ',
  85334. 'ḳ' => 'Ḳ',
  85335. 'ḵ' => 'Ḵ',
  85336. 'ḷ' => 'Ḷ',
  85337. 'ḹ' => 'Ḹ',
  85338. 'ḻ' => 'Ḻ',
  85339. 'ḽ' => 'Ḽ',
  85340. 'ḿ' => 'Ḿ',
  85341. '�' => 'Ṁ',
  85342. 'ṃ' => 'Ṃ',
  85343. 'ṅ' => 'Ṅ',
  85344. 'ṇ' => 'Ṇ',
  85345. 'ṉ' => 'Ṉ',
  85346. 'ṋ' => 'Ṋ',
  85347. '�' => 'Ṍ',
  85348. '�' => 'Ṏ',
  85349. 'ṑ' => '�',
  85350. 'ṓ' => 'Ṓ',
  85351. 'ṕ' => 'Ṕ',
  85352. 'á¹—' => 'á¹–',
  85353. 'ṙ' => 'Ṙ',
  85354. 'ṛ' => 'Ṛ',
  85355. '�' => 'Ṝ',
  85356. 'ṟ' => 'Ṟ',
  85357. 'ṡ' => 'Ṡ',
  85358. 'á¹£' => 'á¹¢',
  85359. 'ṥ' => 'Ṥ',
  85360. 'ṧ' => 'Ṧ',
  85361. 'ṩ' => 'Ṩ',
  85362. 'ṫ' => 'Ṫ',
  85363. 'ṭ' => 'Ṭ',
  85364. 'ṯ' => 'Ṯ',
  85365. 'á¹±' => 'á¹°',
  85366. 'á¹³' => 'á¹²',
  85367. 'á¹µ' => 'á¹´',
  85368. 'á¹·' => 'á¹¶',
  85369. 'ṹ' => 'Ṹ',
  85370. 'ṻ' => 'Ṻ',
  85371. 'á¹½' => 'á¹¼',
  85372. 'ṿ' => 'Ṿ',
  85373. '�' => 'Ẁ',
  85374. 'ẃ' => 'Ẃ',
  85375. 'ẅ' => 'Ẅ',
  85376. 'ẇ' => 'Ẇ',
  85377. 'ẉ' => 'Ẉ',
  85378. 'ẋ' => 'Ẋ',
  85379. '�' => 'Ẍ',
  85380. '�' => 'Ẏ',
  85381. 'ẑ' => '�',
  85382. 'ẓ' => 'Ẓ',
  85383. 'ẕ' => 'Ẕ',
  85384. 'ẛ' => 'Ṡ',
  85385. 'ạ' => 'Ạ',
  85386. 'ả' => 'Ả',
  85387. 'ấ' => 'Ấ',
  85388. 'ầ' => 'Ầ',
  85389. 'ẩ' => 'Ẩ',
  85390. 'ẫ' => 'Ẫ',
  85391. 'ậ' => 'Ậ',
  85392. 'ắ' => 'Ắ',
  85393. 'ằ' => 'Ằ',
  85394. 'ẳ' => 'Ẳ',
  85395. 'ẵ' => 'Ẵ',
  85396. 'ặ' => 'Ặ',
  85397. 'ẹ' => 'Ẹ',
  85398. 'ẻ' => 'Ẻ',
  85399. 'ẽ' => 'Ẽ',
  85400. 'ế' => 'Ế',
  85401. '�' => 'Ề',
  85402. 'ể' => 'Ể',
  85403. 'ễ' => 'Ễ',
  85404. 'ệ' => 'Ệ',
  85405. 'ỉ' => 'Ỉ',
  85406. 'ị' => 'Ị',
  85407. '�' => 'Ọ',
  85408. '�' => 'Ỏ',
  85409. 'ố' => '�',
  85410. 'ồ' => 'Ồ',
  85411. 'ổ' => 'Ổ',
  85412. 'á»—' => 'á»–',
  85413. 'ộ' => 'Ộ',
  85414. 'ớ' => 'Ớ',
  85415. '�' => 'Ờ',
  85416. 'ở' => 'Ở',
  85417. 'ỡ' => 'Ỡ',
  85418. 'ợ' => 'Ợ',
  85419. 'ụ' => 'Ụ',
  85420. 'ủ' => 'Ủ',
  85421. 'ứ' => 'Ứ',
  85422. 'ừ' => 'Ừ',
  85423. 'ử' => 'Ử',
  85424. 'ữ' => 'Ữ',
  85425. 'á»±' => 'á»°',
  85426. 'ỳ' => 'Ỳ',
  85427. 'ỵ' => 'Ỵ',
  85428. 'á»·' => 'á»¶',
  85429. 'ỹ' => 'Ỹ',
  85430. 'ỻ' => 'Ỻ',
  85431. 'ỽ' => 'Ỽ',
  85432. 'ỿ' => 'Ỿ',
  85433. 'ἀ' => 'Ἀ',
  85434. '�' => 'Ἁ',
  85435. 'ἂ' => 'Ἂ',
  85436. 'ἃ' => 'Ἃ',
  85437. 'ἄ' => 'Ἄ',
  85438. 'ἅ' => '�',
  85439. 'ἆ' => 'Ἆ',
  85440. 'ἇ' => '�',
  85441. '�' => 'Ἐ',
  85442. 'ἑ' => 'Ἑ',
  85443. 'ἒ' => 'Ἒ',
  85444. 'ἓ' => 'Ἓ',
  85445. 'ἔ' => 'Ἔ',
  85446. 'ἕ' => '�',
  85447. 'ἠ' => 'Ἠ',
  85448. 'ἡ' => 'Ἡ',
  85449. 'ἢ' => 'Ἢ',
  85450. 'ἣ' => 'Ἣ',
  85451. 'ἤ' => 'Ἤ',
  85452. 'á¼¥' => 'á¼­',
  85453. 'ἦ' => 'Ἦ',
  85454. 'ἧ' => 'Ἧ',
  85455. 'ἰ' => 'Ἰ',
  85456. 'á¼±' => 'á¼¹',
  85457. 'ἲ' => 'Ἲ',
  85458. 'á¼³' => 'á¼»',
  85459. 'á¼´' => 'á¼¼',
  85460. 'á¼µ' => 'á¼½',
  85461. 'á¼¶' => 'á¼¾',
  85462. 'ἷ' => 'Ἷ',
  85463. 'ὀ' => 'Ὀ',
  85464. '�' => 'Ὁ',
  85465. 'ὂ' => 'Ὂ',
  85466. 'ὃ' => 'Ὃ',
  85467. 'ὄ' => 'Ὄ',
  85468. 'ὅ' => '�',
  85469. 'ὑ' => 'Ὑ',
  85470. 'ὓ' => 'Ὓ',
  85471. 'ὕ' => '�',
  85472. 'ὗ' => 'Ὗ',
  85473. 'ὠ' => 'Ὠ',
  85474. 'ὡ' => 'Ὡ',
  85475. 'ὢ' => 'Ὢ',
  85476. 'ὣ' => 'Ὣ',
  85477. 'ὤ' => 'Ὤ',
  85478. 'á½¥' => 'á½­',
  85479. 'ὦ' => 'Ὦ',
  85480. 'ὧ' => 'Ὧ',
  85481. 'ὰ' => 'Ὰ',
  85482. 'á½±' => 'á¾»',
  85483. 'ὲ' => 'Ὲ',
  85484. 'έ' => 'Έ',
  85485. 'ὴ' => 'Ὴ',
  85486. 'á½µ' => 'á¿‹',
  85487. 'ὶ' => 'Ὶ',
  85488. 'á½·' => 'á¿›',
  85489. 'ὸ' => 'Ὸ',
  85490. 'ό' => 'Ό',
  85491. 'ὺ' => 'Ὺ',
  85492. 'á½»' => 'á¿«',
  85493. 'ὼ' => 'Ὼ',
  85494. 'á½½' => 'á¿»',
  85495. 'ᾀ' => 'ἈΙ',
  85496. '�' => 'ἉΙ',
  85497. 'ᾂ' => 'ἊΙ',
  85498. 'ᾃ' => 'ἋΙ',
  85499. 'ᾄ' => 'ἌΙ',
  85500. 'ᾅ' => '�Ι',
  85501. 'ᾆ' => 'ἎΙ',
  85502. 'ᾇ' => '�Ι',
  85503. '�' => 'ἨΙ',
  85504. 'ᾑ' => 'ἩΙ',
  85505. 'ᾒ' => 'ἪΙ',
  85506. 'ᾓ' => 'ἫΙ',
  85507. 'ᾔ' => 'ἬΙ',
  85508. 'ᾕ' => 'ἭΙ',
  85509. 'ᾖ' => 'ἮΙ',
  85510. 'ᾗ' => 'ἯΙ',
  85511. 'ᾠ' => 'ὨΙ',
  85512. 'ᾡ' => 'ὩΙ',
  85513. 'ᾢ' => 'ὪΙ',
  85514. 'ᾣ' => 'ὫΙ',
  85515. 'ᾤ' => 'ὬΙ',
  85516. 'ᾥ' => 'ὭΙ',
  85517. 'ᾦ' => 'ὮΙ',
  85518. 'ᾧ' => 'ὯΙ',
  85519. 'ᾰ' => 'Ᾰ',
  85520. 'á¾±' => 'á¾¹',
  85521. 'ᾳ' => 'ΑΙ',
  85522. 'ι' => 'Ι',
  85523. 'ῃ' => 'ΗΙ',
  85524. '�' => 'Ῐ',
  85525. 'á¿‘' => 'á¿™',
  85526. 'ῠ' => 'Ῠ',
  85527. 'á¿¡' => 'á¿©',
  85528. 'ῥ' => 'Ῥ',
  85529. 'ῳ' => 'ΩΙ',
  85530. 'ⅎ' => 'Ⅎ',
  85531. 'â…°' => 'â… ',
  85532. 'â…±' => 'â…¡',
  85533. 'â…²' => 'â…¢',
  85534. 'â…³' => 'â…£',
  85535. 'â…´' => 'â…¤',
  85536. 'â…µ' => 'â…¥',
  85537. 'â…¶' => 'â…¦',
  85538. 'â…·' => 'â…§',
  85539. 'â…¸' => 'â…¨',
  85540. 'â…¹' => 'â…©',
  85541. 'â…º' => 'â…ª',
  85542. 'â…»' => 'â…«',
  85543. 'â…¼' => 'â…¬',
  85544. 'â…½' => 'â…­',
  85545. 'â…¾' => 'â…®',
  85546. 'â…¿' => 'â…¯',
  85547. 'ↄ' => 'Ↄ',
  85548. '�' => 'Ⓐ',
  85549. 'â“‘' => 'â’·',
  85550. 'â“’' => 'â’¸',
  85551. 'â““' => 'â’¹',
  85552. 'â“”' => 'â’º',
  85553. 'â“•' => 'â’»',
  85554. 'â“–' => 'â’¼',
  85555. 'â“—' => 'â’½',
  85556. 'ⓘ' => 'Ⓘ',
  85557. 'â“™' => 'â’¿',
  85558. 'ⓚ' => 'Ⓚ',
  85559. 'ⓛ' => '�',
  85560. 'ⓜ' => 'Ⓜ',
  85561. '�' => 'Ⓝ',
  85562. 'ⓞ' => 'Ⓞ',
  85563. 'ⓟ' => 'Ⓟ',
  85564. 'ⓠ' => 'Ⓠ',
  85565. 'ⓡ' => 'Ⓡ',
  85566. 'ⓢ' => 'Ⓢ',
  85567. 'ⓣ' => 'Ⓣ',
  85568. 'ⓤ' => 'Ⓤ',
  85569. 'â“¥' => 'â“‹',
  85570. 'ⓦ' => 'Ⓦ',
  85571. 'ⓧ' => '�',
  85572. 'ⓨ' => 'Ⓨ',
  85573. 'ⓩ' => '�',
  85574. 'â°°' => 'â°€',
  85575. 'â°±' => 'â°�',
  85576. 'â°²' => 'â°‚',
  85577. 'â°³' => 'â°ƒ',
  85578. 'â°´' => 'â°„',
  85579. 'â°µ' => 'â°…',
  85580. 'â°¶' => 'â°†',
  85581. 'â°·' => 'â°‡',
  85582. 'â°¸' => 'â°ˆ',
  85583. 'â°¹' => 'â°‰',
  85584. 'â°º' => 'â°Š',
  85585. 'â°»' => 'â°‹',
  85586. 'ⰼ' => 'Ⰼ',
  85587. 'â°½' => 'â°�',
  85588. 'â°¾' => 'â°Ž',
  85589. 'â°¿' => 'â°�',
  85590. 'â±€' => 'â°�',
  85591. '�' => 'Ⱁ',
  85592. 'ⱂ' => 'Ⱂ',
  85593. 'ⱃ' => 'Ⱃ',
  85594. 'ⱄ' => 'Ⱄ',
  85595. 'â±…' => 'â°•',
  85596. 'ⱆ' => 'Ⱆ',
  85597. 'ⱇ' => 'Ⱇ',
  85598. 'ⱈ' => 'Ⱈ',
  85599. 'ⱉ' => 'Ⱉ',
  85600. 'ⱊ' => 'Ⱊ',
  85601. 'ⱋ' => 'Ⱋ',
  85602. 'ⱌ' => 'Ⱌ',
  85603. '�' => '�',
  85604. 'ⱎ' => 'Ⱎ',
  85605. '�' => 'Ⱏ',
  85606. '�' => 'Ⱐ',
  85607. 'ⱑ' => 'Ⱑ',
  85608. 'â±’' => 'â°¢',
  85609. 'ⱓ' => 'Ⱓ',
  85610. 'â±”' => 'â°¤',
  85611. 'ⱕ' => 'Ⱕ',
  85612. 'â±–' => 'â°¦',
  85613. 'â±—' => 'â°§',
  85614. 'ⱘ' => 'Ⱘ',
  85615. 'â±™' => 'â°©',
  85616. 'ⱚ' => 'Ⱚ',
  85617. 'â±›' => 'â°«',
  85618. 'ⱜ' => 'Ⱜ',
  85619. '�' => 'Ⱝ',
  85620. 'ⱞ' => 'Ⱞ',
  85621. 'ⱡ' => 'Ⱡ',
  85622. 'ⱥ' => 'Ⱥ',
  85623. 'ⱦ' => 'Ⱦ',
  85624. 'ⱨ' => 'Ⱨ',
  85625. 'ⱪ' => 'Ⱪ',
  85626. 'ⱬ' => 'Ⱬ',
  85627. 'â±³' => 'â±²',
  85628. 'â±¶' => 'â±µ',
  85629. '�' => 'Ⲁ',
  85630. 'ⲃ' => 'Ⲃ',
  85631. 'ⲅ' => 'Ⲅ',
  85632. 'ⲇ' => 'Ⲇ',
  85633. 'ⲉ' => 'Ⲉ',
  85634. 'ⲋ' => 'Ⲋ',
  85635. '�' => 'Ⲍ',
  85636. '�' => 'Ⲏ',
  85637. 'ⲑ' => '�',
  85638. 'ⲓ' => 'Ⲓ',
  85639. 'ⲕ' => 'Ⲕ',
  85640. 'â²—' => 'â²–',
  85641. 'ⲙ' => 'Ⲙ',
  85642. 'ⲛ' => 'Ⲛ',
  85643. '�' => 'Ⲝ',
  85644. 'ⲟ' => 'Ⲟ',
  85645. 'ⲡ' => 'Ⲡ',
  85646. 'â²£' => 'â²¢',
  85647. 'ⲥ' => 'Ⲥ',
  85648. 'ⲧ' => 'Ⲧ',
  85649. 'ⲩ' => 'Ⲩ',
  85650. 'ⲫ' => 'Ⲫ',
  85651. 'ⲭ' => 'Ⲭ',
  85652. 'ⲯ' => 'Ⲯ',
  85653. 'â²±' => 'â²°',
  85654. 'â²³' => 'â²²',
  85655. 'â²µ' => 'â²´',
  85656. 'â²·' => 'â²¶',
  85657. 'ⲹ' => 'Ⲹ',
  85658. 'ⲻ' => 'Ⲻ',
  85659. 'â²½' => 'â²¼',
  85660. 'ⲿ' => 'Ⲿ',
  85661. '�' => 'Ⳁ',
  85662. 'ⳃ' => 'Ⳃ',
  85663. 'ⳅ' => 'Ⳅ',
  85664. 'ⳇ' => 'Ⳇ',
  85665. 'ⳉ' => 'Ⳉ',
  85666. 'ⳋ' => 'Ⳋ',
  85667. '�' => 'Ⳍ',
  85668. '�' => 'Ⳏ',
  85669. 'ⳑ' => '�',
  85670. 'ⳓ' => 'Ⳓ',
  85671. 'ⳕ' => 'Ⳕ',
  85672. 'â³—' => 'â³–',
  85673. 'ⳙ' => 'Ⳙ',
  85674. 'ⳛ' => 'Ⳛ',
  85675. '�' => 'Ⳝ',
  85676. 'ⳟ' => 'Ⳟ',
  85677. 'ⳡ' => 'Ⳡ',
  85678. 'â³£' => 'â³¢',
  85679. 'ⳬ' => 'Ⳬ',
  85680. 'â³®' => 'â³­',
  85681. 'â³³' => 'â³²',
  85682. 'â´€' => 'á‚ ',
  85683. 'â´�' => 'á‚¡',
  85684. 'â´‚' => 'á‚¢',
  85685. 'â´ƒ' => 'á‚£',
  85686. 'ⴄ' => 'Ⴄ',
  85687. 'â´…' => 'á‚¥',
  85688. 'ⴆ' => 'Ⴆ',
  85689. 'â´‡' => 'á‚§',
  85690. 'ⴈ' => 'Ⴈ',
  85691. 'â´‰' => 'á‚©',
  85692. 'ⴊ' => 'Ⴊ',
  85693. 'â´‹' => 'á‚«',
  85694. 'ⴌ' => 'Ⴌ',
  85695. 'â´�' => 'á‚­',
  85696. 'â´Ž' => 'á‚®',
  85697. '�' => 'Ⴏ',
  85698. 'â´�' => 'á‚°',
  85699. 'ⴑ' => 'Ⴑ',
  85700. 'ⴒ' => 'Ⴒ',
  85701. 'ⴓ' => 'Ⴓ',
  85702. 'â´”' => 'á‚´',
  85703. 'ⴕ' => 'Ⴕ',
  85704. 'â´–' => 'á‚¶',
  85705. 'â´—' => 'á‚·',
  85706. 'ⴘ' => 'Ⴘ',
  85707. 'ⴙ' => 'Ⴙ',
  85708. 'ⴚ' => 'Ⴚ',
  85709. 'â´›' => 'á‚»',
  85710. 'ⴜ' => 'Ⴜ',
  85711. '�' => 'Ⴝ',
  85712. 'ⴞ' => 'Ⴞ',
  85713. 'â´Ÿ' => 'á‚¿',
  85714. 'ⴠ' => 'Ⴠ',
  85715. 'ⴡ' => '�',
  85716. 'ⴢ' => 'Ⴢ',
  85717. 'ⴣ' => 'Ⴣ',
  85718. 'ⴤ' => 'Ⴤ',
  85719. 'ⴥ' => 'Ⴥ',
  85720. 'ⴧ' => 'Ⴧ',
  85721. 'ⴭ' => '�',
  85722. '�' => 'Ꙁ',
  85723. 'ꙃ' => 'Ꙃ',
  85724. 'ꙅ' => 'Ꙅ',
  85725. 'ꙇ' => 'Ꙇ',
  85726. 'ꙉ' => 'Ꙉ',
  85727. 'ꙋ' => 'Ꙋ',
  85728. '�' => 'Ꙍ',
  85729. '�' => 'Ꙏ',
  85730. 'ꙑ' => '�',
  85731. 'ꙓ' => 'Ꙓ',
  85732. 'ꙕ' => 'Ꙕ',
  85733. 'ê™—' => 'ê™–',
  85734. 'ꙙ' => 'Ꙙ',
  85735. 'ꙛ' => 'Ꙛ',
  85736. '�' => 'Ꙝ',
  85737. 'ꙟ' => 'Ꙟ',
  85738. 'ꙡ' => 'Ꙡ',
  85739. 'ꙣ' => 'Ꙣ',
  85740. 'ꙥ' => 'Ꙥ',
  85741. 'ꙧ' => 'Ꙧ',
  85742. 'ꙩ' => 'Ꙩ',
  85743. 'ꙫ' => 'Ꙫ',
  85744. 'ꙭ' => 'Ꙭ',
  85745. '�' => 'Ꚁ',
  85746. 'ꚃ' => 'Ꚃ',
  85747. 'êš…' => 'êš„',
  85748. 'ꚇ' => 'Ꚇ',
  85749. 'ꚉ' => 'Ꚉ',
  85750. 'ꚋ' => 'Ꚋ',
  85751. '�' => 'Ꚍ',
  85752. '�' => 'Ꚏ',
  85753. 'ꚑ' => '�',
  85754. 'êš“' => 'êš’',
  85755. 'êš•' => 'êš”',
  85756. 'êš—' => 'êš–',
  85757. 'ꚙ' => 'Ꚙ',
  85758. 'êš›' => 'êšš',
  85759. 'ꜣ' => 'Ꜣ',
  85760. 'ꜥ' => 'Ꜥ',
  85761. 'ꜧ' => 'Ꜧ',
  85762. 'ꜩ' => 'Ꜩ',
  85763. 'ꜫ' => 'Ꜫ',
  85764. 'ꜭ' => 'Ꜭ',
  85765. 'ꜯ' => 'Ꜯ',
  85766. 'ꜳ' => 'Ꜳ',
  85767. 'ꜵ' => 'Ꜵ',
  85768. 'ꜷ' => 'Ꜷ',
  85769. 'ꜹ' => 'Ꜹ',
  85770. 'ꜻ' => 'Ꜻ',
  85771. 'ꜽ' => 'Ꜽ',
  85772. 'ꜿ' => 'Ꜿ',
  85773. '�' => '�',
  85774. '�' => '�',
  85775. '�' => '�',
  85776. '�' => '�',
  85777. '�' => '�',
  85778. '�' => '�',
  85779. '�' => '�',
  85780. '�' => '�',
  85781. '�' => '�',
  85782. '�' => '�',
  85783. '�' => '�',
  85784. '�' => '�',
  85785. '�' => '�',
  85786. '�' => '�',
  85787. '�' => '�',
  85788. '�' => '�',
  85789. '�' => '�',
  85790. '�' => '�',
  85791. '�' => '�',
  85792. '�' => '�',
  85793. '�' => '�',
  85794. '�' => '�',
  85795. '�' => '�',
  85796. '�' => '�',
  85797. '�' => '�',
  85798. '�' => '�',
  85799. '�' => '�',
  85800. '�' => 'Ꞁ',
  85801. 'ꞃ' => 'Ꞃ',
  85802. 'êž…' => 'êž„',
  85803. 'ꞇ' => 'Ꞇ',
  85804. 'ꞌ' => 'Ꞌ',
  85805. 'ꞑ' => '�',
  85806. 'êž“' => 'êž’',
  85807. 'ꞔ' => 'Ꞔ',
  85808. 'êž—' => 'êž–',
  85809. 'ꞙ' => 'Ꞙ',
  85810. 'êž›' => 'êžš',
  85811. '�' => 'Ꞝ',
  85812. 'ꞟ' => 'Ꞟ',
  85813. 'êž¡' => 'êž ',
  85814. 'ꞣ' => 'Ꞣ',
  85815. 'ꞥ' => 'Ꞥ',
  85816. 'ꞧ' => 'Ꞧ',
  85817. 'ꞩ' => 'Ꞩ',
  85818. 'êžµ' => 'êž´',
  85819. 'êž·' => 'êž¶',
  85820. 'ꞹ' => 'Ꞹ',
  85821. 'ꞻ' => 'Ꞻ',
  85822. 'êž½' => 'êž¼',
  85823. 'êž¿' => 'êž¾',
  85824. 'ꟃ' => 'Ꟃ',
  85825. 'ꟈ' => 'Ꟈ',
  85826. 'ꟊ' => 'Ꟊ',
  85827. 'ꟶ' => 'Ꟶ',
  85828. 'ê­“' => 'êž³',
  85829. 'ꭰ' => 'Ꭰ',
  85830. 'ꭱ' => 'Ꭱ',
  85831. 'ꭲ' => 'Ꭲ',
  85832. 'ꭳ' => 'Ꭳ',
  85833. 'ꭴ' => 'Ꭴ',
  85834. 'ꭵ' => 'Ꭵ',
  85835. 'ꭶ' => 'Ꭶ',
  85836. 'ꭷ' => 'Ꭷ',
  85837. 'ꭸ' => 'Ꭸ',
  85838. 'ꭹ' => 'Ꭹ',
  85839. 'ꭺ' => 'Ꭺ',
  85840. 'ꭻ' => 'Ꭻ',
  85841. 'ꭼ' => 'Ꭼ',
  85842. 'ꭽ' => 'Ꭽ',
  85843. 'ꭾ' => 'Ꭾ',
  85844. 'ꭿ' => 'Ꭿ',
  85845. 'ꮀ' => 'Ꮀ',
  85846. '�' => 'Ꮁ',
  85847. 'ꮂ' => 'Ꮂ',
  85848. 'ꮃ' => 'Ꮃ',
  85849. 'ꮄ' => 'Ꮄ',
  85850. 'ꮅ' => 'Ꮅ',
  85851. 'ꮆ' => 'Ꮆ',
  85852. 'ꮇ' => 'Ꮇ',
  85853. 'ꮈ' => 'Ꮈ',
  85854. 'ꮉ' => 'Ꮉ',
  85855. 'ꮊ' => 'Ꮊ',
  85856. 'ꮋ' => 'Ꮋ',
  85857. 'ꮌ' => 'Ꮌ',
  85858. '�' => 'Ꮍ',
  85859. 'ꮎ' => 'Ꮎ',
  85860. '�' => 'Ꮏ',
  85861. '�' => '�',
  85862. 'ꮑ' => '�',
  85863. 'ꮒ' => '�',
  85864. 'ꮓ' => '�',
  85865. 'ꮔ' => '�',
  85866. 'ꮕ' => '�',
  85867. 'ꮖ' => '�',
  85868. 'ꮗ' => '�',
  85869. 'ꮘ' => '�',
  85870. 'ꮙ' => '�',
  85871. 'ꮚ' => '�',
  85872. 'ꮛ' => '�',
  85873. 'ꮜ' => '�',
  85874. '�' => '�',
  85875. 'ꮞ' => '�',
  85876. 'ꮟ' => '�',
  85877. 'ꮠ' => '�',
  85878. 'ꮡ' => '�',
  85879. 'ꮢ' => '�',
  85880. 'ꮣ' => '�',
  85881. 'ꮤ' => '�',
  85882. 'ꮥ' => '�',
  85883. 'ꮦ' => '�',
  85884. 'ꮧ' => '�',
  85885. 'ꮨ' => '�',
  85886. 'ꮩ' => '�',
  85887. 'ꮪ' => '�',
  85888. 'ꮫ' => '�',
  85889. 'ꮬ' => '�',
  85890. 'ꮭ' => '�',
  85891. 'ꮮ' => '�',
  85892. 'ꮯ' => '�',
  85893. 'ꮰ' => '�',
  85894. 'ꮱ' => '�',
  85895. 'ꮲ' => '�',
  85896. 'ꮳ' => '�',
  85897. 'ꮴ' => '�',
  85898. 'ꮵ' => '�',
  85899. 'ꮶ' => '�',
  85900. 'ꮷ' => '�',
  85901. 'ꮸ' => '�',
  85902. 'ꮹ' => '�',
  85903. 'ꮺ' => '�',
  85904. 'ꮻ' => '�',
  85905. 'ꮼ' => '�',
  85906. 'ꮽ' => '�',
  85907. 'ꮾ' => '�',
  85908. 'ꮿ' => '�',
  85909. '�' => 'A',
  85910. 'b' => 'B',
  85911. 'c' => 'C',
  85912. 'd' => 'D',
  85913. 'ï½…' => 'ï¼¥',
  85914. 'f' => 'F',
  85915. 'g' => 'G',
  85916. 'h' => 'H',
  85917. 'i' => 'I',
  85918. 'j' => 'J',
  85919. 'k' => 'K',
  85920. 'l' => 'L',
  85921. '�' => 'M',
  85922. 'n' => 'N',
  85923. '�' => 'O',
  85924. '�' => 'P',
  85925. 'q' => 'Q',
  85926. 'ï½’' => 'ï¼²',
  85927. 's' => 'S',
  85928. 'ï½”' => 'ï¼´',
  85929. 'u' => 'U',
  85930. 'ï½–' => 'ï¼¶',
  85931. 'ï½—' => 'ï¼·',
  85932. 'x' => 'X',
  85933. 'ï½™' => 'ï¼¹',
  85934. 'z' => 'Z',
  85935. '�' => '�',
  85936. '�' => '�',
  85937. '�' => '�',
  85938. '�' => '�',
  85939. '�' => '�',
  85940. '�' => '�',
  85941. '�' => '�',
  85942. '�' => '�',
  85943. '�' => '�',
  85944. '�' => '�',
  85945. '�' => '�',
  85946. '�' => '�',
  85947. '�' => '�',
  85948. '�' => '�',
  85949. '�' => '�',
  85950. '�' => '�',
  85951. '�' => '�',
  85952. '�' => '�',
  85953. '�' => '�',
  85954. '�' => '�',
  85955. '�' => '�',
  85956. '�' => '�',
  85957. '�' => '�',
  85958. '�' => '�',
  85959. '�' => '�',
  85960. '�' => '�',
  85961. '�' => '�',
  85962. '�' => '�',
  85963. '�' => '�',
  85964. '�' => '�',
  85965. '�' => '�',
  85966. '�' => '�',
  85967. '�' => '�',
  85968. '�' => '�',
  85969. '�' => '�',
  85970. '�' => '�',
  85971. '�' => '�',
  85972. '�' => '�',
  85973. '�' => '�',
  85974. '�' => '�',
  85975. '�' => '�',
  85976. '�' => '�',
  85977. '�' => '�',
  85978. '�' => '�',
  85979. '�' => '�',
  85980. '�' => '�',
  85981. '�' => '�',
  85982. '�' => '�',
  85983. '�' => '�',
  85984. '�' => '�',
  85985. '�' => '�',
  85986. '�' => '�',
  85987. '�' => '�',
  85988. '�' => '�',
  85989. '�' => '�',
  85990. '�' => '�',
  85991. '�' => '�',
  85992. '�' => '�',
  85993. '�' => '�',
  85994. '�' => '�',
  85995. '�' => '�',
  85996. '�' => '�',
  85997. '�' => '�',
  85998. '�' => '�',
  85999. '�' => '�',
  86000. '�' => '�',
  86001. '�' => '�',
  86002. '�' => '�',
  86003. '�' => '�',
  86004. '�' => '�',
  86005. '�' => '�',
  86006. '�' => '�',
  86007. '�' => '�',
  86008. '�' => '�',
  86009. '�' => '�',
  86010. '�' => '�',
  86011. '�' => '�',
  86012. '�' => '�',
  86013. '�' => '�',
  86014. '�' => '�',
  86015. '�' => '�',
  86016. '�' => '�',
  86017. '�' => '�',
  86018. '�' => '�',
  86019. '�' => '�',
  86020. '�' => '�',
  86021. '�' => '�',
  86022. '�' => '�',
  86023. '�' => '�',
  86024. '�' => '�',
  86025. '�' => '�',
  86026. '�' => '�',
  86027. '�' => '�',
  86028. '�' => '�',
  86029. '�' => '�',
  86030. '�' => '�',
  86031. '�' => '�',
  86032. '�' => '�',
  86033. '�' => '�',
  86034. '�' => '�',
  86035. '�' => '�',
  86036. '�' => '�',
  86037. '�' => '�',
  86038. '�' => '�',
  86039. '�' => '�',
  86040. '�' => '�',
  86041. '�' => '�',
  86042. '�' => '�',
  86043. '�' => '�',
  86044. '�' => '�',
  86045. '�' => '�',
  86046. '�' => '�',
  86047. '�' => '�',
  86048. '�' => '�',
  86049. '�' => '�',
  86050. '�' => '�',
  86051. '�' => '�',
  86052. '�' => '�',
  86053. '�' => '�',
  86054. '�' => '�',
  86055. '�' => '�',
  86056. '�' => '�',
  86057. '�' => '�',
  86058. '�' => '�',
  86059. '�' => '�',
  86060. '�' => '�',
  86061. '�' => '�',
  86062. 'ð‘£€' => 'ð‘¢ ',
  86063. '�' => '𑢡',
  86064. '𑣂' => '𑢢',
  86065. '𑣃' => '𑢣',
  86066. '𑣄' => '𑢤',
  86067. 'ð‘£…' => 'ð‘¢¥',
  86068. '𑣆' => '𑢦',
  86069. '𑣇' => '𑢧',
  86070. '𑣈' => '𑢨',
  86071. '𑣉' => '𑢩',
  86072. '𑣊' => '𑢪',
  86073. '𑣋' => '𑢫',
  86074. '𑣌' => '𑢬',
  86075. '�' => '𑢭',
  86076. '𑣎' => '𑢮',
  86077. '�' => '𑢯',
  86078. '�' => '𑢰',
  86079. '𑣑' => '𑢱',
  86080. 'ð‘£’' => 'ð‘¢²',
  86081. '𑣓' => '𑢳',
  86082. 'ð‘£”' => 'ð‘¢´',
  86083. '𑣕' => '𑢵',
  86084. 'ð‘£–' => 'ð‘¢¶',
  86085. 'ð‘£—' => 'ð‘¢·',
  86086. '𑣘' => '𑢸',
  86087. 'ð‘£™' => 'ð‘¢¹',
  86088. '𑣚' => '𑢺',
  86089. 'ð‘£›' => 'ð‘¢»',
  86090. '𑣜' => '𑢼',
  86091. '�' => '𑢽',
  86092. '𑣞' => '𑢾',
  86093. '𑣟' => '𑢿',
  86094. 'ð–¹ ' => 'ð–¹€',
  86095. '𖹡' => '�',
  86096. '𖹢' => '𖹂',
  86097. '𖹣' => '𖹃',
  86098. '𖹤' => '𖹄',
  86099. 'ð–¹¥' => 'ð–¹…',
  86100. '𖹦' => '𖹆',
  86101. '𖹧' => '𖹇',
  86102. '𖹨' => '𖹈',
  86103. '𖹩' => '𖹉',
  86104. '𖹪' => '𖹊',
  86105. '𖹫' => '𖹋',
  86106. '𖹬' => '𖹌',
  86107. '𖹭' => '�',
  86108. '𖹮' => '𖹎',
  86109. '𖹯' => '�',
  86110. '𖹰' => '�',
  86111. '𖹱' => '𖹑',
  86112. 'ð–¹²' => 'ð–¹’',
  86113. '𖹳' => '𖹓',
  86114. 'ð–¹´' => 'ð–¹”',
  86115. '𖹵' => '𖹕',
  86116. 'ð–¹¶' => 'ð–¹–',
  86117. 'ð–¹·' => 'ð–¹—',
  86118. '𖹸' => '𖹘',
  86119. 'ð–¹¹' => 'ð–¹™',
  86120. '𖹺' => '𖹚',
  86121. 'ð–¹»' => 'ð–¹›',
  86122. '𖹼' => '𖹜',
  86123. '𖹽' => '�',
  86124. '𖹾' => '𖹞',
  86125. '𖹿' => '𖹟',
  86126. '𞤢' => '𞤀',
  86127. '𞤣' => '�',
  86128. '𞤤' => '𞤂',
  86129. '𞤥' => '𞤃',
  86130. '𞤦' => '𞤄',
  86131. '𞤧' => '𞤅',
  86132. '𞤨' => '𞤆',
  86133. '𞤩' => '𞤇',
  86134. '𞤪' => '𞤈',
  86135. '𞤫' => '𞤉',
  86136. '𞤬' => '𞤊',
  86137. '𞤭' => '𞤋',
  86138. '𞤮' => '𞤌',
  86139. '𞤯' => '�',
  86140. '𞤰' => '𞤎',
  86141. '𞤱' => '�',
  86142. '𞤲' => '�',
  86143. '𞤳' => '𞤑',
  86144. '𞤴' => '𞤒',
  86145. '𞤵' => '𞤓',
  86146. '𞤶' => '𞤔',
  86147. '𞤷' => '𞤕',
  86148. '𞤸' => '𞤖',
  86149. '𞤹' => '𞤗',
  86150. '𞤺' => '𞤘',
  86151. '𞤻' => '𞤙',
  86152. '𞤼' => '𞤚',
  86153. '𞤽' => '𞤛',
  86154. '𞤾' => '𞤜',
  86155. '𞤿' => '�',
  86156. '𞥀' => '𞤞',
  86157. '�' => '𞤟',
  86158. '𞥂' => '𞤠',
  86159. '𞥃' => '𞤡',
  86160. 'ß' => 'SS',
  86161. 'ff' => 'FF',
  86162. '�' => 'FI',
  86163. 'fl' => 'FL',
  86164. 'ffi' => 'FFI',
  86165. 'ffl' => 'FFL',
  86166. 'ſt' => 'ST',
  86167. 'st' => 'ST',
  86168. 'Ö‡' => 'ÔµÕ’',
  86169. 'ﬓ' => 'ՄՆ',
  86170. 'ﬔ' => 'ՄԵ',
  86171. 'ﬕ' => 'ՄԻ',
  86172. 'ﬖ' => 'ՎՆ',
  86173. 'ﬗ' => 'ՄԽ',
  86174. 'ʼn' => 'ʼN',
  86175. '�' => 'Ϊ�',
  86176. 'ΰ' => 'Ϋ�',
  86177. 'ǰ' => 'J̌',
  86178. 'ẖ' => 'H̱',
  86179. 'ẗ' => 'T̈',
  86180. 'ẘ' => 'W̊',
  86181. 'ẙ' => 'Y̊',
  86182. 'ẚ' => 'Aʾ',
  86183. '�' => 'Υ̓',
  86184. 'ὒ' => 'Υ̓̀',
  86185. 'ὔ' => 'Υ̓�',
  86186. 'ὖ' => 'Υ̓͂',
  86187. 'ᾶ' => 'Α͂',
  86188. 'ῆ' => 'Η͂',
  86189. 'ῒ' => 'Ϊ̀',
  86190. 'ΐ' => 'Ϊ�',
  86191. 'ῖ' => 'Ι͂',
  86192. 'ῗ' => 'Ϊ͂',
  86193. 'ῢ' => 'Ϋ̀',
  86194. 'ΰ' => 'Ϋ�',
  86195. 'ῤ' => 'Ρ̓',
  86196. 'ῦ' => 'Υ͂',
  86197. 'ῧ' => 'Ϋ͂',
  86198. 'ῶ' => 'Ω͂',
  86199. 'ᾈ' => 'ἈΙ',
  86200. 'ᾉ' => 'ἉΙ',
  86201. 'ᾊ' => 'ἊΙ',
  86202. 'ᾋ' => 'ἋΙ',
  86203. 'ᾌ' => 'ἌΙ',
  86204. '�' => '�Ι',
  86205. 'ᾎ' => 'ἎΙ',
  86206. '�' => '�Ι',
  86207. 'ᾘ' => 'ἨΙ',
  86208. 'ᾙ' => 'ἩΙ',
  86209. 'ᾚ' => 'ἪΙ',
  86210. 'ᾛ' => 'ἫΙ',
  86211. 'ᾜ' => 'ἬΙ',
  86212. '�' => 'ἭΙ',
  86213. 'ᾞ' => 'ἮΙ',
  86214. 'ᾟ' => 'ἯΙ',
  86215. 'ᾨ' => 'ὨΙ',
  86216. 'ᾩ' => 'ὩΙ',
  86217. 'ᾪ' => 'ὪΙ',
  86218. 'ᾫ' => 'ὫΙ',
  86219. 'ᾬ' => 'ὬΙ',
  86220. 'ᾭ' => 'ὭΙ',
  86221. 'ᾮ' => 'ὮΙ',
  86222. 'ᾯ' => 'ὯΙ',
  86223. 'ᾼ' => 'ΑΙ',
  86224. 'ῌ' => 'ΗΙ',
  86225. 'ῼ' => 'ΩΙ',
  86226. 'ᾲ' => 'ᾺΙ',
  86227. 'ᾴ' => 'ΆΙ',
  86228. 'ῂ' => 'ῊΙ',
  86229. 'ῄ' => 'ΉΙ',
  86230. 'ῲ' => 'ῺΙ',
  86231. 'ῴ' => '�Ι',
  86232. 'ᾷ' => 'Α͂Ι',
  86233. 'ῇ' => 'Η͂Ι',
  86234. 'ῷ' => 'Ω͂Ι',
  86235. );
  86236. <?php
  86237. use Symfony\Polyfill\Mbstring as p;
  86238. if (\PHP_VERSION_ID >= 80000) {
  86239. return require __DIR__.'/bootstrap80.php';
  86240. }
  86241. if (!function_exists('mb_convert_encoding')) {
  86242. function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
  86243. }
  86244. if (!function_exists('mb_decode_mimeheader')) {
  86245. function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
  86246. }
  86247. if (!function_exists('mb_encode_mimeheader')) {
  86248. 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); }
  86249. }
  86250. if (!function_exists('mb_decode_numericentity')) {
  86251. function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
  86252. }
  86253. if (!function_exists('mb_encode_numericentity')) {
  86254. function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); }
  86255. }
  86256. if (!function_exists('mb_convert_case')) {
  86257. function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); }
  86258. }
  86259. if (!function_exists('mb_internal_encoding')) {
  86260. function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); }
  86261. }
  86262. if (!function_exists('mb_language')) {
  86263. function mb_language($language = null) { return p\Mbstring::mb_language($language); }
  86264. }
  86265. if (!function_exists('mb_list_encodings')) {
  86266. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  86267. }
  86268. if (!function_exists('mb_encoding_aliases')) {
  86269. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  86270. }
  86271. if (!function_exists('mb_check_encoding')) {
  86272. function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); }
  86273. }
  86274. if (!function_exists('mb_detect_encoding')) {
  86275. function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); }
  86276. }
  86277. if (!function_exists('mb_detect_order')) {
  86278. function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
  86279. }
  86280. if (!function_exists('mb_parse_str')) {
  86281. function mb_parse_str($string, &$result = []) { parse_str($string, $result); return (bool) $result; }
  86282. }
  86283. if (!function_exists('mb_strlen')) {
  86284. function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
  86285. }
  86286. if (!function_exists('mb_strpos')) {
  86287. function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); }
  86288. }
  86289. if (!function_exists('mb_strtolower')) {
  86290. function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); }
  86291. }
  86292. if (!function_exists('mb_strtoupper')) {
  86293. function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); }
  86294. }
  86295. if (!function_exists('mb_substitute_character')) {
  86296. function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); }
  86297. }
  86298. if (!function_exists('mb_substr')) {
  86299. function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); }
  86300. }
  86301. if (!function_exists('mb_stripos')) {
  86302. function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); }
  86303. }
  86304. if (!function_exists('mb_stristr')) {
  86305. function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); }
  86306. }
  86307. if (!function_exists('mb_strrchr')) {
  86308. function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); }
  86309. }
  86310. if (!function_exists('mb_strrichr')) {
  86311. function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); }
  86312. }
  86313. if (!function_exists('mb_strripos')) {
  86314. function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); }
  86315. }
  86316. if (!function_exists('mb_strrpos')) {
  86317. function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); }
  86318. }
  86319. if (!function_exists('mb_strstr')) {
  86320. function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); }
  86321. }
  86322. if (!function_exists('mb_get_info')) {
  86323. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  86324. }
  86325. if (!function_exists('mb_http_output')) {
  86326. function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); }
  86327. }
  86328. if (!function_exists('mb_strwidth')) {
  86329. function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); }
  86330. }
  86331. if (!function_exists('mb_substr_count')) {
  86332. function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); }
  86333. }
  86334. if (!function_exists('mb_output_handler')) {
  86335. function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
  86336. }
  86337. if (!function_exists('mb_http_input')) {
  86338. function mb_http_input($type = null) { return p\Mbstring::mb_http_input($type); }
  86339. }
  86340. if (!function_exists('mb_convert_variables')) {
  86341. function mb_convert_variables($to_encoding, $from_encoding, &...$vars) { return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); }
  86342. }
  86343. if (!function_exists('mb_ord')) {
  86344. function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); }
  86345. }
  86346. if (!function_exists('mb_chr')) {
  86347. function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); }
  86348. }
  86349. if (!function_exists('mb_scrub')) {
  86350. function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); }
  86351. }
  86352. if (!function_exists('mb_str_split')) {
  86353. function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
  86354. }
  86355. if (!function_exists('mb_str_pad')) {
  86356. 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); }
  86357. }
  86358. if (!function_exists('mb_ucfirst')) {
  86359. function mb_ucfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_ucfirst($string, $encoding); }
  86360. }
  86361. if (!function_exists('mb_lcfirst')) {
  86362. function mb_lcfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); }
  86363. }
  86364. if (!function_exists('mb_trim')) {
  86365. function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_trim($string, $characters, $encoding); }
  86366. }
  86367. if (!function_exists('mb_ltrim')) {
  86368. function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_ltrim($string, $characters, $encoding); }
  86369. }
  86370. if (!function_exists('mb_rtrim')) {
  86371. function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_rtrim($string, $characters, $encoding); }
  86372. }
  86373. if (extension_loaded('mbstring')) {
  86374. return;
  86375. }
  86376. if (!defined('MB_CASE_UPPER')) {
  86377. define('MB_CASE_UPPER', 0);
  86378. }
  86379. if (!defined('MB_CASE_LOWER')) {
  86380. define('MB_CASE_LOWER', 1);
  86381. }
  86382. if (!defined('MB_CASE_TITLE')) {
  86383. define('MB_CASE_TITLE', 2);
  86384. }
  86385. <?php
  86386. use Symfony\Polyfill\Mbstring as p;
  86387. if (!function_exists('mb_convert_encoding')) {
  86388. 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); }
  86389. }
  86390. if (!function_exists('mb_decode_mimeheader')) {
  86391. function mb_decode_mimeheader(?string $string): string { return p\Mbstring::mb_decode_mimeheader((string) $string); }
  86392. }
  86393. if (!function_exists('mb_encode_mimeheader')) {
  86394. 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); }
  86395. }
  86396. if (!function_exists('mb_decode_numericentity')) {
  86397. function mb_decode_numericentity(?string $string, array $map, ?string $encoding = null): string { return p\Mbstring::mb_decode_numericentity((string) $string, $map, $encoding); }
  86398. }
  86399. if (!function_exists('mb_encode_numericentity')) {
  86400. 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); }
  86401. }
  86402. if (!function_exists('mb_convert_case')) {
  86403. function mb_convert_case(?string $string, ?int $mode, ?string $encoding = null): string { return p\Mbstring::mb_convert_case((string) $string, (int) $mode, $encoding); }
  86404. }
  86405. if (!function_exists('mb_internal_encoding')) {
  86406. function mb_internal_encoding(?string $encoding = null): string|bool { return p\Mbstring::mb_internal_encoding($encoding); }
  86407. }
  86408. if (!function_exists('mb_language')) {
  86409. function mb_language(?string $language = null): string|bool { return p\Mbstring::mb_language($language); }
  86410. }
  86411. if (!function_exists('mb_list_encodings')) {
  86412. function mb_list_encodings(): array { return p\Mbstring::mb_list_encodings(); }
  86413. }
  86414. if (!function_exists('mb_encoding_aliases')) {
  86415. function mb_encoding_aliases(?string $encoding): array { return p\Mbstring::mb_encoding_aliases((string) $encoding); }
  86416. }
  86417. if (!function_exists('mb_check_encoding')) {
  86418. function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool { return p\Mbstring::mb_check_encoding($value, $encoding); }
  86419. }
  86420. if (!function_exists('mb_detect_encoding')) {
  86421. 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); }
  86422. }
  86423. if (!function_exists('mb_detect_order')) {
  86424. function mb_detect_order(array|string|null $encoding = null): array|bool { return p\Mbstring::mb_detect_order($encoding); }
  86425. }
  86426. if (!function_exists('mb_parse_str')) {
  86427. function mb_parse_str(?string $string, &$result = []): bool { parse_str((string) $string, $result); return (bool) $result; }
  86428. }
  86429. if (!function_exists('mb_strlen')) {
  86430. function mb_strlen(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strlen((string) $string, $encoding); }
  86431. }
  86432. if (!function_exists('mb_strpos')) {
  86433. 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); }
  86434. }
  86435. if (!function_exists('mb_strtolower')) {
  86436. function mb_strtolower(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtolower((string) $string, $encoding); }
  86437. }
  86438. if (!function_exists('mb_strtoupper')) {
  86439. function mb_strtoupper(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtoupper((string) $string, $encoding); }
  86440. }
  86441. if (!function_exists('mb_substitute_character')) {
  86442. function mb_substitute_character(string|int|null $substitute_character = null): string|int|bool { return p\Mbstring::mb_substitute_character($substitute_character); }
  86443. }
  86444. if (!function_exists('mb_substr')) {
  86445. 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); }
  86446. }
  86447. if (!function_exists('mb_stripos')) {
  86448. 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); }
  86449. }
  86450. if (!function_exists('mb_stristr')) {
  86451. 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); }
  86452. }
  86453. if (!function_exists('mb_strrchr')) {
  86454. 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); }
  86455. }
  86456. if (!function_exists('mb_strrichr')) {
  86457. 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); }
  86458. }
  86459. if (!function_exists('mb_strripos')) {
  86460. 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); }
  86461. }
  86462. if (!function_exists('mb_strrpos')) {
  86463. 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); }
  86464. }
  86465. if (!function_exists('mb_strstr')) {
  86466. 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); }
  86467. }
  86468. if (!function_exists('mb_get_info')) {
  86469. function mb_get_info(?string $type = 'all'): array|string|int|false|null { return p\Mbstring::mb_get_info((string) $type); }
  86470. }
  86471. if (!function_exists('mb_http_output')) {
  86472. function mb_http_output(?string $encoding = null): string|bool { return p\Mbstring::mb_http_output($encoding); }
  86473. }
  86474. if (!function_exists('mb_strwidth')) {
  86475. function mb_strwidth(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strwidth((string) $string, $encoding); }
  86476. }
  86477. if (!function_exists('mb_substr_count')) {
  86478. function mb_substr_count(?string $haystack, ?string $needle, ?string $encoding = null): int { return p\Mbstring::mb_substr_count((string) $haystack, (string) $needle, $encoding); }
  86479. }
  86480. if (!function_exists('mb_output_handler')) {
  86481. function mb_output_handler(?string $string, ?int $status): string { return p\Mbstring::mb_output_handler((string) $string, (int) $status); }
  86482. }
  86483. if (!function_exists('mb_http_input')) {
  86484. function mb_http_input(?string $type = null): array|string|false { return p\Mbstring::mb_http_input($type); }
  86485. }
  86486. if (!function_exists('mb_convert_variables')) {
  86487. 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); }
  86488. }
  86489. if (!function_exists('mb_ord')) {
  86490. function mb_ord(?string $string, ?string $encoding = null): int|false { return p\Mbstring::mb_ord((string) $string, $encoding); }
  86491. }
  86492. if (!function_exists('mb_chr')) {
  86493. function mb_chr(?int $codepoint, ?string $encoding = null): string|false { return p\Mbstring::mb_chr((int) $codepoint, $encoding); }
  86494. }
  86495. if (!function_exists('mb_scrub')) {
  86496. function mb_scrub(?string $string, ?string $encoding = null): string { $encoding ??= mb_internal_encoding(); return mb_convert_encoding((string) $string, $encoding, $encoding); }
  86497. }
  86498. if (!function_exists('mb_str_split')) {
  86499. function mb_str_split(?string $string, ?int $length = 1, ?string $encoding = null): array { return p\Mbstring::mb_str_split((string) $string, (int) $length, $encoding); }
  86500. }
  86501. if (!function_exists('mb_str_pad')) {
  86502. 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); }
  86503. }
  86504. if (!function_exists('mb_ucfirst')) {
  86505. function mb_ucfirst($string, ?string $encoding = null): string { return p\Mbstring::mb_ucfirst($string, $encoding); }
  86506. }
  86507. if (!function_exists('mb_lcfirst')) {
  86508. function mb_lcfirst($string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); }
  86509. }
  86510. if (!function_exists('mb_trim')) {
  86511. function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_trim($string, $characters, $encoding); }
  86512. }
  86513. if (!function_exists('mb_ltrim')) {
  86514. function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_ltrim($string, $characters, $encoding); }
  86515. }
  86516. if (!function_exists('mb_rtrim')) {
  86517. function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_rtrim($string, $characters, $encoding); }
  86518. }
  86519. if (extension_loaded('mbstring')) {
  86520. return;
  86521. }
  86522. if (!defined('MB_CASE_UPPER')) {
  86523. define('MB_CASE_UPPER', 0);
  86524. }
  86525. if (!defined('MB_CASE_LOWER')) {
  86526. define('MB_CASE_LOWER', 1);
  86527. }
  86528. if (!defined('MB_CASE_TITLE')) {
  86529. define('MB_CASE_TITLE', 2);
  86530. }
  86531. Copyright (c) 2018-present Fabien Potencier
  86532. Permission is hereby granted, free of charge, to any person obtaining a copy
  86533. of this software and associated documentation files (the "Software"), to deal
  86534. in the Software without restriction, including without limitation the rights
  86535. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  86536. copies of the Software, and to permit persons to whom the Software is furnished
  86537. to do so, subject to the following conditions:
  86538. The above copyright notice and this permission notice shall be included in all
  86539. copies or substantial portions of the Software.
  86540. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  86541. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  86542. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  86543. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  86544. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  86545. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  86546. THE SOFTWARE.
  86547. <?php
  86548. namespace Symfony\Polyfill\Php73;
  86549. final class Php73
  86550. {
  86551. public static $startAt = 1533462603;
  86552. public static function hrtime($asNum = false)
  86553. {
  86554. $ns = microtime(false);
  86555. $s = substr($ns, 11) - self::$startAt;
  86556. $ns = 1E9 * (float) $ns;
  86557. if ($asNum) {
  86558. $ns += $s * 1E9;
  86559. return \PHP_INT_SIZE === 4 ? $ns : (int) $ns;
  86560. }
  86561. return [$s, (int) $ns];
  86562. }
  86563. }
  86564. <?php
  86565. if (\PHP_VERSION_ID < 70300) {
  86566. class JsonException extends Exception
  86567. {
  86568. }
  86569. }
  86570. <?php
  86571. use Symfony\Polyfill\Php73 as p;
  86572. if (\PHP_VERSION_ID >= 70300) {
  86573. return;
  86574. }
  86575. if (!function_exists('is_countable')) {
  86576. function is_countable($value) { return is_array($value) || $value instanceof Countable || $value instanceof ResourceBundle || $value instanceof SimpleXmlElement; }
  86577. }
  86578. if (!function_exists('hrtime')) {
  86579. require_once __DIR__.'/Php73.php';
  86580. p\Php73::$startAt = (int) microtime(true);
  86581. function hrtime($as_number = false) { return p\Php73::hrtime($as_number); }
  86582. }
  86583. if (!function_exists('array_key_first')) {
  86584. function array_key_first(array $array) { foreach ($array as $key => $value) { return $key; } }
  86585. }
  86586. if (!function_exists('array_key_last')) {
  86587. function array_key_last(array $array) { return key(array_slice($array, -1, 1, true)); }
  86588. }
  86589. Copyright (c) 2020-present Fabien Potencier
  86590. Permission is hereby granted, free of charge, to any person obtaining a copy
  86591. of this software and associated documentation files (the "Software"), to deal
  86592. in the Software without restriction, including without limitation the rights
  86593. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  86594. copies of the Software, and to permit persons to whom the Software is furnished
  86595. to do so, subject to the following conditions:
  86596. The above copyright notice and this permission notice shall be included in all
  86597. copies or substantial portions of the Software.
  86598. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  86599. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  86600. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  86601. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  86602. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  86603. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  86604. THE SOFTWARE.
  86605. <?php
  86606. namespace Symfony\Polyfill\Php80;
  86607. final class Php80
  86608. {
  86609. public static function fdiv(float $dividend, float $divisor): float
  86610. {
  86611. return @($dividend / $divisor);
  86612. }
  86613. public static function get_debug_type($value): string
  86614. {
  86615. switch (true) {
  86616. case null === $value: return 'null';
  86617. case \is_bool($value): return 'bool';
  86618. case \is_string($value): return 'string';
  86619. case \is_array($value): return 'array';
  86620. case \is_int($value): return 'int';
  86621. case \is_float($value): return 'float';
  86622. case \is_object($value): break;
  86623. case $value instanceof \__PHP_Incomplete_Class: return '__PHP_Incomplete_Class';
  86624. default:
  86625. if (null === $type = @get_resource_type($value)) {
  86626. return 'unknown';
  86627. }
  86628. if ('Unknown' === $type) {
  86629. $type = 'closed';
  86630. }
  86631. return "resource ($type)";
  86632. }
  86633. $class = \get_class($value);
  86634. if (false === strpos($class, '@')) {
  86635. return $class;
  86636. }
  86637. return (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous';
  86638. }
  86639. public static function get_resource_id($res): int
  86640. {
  86641. if (!\is_resource($res) && null === @get_resource_type($res)) {
  86642. throw new \TypeError(sprintf('Argument 1 passed to get_resource_id() must be of the type resource, %s given', get_debug_type($res)));
  86643. }
  86644. return (int) $res;
  86645. }
  86646. public static function preg_last_error_msg(): string
  86647. {
  86648. switch (preg_last_error()) {
  86649. case \PREG_INTERNAL_ERROR:
  86650. return 'Internal error';
  86651. case \PREG_BAD_UTF8_ERROR:
  86652. return 'Malformed UTF-8 characters, possibly incorrectly encoded';
  86653. case \PREG_BAD_UTF8_OFFSET_ERROR:
  86654. return 'The offset did not correspond to the beginning of a valid UTF-8 code point';
  86655. case \PREG_BACKTRACK_LIMIT_ERROR:
  86656. return 'Backtrack limit exhausted';
  86657. case \PREG_RECURSION_LIMIT_ERROR:
  86658. return 'Recursion limit exhausted';
  86659. case \PREG_JIT_STACKLIMIT_ERROR:
  86660. return 'JIT stack limit exhausted';
  86661. case \PREG_NO_ERROR:
  86662. return 'No error';
  86663. default:
  86664. return 'Unknown error';
  86665. }
  86666. }
  86667. public static function str_contains(string $haystack, string $needle): bool
  86668. {
  86669. return '' === $needle || false !== strpos($haystack, $needle);
  86670. }
  86671. public static function str_starts_with(string $haystack, string $needle): bool
  86672. {
  86673. return 0 === strncmp($haystack, $needle, \strlen($needle));
  86674. }
  86675. public static function str_ends_with(string $haystack, string $needle): bool
  86676. {
  86677. if ('' === $needle || $needle === $haystack) {
  86678. return true;
  86679. }
  86680. if ('' === $haystack) {
  86681. return false;
  86682. }
  86683. $needleLength = \strlen($needle);
  86684. return $needleLength <= \strlen($haystack) && 0 === substr_compare($haystack, $needle, -$needleLength);
  86685. }
  86686. }
  86687. <?php
  86688. namespace Symfony\Polyfill\Php80;
  86689. class PhpToken implements \Stringable
  86690. {
  86691. public $id;
  86692. public $text;
  86693. public $line;
  86694. public $pos;
  86695. public function __construct(int $id, string $text, int $line = -1, int $position = -1)
  86696. {
  86697. $this->id = $id;
  86698. $this->text = $text;
  86699. $this->line = $line;
  86700. $this->pos = $position;
  86701. }
  86702. public function getTokenName(): ?string
  86703. {
  86704. if ('UNKNOWN' === $name = token_name($this->id)) {
  86705. $name = \strlen($this->text) > 1 || \ord($this->text) < 32 ? null : $this->text;
  86706. }
  86707. return $name;
  86708. }
  86709. public function is($kind): bool
  86710. {
  86711. foreach ((array) $kind as $value) {
  86712. if (\in_array($value, [$this->id, $this->text], true)) {
  86713. return true;
  86714. }
  86715. }
  86716. return false;
  86717. }
  86718. public function isIgnorable(): bool
  86719. {
  86720. return \in_array($this->id, [\T_WHITESPACE, \T_COMMENT, \T_DOC_COMMENT, \T_OPEN_TAG], true);
  86721. }
  86722. public function __toString(): string
  86723. {
  86724. return (string) $this->text;
  86725. }
  86726. public static function tokenize(string $code, int $flags = 0): array
  86727. {
  86728. $line = 1;
  86729. $position = 0;
  86730. $tokens = token_get_all($code, $flags);
  86731. foreach ($tokens as $index => $token) {
  86732. if (\is_string($token)) {
  86733. $id = \ord($token);
  86734. $text = $token;
  86735. } else {
  86736. [$id, $text, $line] = $token;
  86737. }
  86738. $tokens[$index] = new static($id, $text, $line, $position);
  86739. $position += \strlen($text);
  86740. }
  86741. return $tokens;
  86742. }
  86743. }
  86744. <?php
  86745. #[Attribute(Attribute::TARGET_CLASS)]
  86746. final class Attribute
  86747. {
  86748. public const TARGET_CLASS = 1;
  86749. public const TARGET_FUNCTION = 2;
  86750. public const TARGET_METHOD = 4;
  86751. public const TARGET_PROPERTY = 8;
  86752. public const TARGET_CLASS_CONSTANT = 16;
  86753. public const TARGET_PARAMETER = 32;
  86754. public const TARGET_ALL = 63;
  86755. public const IS_REPEATABLE = 64;
  86756. public $flags;
  86757. public function __construct(int $flags = self::TARGET_ALL)
  86758. {
  86759. $this->flags = $flags;
  86760. }
  86761. }
  86762. <?php
  86763. if (\PHP_VERSION_ID < 80000 && extension_loaded('tokenizer')) {
  86764. class PhpToken extends Symfony\Polyfill\Php80\PhpToken
  86765. {
  86766. }
  86767. }
  86768. <?php
  86769. if (\PHP_VERSION_ID < 80000) {
  86770. interface Stringable
  86771. {
  86772. public function __toString();
  86773. }
  86774. }
  86775. <?php
  86776. if (\PHP_VERSION_ID < 80000) {
  86777. class UnhandledMatchError extends Error
  86778. {
  86779. }
  86780. }
  86781. <?php
  86782. if (\PHP_VERSION_ID < 80000) {
  86783. class ValueError extends Error
  86784. {
  86785. }
  86786. }
  86787. <?php
  86788. use Symfony\Polyfill\Php80 as p;
  86789. if (\PHP_VERSION_ID >= 80000) {
  86790. return;
  86791. }
  86792. if (!defined('FILTER_VALIDATE_BOOL') && defined('FILTER_VALIDATE_BOOLEAN')) {
  86793. define('FILTER_VALIDATE_BOOL', \FILTER_VALIDATE_BOOLEAN);
  86794. }
  86795. if (!function_exists('fdiv')) {
  86796. function fdiv(float $num1, float $num2): float { return p\Php80::fdiv($num1, $num2); }
  86797. }
  86798. if (!function_exists('preg_last_error_msg')) {
  86799. function preg_last_error_msg(): string { return p\Php80::preg_last_error_msg(); }
  86800. }
  86801. if (!function_exists('str_contains')) {
  86802. function str_contains(?string $haystack, ?string $needle): bool { return p\Php80::str_contains($haystack ?? '', $needle ?? ''); }
  86803. }
  86804. if (!function_exists('str_starts_with')) {
  86805. function str_starts_with(?string $haystack, ?string $needle): bool { return p\Php80::str_starts_with($haystack ?? '', $needle ?? ''); }
  86806. }
  86807. if (!function_exists('str_ends_with')) {
  86808. function str_ends_with(?string $haystack, ?string $needle): bool { return p\Php80::str_ends_with($haystack ?? '', $needle ?? ''); }
  86809. }
  86810. if (!function_exists('get_debug_type')) {
  86811. function get_debug_type($value): string { return p\Php80::get_debug_type($value); }
  86812. }
  86813. if (!function_exists('get_resource_id')) {
  86814. function get_resource_id($resource): int { return p\Php80::get_resource_id($resource); }
  86815. }
  86816. Copyright (c) 2021-present Fabien Potencier
  86817. Permission is hereby granted, free of charge, to any person obtaining a copy
  86818. of this software and associated documentation files (the "Software"), to deal
  86819. in the Software without restriction, including without limitation the rights
  86820. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  86821. copies of the Software, and to permit persons to whom the Software is furnished
  86822. to do so, subject to the following conditions:
  86823. The above copyright notice and this permission notice shall be included in all
  86824. copies or substantial portions of the Software.
  86825. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  86826. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  86827. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  86828. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  86829. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  86830. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  86831. THE SOFTWARE.
  86832. <?php
  86833. namespace Symfony\Polyfill\Php81;
  86834. final class Php81
  86835. {
  86836. public static function array_is_list(array $array): bool
  86837. {
  86838. if ([] === $array || $array === array_values($array)) {
  86839. return true;
  86840. }
  86841. $nextKey = -1;
  86842. foreach ($array as $k => $v) {
  86843. if ($k !== ++$nextKey) {
  86844. return false;
  86845. }
  86846. }
  86847. return true;
  86848. }
  86849. }
  86850. <?php
  86851. if (\PHP_VERSION_ID >= 70400 && extension_loaded('curl')) {
  86852. class CURLStringFile extends CURLFile
  86853. {
  86854. private $data;
  86855. public function __construct(string $data, string $postname, string $mime = 'application/octet-stream')
  86856. {
  86857. $this->data = $data;
  86858. parent::__construct('data://application/octet-stream;base64,'.base64_encode($data), $mime, $postname);
  86859. }
  86860. public function __set(string $name, $value): void
  86861. {
  86862. if ('data' !== $name) {
  86863. $this->$name = $value;
  86864. return;
  86865. }
  86866. if (is_object($value) ? !method_exists($value, '__toString') : !is_scalar($value)) {
  86867. throw new TypeError('Cannot assign '.gettype($value).' to property CURLStringFile::$data of type string');
  86868. }
  86869. $this->name = 'data://application/octet-stream;base64,'.base64_encode($value);
  86870. }
  86871. public function __isset(string $name): bool
  86872. {
  86873. return isset($this->$name);
  86874. }
  86875. public function &__get(string $name)
  86876. {
  86877. return $this->$name;
  86878. }
  86879. }
  86880. }
  86881. <?php
  86882. if (\PHP_VERSION_ID < 80100) {
  86883. #[Attribute(Attribute::TARGET_METHOD)]
  86884. final class ReturnTypeWillChange
  86885. {
  86886. public function __construct()
  86887. {
  86888. }
  86889. }
  86890. }
  86891. <?php
  86892. use Symfony\Polyfill\Php81 as p;
  86893. if (\PHP_VERSION_ID >= 80100) {
  86894. return;
  86895. }
  86896. if (defined('MYSQLI_REFRESH_SLAVE') && !defined('MYSQLI_REFRESH_REPLICA')) {
  86897. define('MYSQLI_REFRESH_REPLICA', 64);
  86898. }
  86899. if (!function_exists('array_is_list')) {
  86900. function array_is_list(array $array): bool { return p\Php81::array_is_list($array); }
  86901. }
  86902. if (!function_exists('enum_exists')) {
  86903. function enum_exists(string $enum, bool $autoload = true): bool { return $autoload && class_exists($enum) && false; }
  86904. }
  86905. <?php
  86906. namespace Symfony\Component\Process\Exception;
  86907. interface ExceptionInterface extends \Throwable
  86908. {
  86909. }
  86910. <?php
  86911. namespace Symfony\Component\Process\Exception;
  86912. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  86913. {
  86914. }
  86915. <?php
  86916. namespace Symfony\Component\Process\Exception;
  86917. class LogicException extends \LogicException implements ExceptionInterface
  86918. {
  86919. }
  86920. <?php
  86921. namespace Symfony\Component\Process\Exception;
  86922. use Symfony\Component\Process\Process;
  86923. class ProcessFailedException extends RuntimeException
  86924. {
  86925. private $process;
  86926. public function __construct(Process $process)
  86927. {
  86928. if ($process->isSuccessful()) {
  86929. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  86930. }
  86931. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  86932. $process->getCommandLine(),
  86933. $process->getExitCode(),
  86934. $process->getExitCodeText(),
  86935. $process->getWorkingDirectory()
  86936. );
  86937. if (!$process->isOutputDisabled()) {
  86938. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  86939. $process->getOutput(),
  86940. $process->getErrorOutput()
  86941. );
  86942. }
  86943. parent::__construct($error);
  86944. $this->process = $process;
  86945. }
  86946. public function getProcess()
  86947. {
  86948. return $this->process;
  86949. }
  86950. }
  86951. <?php
  86952. namespace Symfony\Component\Process\Exception;
  86953. use Symfony\Component\Process\Process;
  86954. final class ProcessSignaledException extends RuntimeException
  86955. {
  86956. private $process;
  86957. public function __construct(Process $process)
  86958. {
  86959. $this->process = $process;
  86960. parent::__construct(sprintf('The process has been signaled with signal "%s".', $process->getTermSignal()));
  86961. }
  86962. public function getProcess(): Process
  86963. {
  86964. return $this->process;
  86965. }
  86966. public function getSignal(): int
  86967. {
  86968. return $this->getProcess()->getTermSignal();
  86969. }
  86970. }
  86971. <?php
  86972. namespace Symfony\Component\Process\Exception;
  86973. use Symfony\Component\Process\Process;
  86974. class ProcessTimedOutException extends RuntimeException
  86975. {
  86976. public const TYPE_GENERAL = 1;
  86977. public const TYPE_IDLE = 2;
  86978. private $process;
  86979. private $timeoutType;
  86980. public function __construct(Process $process, int $timeoutType)
  86981. {
  86982. $this->process = $process;
  86983. $this->timeoutType = $timeoutType;
  86984. parent::__construct(sprintf(
  86985. 'The process "%s" exceeded the timeout of %s seconds.',
  86986. $process->getCommandLine(),
  86987. $this->getExceededTimeout()
  86988. ));
  86989. }
  86990. public function getProcess()
  86991. {
  86992. return $this->process;
  86993. }
  86994. public function isGeneralTimeout()
  86995. {
  86996. return self::TYPE_GENERAL === $this->timeoutType;
  86997. }
  86998. public function isIdleTimeout()
  86999. {
  87000. return self::TYPE_IDLE === $this->timeoutType;
  87001. }
  87002. public function getExceededTimeout()
  87003. {
  87004. switch ($this->timeoutType) {
  87005. case self::TYPE_GENERAL:
  87006. return $this->process->getTimeout();
  87007. case self::TYPE_IDLE:
  87008. return $this->process->getIdleTimeout();
  87009. default:
  87010. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  87011. }
  87012. }
  87013. }
  87014. <?php
  87015. namespace Symfony\Component\Process\Exception;
  87016. class RuntimeException extends \RuntimeException implements ExceptionInterface
  87017. {
  87018. }
  87019. <?php
  87020. namespace Symfony\Component\Process;
  87021. class ExecutableFinder
  87022. {
  87023. private const CMD_BUILTINS = [
  87024. 'assoc', 'break', 'call', 'cd', 'chdir', 'cls', 'color', 'copy', 'date',
  87025. 'del', 'dir', 'echo', 'endlocal', 'erase', 'exit', 'for', 'ftype', 'goto',
  87026. 'help', 'if', 'label', 'md', 'mkdir', 'mklink', 'move', 'path', 'pause',
  87027. 'popd', 'prompt', 'pushd', 'rd', 'rem', 'ren', 'rename', 'rmdir', 'set',
  87028. 'setlocal', 'shift', 'start', 'time', 'title', 'type', 'ver', 'vol',
  87029. ];
  87030. private $suffixes = [];
  87031. public function setSuffixes(array $suffixes)
  87032. {
  87033. $this->suffixes = $suffixes;
  87034. }
  87035. public function addSuffix(string $suffix)
  87036. {
  87037. $this->suffixes[] = $suffix;
  87038. }
  87039. public function find(string $name, ?string $default = null, array $extraDirs = [])
  87040. {
  87041. if ('\\' === \DIRECTORY_SEPARATOR && \in_array(strtolower($name), self::CMD_BUILTINS, true)) {
  87042. return $name;
  87043. }
  87044. $dirs = array_merge(
  87045. explode(\PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  87046. $extraDirs
  87047. );
  87048. $suffixes = [];
  87049. if ('\\' === \DIRECTORY_SEPARATOR) {
  87050. $pathExt = getenv('PATHEXT');
  87051. $suffixes = $this->suffixes;
  87052. $suffixes = array_merge($suffixes, $pathExt ? explode(\PATH_SEPARATOR, $pathExt) : ['.exe', '.bat', '.cmd', '.com']);
  87053. }
  87054. $suffixes = '' !== pathinfo($name, PATHINFO_EXTENSION) ? array_merge([''], $suffixes) : array_merge($suffixes, ['']);
  87055. foreach ($suffixes as $suffix) {
  87056. foreach ($dirs as $dir) {
  87057. if ('' === $dir) {
  87058. $dir = '.';
  87059. }
  87060. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  87061. return $file;
  87062. }
  87063. if (!@is_dir($dir) && basename($dir) === $name.$suffix && @is_executable($dir)) {
  87064. return $dir;
  87065. }
  87066. }
  87067. }
  87068. if ('\\' === \DIRECTORY_SEPARATOR || !\function_exists('exec') || \strlen($name) !== strcspn($name, '/'.\DIRECTORY_SEPARATOR)) {
  87069. return $default;
  87070. }
  87071. $execResult = exec('command -v -- '.escapeshellarg($name));
  87072. if (($executablePath = substr($execResult, 0, strpos($execResult, \PHP_EOL) ?: null)) && @is_executable($executablePath)) {
  87073. return $executablePath;
  87074. }
  87075. return $default;
  87076. }
  87077. }
  87078. <?php
  87079. namespace Symfony\Component\Process;
  87080. use Symfony\Component\Process\Exception\RuntimeException;
  87081. class InputStream implements \IteratorAggregate
  87082. {
  87083. private $onEmpty = null;
  87084. private $input = [];
  87085. private $open = true;
  87086. public function onEmpty(?callable $onEmpty = null)
  87087. {
  87088. $this->onEmpty = $onEmpty;
  87089. }
  87090. public function write($input)
  87091. {
  87092. if (null === $input) {
  87093. return;
  87094. }
  87095. if ($this->isClosed()) {
  87096. throw new RuntimeException(sprintf('"%s" is closed.', static::class));
  87097. }
  87098. $this->input[] = ProcessUtils::validateInput(__METHOD__, $input);
  87099. }
  87100. public function close()
  87101. {
  87102. $this->open = false;
  87103. }
  87104. public function isClosed()
  87105. {
  87106. return !$this->open;
  87107. }
  87108. #[\ReturnTypeWillChange]
  87109. public function getIterator()
  87110. {
  87111. $this->open = true;
  87112. while ($this->open || $this->input) {
  87113. if (!$this->input) {
  87114. yield '';
  87115. continue;
  87116. }
  87117. $current = array_shift($this->input);
  87118. if ($current instanceof \Iterator) {
  87119. yield from $current;
  87120. } else {
  87121. yield $current;
  87122. }
  87123. if (!$this->input && $this->open && null !== $onEmpty = $this->onEmpty) {
  87124. $this->write($onEmpty($this));
  87125. }
  87126. }
  87127. }
  87128. }
  87129. Copyright (c) 2004-present Fabien Potencier
  87130. Permission is hereby granted, free of charge, to any person obtaining a copy
  87131. of this software and associated documentation files (the "Software"), to deal
  87132. in the Software without restriction, including without limitation the rights
  87133. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  87134. copies of the Software, and to permit persons to whom the Software is furnished
  87135. to do so, subject to the following conditions:
  87136. The above copyright notice and this permission notice shall be included in all
  87137. copies or substantial portions of the Software.
  87138. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  87139. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  87140. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  87141. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  87142. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  87143. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  87144. THE SOFTWARE.
  87145. <?php
  87146. namespace Symfony\Component\Process;
  87147. class PhpExecutableFinder
  87148. {
  87149. private $executableFinder;
  87150. public function __construct()
  87151. {
  87152. $this->executableFinder = new ExecutableFinder();
  87153. }
  87154. public function find(bool $includeArgs = true)
  87155. {
  87156. if ($php = getenv('PHP_BINARY')) {
  87157. if (!is_executable($php) && !$php = $this->executableFinder->find($php)) {
  87158. return false;
  87159. }
  87160. if (@is_dir($php)) {
  87161. return false;
  87162. }
  87163. return $php;
  87164. }
  87165. $args = $this->findArguments();
  87166. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  87167. if (\PHP_BINARY && \in_array(\PHP_SAPI, ['cli', 'cli-server', 'phpdbg'], true)) {
  87168. return \PHP_BINARY.$args;
  87169. }
  87170. if ($php = getenv('PHP_PATH')) {
  87171. if (!@is_executable($php) || @is_dir($php)) {
  87172. return false;
  87173. }
  87174. return $php;
  87175. }
  87176. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  87177. if (@is_executable($php) && !@is_dir($php)) {
  87178. return $php;
  87179. }
  87180. }
  87181. if (@is_executable($php = \PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php')) && !@is_dir($php)) {
  87182. return $php;
  87183. }
  87184. $dirs = [\PHP_BINDIR];
  87185. if ('\\' === \DIRECTORY_SEPARATOR) {
  87186. $dirs[] = 'C:\xampp\php\\';
  87187. }
  87188. return $this->executableFinder->find('php', false, $dirs);
  87189. }
  87190. public function findArguments()
  87191. {
  87192. $arguments = [];
  87193. if ('phpdbg' === \PHP_SAPI) {
  87194. $arguments[] = '-qrr';
  87195. }
  87196. return $arguments;
  87197. }
  87198. }
  87199. <?php
  87200. namespace Symfony\Component\Process;
  87201. use Symfony\Component\Process\Exception\LogicException;
  87202. use Symfony\Component\Process\Exception\RuntimeException;
  87203. class PhpProcess extends Process
  87204. {
  87205. public function __construct(string $script, ?string $cwd = null, ?array $env = null, int $timeout = 60, ?array $php = null)
  87206. {
  87207. if (null === $php) {
  87208. $executableFinder = new PhpExecutableFinder();
  87209. $php = $executableFinder->find(false);
  87210. $php = false === $php ? null : array_merge([$php], $executableFinder->findArguments());
  87211. }
  87212. if ('phpdbg' === \PHP_SAPI) {
  87213. $file = tempnam(sys_get_temp_dir(), 'dbg');
  87214. file_put_contents($file, $script);
  87215. register_shutdown_function('unlink', $file);
  87216. $php[] = $file;
  87217. $script = null;
  87218. }
  87219. parent::__construct($php, $cwd, $env, $script, $timeout);
  87220. }
  87221. public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, $input = null, ?float $timeout = 60)
  87222. {
  87223. throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
  87224. }
  87225. public function start(?callable $callback = null, array $env = [])
  87226. {
  87227. if (null === $this->getCommandLine()) {
  87228. throw new RuntimeException('Unable to find the PHP executable.');
  87229. }
  87230. parent::start($callback, $env);
  87231. }
  87232. }
  87233. <?php
  87234. namespace Symfony\Component\Process\Pipes;
  87235. use Symfony\Component\Process\Exception\InvalidArgumentException;
  87236. abstract class AbstractPipes implements PipesInterface
  87237. {
  87238. public $pipes = [];
  87239. private $inputBuffer = '';
  87240. private $input;
  87241. private $blocked = true;
  87242. private $lastError;
  87243. public function __construct($input)
  87244. {
  87245. if (\is_resource($input) || $input instanceof \Iterator) {
  87246. $this->input = $input;
  87247. } elseif (\is_string($input)) {
  87248. $this->inputBuffer = $input;
  87249. } else {
  87250. $this->inputBuffer = (string) $input;
  87251. }
  87252. }
  87253. public function close()
  87254. {
  87255. foreach ($this->pipes as $pipe) {
  87256. if (\is_resource($pipe)) {
  87257. fclose($pipe);
  87258. }
  87259. }
  87260. $this->pipes = [];
  87261. }
  87262. protected function hasSystemCallBeenInterrupted(): bool
  87263. {
  87264. $lastError = $this->lastError;
  87265. $this->lastError = null;
  87266. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  87267. }
  87268. protected function unblock()
  87269. {
  87270. if (!$this->blocked) {
  87271. return;
  87272. }
  87273. foreach ($this->pipes as $pipe) {
  87274. stream_set_blocking($pipe, 0);
  87275. }
  87276. if (\is_resource($this->input)) {
  87277. stream_set_blocking($this->input, 0);
  87278. }
  87279. $this->blocked = false;
  87280. }
  87281. protected function write(): ?array
  87282. {
  87283. if (!isset($this->pipes[0])) {
  87284. return null;
  87285. }
  87286. $input = $this->input;
  87287. if ($input instanceof \Iterator) {
  87288. if (!$input->valid()) {
  87289. $input = null;
  87290. } elseif (\is_resource($input = $input->current())) {
  87291. stream_set_blocking($input, 0);
  87292. } elseif (!isset($this->inputBuffer[0])) {
  87293. if (!\is_string($input)) {
  87294. if (!\is_scalar($input)) {
  87295. 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)));
  87296. }
  87297. $input = (string) $input;
  87298. }
  87299. $this->inputBuffer = $input;
  87300. $this->input->next();
  87301. $input = null;
  87302. } else {
  87303. $input = null;
  87304. }
  87305. }
  87306. $r = $e = [];
  87307. $w = [$this->pipes[0]];
  87308. if (false === @stream_select($r, $w, $e, 0, 0)) {
  87309. return null;
  87310. }
  87311. foreach ($w as $stdin) {
  87312. if (isset($this->inputBuffer[0])) {
  87313. $written = fwrite($stdin, $this->inputBuffer);
  87314. $this->inputBuffer = substr($this->inputBuffer, $written);
  87315. if (isset($this->inputBuffer[0])) {
  87316. return [$this->pipes[0]];
  87317. }
  87318. }
  87319. if ($input) {
  87320. while (true) {
  87321. $data = fread($input, self::CHUNK_SIZE);
  87322. if (!isset($data[0])) {
  87323. break;
  87324. }
  87325. $written = fwrite($stdin, $data);
  87326. $data = substr($data, $written);
  87327. if (isset($data[0])) {
  87328. $this->inputBuffer = $data;
  87329. return [$this->pipes[0]];
  87330. }
  87331. }
  87332. if (feof($input)) {
  87333. if ($this->input instanceof \Iterator) {
  87334. $this->input->next();
  87335. } else {
  87336. $this->input = null;
  87337. }
  87338. }
  87339. }
  87340. }
  87341. if (!isset($this->inputBuffer[0]) && !($this->input instanceof \Iterator ? $this->input->valid() : $this->input)) {
  87342. $this->input = null;
  87343. fclose($this->pipes[0]);
  87344. unset($this->pipes[0]);
  87345. } elseif (!$w) {
  87346. return [$this->pipes[0]];
  87347. }
  87348. return null;
  87349. }
  87350. public function handleError(int $type, string $msg)
  87351. {
  87352. $this->lastError = $msg;
  87353. }
  87354. }
  87355. <?php
  87356. namespace Symfony\Component\Process\Pipes;
  87357. interface PipesInterface
  87358. {
  87359. public const CHUNK_SIZE = 16384;
  87360. public function getDescriptors(): array;
  87361. public function getFiles(): array;
  87362. public function readAndWrite(bool $blocking, bool $close = false): array;
  87363. public function areOpen(): bool;
  87364. public function haveReadSupport(): bool;
  87365. public function close();
  87366. }
  87367. <?php
  87368. namespace Symfony\Component\Process\Pipes;
  87369. use Symfony\Component\Process\Process;
  87370. class UnixPipes extends AbstractPipes
  87371. {
  87372. private $ttyMode;
  87373. private $ptyMode;
  87374. private $haveReadSupport;
  87375. public function __construct(?bool $ttyMode, bool $ptyMode, $input, bool $haveReadSupport)
  87376. {
  87377. $this->ttyMode = $ttyMode;
  87378. $this->ptyMode = $ptyMode;
  87379. $this->haveReadSupport = $haveReadSupport;
  87380. parent::__construct($input);
  87381. }
  87382. public function __sleep(): array
  87383. {
  87384. throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
  87385. }
  87386. public function __wakeup()
  87387. {
  87388. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  87389. }
  87390. public function __destruct()
  87391. {
  87392. $this->close();
  87393. }
  87394. public function getDescriptors(): array
  87395. {
  87396. if (!$this->haveReadSupport) {
  87397. $nullstream = fopen('/dev/null', 'c');
  87398. return [
  87399. ['pipe', 'r'],
  87400. $nullstream,
  87401. $nullstream,
  87402. ];
  87403. }
  87404. if ($this->ttyMode) {
  87405. return [
  87406. ['file', '/dev/tty', 'r'],
  87407. ['file', '/dev/tty', 'w'],
  87408. ['file', '/dev/tty', 'w'],
  87409. ];
  87410. }
  87411. if ($this->ptyMode && Process::isPtySupported()) {
  87412. return [
  87413. ['pty'],
  87414. ['pty'],
  87415. ['pty'],
  87416. ];
  87417. }
  87418. return [
  87419. ['pipe', 'r'],
  87420. ['pipe', 'w'],
  87421. ['pipe', 'w'],
  87422. ];
  87423. }
  87424. public function getFiles(): array
  87425. {
  87426. return [];
  87427. }
  87428. public function readAndWrite(bool $blocking, bool $close = false): array
  87429. {
  87430. $this->unblock();
  87431. $w = $this->write();
  87432. $read = $e = [];
  87433. $r = $this->pipes;
  87434. unset($r[0]);
  87435. set_error_handler([$this, 'handleError']);
  87436. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  87437. restore_error_handler();
  87438. if (!$this->hasSystemCallBeenInterrupted()) {
  87439. $this->pipes = [];
  87440. }
  87441. return $read;
  87442. }
  87443. restore_error_handler();
  87444. foreach ($r as $pipe) {
  87445. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  87446. do {
  87447. $data = @fread($pipe, self::CHUNK_SIZE);
  87448. $read[$type] .= $data;
  87449. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  87450. if (!isset($read[$type][0])) {
  87451. unset($read[$type]);
  87452. }
  87453. if ($close && feof($pipe)) {
  87454. fclose($pipe);
  87455. unset($this->pipes[$type]);
  87456. }
  87457. }
  87458. return $read;
  87459. }
  87460. public function haveReadSupport(): bool
  87461. {
  87462. return $this->haveReadSupport;
  87463. }
  87464. public function areOpen(): bool
  87465. {
  87466. return (bool) $this->pipes;
  87467. }
  87468. }
  87469. <?php
  87470. namespace Symfony\Component\Process\Pipes;
  87471. use Symfony\Component\Process\Exception\RuntimeException;
  87472. use Symfony\Component\Process\Process;
  87473. class WindowsPipes extends AbstractPipes
  87474. {
  87475. private $files = [];
  87476. private $fileHandles = [];
  87477. private $lockHandles = [];
  87478. private $readBytes = [
  87479. Process::STDOUT => 0,
  87480. Process::STDERR => 0,
  87481. ];
  87482. private $haveReadSupport;
  87483. public function __construct($input, bool $haveReadSupport)
  87484. {
  87485. $this->haveReadSupport = $haveReadSupport;
  87486. if ($this->haveReadSupport) {
  87487. $pipes = [
  87488. Process::STDOUT => Process::OUT,
  87489. Process::STDERR => Process::ERR,
  87490. ];
  87491. $tmpDir = sys_get_temp_dir();
  87492. $lastError = 'unknown reason';
  87493. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  87494. for ($i = 0;; ++$i) {
  87495. foreach ($pipes as $pipe => $name) {
  87496. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  87497. if (!$h = fopen($file.'.lock', 'w')) {
  87498. if (file_exists($file.'.lock')) {
  87499. continue 2;
  87500. }
  87501. restore_error_handler();
  87502. throw new RuntimeException('A temporary file could not be opened to write the process output: '.$lastError);
  87503. }
  87504. if (!flock($h, \LOCK_EX | \LOCK_NB)) {
  87505. continue 2;
  87506. }
  87507. if (isset($this->lockHandles[$pipe])) {
  87508. flock($this->lockHandles[$pipe], \LOCK_UN);
  87509. fclose($this->lockHandles[$pipe]);
  87510. }
  87511. $this->lockHandles[$pipe] = $h;
  87512. if (!($h = fopen($file, 'w')) || !fclose($h) || !$h = fopen($file, 'r')) {
  87513. flock($this->lockHandles[$pipe], \LOCK_UN);
  87514. fclose($this->lockHandles[$pipe]);
  87515. unset($this->lockHandles[$pipe]);
  87516. continue 2;
  87517. }
  87518. $this->fileHandles[$pipe] = $h;
  87519. $this->files[$pipe] = $file;
  87520. }
  87521. break;
  87522. }
  87523. restore_error_handler();
  87524. }
  87525. parent::__construct($input);
  87526. }
  87527. public function __sleep(): array
  87528. {
  87529. throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
  87530. }
  87531. public function __wakeup()
  87532. {
  87533. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  87534. }
  87535. public function __destruct()
  87536. {
  87537. $this->close();
  87538. }
  87539. public function getDescriptors(): array
  87540. {
  87541. if (!$this->haveReadSupport) {
  87542. $nullstream = fopen('NUL', 'c');
  87543. return [
  87544. ['pipe', 'r'],
  87545. $nullstream,
  87546. $nullstream,
  87547. ];
  87548. }
  87549. return [
  87550. ['pipe', 'r'],
  87551. ['file', 'NUL', 'w'],
  87552. ['file', 'NUL', 'w'],
  87553. ];
  87554. }
  87555. public function getFiles(): array
  87556. {
  87557. return $this->files;
  87558. }
  87559. public function readAndWrite(bool $blocking, bool $close = false): array
  87560. {
  87561. $this->unblock();
  87562. $w = $this->write();
  87563. $read = $r = $e = [];
  87564. if ($blocking) {
  87565. if ($w) {
  87566. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  87567. } elseif ($this->fileHandles) {
  87568. usleep((int) (Process::TIMEOUT_PRECISION * 1E6));
  87569. }
  87570. }
  87571. foreach ($this->fileHandles as $type => $fileHandle) {
  87572. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  87573. if (isset($data[0])) {
  87574. $this->readBytes[$type] += \strlen($data);
  87575. $read[$type] = $data;
  87576. }
  87577. if ($close) {
  87578. ftruncate($fileHandle, 0);
  87579. fclose($fileHandle);
  87580. flock($this->lockHandles[$type], \LOCK_UN);
  87581. fclose($this->lockHandles[$type]);
  87582. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  87583. }
  87584. }
  87585. return $read;
  87586. }
  87587. public function haveReadSupport(): bool
  87588. {
  87589. return $this->haveReadSupport;
  87590. }
  87591. public function areOpen(): bool
  87592. {
  87593. return $this->pipes && $this->fileHandles;
  87594. }
  87595. public function close()
  87596. {
  87597. parent::close();
  87598. foreach ($this->fileHandles as $type => $handle) {
  87599. ftruncate($handle, 0);
  87600. fclose($handle);
  87601. flock($this->lockHandles[$type], \LOCK_UN);
  87602. fclose($this->lockHandles[$type]);
  87603. }
  87604. $this->fileHandles = $this->lockHandles = [];
  87605. }
  87606. }
  87607. <?php
  87608. namespace Symfony\Component\Process;
  87609. use Symfony\Component\Process\Exception\InvalidArgumentException;
  87610. use Symfony\Component\Process\Exception\LogicException;
  87611. use Symfony\Component\Process\Exception\ProcessFailedException;
  87612. use Symfony\Component\Process\Exception\ProcessSignaledException;
  87613. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  87614. use Symfony\Component\Process\Exception\RuntimeException;
  87615. use Symfony\Component\Process\Pipes\PipesInterface;
  87616. use Symfony\Component\Process\Pipes\UnixPipes;
  87617. use Symfony\Component\Process\Pipes\WindowsPipes;
  87618. class Process implements \IteratorAggregate
  87619. {
  87620. public const ERR = 'err';
  87621. public const OUT = 'out';
  87622. public const STATUS_READY = 'ready';
  87623. public const STATUS_STARTED = 'started';
  87624. public const STATUS_TERMINATED = 'terminated';
  87625. public const STDIN = 0;
  87626. public const STDOUT = 1;
  87627. public const STDERR = 2;
  87628. public const TIMEOUT_PRECISION = 0.2;
  87629. public const ITER_NON_BLOCKING = 1;
  87630. public const ITER_KEEP_OUTPUT = 2;
  87631. public const ITER_SKIP_OUT = 4;
  87632. public const ITER_SKIP_ERR = 8;
  87633. private $callback;
  87634. private $hasCallback = false;
  87635. private $commandline;
  87636. private $cwd;
  87637. private $env = [];
  87638. private $input;
  87639. private $starttime;
  87640. private $lastOutputTime;
  87641. private $timeout;
  87642. private $idleTimeout;
  87643. private $exitcode;
  87644. private $fallbackStatus = [];
  87645. private $processInformation;
  87646. private $outputDisabled = false;
  87647. private $stdout;
  87648. private $stderr;
  87649. private $process;
  87650. private $status = self::STATUS_READY;
  87651. private $incrementalOutputOffset = 0;
  87652. private $incrementalErrorOutputOffset = 0;
  87653. private $tty = false;
  87654. private $pty;
  87655. private $options = ['suppress_errors' => true, 'bypass_shell' => true];
  87656. private $useFileHandles = false;
  87657. private $processPipes;
  87658. private $latestSignal;
  87659. private $cachedExitCode;
  87660. private static $sigchild;
  87661. public static $exitCodes = [
  87662. 0 => 'OK',
  87663. 1 => 'General error',
  87664. 2 => 'Misuse of shell builtins',
  87665. 126 => 'Invoked command cannot execute',
  87666. 127 => 'Command not found',
  87667. 128 => 'Invalid exit argument',
  87668. 129 => 'Hangup',
  87669. 130 => 'Interrupt',
  87670. 131 => 'Quit and dump core',
  87671. 132 => 'Illegal instruction',
  87672. 133 => 'Trace/breakpoint trap',
  87673. 134 => 'Process aborted',
  87674. 135 => 'Bus error: "access to undefined portion of memory object"',
  87675. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  87676. 137 => 'Kill (terminate immediately)',
  87677. 138 => 'User-defined 1',
  87678. 139 => 'Segmentation violation',
  87679. 140 => 'User-defined 2',
  87680. 141 => 'Write to pipe with no one reading',
  87681. 142 => 'Signal raised by alarm',
  87682. 143 => 'Termination (request to terminate)',
  87683. 145 => 'Child process terminated, stopped (or continued*)',
  87684. 146 => 'Continue if stopped',
  87685. 147 => 'Stop executing temporarily',
  87686. 148 => 'Terminal stop signal',
  87687. 149 => 'Background process attempting to read from tty ("in")',
  87688. 150 => 'Background process attempting to write to tty ("out")',
  87689. 151 => 'Urgent data available on socket',
  87690. 152 => 'CPU time limit exceeded',
  87691. 153 => 'File size limit exceeded',
  87692. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  87693. 155 => 'Profiling timer expired',
  87694. 157 => 'Pollable event',
  87695. 159 => 'Bad syscall',
  87696. ];
  87697. public function __construct(array $command, ?string $cwd = null, ?array $env = null, $input = null, ?float $timeout = 60)
  87698. {
  87699. if (!\function_exists('proc_open')) {
  87700. throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.');
  87701. }
  87702. $this->commandline = $command;
  87703. $this->cwd = $cwd;
  87704. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  87705. $this->cwd = getcwd();
  87706. }
  87707. if (null !== $env) {
  87708. $this->setEnv($env);
  87709. }
  87710. $this->setInput($input);
  87711. $this->setTimeout($timeout);
  87712. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  87713. $this->pty = false;
  87714. }
  87715. public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, $input = null, ?float $timeout = 60)
  87716. {
  87717. $process = new static([], $cwd, $env, $input, $timeout);
  87718. $process->commandline = $command;
  87719. return $process;
  87720. }
  87721. public function __sleep()
  87722. {
  87723. throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
  87724. }
  87725. public function __wakeup()
  87726. {
  87727. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  87728. }
  87729. public function __destruct()
  87730. {
  87731. if ($this->options['create_new_console'] ?? false) {
  87732. $this->processPipes->close();
  87733. } else {
  87734. $this->stop(0);
  87735. }
  87736. }
  87737. public function __clone()
  87738. {
  87739. $this->resetProcessData();
  87740. }
  87741. public function run(?callable $callback = null, array $env = []): int
  87742. {
  87743. $this->start($callback, $env);
  87744. return $this->wait();
  87745. }
  87746. public function mustRun(?callable $callback = null, array $env = []): self
  87747. {
  87748. if (0 !== $this->run($callback, $env)) {
  87749. throw new ProcessFailedException($this);
  87750. }
  87751. return $this;
  87752. }
  87753. public function start(?callable $callback = null, array $env = [])
  87754. {
  87755. if ($this->isRunning()) {
  87756. throw new RuntimeException('Process is already running.');
  87757. }
  87758. $this->resetProcessData();
  87759. $this->starttime = $this->lastOutputTime = microtime(true);
  87760. $this->callback = $this->buildCallback($callback);
  87761. $this->hasCallback = null !== $callback;
  87762. $descriptors = $this->getDescriptors();
  87763. if ($this->env) {
  87764. $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env;
  87765. }
  87766. $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $this->getDefaultEnv();
  87767. if (\is_array($commandline = $this->commandline)) {
  87768. $commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline));
  87769. if ('\\' !== \DIRECTORY_SEPARATOR) {
  87770. $commandline = 'exec '.$commandline;
  87771. }
  87772. } else {
  87773. $commandline = $this->replacePlaceholders($commandline, $env);
  87774. }
  87775. if ('\\' === \DIRECTORY_SEPARATOR) {
  87776. $commandline = $this->prepareWindowsCommandLine($commandline, $env);
  87777. } elseif (!$this->useFileHandles && $this->isSigchildEnabled()) {
  87778. $descriptors[3] = ['pipe', 'w'];
  87779. $commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  87780. $commandline .= 'pid=$!; echo $pid >&3; wait $pid 2>/dev/null; code=$?; echo $code >&3; exit $code';
  87781. $ptsWorkaround = fopen(__FILE__, 'r');
  87782. }
  87783. $envPairs = [];
  87784. foreach ($env as $k => $v) {
  87785. if (false !== $v && false === \in_array($k, ['argc', 'argv', 'ARGC', 'ARGV'], true)) {
  87786. $envPairs[] = $k.'='.$v;
  87787. }
  87788. }
  87789. if (!is_dir($this->cwd)) {
  87790. throw new RuntimeException(sprintf('The provided cwd "%s" does not exist.', $this->cwd));
  87791. }
  87792. $this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
  87793. if (!$this->process) {
  87794. throw new RuntimeException('Unable to launch a new process.');
  87795. }
  87796. $this->status = self::STATUS_STARTED;
  87797. if (isset($descriptors[3])) {
  87798. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  87799. }
  87800. if ($this->tty) {
  87801. return;
  87802. }
  87803. $this->updateStatus(false);
  87804. $this->checkTimeout();
  87805. }
  87806. public function restart(?callable $callback = null, array $env = []): self
  87807. {
  87808. if ($this->isRunning()) {
  87809. throw new RuntimeException('Process is already running.');
  87810. }
  87811. $process = clone $this;
  87812. $process->start($callback, $env);
  87813. return $process;
  87814. }
  87815. public function wait(?callable $callback = null)
  87816. {
  87817. $this->requireProcessIsStarted(__FUNCTION__);
  87818. $this->updateStatus(false);
  87819. if (null !== $callback) {
  87820. if (!$this->processPipes->haveReadSupport()) {
  87821. $this->stop(0);
  87822. throw new LogicException('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::wait".');
  87823. }
  87824. $this->callback = $this->buildCallback($callback);
  87825. }
  87826. do {
  87827. $this->checkTimeout();
  87828. $running = $this->isRunning() && ('\\' === \DIRECTORY_SEPARATOR || $this->processPipes->areOpen());
  87829. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  87830. } while ($running);
  87831. while ($this->isRunning()) {
  87832. $this->checkTimeout();
  87833. usleep(1000);
  87834. }
  87835. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  87836. throw new ProcessSignaledException($this);
  87837. }
  87838. return $this->exitcode;
  87839. }
  87840. public function waitUntil(callable $callback): bool
  87841. {
  87842. $this->requireProcessIsStarted(__FUNCTION__);
  87843. $this->updateStatus(false);
  87844. if (!$this->processPipes->haveReadSupport()) {
  87845. $this->stop(0);
  87846. throw new LogicException('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::waitUntil".');
  87847. }
  87848. $callback = $this->buildCallback($callback);
  87849. $ready = false;
  87850. while (true) {
  87851. $this->checkTimeout();
  87852. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  87853. $output = $this->processPipes->readAndWrite($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  87854. foreach ($output as $type => $data) {
  87855. if (3 !== $type) {
  87856. $ready = $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data) || $ready;
  87857. } elseif (!isset($this->fallbackStatus['signaled'])) {
  87858. $this->fallbackStatus['exitcode'] = (int) $data;
  87859. }
  87860. }
  87861. if ($ready) {
  87862. return true;
  87863. }
  87864. if (!$running) {
  87865. return false;
  87866. }
  87867. usleep(1000);
  87868. }
  87869. }
  87870. public function getPid()
  87871. {
  87872. return $this->isRunning() ? $this->processInformation['pid'] : null;
  87873. }
  87874. public function signal(int $signal)
  87875. {
  87876. $this->doSignal($signal, true);
  87877. return $this;
  87878. }
  87879. public function disableOutput()
  87880. {
  87881. if ($this->isRunning()) {
  87882. throw new RuntimeException('Disabling output while the process is running is not possible.');
  87883. }
  87884. if (null !== $this->idleTimeout) {
  87885. throw new LogicException('Output cannot be disabled while an idle timeout is set.');
  87886. }
  87887. $this->outputDisabled = true;
  87888. return $this;
  87889. }
  87890. public function enableOutput()
  87891. {
  87892. if ($this->isRunning()) {
  87893. throw new RuntimeException('Enabling output while the process is running is not possible.');
  87894. }
  87895. $this->outputDisabled = false;
  87896. return $this;
  87897. }
  87898. public function isOutputDisabled()
  87899. {
  87900. return $this->outputDisabled;
  87901. }
  87902. public function getOutput()
  87903. {
  87904. $this->readPipesForOutput(__FUNCTION__);
  87905. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  87906. return '';
  87907. }
  87908. return $ret;
  87909. }
  87910. public function getIncrementalOutput()
  87911. {
  87912. $this->readPipesForOutput(__FUNCTION__);
  87913. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  87914. $this->incrementalOutputOffset = ftell($this->stdout);
  87915. if (false === $latest) {
  87916. return '';
  87917. }
  87918. return $latest;
  87919. }
  87920. #[\ReturnTypeWillChange]
  87921. public function getIterator(int $flags = 0)
  87922. {
  87923. $this->readPipesForOutput(__FUNCTION__, false);
  87924. $clearOutput = !(self::ITER_KEEP_OUTPUT & $flags);
  87925. $blocking = !(self::ITER_NON_BLOCKING & $flags);
  87926. $yieldOut = !(self::ITER_SKIP_OUT & $flags);
  87927. $yieldErr = !(self::ITER_SKIP_ERR & $flags);
  87928. while (null !== $this->callback || ($yieldOut && !feof($this->stdout)) || ($yieldErr && !feof($this->stderr))) {
  87929. if ($yieldOut) {
  87930. $out = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  87931. if (isset($out[0])) {
  87932. if ($clearOutput) {
  87933. $this->clearOutput();
  87934. } else {
  87935. $this->incrementalOutputOffset = ftell($this->stdout);
  87936. }
  87937. yield self::OUT => $out;
  87938. }
  87939. }
  87940. if ($yieldErr) {
  87941. $err = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  87942. if (isset($err[0])) {
  87943. if ($clearOutput) {
  87944. $this->clearErrorOutput();
  87945. } else {
  87946. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  87947. }
  87948. yield self::ERR => $err;
  87949. }
  87950. }
  87951. if (!$blocking && !isset($out[0]) && !isset($err[0])) {
  87952. yield self::OUT => '';
  87953. }
  87954. $this->checkTimeout();
  87955. $this->readPipesForOutput(__FUNCTION__, $blocking);
  87956. }
  87957. }
  87958. public function clearOutput()
  87959. {
  87960. ftruncate($this->stdout, 0);
  87961. fseek($this->stdout, 0);
  87962. $this->incrementalOutputOffset = 0;
  87963. return $this;
  87964. }
  87965. public function getErrorOutput()
  87966. {
  87967. $this->readPipesForOutput(__FUNCTION__);
  87968. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  87969. return '';
  87970. }
  87971. return $ret;
  87972. }
  87973. public function getIncrementalErrorOutput()
  87974. {
  87975. $this->readPipesForOutput(__FUNCTION__);
  87976. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  87977. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  87978. if (false === $latest) {
  87979. return '';
  87980. }
  87981. return $latest;
  87982. }
  87983. public function clearErrorOutput()
  87984. {
  87985. ftruncate($this->stderr, 0);
  87986. fseek($this->stderr, 0);
  87987. $this->incrementalErrorOutputOffset = 0;
  87988. return $this;
  87989. }
  87990. public function getExitCode()
  87991. {
  87992. $this->updateStatus(false);
  87993. return $this->exitcode;
  87994. }
  87995. public function getExitCodeText()
  87996. {
  87997. if (null === $exitcode = $this->getExitCode()) {
  87998. return null;
  87999. }
  88000. return self::$exitCodes[$exitcode] ?? 'Unknown error';
  88001. }
  88002. public function isSuccessful()
  88003. {
  88004. return 0 === $this->getExitCode();
  88005. }
  88006. public function hasBeenSignaled()
  88007. {
  88008. $this->requireProcessIsTerminated(__FUNCTION__);
  88009. return $this->processInformation['signaled'];
  88010. }
  88011. public function getTermSignal()
  88012. {
  88013. $this->requireProcessIsTerminated(__FUNCTION__);
  88014. if ($this->isSigchildEnabled() && -1 === $this->processInformation['termsig']) {
  88015. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal cannot be retrieved.');
  88016. }
  88017. return $this->processInformation['termsig'];
  88018. }
  88019. public function hasBeenStopped()
  88020. {
  88021. $this->requireProcessIsTerminated(__FUNCTION__);
  88022. return $this->processInformation['stopped'];
  88023. }
  88024. public function getStopSignal()
  88025. {
  88026. $this->requireProcessIsTerminated(__FUNCTION__);
  88027. return $this->processInformation['stopsig'];
  88028. }
  88029. public function isRunning()
  88030. {
  88031. if (self::STATUS_STARTED !== $this->status) {
  88032. return false;
  88033. }
  88034. $this->updateStatus(false);
  88035. return $this->processInformation['running'];
  88036. }
  88037. public function isStarted()
  88038. {
  88039. return self::STATUS_READY != $this->status;
  88040. }
  88041. public function isTerminated()
  88042. {
  88043. $this->updateStatus(false);
  88044. return self::STATUS_TERMINATED == $this->status;
  88045. }
  88046. public function getStatus()
  88047. {
  88048. $this->updateStatus(false);
  88049. return $this->status;
  88050. }
  88051. public function stop(float $timeout = 10, ?int $signal = null)
  88052. {
  88053. $timeoutMicro = microtime(true) + $timeout;
  88054. if ($this->isRunning()) {
  88055. $this->doSignal(15, false);
  88056. do {
  88057. usleep(1000);
  88058. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  88059. if ($this->isRunning()) {
  88060. $this->doSignal($signal ?: 9, false);
  88061. }
  88062. }
  88063. if ($this->isRunning()) {
  88064. if (isset($this->fallbackStatus['pid'])) {
  88065. unset($this->fallbackStatus['pid']);
  88066. return $this->stop(0, $signal);
  88067. }
  88068. $this->close();
  88069. }
  88070. return $this->exitcode;
  88071. }
  88072. public function addOutput(string $line)
  88073. {
  88074. $this->lastOutputTime = microtime(true);
  88075. fseek($this->stdout, 0, \SEEK_END);
  88076. fwrite($this->stdout, $line);
  88077. fseek($this->stdout, $this->incrementalOutputOffset);
  88078. }
  88079. public function addErrorOutput(string $line)
  88080. {
  88081. $this->lastOutputTime = microtime(true);
  88082. fseek($this->stderr, 0, \SEEK_END);
  88083. fwrite($this->stderr, $line);
  88084. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  88085. }
  88086. public function getLastOutputTime(): ?float
  88087. {
  88088. return $this->lastOutputTime;
  88089. }
  88090. public function getCommandLine()
  88091. {
  88092. return \is_array($this->commandline) ? implode(' ', array_map([$this, 'escapeArgument'], $this->commandline)) : $this->commandline;
  88093. }
  88094. public function getTimeout()
  88095. {
  88096. return $this->timeout;
  88097. }
  88098. public function getIdleTimeout()
  88099. {
  88100. return $this->idleTimeout;
  88101. }
  88102. public function setTimeout(?float $timeout)
  88103. {
  88104. $this->timeout = $this->validateTimeout($timeout);
  88105. return $this;
  88106. }
  88107. public function setIdleTimeout(?float $timeout)
  88108. {
  88109. if (null !== $timeout && $this->outputDisabled) {
  88110. throw new LogicException('Idle timeout cannot be set while the output is disabled.');
  88111. }
  88112. $this->idleTimeout = $this->validateTimeout($timeout);
  88113. return $this;
  88114. }
  88115. public function setTty(bool $tty)
  88116. {
  88117. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  88118. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  88119. }
  88120. if ($tty && !self::isTtySupported()) {
  88121. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  88122. }
  88123. $this->tty = $tty;
  88124. return $this;
  88125. }
  88126. public function isTty()
  88127. {
  88128. return $this->tty;
  88129. }
  88130. public function setPty(bool $bool)
  88131. {
  88132. $this->pty = $bool;
  88133. return $this;
  88134. }
  88135. public function isPty()
  88136. {
  88137. return $this->pty;
  88138. }
  88139. public function getWorkingDirectory()
  88140. {
  88141. if (null === $this->cwd) {
  88142. return getcwd() ?: null;
  88143. }
  88144. return $this->cwd;
  88145. }
  88146. public function setWorkingDirectory(string $cwd)
  88147. {
  88148. $this->cwd = $cwd;
  88149. return $this;
  88150. }
  88151. public function getEnv()
  88152. {
  88153. return $this->env;
  88154. }
  88155. public function setEnv(array $env)
  88156. {
  88157. $this->env = $env;
  88158. return $this;
  88159. }
  88160. public function getInput()
  88161. {
  88162. return $this->input;
  88163. }
  88164. public function setInput($input)
  88165. {
  88166. if ($this->isRunning()) {
  88167. throw new LogicException('Input cannot be set while the process is running.');
  88168. }
  88169. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  88170. return $this;
  88171. }
  88172. public function checkTimeout()
  88173. {
  88174. if (self::STATUS_STARTED !== $this->status) {
  88175. return;
  88176. }
  88177. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  88178. $this->stop(0);
  88179. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  88180. }
  88181. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  88182. $this->stop(0);
  88183. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  88184. }
  88185. }
  88186. public function getStartTime(): float
  88187. {
  88188. if (!$this->isStarted()) {
  88189. throw new LogicException('Start time is only available after process start.');
  88190. }
  88191. return $this->starttime;
  88192. }
  88193. public function setOptions(array $options)
  88194. {
  88195. if ($this->isRunning()) {
  88196. throw new RuntimeException('Setting options while the process is running is not possible.');
  88197. }
  88198. $defaultOptions = $this->options;
  88199. $existingOptions = ['blocking_pipes', 'create_process_group', 'create_new_console'];
  88200. foreach ($options as $key => $value) {
  88201. if (!\in_array($key, $existingOptions)) {
  88202. $this->options = $defaultOptions;
  88203. throw new LogicException(sprintf('Invalid option "%s" passed to "%s()". Supported options are "%s".', $key, __METHOD__, implode('", "', $existingOptions)));
  88204. }
  88205. $this->options[$key] = $value;
  88206. }
  88207. }
  88208. public static function isTtySupported(): bool
  88209. {
  88210. static $isTtySupported;
  88211. if (null === $isTtySupported) {
  88212. $isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
  88213. }
  88214. return $isTtySupported;
  88215. }
  88216. public static function isPtySupported()
  88217. {
  88218. static $result;
  88219. if (null !== $result) {
  88220. return $result;
  88221. }
  88222. if ('\\' === \DIRECTORY_SEPARATOR) {
  88223. return $result = false;
  88224. }
  88225. return $result = (bool) @proc_open('echo 1 >/dev/null', [['pty'], ['pty'], ['pty']], $pipes);
  88226. }
  88227. private function getDescriptors(): array
  88228. {
  88229. if ($this->input instanceof \Iterator) {
  88230. $this->input->rewind();
  88231. }
  88232. if ('\\' === \DIRECTORY_SEPARATOR) {
  88233. $this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback);
  88234. } else {
  88235. $this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback);
  88236. }
  88237. return $this->processPipes->getDescriptors();
  88238. }
  88239. protected function buildCallback(?callable $callback = null)
  88240. {
  88241. if ($this->outputDisabled) {
  88242. return function ($type, $data) use ($callback): bool {
  88243. return null !== $callback && $callback($type, $data);
  88244. };
  88245. }
  88246. $out = self::OUT;
  88247. return function ($type, $data) use ($callback, $out): bool {
  88248. if ($out == $type) {
  88249. $this->addOutput($data);
  88250. } else {
  88251. $this->addErrorOutput($data);
  88252. }
  88253. return null !== $callback && $callback($type, $data);
  88254. };
  88255. }
  88256. protected function updateStatus(bool $blocking)
  88257. {
  88258. if (self::STATUS_STARTED !== $this->status) {
  88259. return;
  88260. }
  88261. $this->processInformation = proc_get_status($this->process);
  88262. $running = $this->processInformation['running'];
  88263. if (\PHP_VERSION_ID < 80300) {
  88264. if (!isset($this->cachedExitCode) && !$running && -1 !== $this->processInformation['exitcode']) {
  88265. $this->cachedExitCode = $this->processInformation['exitcode'];
  88266. }
  88267. if (isset($this->cachedExitCode) && !$running && -1 === $this->processInformation['exitcode']) {
  88268. $this->processInformation['exitcode'] = $this->cachedExitCode;
  88269. }
  88270. }
  88271. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  88272. if ($this->fallbackStatus && $this->isSigchildEnabled()) {
  88273. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  88274. }
  88275. if (!$running) {
  88276. $this->close();
  88277. }
  88278. }
  88279. protected function isSigchildEnabled()
  88280. {
  88281. if (null !== self::$sigchild) {
  88282. return self::$sigchild;
  88283. }
  88284. if (!\function_exists('phpinfo')) {
  88285. return self::$sigchild = false;
  88286. }
  88287. ob_start();
  88288. phpinfo(\INFO_GENERAL);
  88289. return self::$sigchild = str_contains(ob_get_clean(), '--enable-sigchild');
  88290. }
  88291. private function readPipesForOutput(string $caller, bool $blocking = false)
  88292. {
  88293. if ($this->outputDisabled) {
  88294. throw new LogicException('Output has been disabled.');
  88295. }
  88296. $this->requireProcessIsStarted($caller);
  88297. $this->updateStatus($blocking);
  88298. }
  88299. private function validateTimeout(?float $timeout): ?float
  88300. {
  88301. $timeout = (float) $timeout;
  88302. if (0.0 === $timeout) {
  88303. $timeout = null;
  88304. } elseif ($timeout < 0) {
  88305. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  88306. }
  88307. return $timeout;
  88308. }
  88309. private function readPipes(bool $blocking, bool $close)
  88310. {
  88311. $result = $this->processPipes->readAndWrite($blocking, $close);
  88312. $callback = $this->callback;
  88313. foreach ($result as $type => $data) {
  88314. if (3 !== $type) {
  88315. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  88316. } elseif (!isset($this->fallbackStatus['signaled'])) {
  88317. $this->fallbackStatus['exitcode'] = (int) $data;
  88318. }
  88319. }
  88320. }
  88321. private function close(): int
  88322. {
  88323. $this->processPipes->close();
  88324. if ($this->process) {
  88325. proc_close($this->process);
  88326. $this->process = null;
  88327. }
  88328. $this->exitcode = $this->processInformation['exitcode'];
  88329. $this->status = self::STATUS_TERMINATED;
  88330. if (-1 === $this->exitcode) {
  88331. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  88332. $this->exitcode = 128 + $this->processInformation['termsig'];
  88333. } elseif ($this->isSigchildEnabled()) {
  88334. $this->processInformation['signaled'] = true;
  88335. $this->processInformation['termsig'] = -1;
  88336. }
  88337. }
  88338. $this->callback = null;
  88339. return $this->exitcode;
  88340. }
  88341. private function resetProcessData()
  88342. {
  88343. $this->starttime = null;
  88344. $this->callback = null;
  88345. $this->exitcode = null;
  88346. $this->fallbackStatus = [];
  88347. $this->processInformation = null;
  88348. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+');
  88349. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+');
  88350. $this->process = null;
  88351. $this->latestSignal = null;
  88352. $this->status = self::STATUS_READY;
  88353. $this->incrementalOutputOffset = 0;
  88354. $this->incrementalErrorOutputOffset = 0;
  88355. }
  88356. private function doSignal(int $signal, bool $throwException): bool
  88357. {
  88358. if (null === $pid = $this->getPid()) {
  88359. if ($throwException) {
  88360. throw new LogicException('Cannot send signal on a non running process.');
  88361. }
  88362. return false;
  88363. }
  88364. if ('\\' === \DIRECTORY_SEPARATOR) {
  88365. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  88366. if ($exitCode && $this->isRunning()) {
  88367. if ($throwException) {
  88368. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  88369. }
  88370. return false;
  88371. }
  88372. } else {
  88373. if (!$this->isSigchildEnabled()) {
  88374. $ok = @proc_terminate($this->process, $signal);
  88375. } elseif (\function_exists('posix_kill')) {
  88376. $ok = @posix_kill($pid, $signal);
  88377. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), [2 => ['pipe', 'w']], $pipes)) {
  88378. $ok = false === fgets($pipes[2]);
  88379. }
  88380. if (!$ok) {
  88381. if ($throwException) {
  88382. throw new RuntimeException(sprintf('Error while sending signal "%s".', $signal));
  88383. }
  88384. return false;
  88385. }
  88386. }
  88387. $this->latestSignal = $signal;
  88388. $this->fallbackStatus['signaled'] = true;
  88389. $this->fallbackStatus['exitcode'] = -1;
  88390. $this->fallbackStatus['termsig'] = $this->latestSignal;
  88391. return true;
  88392. }
  88393. private function prepareWindowsCommandLine(string $cmd, array &$env): string
  88394. {
  88395. $uid = uniqid('', true);
  88396. $varCount = 0;
  88397. $varCache = [];
  88398. $cmd = preg_replace_callback(
  88399. '/"(?:(
  88400. [^"%!^]*+
  88401. (?:
  88402. (?: !LF! | "(?:\^[%!^])?+" )
  88403. [^"%!^]*+
  88404. )++
  88405. ) | [^"]*+ )"/x',
  88406. function ($m) use (&$env, &$varCache, &$varCount, $uid) {
  88407. if (!isset($m[1])) {
  88408. return $m[0];
  88409. }
  88410. if (isset($varCache[$m[0]])) {
  88411. return $varCache[$m[0]];
  88412. }
  88413. if (str_contains($value = $m[1], "\0")) {
  88414. $value = str_replace("\0", '?', $value);
  88415. }
  88416. if (false === strpbrk($value, "\"%!\n")) {
  88417. return '"'.$value.'"';
  88418. }
  88419. $value = str_replace(['!LF!', '"^!"', '"^%"', '"^^"', '""'], ["\n", '!', '%', '^', '"'], $value);
  88420. $value = '"'.preg_replace('/(\\\\*)"/', '$1$1\\"', $value).'"';
  88421. $var = $uid.++$varCount;
  88422. $env[$var] = $value;
  88423. return $varCache[$m[0]] = '!'.$var.'!';
  88424. },
  88425. $cmd
  88426. );
  88427. static $comSpec;
  88428. if (!$comSpec && $comSpec = (new ExecutableFinder())->find('cmd.exe')) {
  88429. $comSpec = '"'.preg_replace('{(\\\\*+)"}', '$1$1\"', $comSpec) .'"';
  88430. }
  88431. $cmd = ($comSpec ?? 'cmd').' /V:ON /E:ON /D /C ('.str_replace("\n", ' ', $cmd).')';
  88432. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  88433. $cmd .= ' '.$offset.'>"'.$filename.'"';
  88434. }
  88435. return $cmd;
  88436. }
  88437. private function requireProcessIsStarted(string $functionName)
  88438. {
  88439. if (!$this->isStarted()) {
  88440. throw new LogicException(sprintf('Process must be started before calling "%s()".', $functionName));
  88441. }
  88442. }
  88443. private function requireProcessIsTerminated(string $functionName)
  88444. {
  88445. if (!$this->isTerminated()) {
  88446. throw new LogicException(sprintf('Process must be terminated before calling "%s()".', $functionName));
  88447. }
  88448. }
  88449. private function escapeArgument(?string $argument): string
  88450. {
  88451. if ('' === $argument || null === $argument) {
  88452. return '""';
  88453. }
  88454. if ('\\' !== \DIRECTORY_SEPARATOR) {
  88455. return "'".str_replace("'", "'\\''", $argument)."'";
  88456. }
  88457. if (str_contains($argument, "\0")) {
  88458. $argument = str_replace("\0", '?', $argument);
  88459. }
  88460. if (!preg_match('/[()%!^"<>&|\s]/', $argument)) {
  88461. return $argument;
  88462. }
  88463. $argument = preg_replace('/(\\\\+)$/', '$1$1', $argument);
  88464. return '"'.str_replace(['"', '^', '%', '!', "\n"], ['""', '"^^"', '"^%"', '"^!"', '!LF!'], $argument).'"';
  88465. }
  88466. private function replacePlaceholders(string $commandline, array $env)
  88467. {
  88468. return preg_replace_callback('/"\$\{:([_a-zA-Z]++[_a-zA-Z0-9]*+)\}"/', function ($matches) use ($commandline, $env) {
  88469. if (!isset($env[$matches[1]]) || false === $env[$matches[1]]) {
  88470. throw new InvalidArgumentException(sprintf('Command line is missing a value for parameter "%s": ', $matches[1]).$commandline);
  88471. }
  88472. return $this->escapeArgument($env[$matches[1]]);
  88473. }, $commandline);
  88474. }
  88475. private function getDefaultEnv(): array
  88476. {
  88477. $env = getenv();
  88478. $env = ('\\' === \DIRECTORY_SEPARATOR ? array_intersect_ukey($env, $_SERVER, 'strcasecmp') : array_intersect_key($env, $_SERVER)) ?: $env;
  88479. return $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, 'strcasecmp') : $env);
  88480. }
  88481. }
  88482. <?php
  88483. namespace Symfony\Component\Process;
  88484. use Symfony\Component\Process\Exception\InvalidArgumentException;
  88485. class ProcessUtils
  88486. {
  88487. private function __construct()
  88488. {
  88489. }
  88490. public static function validateInput(string $caller, $input)
  88491. {
  88492. if (null !== $input) {
  88493. if (\is_resource($input)) {
  88494. return $input;
  88495. }
  88496. if (\is_string($input)) {
  88497. return $input;
  88498. }
  88499. if (\is_scalar($input)) {
  88500. return (string) $input;
  88501. }
  88502. if ($input instanceof Process) {
  88503. return $input->getIterator($input::ITER_SKIP_ERR);
  88504. }
  88505. if ($input instanceof \Iterator) {
  88506. return $input;
  88507. }
  88508. if ($input instanceof \Traversable) {
  88509. return new \IteratorIterator($input);
  88510. }
  88511. throw new InvalidArgumentException(sprintf('"%s" only accepts strings, Traversable objects or stream resources.', $caller));
  88512. }
  88513. return $input;
  88514. }
  88515. }
  88516. <?php
  88517. namespace Symfony\Contracts\Service\Attribute;
  88518. #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
  88519. final class Required
  88520. {
  88521. }
  88522. <?php
  88523. namespace Symfony\Contracts\Service\Attribute;
  88524. use Symfony\Contracts\Service\ServiceSubscriberTrait;
  88525. #[\Attribute(\Attribute::TARGET_METHOD)]
  88526. final class SubscribedService
  88527. {
  88528. public function __construct(
  88529. public ?string $key = null
  88530. ) {
  88531. }
  88532. }
  88533. Copyright (c) 2018-present Fabien Potencier
  88534. Permission is hereby granted, free of charge, to any person obtaining a copy
  88535. of this software and associated documentation files (the "Software"), to deal
  88536. in the Software without restriction, including without limitation the rights
  88537. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  88538. copies of the Software, and to permit persons to whom the Software is furnished
  88539. to do so, subject to the following conditions:
  88540. The above copyright notice and this permission notice shall be included in all
  88541. copies or substantial portions of the Software.
  88542. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  88543. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  88544. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  88545. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  88546. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  88547. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  88548. THE SOFTWARE.
  88549. <?php
  88550. namespace Symfony\Contracts\Service;
  88551. interface ResetInterface
  88552. {
  88553. public function reset();
  88554. }
  88555. <?php
  88556. namespace Symfony\Contracts\Service;
  88557. use Psr\Container\ContainerExceptionInterface;
  88558. use Psr\Container\NotFoundExceptionInterface;
  88559. class_exists(ContainerExceptionInterface::class);
  88560. class_exists(NotFoundExceptionInterface::class);
  88561. trait ServiceLocatorTrait
  88562. {
  88563. private $factories;
  88564. private $loading = [];
  88565. private $providedTypes;
  88566. public function __construct(array $factories)
  88567. {
  88568. $this->factories = $factories;
  88569. }
  88570. public function has(string $id)
  88571. {
  88572. return isset($this->factories[$id]);
  88573. }
  88574. public function get(string $id)
  88575. {
  88576. if (!isset($this->factories[$id])) {
  88577. throw $this->createNotFoundException($id);
  88578. }
  88579. if (isset($this->loading[$id])) {
  88580. $ids = array_values($this->loading);
  88581. $ids = \array_slice($this->loading, array_search($id, $ids));
  88582. $ids[] = $id;
  88583. throw $this->createCircularReferenceException($id, $ids);
  88584. }
  88585. $this->loading[$id] = $id;
  88586. try {
  88587. return $this->factories[$id]($this);
  88588. } finally {
  88589. unset($this->loading[$id]);
  88590. }
  88591. }
  88592. public function getProvidedServices(): array
  88593. {
  88594. if (null === $this->providedTypes) {
  88595. $this->providedTypes = [];
  88596. foreach ($this->factories as $name => $factory) {
  88597. if (!\is_callable($factory)) {
  88598. $this->providedTypes[$name] = '?';
  88599. } else {
  88600. $type = (new \ReflectionFunction($factory))->getReturnType();
  88601. $this->providedTypes[$name] = $type ? ($type->allowsNull() ? '?' : '').($type instanceof \ReflectionNamedType ? $type->getName() : $type) : '?';
  88602. }
  88603. }
  88604. }
  88605. return $this->providedTypes;
  88606. }
  88607. private function createNotFoundException(string $id): NotFoundExceptionInterface
  88608. {
  88609. if (!$alternatives = array_keys($this->factories)) {
  88610. $message = 'is empty...';
  88611. } else {
  88612. $last = array_pop($alternatives);
  88613. if ($alternatives) {
  88614. $message = sprintf('only knows about the "%s" and "%s" services.', implode('", "', $alternatives), $last);
  88615. } else {
  88616. $message = sprintf('only knows about the "%s" service.', $last);
  88617. }
  88618. }
  88619. if ($this->loading) {
  88620. $message = sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', end($this->loading), $id, $message);
  88621. } else {
  88622. $message = sprintf('Service "%s" not found: the current service locator %s', $id, $message);
  88623. }
  88624. return new class($message) extends \InvalidArgumentException implements NotFoundExceptionInterface {
  88625. };
  88626. }
  88627. private function createCircularReferenceException(string $id, array $path): ContainerExceptionInterface
  88628. {
  88629. return new class(sprintf('Circular reference detected for service "%s", path: "%s".', $id, implode(' -> ', $path))) extends \RuntimeException implements ContainerExceptionInterface {
  88630. };
  88631. }
  88632. }
  88633. <?php
  88634. namespace Symfony\Contracts\Service;
  88635. use Psr\Container\ContainerInterface;
  88636. interface ServiceProviderInterface extends ContainerInterface
  88637. {
  88638. public function getProvidedServices(): array;
  88639. }
  88640. <?php
  88641. namespace Symfony\Contracts\Service;
  88642. interface ServiceSubscriberInterface
  88643. {
  88644. public static function getSubscribedServices();
  88645. }
  88646. <?php
  88647. namespace Symfony\Contracts\Service;
  88648. use Psr\Container\ContainerInterface;
  88649. use Symfony\Contracts\Service\Attribute\SubscribedService;
  88650. trait ServiceSubscriberTrait
  88651. {
  88652. protected $container;
  88653. public static function getSubscribedServices(): array
  88654. {
  88655. $services = method_exists(get_parent_class(self::class) ?: '', __FUNCTION__) ? parent::getSubscribedServices() : [];
  88656. $attributeOptIn = false;
  88657. if (\PHP_VERSION_ID >= 80000) {
  88658. foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
  88659. if (self::class !== $method->getDeclaringClass()->name) {
  88660. continue;
  88661. }
  88662. if (!$attribute = $method->getAttributes(SubscribedService::class)[0] ?? null) {
  88663. continue;
  88664. }
  88665. if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
  88666. 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));
  88667. }
  88668. if (!$returnType = $method->getReturnType()) {
  88669. throw new \LogicException(sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class));
  88670. }
  88671. $serviceId = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType;
  88672. if ($returnType->allowsNull()) {
  88673. $serviceId = '?'.$serviceId;
  88674. }
  88675. $services[$attribute->newInstance()->key ?? self::class.'::'.$method->name] = $serviceId;
  88676. $attributeOptIn = true;
  88677. }
  88678. }
  88679. if (!$attributeOptIn) {
  88680. foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
  88681. if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
  88682. continue;
  88683. }
  88684. if (self::class !== $method->getDeclaringClass()->name) {
  88685. continue;
  88686. }
  88687. if (!($returnType = $method->getReturnType()) instanceof \ReflectionNamedType) {
  88688. continue;
  88689. }
  88690. if ($returnType->isBuiltin()) {
  88691. continue;
  88692. }
  88693. if (\PHP_VERSION_ID >= 80000) {
  88694. 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);
  88695. }
  88696. $services[self::class.'::'.$method->name] = '?'.($returnType instanceof \ReflectionNamedType ? $returnType->getName() : $returnType);
  88697. }
  88698. }
  88699. return $services;
  88700. }
  88701. public function setContainer(ContainerInterface $container)
  88702. {
  88703. $ret = null;
  88704. if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) {
  88705. $ret = parent::setContainer($container);
  88706. }
  88707. $this->container = $container;
  88708. return $ret;
  88709. }
  88710. }
  88711. <?php
  88712. namespace Symfony\Contracts\Service\Test;
  88713. class_alias(ServiceLocatorTestCase::class, ServiceLocatorTest::class);
  88714. if (false) {
  88715. class ServiceLocatorTest
  88716. {
  88717. }
  88718. }
  88719. <?php
  88720. namespace Symfony\Contracts\Service\Test;
  88721. use PHPUnit\Framework\TestCase;
  88722. use Psr\Container\ContainerInterface;
  88723. use Symfony\Contracts\Service\ServiceLocatorTrait;
  88724. abstract class ServiceLocatorTestCase extends TestCase
  88725. {
  88726. protected function getServiceLocator(array $factories)
  88727. {
  88728. return new class($factories) implements ContainerInterface {
  88729. use ServiceLocatorTrait;
  88730. };
  88731. }
  88732. public function testHas()
  88733. {
  88734. $locator = $this->getServiceLocator([
  88735. 'foo' => function () { return 'bar'; },
  88736. 'bar' => function () { return 'baz'; },
  88737. function () { return 'dummy'; },
  88738. ]);
  88739. $this->assertTrue($locator->has('foo'));
  88740. $this->assertTrue($locator->has('bar'));
  88741. $this->assertFalse($locator->has('dummy'));
  88742. }
  88743. public function testGet()
  88744. {
  88745. $locator = $this->getServiceLocator([
  88746. 'foo' => function () { return 'bar'; },
  88747. 'bar' => function () { return 'baz'; },
  88748. ]);
  88749. $this->assertSame('bar', $locator->get('foo'));
  88750. $this->assertSame('baz', $locator->get('bar'));
  88751. }
  88752. public function testGetDoesNotMemoize()
  88753. {
  88754. $i = 0;
  88755. $locator = $this->getServiceLocator([
  88756. 'foo' => function () use (&$i) {
  88757. ++$i;
  88758. return 'bar';
  88759. },
  88760. ]);
  88761. $this->assertSame('bar', $locator->get('foo'));
  88762. $this->assertSame('bar', $locator->get('foo'));
  88763. $this->assertSame(2, $i);
  88764. }
  88765. public function testThrowsOnUndefinedInternalService()
  88766. {
  88767. if (!$this->getExpectedException()) {
  88768. $this->expectException(\Psr\Container\NotFoundExceptionInterface::class);
  88769. $this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.');
  88770. }
  88771. $locator = $this->getServiceLocator([
  88772. 'foo' => function () use (&$locator) { return $locator->get('bar'); },
  88773. ]);
  88774. $locator->get('foo');
  88775. }
  88776. public function testThrowsOnCircularReference()
  88777. {
  88778. $this->expectException(\Psr\Container\ContainerExceptionInterface::class);
  88779. $this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".');
  88780. $locator = $this->getServiceLocator([
  88781. 'foo' => function () use (&$locator) { return $locator->get('bar'); },
  88782. 'bar' => function () use (&$locator) { return $locator->get('baz'); },
  88783. 'baz' => function () use (&$locator) { return $locator->get('bar'); },
  88784. ]);
  88785. $locator->get('foo');
  88786. }
  88787. }
  88788. <?php
  88789. namespace Symfony\Component\String;
  88790. use Symfony\Component\String\Exception\ExceptionInterface;
  88791. use Symfony\Component\String\Exception\InvalidArgumentException;
  88792. use Symfony\Component\String\Exception\RuntimeException;
  88793. abstract class AbstractString implements \Stringable, \JsonSerializable
  88794. {
  88795. public const PREG_PATTERN_ORDER = \PREG_PATTERN_ORDER;
  88796. public const PREG_SET_ORDER = \PREG_SET_ORDER;
  88797. public const PREG_OFFSET_CAPTURE = \PREG_OFFSET_CAPTURE;
  88798. public const PREG_UNMATCHED_AS_NULL = \PREG_UNMATCHED_AS_NULL;
  88799. public const PREG_SPLIT = 0;
  88800. public const PREG_SPLIT_NO_EMPTY = \PREG_SPLIT_NO_EMPTY;
  88801. public const PREG_SPLIT_DELIM_CAPTURE = \PREG_SPLIT_DELIM_CAPTURE;
  88802. public const PREG_SPLIT_OFFSET_CAPTURE = \PREG_SPLIT_OFFSET_CAPTURE;
  88803. protected $string = '';
  88804. protected $ignoreCase = false;
  88805. abstract public function __construct(string $string = '');
  88806. public static function unwrap(array $values): array
  88807. {
  88808. foreach ($values as $k => $v) {
  88809. if ($v instanceof self) {
  88810. $values[$k] = $v->__toString();
  88811. } elseif (\is_array($v) && $values[$k] !== $v = static::unwrap($v)) {
  88812. $values[$k] = $v;
  88813. }
  88814. }
  88815. return $values;
  88816. }
  88817. public static function wrap(array $values): array
  88818. {
  88819. $i = 0;
  88820. $keys = null;
  88821. foreach ($values as $k => $v) {
  88822. if (\is_string($k) && '' !== $k && $k !== $j = (string) new static($k)) {
  88823. $keys = $keys ?? array_keys($values);
  88824. $keys[$i] = $j;
  88825. }
  88826. if (\is_string($v)) {
  88827. $values[$k] = new static($v);
  88828. } elseif (\is_array($v) && $values[$k] !== $v = static::wrap($v)) {
  88829. $values[$k] = $v;
  88830. }
  88831. ++$i;
  88832. }
  88833. return null !== $keys ? array_combine($keys, $values) : $values;
  88834. }
  88835. public function after($needle, bool $includeNeedle = false, int $offset = 0): self
  88836. {
  88837. $str = clone $this;
  88838. $i = \PHP_INT_MAX;
  88839. foreach ((array) $needle as $n) {
  88840. $n = (string) $n;
  88841. $j = $this->indexOf($n, $offset);
  88842. if (null !== $j && $j < $i) {
  88843. $i = $j;
  88844. $str->string = $n;
  88845. }
  88846. }
  88847. if (\PHP_INT_MAX === $i) {
  88848. return $str;
  88849. }
  88850. if (!$includeNeedle) {
  88851. $i += $str->length();
  88852. }
  88853. return $this->slice($i);
  88854. }
  88855. public function afterLast($needle, bool $includeNeedle = false, int $offset = 0): self
  88856. {
  88857. $str = clone $this;
  88858. $i = null;
  88859. foreach ((array) $needle as $n) {
  88860. $n = (string) $n;
  88861. $j = $this->indexOfLast($n, $offset);
  88862. if (null !== $j && $j >= $i) {
  88863. $i = $offset = $j;
  88864. $str->string = $n;
  88865. }
  88866. }
  88867. if (null === $i) {
  88868. return $str;
  88869. }
  88870. if (!$includeNeedle) {
  88871. $i += $str->length();
  88872. }
  88873. return $this->slice($i);
  88874. }
  88875. abstract public function append(string ...$suffix): self;
  88876. public function before($needle, bool $includeNeedle = false, int $offset = 0): self
  88877. {
  88878. $str = clone $this;
  88879. $i = \PHP_INT_MAX;
  88880. foreach ((array) $needle as $n) {
  88881. $n = (string) $n;
  88882. $j = $this->indexOf($n, $offset);
  88883. if (null !== $j && $j < $i) {
  88884. $i = $j;
  88885. $str->string = $n;
  88886. }
  88887. }
  88888. if (\PHP_INT_MAX === $i) {
  88889. return $str;
  88890. }
  88891. if ($includeNeedle) {
  88892. $i += $str->length();
  88893. }
  88894. return $this->slice(0, $i);
  88895. }
  88896. public function beforeLast($needle, bool $includeNeedle = false, int $offset = 0): self
  88897. {
  88898. $str = clone $this;
  88899. $i = null;
  88900. foreach ((array) $needle as $n) {
  88901. $n = (string) $n;
  88902. $j = $this->indexOfLast($n, $offset);
  88903. if (null !== $j && $j >= $i) {
  88904. $i = $offset = $j;
  88905. $str->string = $n;
  88906. }
  88907. }
  88908. if (null === $i) {
  88909. return $str;
  88910. }
  88911. if ($includeNeedle) {
  88912. $i += $str->length();
  88913. }
  88914. return $this->slice(0, $i);
  88915. }
  88916. public function bytesAt(int $offset): array
  88917. {
  88918. $str = $this->slice($offset, 1);
  88919. return '' === $str->string ? [] : array_values(unpack('C*', $str->string));
  88920. }
  88921. abstract public function camel(): self;
  88922. abstract public function chunk(int $length = 1): array;
  88923. public function collapseWhitespace(): self
  88924. {
  88925. $str = clone $this;
  88926. $str->string = trim(preg_replace("/(?:[ \n\r\t\x0C]{2,}+|[\n\r\t\x0C])/", ' ', $str->string), " \n\r\t\x0C");
  88927. return $str;
  88928. }
  88929. public function containsAny($needle): bool
  88930. {
  88931. return null !== $this->indexOf($needle);
  88932. }
  88933. public function endsWith($suffix): bool
  88934. {
  88935. if (!\is_array($suffix) && !$suffix instanceof \Traversable) {
  88936. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  88937. }
  88938. foreach ($suffix as $s) {
  88939. if ($this->endsWith((string) $s)) {
  88940. return true;
  88941. }
  88942. }
  88943. return false;
  88944. }
  88945. public function ensureEnd(string $suffix): self
  88946. {
  88947. if (!$this->endsWith($suffix)) {
  88948. return $this->append($suffix);
  88949. }
  88950. $suffix = preg_quote($suffix);
  88951. $regex = '{('.$suffix.')(?:'.$suffix.')++$}D';
  88952. return $this->replaceMatches($regex.($this->ignoreCase ? 'i' : ''), '$1');
  88953. }
  88954. public function ensureStart(string $prefix): self
  88955. {
  88956. $prefix = new static($prefix);
  88957. if (!$this->startsWith($prefix)) {
  88958. return $this->prepend($prefix);
  88959. }
  88960. $str = clone $this;
  88961. $i = $prefixLen = $prefix->length();
  88962. while ($this->indexOf($prefix, $i) === $i) {
  88963. $str = $str->slice($prefixLen);
  88964. $i += $prefixLen;
  88965. }
  88966. return $str;
  88967. }
  88968. public function equalsTo($string): bool
  88969. {
  88970. if (!\is_array($string) && !$string instanceof \Traversable) {
  88971. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  88972. }
  88973. foreach ($string as $s) {
  88974. if ($this->equalsTo((string) $s)) {
  88975. return true;
  88976. }
  88977. }
  88978. return false;
  88979. }
  88980. abstract public function folded(): self;
  88981. public function ignoreCase(): self
  88982. {
  88983. $str = clone $this;
  88984. $str->ignoreCase = true;
  88985. return $str;
  88986. }
  88987. public function indexOf($needle, int $offset = 0): ?int
  88988. {
  88989. if (!\is_array($needle) && !$needle instanceof \Traversable) {
  88990. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  88991. }
  88992. $i = \PHP_INT_MAX;
  88993. foreach ($needle as $n) {
  88994. $j = $this->indexOf((string) $n, $offset);
  88995. if (null !== $j && $j < $i) {
  88996. $i = $j;
  88997. }
  88998. }
  88999. return \PHP_INT_MAX === $i ? null : $i;
  89000. }
  89001. public function indexOfLast($needle, int $offset = 0): ?int
  89002. {
  89003. if (!\is_array($needle) && !$needle instanceof \Traversable) {
  89004. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  89005. }
  89006. $i = null;
  89007. foreach ($needle as $n) {
  89008. $j = $this->indexOfLast((string) $n, $offset);
  89009. if (null !== $j && $j >= $i) {
  89010. $i = $offset = $j;
  89011. }
  89012. }
  89013. return $i;
  89014. }
  89015. public function isEmpty(): bool
  89016. {
  89017. return '' === $this->string;
  89018. }
  89019. abstract public function join(array $strings, ?string $lastGlue = null): self;
  89020. public function jsonSerialize(): string
  89021. {
  89022. return $this->string;
  89023. }
  89024. abstract public function length(): int;
  89025. abstract public function lower(): self;
  89026. abstract public function match(string $regexp, int $flags = 0, int $offset = 0): array;
  89027. abstract public function padBoth(int $length, string $padStr = ' '): self;
  89028. abstract public function padEnd(int $length, string $padStr = ' '): self;
  89029. abstract public function padStart(int $length, string $padStr = ' '): self;
  89030. abstract public function prepend(string ...$prefix): self;
  89031. public function repeat(int $multiplier): self
  89032. {
  89033. if (0 > $multiplier) {
  89034. throw new InvalidArgumentException(sprintf('Multiplier must be positive, %d given.', $multiplier));
  89035. }
  89036. $str = clone $this;
  89037. $str->string = str_repeat($str->string, $multiplier);
  89038. return $str;
  89039. }
  89040. abstract public function replace(string $from, string $to): self;
  89041. abstract public function replaceMatches(string $fromRegexp, $to): self;
  89042. abstract public function reverse(): self;
  89043. abstract public function slice(int $start = 0, ?int $length = null): self;
  89044. abstract public function snake(): self;
  89045. abstract public function splice(string $replacement, int $start = 0, ?int $length = null): self;
  89046. public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
  89047. {
  89048. if (null === $flags) {
  89049. throw new \TypeError('Split behavior when $flags is null must be implemented by child classes.');
  89050. }
  89051. if ($this->ignoreCase) {
  89052. $delimiter .= 'i';
  89053. }
  89054. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  89055. try {
  89056. if (false === $chunks = preg_split($delimiter, $this->string, $limit, $flags)) {
  89057. $lastError = preg_last_error();
  89058. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  89059. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  89060. throw new RuntimeException('Splitting failed with '.$k.'.');
  89061. }
  89062. }
  89063. throw new RuntimeException('Splitting failed with unknown error code.');
  89064. }
  89065. } finally {
  89066. restore_error_handler();
  89067. }
  89068. $str = clone $this;
  89069. if (self::PREG_SPLIT_OFFSET_CAPTURE & $flags) {
  89070. foreach ($chunks as &$chunk) {
  89071. $str->string = $chunk[0];
  89072. $chunk[0] = clone $str;
  89073. }
  89074. } else {
  89075. foreach ($chunks as &$chunk) {
  89076. $str->string = $chunk;
  89077. $chunk = clone $str;
  89078. }
  89079. }
  89080. return $chunks;
  89081. }
  89082. public function startsWith($prefix): bool
  89083. {
  89084. if (!\is_array($prefix) && !$prefix instanceof \Traversable) {
  89085. throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
  89086. }
  89087. foreach ($prefix as $prefix) {
  89088. if ($this->startsWith((string) $prefix)) {
  89089. return true;
  89090. }
  89091. }
  89092. return false;
  89093. }
  89094. abstract public function title(bool $allWords = false): self;
  89095. public function toByteString(?string $toEncoding = null): ByteString
  89096. {
  89097. $b = new ByteString();
  89098. $toEncoding = \in_array($toEncoding, ['utf8', 'utf-8', 'UTF8'], true) ? 'UTF-8' : $toEncoding;
  89099. if (null === $toEncoding || $toEncoding === $fromEncoding = $this instanceof AbstractUnicodeString || preg_match('//u', $b->string) ? 'UTF-8' : 'Windows-1252') {
  89100. $b->string = $this->string;
  89101. return $b;
  89102. }
  89103. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  89104. try {
  89105. try {
  89106. $b->string = mb_convert_encoding($this->string, $toEncoding, 'UTF-8');
  89107. } catch (InvalidArgumentException|\ValueError $e) {
  89108. if (!\function_exists('iconv')) {
  89109. if ($e instanceof \ValueError) {
  89110. throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
  89111. }
  89112. throw $e;
  89113. }
  89114. $b->string = iconv('UTF-8', $toEncoding, $this->string);
  89115. }
  89116. } finally {
  89117. restore_error_handler();
  89118. }
  89119. return $b;
  89120. }
  89121. public function toCodePointString(): CodePointString
  89122. {
  89123. return new CodePointString($this->string);
  89124. }
  89125. public function toString(): string
  89126. {
  89127. return $this->string;
  89128. }
  89129. public function toUnicodeString(): UnicodeString
  89130. {
  89131. return new UnicodeString($this->string);
  89132. }
  89133. abstract public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
  89134. abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
  89135. public function trimPrefix($prefix): self
  89136. {
  89137. if (\is_array($prefix) || $prefix instanceof \Traversable) {
  89138. foreach ($prefix as $s) {
  89139. $t = $this->trimPrefix($s);
  89140. if ($t->string !== $this->string) {
  89141. return $t;
  89142. }
  89143. }
  89144. return clone $this;
  89145. }
  89146. $str = clone $this;
  89147. if ($prefix instanceof self) {
  89148. $prefix = $prefix->string;
  89149. } else {
  89150. $prefix = (string) $prefix;
  89151. }
  89152. if ('' !== $prefix && \strlen($this->string) >= \strlen($prefix) && 0 === substr_compare($this->string, $prefix, 0, \strlen($prefix), $this->ignoreCase)) {
  89153. $str->string = substr($this->string, \strlen($prefix));
  89154. }
  89155. return $str;
  89156. }
  89157. abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
  89158. public function trimSuffix($suffix): self
  89159. {
  89160. if (\is_array($suffix) || $suffix instanceof \Traversable) {
  89161. foreach ($suffix as $s) {
  89162. $t = $this->trimSuffix($s);
  89163. if ($t->string !== $this->string) {
  89164. return $t;
  89165. }
  89166. }
  89167. return clone $this;
  89168. }
  89169. $str = clone $this;
  89170. if ($suffix instanceof self) {
  89171. $suffix = $suffix->string;
  89172. } else {
  89173. $suffix = (string) $suffix;
  89174. }
  89175. if ('' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase)) {
  89176. $str->string = substr($this->string, 0, -\strlen($suffix));
  89177. }
  89178. return $str;
  89179. }
  89180. public function truncate(int $length, string $ellipsis = '', bool $cut = true): self
  89181. {
  89182. $stringLength = $this->length();
  89183. if ($stringLength <= $length) {
  89184. return clone $this;
  89185. }
  89186. $ellipsisLength = '' !== $ellipsis ? (new static($ellipsis))->length() : 0;
  89187. if ($length < $ellipsisLength) {
  89188. $ellipsisLength = 0;
  89189. }
  89190. if (!$cut) {
  89191. if (null === $length = $this->indexOf([' ', "\r", "\n", "\t"], ($length ?: 1) - 1)) {
  89192. return clone $this;
  89193. }
  89194. $length += $ellipsisLength;
  89195. }
  89196. $str = $this->slice(0, $length - $ellipsisLength);
  89197. return $ellipsisLength ? $str->trimEnd()->append($ellipsis) : $str;
  89198. }
  89199. abstract public function upper(): self;
  89200. abstract public function width(bool $ignoreAnsiDecoration = true): int;
  89201. public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): self
  89202. {
  89203. $lines = '' !== $break ? $this->split($break) : [clone $this];
  89204. $chars = [];
  89205. $mask = '';
  89206. if (1 === \count($lines) && '' === $lines[0]->string) {
  89207. return $lines[0];
  89208. }
  89209. foreach ($lines as $i => $line) {
  89210. if ($i) {
  89211. $chars[] = $break;
  89212. $mask .= '#';
  89213. }
  89214. foreach ($line->chunk() as $char) {
  89215. $chars[] = $char->string;
  89216. $mask .= ' ' === $char->string ? ' ' : '?';
  89217. }
  89218. }
  89219. $string = '';
  89220. $j = 0;
  89221. $b = $i = -1;
  89222. $mask = wordwrap($mask, $width, '#', $cut);
  89223. while (false !== $b = strpos($mask, '#', $b + 1)) {
  89224. for (++$i; $i < $b; ++$i) {
  89225. $string .= $chars[$j];
  89226. unset($chars[$j++]);
  89227. }
  89228. if ($break === $chars[$j] || ' ' === $chars[$j]) {
  89229. unset($chars[$j++]);
  89230. }
  89231. $string .= $break;
  89232. }
  89233. $str = clone $this;
  89234. $str->string = $string.implode('', $chars);
  89235. return $str;
  89236. }
  89237. public function __sleep(): array
  89238. {
  89239. return ['string'];
  89240. }
  89241. public function __clone()
  89242. {
  89243. $this->ignoreCase = false;
  89244. }
  89245. public function __toString(): string
  89246. {
  89247. return $this->string;
  89248. }
  89249. }
  89250. <?php
  89251. namespace Symfony\Component\String;
  89252. use Symfony\Component\String\Exception\ExceptionInterface;
  89253. use Symfony\Component\String\Exception\InvalidArgumentException;
  89254. use Symfony\Component\String\Exception\RuntimeException;
  89255. abstract class AbstractUnicodeString extends AbstractString
  89256. {
  89257. public const NFC = \Normalizer::NFC;
  89258. public const NFD = \Normalizer::NFD;
  89259. public const NFKC = \Normalizer::NFKC;
  89260. public const NFKD = \Normalizer::NFKD;
  89261. 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";
  89262. private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', '�', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'ʼn', 'ǰ', '�', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', '�', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', '�', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', '�', 'ᾎ', '�', '�', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', '�', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', '�', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ'];
  89263. private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', 'ṡ', 'ι', 'ss', 'ʼn', 'ǰ', '�', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', '�', 'ὒ', 'ὔ', 'ὖ', 'ἀι', '�ι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', '�ι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ'];
  89264. private const UPPER_FROM = ['ß', 'ff', '�', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'և', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ', 'ʼn', '�', 'ΰ', 'ǰ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', '�', 'ὒ', 'ὔ', 'ὖ', 'ᾶ', 'ῆ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῶ'];
  89265. private const UPPER_TO = ['SS', 'FF', 'FI', 'FL', 'FFI', 'FFL', 'ST', 'ST', 'ԵՒ', 'ՄՆ', 'ՄԵ', 'ՄԻ', 'ՎՆ', 'ՄԽ', 'ʼN', 'Ϊ�', 'Ϋ�', 'J̌', 'H̱', 'T̈', 'W̊', 'Y̊', 'Aʾ', 'Υ̓', 'Υ̓̀', 'Υ̓�', 'Υ̓͂', 'Α͂', 'Η͂', 'Ϊ̀', 'Ϊ�', 'Ι͂', 'Ϊ͂', 'Ϋ̀', 'Ϋ�', 'Ρ̓', 'Υ͂', 'Ϋ͂', 'Ω͂'];
  89266. private const TRANSLIT_FROM = ['Æ', '�', 'Ø', 'Þ', 'ß', 'æ', 'ð', 'ø', 'þ', '�', 'đ', 'Ħ', 'ħ', 'ı', 'ĸ', 'Ŀ', 'ŀ', '�', 'ł', 'ʼn', 'Ŋ', 'ŋ', 'Œ', 'œ', 'Ŧ', 'ŧ', 'ƀ', '�', 'Ƃ', 'ƃ', 'Ƈ', 'ƈ', 'Ɖ', 'Ɗ', 'Ƌ', 'ƌ', '�', 'Ƒ', 'ƒ', 'Ɠ', 'ƕ', 'Ɩ', 'Ɨ', 'Ƙ', 'ƙ', 'ƚ', '�', 'ƞ', 'Ƣ', 'ƣ', 'Ƥ', 'ƥ', 'ƫ', 'Ƭ', 'ƭ', 'Ʈ', 'Ʋ', 'Ƴ', 'ƴ', 'Ƶ', 'ƶ', 'DŽ', 'Dž', 'dž', 'Ǥ', 'ǥ', 'ȡ', 'Ȥ', 'ȥ', 'ȴ', 'ȵ', 'ȶ', 'ȷ', 'ȸ', 'ȹ', 'Ⱥ', 'Ȼ', 'ȼ', 'Ƚ', 'Ⱦ', 'ȿ', 'ɀ', 'Ƀ', 'Ʉ', 'Ɇ', 'ɇ', 'Ɉ', 'ɉ', 'Ɍ', '�', 'Ɏ', '�', 'ɓ', 'ɕ', 'ɖ', 'ɗ', 'ɛ', 'ɟ', 'ɠ', 'ɡ', 'ɢ', 'ɦ', 'ɧ', 'ɨ', 'ɪ', 'ɫ', 'ɬ', 'ɭ', 'ɱ', 'ɲ', 'ɳ', 'ɴ', 'ɶ', 'ɼ', 'ɽ', 'ɾ', 'ʀ', 'ʂ', 'ʈ', 'ʉ', 'ʋ', '�', '�', 'ʑ', 'ʙ', 'ʛ', 'ʜ', '�', 'ʟ', 'ʠ', 'ʣ', 'ʥ', 'ʦ', 'ʪ', 'ʫ', 'ᴀ', '�', 'ᴃ', 'ᴄ', 'ᴅ', 'ᴆ', 'ᴇ', 'ᴊ', 'ᴋ', 'ᴌ', '�', '�', 'ᴘ', 'ᴛ', 'ᴜ', 'ᴠ', 'ᴡ', 'ᴢ', 'ᵫ', 'ᵬ', 'ᵭ', 'ᵮ', 'ᵯ', 'ᵰ', 'ᵱ', 'ᵲ', 'ᵳ', 'ᵴ', 'ᵵ', 'ᵶ', 'ᵺ', 'ᵻ', 'ᵽ', 'ᵾ', 'ᶀ', '�', 'ᶂ', 'ᶃ', 'ᶄ', 'ᶅ', 'ᶆ', 'ᶇ', 'ᶈ', 'ᶉ', 'ᶊ', 'ᶌ', '�', 'ᶎ', '�', 'ᶑ', 'ᶒ', 'ᶓ', 'ᶖ', 'ᶙ', 'ẚ', 'ẜ', '�', 'ẞ', 'Ỻ', 'ỻ', 'Ỽ', 'ỽ', 'Ỿ', 'ỿ', '©', '®', '₠', '₢', '₣', '₤', '₧', '₺', '₹', 'ℌ', '℞', '㎧', '㎮', '�', '�', '�', '�', '¼', '½', '¾', '⅓', '⅔', '⅕', '⅖', '⅗', '⅘', '⅙', '⅚', '⅛', '⅜', '�', '⅞', '⅟', '〇', '‘', '’', '‚', '‛', '“', '�', '„', '‟', '′', '″', '�', '〞', '«', '»', '‹', '›', '�', '‑', '‒', '–', '—', '―', '︱', '︲', '﹘', '‖', '�', '�', '�', '�', '�', '。', '〈', '〉', '《', '》', '〔', '〕', '〘', '〙', '〚', '〛', '︑', '︒', '︹', '︺', '︽', '︾', '︿', '﹀', '﹑', '�', '﹞', '⦅', '⦆', '。', '、', '×', '÷', '−', '∕', '∖', '∣', '∥', '≪', '≫', '⦅', '⦆'];
  89267. 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', '\'', '\'', ',', '\'', '"', '"', ',,', '"', '\'', '"', '"', '"', '<<', '>>', '<', '>', '-', '-', '-', '-', '-', '-', '-', '-', '-', '||', '/', '[', ']', '*', ',', '.', '<', '>', '<<', '>>', '[', ']', '[', ']', '[', ']', ',', '.', '[', ']', '<<', '>>', '<', '>', ',', '[', ']', '((', '))', '.', ',', '*', '/', '-', '/', '\\', '|', '||', '<<', '>>', '((', '))'];
  89268. private static $transliterators = [];
  89269. private static $tableZero;
  89270. private static $tableWide;
  89271. public static function fromCodePoints(int ...$codes): self
  89272. {
  89273. $string = '';
  89274. foreach ($codes as $code) {
  89275. if (0x80 > $code %= 0x200000) {
  89276. $string .= \chr($code);
  89277. } elseif (0x800 > $code) {
  89278. $string .= \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  89279. } elseif (0x10000 > $code) {
  89280. $string .= \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  89281. } else {
  89282. $string .= \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  89283. }
  89284. }
  89285. return new static($string);
  89286. }
  89287. public function ascii(array $rules = []): self
  89288. {
  89289. $str = clone $this;
  89290. $s = $str->string;
  89291. $str->string = '';
  89292. array_unshift($rules, 'nfd');
  89293. $rules[] = 'latin-ascii';
  89294. if (\function_exists('transliterator_transliterate')) {
  89295. $rules[] = 'any-latin/bgn';
  89296. }
  89297. $rules[] = 'nfkd';
  89298. $rules[] = '[:nonspacing mark:] remove';
  89299. while (\strlen($s) - 1 > $i = strspn($s, self::ASCII)) {
  89300. if (0 < --$i) {
  89301. $str->string .= substr($s, 0, $i);
  89302. $s = substr($s, $i);
  89303. }
  89304. if (!$rule = array_shift($rules)) {
  89305. $rules = [];
  89306. }
  89307. if ($rule instanceof \Transliterator) {
  89308. $s = $rule->transliterate($s);
  89309. } elseif ($rule instanceof \Closure) {
  89310. $s = $rule($s);
  89311. } elseif ($rule) {
  89312. if ('nfd' === $rule = strtolower($rule)) {
  89313. normalizer_is_normalized($s, self::NFD) ?: $s = normalizer_normalize($s, self::NFD);
  89314. } elseif ('nfkd' === $rule) {
  89315. normalizer_is_normalized($s, self::NFKD) ?: $s = normalizer_normalize($s, self::NFKD);
  89316. } elseif ('[:nonspacing mark:] remove' === $rule) {
  89317. $s = preg_replace('/\p{Mn}++/u', '', $s);
  89318. } elseif ('latin-ascii' === $rule) {
  89319. $s = str_replace(self::TRANSLIT_FROM, self::TRANSLIT_TO, $s);
  89320. } elseif ('de-ascii' === $rule) {
  89321. $s = preg_replace("/([AUO])\u{0308}(?=\p{Ll})/u", '$1e', $s);
  89322. $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);
  89323. } elseif (\function_exists('transliterator_transliterate')) {
  89324. if (null === $transliterator = self::$transliterators[$rule] ?? self::$transliterators[$rule] = \Transliterator::create($rule)) {
  89325. if ('any-latin/bgn' === $rule) {
  89326. $rule = 'any-latin';
  89327. $transliterator = self::$transliterators[$rule] ?? self::$transliterators[$rule] = \Transliterator::create($rule);
  89328. }
  89329. if (null === $transliterator) {
  89330. throw new InvalidArgumentException(sprintf('Unknown transliteration rule "%s".', $rule));
  89331. }
  89332. self::$transliterators['any-latin/bgn'] = $transliterator;
  89333. }
  89334. $s = $transliterator->transliterate($s);
  89335. }
  89336. } elseif (!\function_exists('iconv')) {
  89337. $s = preg_replace('/[^\x00-\x7F]/u', '?', $s);
  89338. } else {
  89339. $s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
  89340. $c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]);
  89341. if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) {
  89342. throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
  89343. }
  89344. return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : ('' !== $c ? $c : '?');
  89345. }, $s);
  89346. }
  89347. }
  89348. $str->string .= $s;
  89349. return $str;
  89350. }
  89351. public function camel(): parent
  89352. {
  89353. $str = clone $this;
  89354. $str->string = str_replace(' ', '', preg_replace_callback('/\b.(?!\p{Lu})/u', static function ($m) use (&$i) {
  89355. return 1 === ++$i ? ('İ' === $m[0] ? 'i̇' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
  89356. }, preg_replace('/[^\pL0-9]++/u', ' ', $this->string)));
  89357. return $str;
  89358. }
  89359. public function codePointsAt(int $offset): array
  89360. {
  89361. $str = $this->slice($offset, 1);
  89362. if ('' === $str->string) {
  89363. return [];
  89364. }
  89365. $codePoints = [];
  89366. foreach (preg_split('//u', $str->string, -1, \PREG_SPLIT_NO_EMPTY) as $c) {
  89367. $codePoints[] = mb_ord($c, 'UTF-8');
  89368. }
  89369. return $codePoints;
  89370. }
  89371. public function folded(bool $compat = true): parent
  89372. {
  89373. $str = clone $this;
  89374. if (!$compat || \PHP_VERSION_ID < 70300 || !\defined('Normalizer::NFKC_CF')) {
  89375. $str->string = normalizer_normalize($str->string, $compat ? \Normalizer::NFKC : \Normalizer::NFC);
  89376. $str->string = mb_strtolower(str_replace(self::FOLD_FROM, self::FOLD_TO, $str->string), 'UTF-8');
  89377. } else {
  89378. $str->string = normalizer_normalize($str->string, \Normalizer::NFKC_CF);
  89379. }
  89380. return $str;
  89381. }
  89382. public function join(array $strings, ?string $lastGlue = null): parent
  89383. {
  89384. $str = clone $this;
  89385. $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue.array_pop($strings) : '';
  89386. $str->string = implode($this->string, $strings).$tail;
  89387. if (!preg_match('//u', $str->string)) {
  89388. throw new InvalidArgumentException('Invalid UTF-8 string.');
  89389. }
  89390. return $str;
  89391. }
  89392. public function lower(): parent
  89393. {
  89394. $str = clone $this;
  89395. $str->string = mb_strtolower(str_replace('İ', 'i̇', $str->string), 'UTF-8');
  89396. return $str;
  89397. }
  89398. public function match(string $regexp, int $flags = 0, int $offset = 0): array
  89399. {
  89400. $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
  89401. if ($this->ignoreCase) {
  89402. $regexp .= 'i';
  89403. }
  89404. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  89405. try {
  89406. if (false === $match($regexp.'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
  89407. $lastError = preg_last_error();
  89408. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  89409. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  89410. throw new RuntimeException('Matching failed with '.$k.'.');
  89411. }
  89412. }
  89413. throw new RuntimeException('Matching failed with unknown error code.');
  89414. }
  89415. } finally {
  89416. restore_error_handler();
  89417. }
  89418. return $matches;
  89419. }
  89420. public function normalize(int $form = self::NFC): self
  89421. {
  89422. if (!\in_array($form, [self::NFC, self::NFD, self::NFKC, self::NFKD])) {
  89423. throw new InvalidArgumentException('Unsupported normalization form.');
  89424. }
  89425. $str = clone $this;
  89426. normalizer_is_normalized($str->string, $form) ?: $str->string = normalizer_normalize($str->string, $form);
  89427. return $str;
  89428. }
  89429. public function padBoth(int $length, string $padStr = ' '): parent
  89430. {
  89431. if ('' === $padStr || !preg_match('//u', $padStr)) {
  89432. throw new InvalidArgumentException('Invalid UTF-8 string.');
  89433. }
  89434. $pad = clone $this;
  89435. $pad->string = $padStr;
  89436. return $this->pad($length, $pad, \STR_PAD_BOTH);
  89437. }
  89438. public function padEnd(int $length, string $padStr = ' '): parent
  89439. {
  89440. if ('' === $padStr || !preg_match('//u', $padStr)) {
  89441. throw new InvalidArgumentException('Invalid UTF-8 string.');
  89442. }
  89443. $pad = clone $this;
  89444. $pad->string = $padStr;
  89445. return $this->pad($length, $pad, \STR_PAD_RIGHT);
  89446. }
  89447. public function padStart(int $length, string $padStr = ' '): parent
  89448. {
  89449. if ('' === $padStr || !preg_match('//u', $padStr)) {
  89450. throw new InvalidArgumentException('Invalid UTF-8 string.');
  89451. }
  89452. $pad = clone $this;
  89453. $pad->string = $padStr;
  89454. return $this->pad($length, $pad, \STR_PAD_LEFT);
  89455. }
  89456. public function replaceMatches(string $fromRegexp, $to): parent
  89457. {
  89458. if ($this->ignoreCase) {
  89459. $fromRegexp .= 'i';
  89460. }
  89461. if (\is_array($to) || $to instanceof \Closure) {
  89462. if (!\is_callable($to)) {
  89463. throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
  89464. }
  89465. $replace = 'preg_replace_callback';
  89466. $to = static function (array $m) use ($to): string {
  89467. $to = $to($m);
  89468. if ('' !== $to && (!\is_string($to) || !preg_match('//u', $to))) {
  89469. throw new InvalidArgumentException('Replace callback must return a valid UTF-8 string.');
  89470. }
  89471. return $to;
  89472. };
  89473. } elseif ('' !== $to && !preg_match('//u', $to)) {
  89474. throw new InvalidArgumentException('Invalid UTF-8 string.');
  89475. } else {
  89476. $replace = 'preg_replace';
  89477. }
  89478. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  89479. try {
  89480. if (null === $string = $replace($fromRegexp.'u', $to, $this->string)) {
  89481. $lastError = preg_last_error();
  89482. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  89483. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  89484. throw new RuntimeException('Matching failed with '.$k.'.');
  89485. }
  89486. }
  89487. throw new RuntimeException('Matching failed with unknown error code.');
  89488. }
  89489. } finally {
  89490. restore_error_handler();
  89491. }
  89492. $str = clone $this;
  89493. $str->string = $string;
  89494. return $str;
  89495. }
  89496. public function reverse(): parent
  89497. {
  89498. $str = clone $this;
  89499. $str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)));
  89500. return $str;
  89501. }
  89502. public function snake(): parent
  89503. {
  89504. $str = $this->camel();
  89505. $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');
  89506. return $str;
  89507. }
  89508. public function title(bool $allWords = false): parent
  89509. {
  89510. $str = clone $this;
  89511. $limit = $allWords ? -1 : 1;
  89512. $str->string = preg_replace_callback('/\b./u', static function (array $m): string {
  89513. return mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
  89514. }, $str->string, $limit);
  89515. return $str;
  89516. }
  89517. public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
  89518. {
  89519. if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
  89520. throw new InvalidArgumentException('Invalid UTF-8 chars.');
  89521. }
  89522. $chars = preg_quote($chars);
  89523. $str = clone $this;
  89524. $str->string = preg_replace("{^[$chars]++|[$chars]++$}uD", '', $str->string);
  89525. return $str;
  89526. }
  89527. public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
  89528. {
  89529. if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
  89530. throw new InvalidArgumentException('Invalid UTF-8 chars.');
  89531. }
  89532. $chars = preg_quote($chars);
  89533. $str = clone $this;
  89534. $str->string = preg_replace("{[$chars]++$}uD", '', $str->string);
  89535. return $str;
  89536. }
  89537. public function trimPrefix($prefix): parent
  89538. {
  89539. if (!$this->ignoreCase) {
  89540. return parent::trimPrefix($prefix);
  89541. }
  89542. $str = clone $this;
  89543. if ($prefix instanceof \Traversable) {
  89544. $prefix = iterator_to_array($prefix, false);
  89545. } elseif ($prefix instanceof parent) {
  89546. $prefix = $prefix->string;
  89547. }
  89548. $prefix = implode('|', array_map('preg_quote', (array) $prefix));
  89549. $str->string = preg_replace("{^(?:$prefix)}iuD", '', $this->string);
  89550. return $str;
  89551. }
  89552. public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
  89553. {
  89554. if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
  89555. throw new InvalidArgumentException('Invalid UTF-8 chars.');
  89556. }
  89557. $chars = preg_quote($chars);
  89558. $str = clone $this;
  89559. $str->string = preg_replace("{^[$chars]++}uD", '', $str->string);
  89560. return $str;
  89561. }
  89562. public function trimSuffix($suffix): parent
  89563. {
  89564. if (!$this->ignoreCase) {
  89565. return parent::trimSuffix($suffix);
  89566. }
  89567. $str = clone $this;
  89568. if ($suffix instanceof \Traversable) {
  89569. $suffix = iterator_to_array($suffix, false);
  89570. } elseif ($suffix instanceof parent) {
  89571. $suffix = $suffix->string;
  89572. }
  89573. $suffix = implode('|', array_map('preg_quote', (array) $suffix));
  89574. $str->string = preg_replace("{(?:$suffix)$}iuD", '', $this->string);
  89575. return $str;
  89576. }
  89577. public function upper(): parent
  89578. {
  89579. $str = clone $this;
  89580. $str->string = mb_strtoupper($str->string, 'UTF-8');
  89581. if (\PHP_VERSION_ID < 70300) {
  89582. $str->string = str_replace(self::UPPER_FROM, self::UPPER_TO, $str->string);
  89583. }
  89584. return $str;
  89585. }
  89586. public function width(bool $ignoreAnsiDecoration = true): int
  89587. {
  89588. $width = 0;
  89589. $s = str_replace(["\x00", "\x05", "\x07"], '', $this->string);
  89590. if (false !== strpos($s, "\r")) {
  89591. $s = str_replace(["\r\n", "\r"], "\n", $s);
  89592. }
  89593. if (!$ignoreAnsiDecoration) {
  89594. $s = preg_replace('/[\p{Cc}\x7F]++/u', '', $s);
  89595. }
  89596. foreach (explode("\n", $s) as $s) {
  89597. if ($ignoreAnsiDecoration) {
  89598. $s = preg_replace('/(?:\x1B(?:
  89599. \[ [\x30-\x3F]*+ [\x20-\x2F]*+ [\x40-\x7E]
  89600. | [P\]X^_] .*? \x1B\\\\
  89601. | [\x41-\x7E]
  89602. )|[\p{Cc}\x7F]++)/xu', '', $s);
  89603. }
  89604. $lineWidth = $this->wcswidth($s);
  89605. if ($lineWidth > $width) {
  89606. $width = $lineWidth;
  89607. }
  89608. }
  89609. return $width;
  89610. }
  89611. private function pad(int $len, self $pad, int $type): parent
  89612. {
  89613. $sLen = $this->length();
  89614. if ($len <= $sLen) {
  89615. return clone $this;
  89616. }
  89617. $padLen = $pad->length();
  89618. $freeLen = $len - $sLen;
  89619. $len = $freeLen % $padLen;
  89620. switch ($type) {
  89621. case \STR_PAD_RIGHT:
  89622. return $this->append(str_repeat($pad->string, intdiv($freeLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  89623. case \STR_PAD_LEFT:
  89624. return $this->prepend(str_repeat($pad->string, intdiv($freeLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  89625. case \STR_PAD_BOTH:
  89626. $freeLen /= 2;
  89627. $rightLen = ceil($freeLen);
  89628. $len = $rightLen % $padLen;
  89629. $str = $this->append(str_repeat($pad->string, intdiv($rightLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  89630. $leftLen = floor($freeLen);
  89631. $len = $leftLen % $padLen;
  89632. return $str->prepend(str_repeat($pad->string, intdiv($leftLen, $padLen)).($len ? $pad->slice(0, $len) : ''));
  89633. default:
  89634. throw new InvalidArgumentException('Invalid padding type.');
  89635. }
  89636. }
  89637. private function wcswidth(string $string): int
  89638. {
  89639. $width = 0;
  89640. foreach (preg_split('//u', $string, -1, \PREG_SPLIT_NO_EMPTY) as $c) {
  89641. $codePoint = mb_ord($c, 'UTF-8');
  89642. if (0 === $codePoint
  89643. || 0x034F === $codePoint
  89644. || (0x200B <= $codePoint && 0x200F >= $codePoint)
  89645. || 0x2028 === $codePoint
  89646. || 0x2029 === $codePoint
  89647. || (0x202A <= $codePoint && 0x202E >= $codePoint)
  89648. || (0x2060 <= $codePoint && 0x2063 >= $codePoint)
  89649. ) {
  89650. continue;
  89651. }
  89652. if (32 > $codePoint
  89653. || (0x07F <= $codePoint && 0x0A0 > $codePoint)
  89654. ) {
  89655. return -1;
  89656. }
  89657. if (null === self::$tableZero) {
  89658. self::$tableZero = require __DIR__.'/Resources/data/wcswidth_table_zero.php';
  89659. }
  89660. if ($codePoint >= self::$tableZero[0][0] && $codePoint <= self::$tableZero[$ubound = \count(self::$tableZero) - 1][1]) {
  89661. $lbound = 0;
  89662. while ($ubound >= $lbound) {
  89663. $mid = floor(($lbound + $ubound) / 2);
  89664. if ($codePoint > self::$tableZero[$mid][1]) {
  89665. $lbound = $mid + 1;
  89666. } elseif ($codePoint < self::$tableZero[$mid][0]) {
  89667. $ubound = $mid - 1;
  89668. } else {
  89669. continue 2;
  89670. }
  89671. }
  89672. }
  89673. if (null === self::$tableWide) {
  89674. self::$tableWide = require __DIR__.'/Resources/data/wcswidth_table_wide.php';
  89675. }
  89676. if ($codePoint >= self::$tableWide[0][0] && $codePoint <= self::$tableWide[$ubound = \count(self::$tableWide) - 1][1]) {
  89677. $lbound = 0;
  89678. while ($ubound >= $lbound) {
  89679. $mid = floor(($lbound + $ubound) / 2);
  89680. if ($codePoint > self::$tableWide[$mid][1]) {
  89681. $lbound = $mid + 1;
  89682. } elseif ($codePoint < self::$tableWide[$mid][0]) {
  89683. $ubound = $mid - 1;
  89684. } else {
  89685. $width += 2;
  89686. continue 2;
  89687. }
  89688. }
  89689. }
  89690. ++$width;
  89691. }
  89692. return $width;
  89693. }
  89694. }
  89695. <?php
  89696. namespace Symfony\Component\String;
  89697. use Symfony\Component\String\Exception\ExceptionInterface;
  89698. use Symfony\Component\String\Exception\InvalidArgumentException;
  89699. use Symfony\Component\String\Exception\RuntimeException;
  89700. class ByteString extends AbstractString
  89701. {
  89702. private const ALPHABET_ALPHANUMERIC = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
  89703. public function __construct(string $string = '')
  89704. {
  89705. $this->string = $string;
  89706. }
  89707. public static function fromRandom(int $length = 16, ?string $alphabet = null): self
  89708. {
  89709. if ($length <= 0) {
  89710. throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length));
  89711. }
  89712. $alphabet = $alphabet ?? self::ALPHABET_ALPHANUMERIC;
  89713. $alphabetSize = \strlen($alphabet);
  89714. $bits = (int) ceil(log($alphabetSize, 2.0));
  89715. if ($bits <= 0 || $bits > 56) {
  89716. throw new InvalidArgumentException('The length of the alphabet must in the [2^1, 2^56] range.');
  89717. }
  89718. $ret = '';
  89719. while ($length > 0) {
  89720. $urandomLength = (int) ceil(2 * $length * $bits / 8.0);
  89721. $data = random_bytes($urandomLength);
  89722. $unpackedData = 0;
  89723. $unpackedBits = 0;
  89724. for ($i = 0; $i < $urandomLength && $length > 0; ++$i) {
  89725. $unpackedData = ($unpackedData << 8) | \ord($data[$i]);
  89726. $unpackedBits += 8;
  89727. for (; $unpackedBits >= $bits && $length > 0; $unpackedBits -= $bits) {
  89728. $index = ($unpackedData & ((1 << $bits) - 1));
  89729. $unpackedData >>= $bits;
  89730. if ($index < $alphabetSize) {
  89731. $ret .= $alphabet[$index];
  89732. --$length;
  89733. }
  89734. }
  89735. }
  89736. }
  89737. return new static($ret);
  89738. }
  89739. public function bytesAt(int $offset): array
  89740. {
  89741. $str = $this->string[$offset] ?? '';
  89742. return '' === $str ? [] : [\ord($str)];
  89743. }
  89744. public function append(string ...$suffix): parent
  89745. {
  89746. $str = clone $this;
  89747. $str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
  89748. return $str;
  89749. }
  89750. public function camel(): parent
  89751. {
  89752. $str = clone $this;
  89753. $parts = explode(' ', trim(ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string))));
  89754. $parts[0] = 1 !== \strlen($parts[0]) && ctype_upper($parts[0]) ? $parts[0] : lcfirst($parts[0]);
  89755. $str->string = implode('', $parts);
  89756. return $str;
  89757. }
  89758. public function chunk(int $length = 1): array
  89759. {
  89760. if (1 > $length) {
  89761. throw new InvalidArgumentException('The chunk length must be greater than zero.');
  89762. }
  89763. if ('' === $this->string) {
  89764. return [];
  89765. }
  89766. $str = clone $this;
  89767. $chunks = [];
  89768. foreach (str_split($this->string, $length) as $chunk) {
  89769. $str->string = $chunk;
  89770. $chunks[] = clone $str;
  89771. }
  89772. return $chunks;
  89773. }
  89774. public function endsWith($suffix): bool
  89775. {
  89776. if ($suffix instanceof parent) {
  89777. $suffix = $suffix->string;
  89778. } elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
  89779. return parent::endsWith($suffix);
  89780. } else {
  89781. $suffix = (string) $suffix;
  89782. }
  89783. return '' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase);
  89784. }
  89785. public function equalsTo($string): bool
  89786. {
  89787. if ($string instanceof parent) {
  89788. $string = $string->string;
  89789. } elseif (\is_array($string) || $string instanceof \Traversable) {
  89790. return parent::equalsTo($string);
  89791. } else {
  89792. $string = (string) $string;
  89793. }
  89794. if ('' !== $string && $this->ignoreCase) {
  89795. return 0 === strcasecmp($string, $this->string);
  89796. }
  89797. return $string === $this->string;
  89798. }
  89799. public function folded(): parent
  89800. {
  89801. $str = clone $this;
  89802. $str->string = strtolower($str->string);
  89803. return $str;
  89804. }
  89805. public function indexOf($needle, int $offset = 0): ?int
  89806. {
  89807. if ($needle instanceof parent) {
  89808. $needle = $needle->string;
  89809. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  89810. return parent::indexOf($needle, $offset);
  89811. } else {
  89812. $needle = (string) $needle;
  89813. }
  89814. if ('' === $needle) {
  89815. return null;
  89816. }
  89817. $i = $this->ignoreCase ? stripos($this->string, $needle, $offset) : strpos($this->string, $needle, $offset);
  89818. return false === $i ? null : $i;
  89819. }
  89820. public function indexOfLast($needle, int $offset = 0): ?int
  89821. {
  89822. if ($needle instanceof parent) {
  89823. $needle = $needle->string;
  89824. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  89825. return parent::indexOfLast($needle, $offset);
  89826. } else {
  89827. $needle = (string) $needle;
  89828. }
  89829. if ('' === $needle) {
  89830. return null;
  89831. }
  89832. $i = $this->ignoreCase ? strripos($this->string, $needle, $offset) : strrpos($this->string, $needle, $offset);
  89833. return false === $i ? null : $i;
  89834. }
  89835. public function isUtf8(): bool
  89836. {
  89837. return '' === $this->string || preg_match('//u', $this->string);
  89838. }
  89839. public function join(array $strings, ?string $lastGlue = null): parent
  89840. {
  89841. $str = clone $this;
  89842. $tail = null !== $lastGlue && 1 < \count($strings) ? $lastGlue.array_pop($strings) : '';
  89843. $str->string = implode($this->string, $strings).$tail;
  89844. return $str;
  89845. }
  89846. public function length(): int
  89847. {
  89848. return \strlen($this->string);
  89849. }
  89850. public function lower(): parent
  89851. {
  89852. $str = clone $this;
  89853. $str->string = strtolower($str->string);
  89854. return $str;
  89855. }
  89856. public function match(string $regexp, int $flags = 0, int $offset = 0): array
  89857. {
  89858. $match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
  89859. if ($this->ignoreCase) {
  89860. $regexp .= 'i';
  89861. }
  89862. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  89863. try {
  89864. if (false === $match($regexp, $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
  89865. $lastError = preg_last_error();
  89866. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  89867. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  89868. throw new RuntimeException('Matching failed with '.$k.'.');
  89869. }
  89870. }
  89871. throw new RuntimeException('Matching failed with unknown error code.');
  89872. }
  89873. } finally {
  89874. restore_error_handler();
  89875. }
  89876. return $matches;
  89877. }
  89878. public function padBoth(int $length, string $padStr = ' '): parent
  89879. {
  89880. $str = clone $this;
  89881. $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_BOTH);
  89882. return $str;
  89883. }
  89884. public function padEnd(int $length, string $padStr = ' '): parent
  89885. {
  89886. $str = clone $this;
  89887. $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT);
  89888. return $str;
  89889. }
  89890. public function padStart(int $length, string $padStr = ' '): parent
  89891. {
  89892. $str = clone $this;
  89893. $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_LEFT);
  89894. return $str;
  89895. }
  89896. public function prepend(string ...$prefix): parent
  89897. {
  89898. $str = clone $this;
  89899. $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$str->string;
  89900. return $str;
  89901. }
  89902. public function replace(string $from, string $to): parent
  89903. {
  89904. $str = clone $this;
  89905. if ('' !== $from) {
  89906. $str->string = $this->ignoreCase ? str_ireplace($from, $to, $this->string) : str_replace($from, $to, $this->string);
  89907. }
  89908. return $str;
  89909. }
  89910. public function replaceMatches(string $fromRegexp, $to): parent
  89911. {
  89912. if ($this->ignoreCase) {
  89913. $fromRegexp .= 'i';
  89914. }
  89915. if (\is_array($to)) {
  89916. if (!\is_callable($to)) {
  89917. throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
  89918. }
  89919. $replace = 'preg_replace_callback';
  89920. } else {
  89921. $replace = $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
  89922. }
  89923. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  89924. try {
  89925. if (null === $string = $replace($fromRegexp, $to, $this->string)) {
  89926. $lastError = preg_last_error();
  89927. foreach (get_defined_constants(true)['pcre'] as $k => $v) {
  89928. if ($lastError === $v && '_ERROR' === substr($k, -6)) {
  89929. throw new RuntimeException('Matching failed with '.$k.'.');
  89930. }
  89931. }
  89932. throw new RuntimeException('Matching failed with unknown error code.');
  89933. }
  89934. } finally {
  89935. restore_error_handler();
  89936. }
  89937. $str = clone $this;
  89938. $str->string = $string;
  89939. return $str;
  89940. }
  89941. public function reverse(): parent
  89942. {
  89943. $str = clone $this;
  89944. $str->string = strrev($str->string);
  89945. return $str;
  89946. }
  89947. public function slice(int $start = 0, ?int $length = null): parent
  89948. {
  89949. $str = clone $this;
  89950. $str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
  89951. return $str;
  89952. }
  89953. public function snake(): parent
  89954. {
  89955. $str = $this->camel();
  89956. $str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));
  89957. return $str;
  89958. }
  89959. public function splice(string $replacement, int $start = 0, ?int $length = null): parent
  89960. {
  89961. $str = clone $this;
  89962. $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
  89963. return $str;
  89964. }
  89965. public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
  89966. {
  89967. if (1 > $limit = $limit ?? \PHP_INT_MAX) {
  89968. throw new InvalidArgumentException('Split limit must be a positive integer.');
  89969. }
  89970. if ('' === $delimiter) {
  89971. throw new InvalidArgumentException('Split delimiter is empty.');
  89972. }
  89973. if (null !== $flags) {
  89974. return parent::split($delimiter, $limit, $flags);
  89975. }
  89976. $str = clone $this;
  89977. $chunks = $this->ignoreCase
  89978. ? preg_split('{'.preg_quote($delimiter).'}iD', $this->string, $limit)
  89979. : explode($delimiter, $this->string, $limit);
  89980. foreach ($chunks as &$chunk) {
  89981. $str->string = $chunk;
  89982. $chunk = clone $str;
  89983. }
  89984. return $chunks;
  89985. }
  89986. public function startsWith($prefix): bool
  89987. {
  89988. if ($prefix instanceof parent) {
  89989. $prefix = $prefix->string;
  89990. } elseif (!\is_string($prefix)) {
  89991. return parent::startsWith($prefix);
  89992. }
  89993. return '' !== $prefix && 0 === ($this->ignoreCase ? strncasecmp($this->string, $prefix, \strlen($prefix)) : strncmp($this->string, $prefix, \strlen($prefix)));
  89994. }
  89995. public function title(bool $allWords = false): parent
  89996. {
  89997. $str = clone $this;
  89998. $str->string = $allWords ? ucwords($str->string) : ucfirst($str->string);
  89999. return $str;
  90000. }
  90001. public function toUnicodeString(?string $fromEncoding = null): UnicodeString
  90002. {
  90003. return new UnicodeString($this->toCodePointString($fromEncoding)->string);
  90004. }
  90005. public function toCodePointString(?string $fromEncoding = null): CodePointString
  90006. {
  90007. $u = new CodePointString();
  90008. if (\in_array($fromEncoding, [null, 'utf8', 'utf-8', 'UTF8', 'UTF-8'], true) && preg_match('//u', $this->string)) {
  90009. $u->string = $this->string;
  90010. return $u;
  90011. }
  90012. set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
  90013. try {
  90014. try {
  90015. $validEncoding = false !== mb_detect_encoding($this->string, $fromEncoding ?? 'Windows-1252', true);
  90016. } catch (InvalidArgumentException $e) {
  90017. if (!\function_exists('iconv')) {
  90018. throw $e;
  90019. }
  90020. $u->string = iconv($fromEncoding ?? 'Windows-1252', 'UTF-8', $this->string);
  90021. return $u;
  90022. }
  90023. } finally {
  90024. restore_error_handler();
  90025. }
  90026. if (!$validEncoding) {
  90027. throw new InvalidArgumentException(sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
  90028. }
  90029. $u->string = mb_convert_encoding($this->string, 'UTF-8', $fromEncoding ?? 'Windows-1252');
  90030. return $u;
  90031. }
  90032. public function trim(string $chars = " \t\n\r\0\x0B\x0C"): parent
  90033. {
  90034. $str = clone $this;
  90035. $str->string = trim($str->string, $chars);
  90036. return $str;
  90037. }
  90038. public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): parent
  90039. {
  90040. $str = clone $this;
  90041. $str->string = rtrim($str->string, $chars);
  90042. return $str;
  90043. }
  90044. public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): parent
  90045. {
  90046. $str = clone $this;
  90047. $str->string = ltrim($str->string, $chars);
  90048. return $str;
  90049. }
  90050. public function upper(): parent
  90051. {
  90052. $str = clone $this;
  90053. $str->string = strtoupper($str->string);
  90054. return $str;
  90055. }
  90056. public function width(bool $ignoreAnsiDecoration = true): int
  90057. {
  90058. $string = preg_match('//u', $this->string) ? $this->string : preg_replace('/[\x80-\xFF]/', '?', $this->string);
  90059. return (new CodePointString($string))->width($ignoreAnsiDecoration);
  90060. }
  90061. }
  90062. <?php
  90063. namespace Symfony\Component\String;
  90064. use Symfony\Component\String\Exception\ExceptionInterface;
  90065. use Symfony\Component\String\Exception\InvalidArgumentException;
  90066. class CodePointString extends AbstractUnicodeString
  90067. {
  90068. public function __construct(string $string = '')
  90069. {
  90070. if ('' !== $string && !preg_match('//u', $string)) {
  90071. throw new InvalidArgumentException('Invalid UTF-8 string.');
  90072. }
  90073. $this->string = $string;
  90074. }
  90075. public function append(string ...$suffix): AbstractString
  90076. {
  90077. $str = clone $this;
  90078. $str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
  90079. if (!preg_match('//u', $str->string)) {
  90080. throw new InvalidArgumentException('Invalid UTF-8 string.');
  90081. }
  90082. return $str;
  90083. }
  90084. public function chunk(int $length = 1): array
  90085. {
  90086. if (1 > $length) {
  90087. throw new InvalidArgumentException('The chunk length must be greater than zero.');
  90088. }
  90089. if ('' === $this->string) {
  90090. return [];
  90091. }
  90092. $rx = '/(';
  90093. while (65535 < $length) {
  90094. $rx .= '.{65535}';
  90095. $length -= 65535;
  90096. }
  90097. $rx .= '.{'.$length.'})/us';
  90098. $str = clone $this;
  90099. $chunks = [];
  90100. foreach (preg_split($rx, $this->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY) as $chunk) {
  90101. $str->string = $chunk;
  90102. $chunks[] = clone $str;
  90103. }
  90104. return $chunks;
  90105. }
  90106. public function codePointsAt(int $offset): array
  90107. {
  90108. $str = $offset ? $this->slice($offset, 1) : $this;
  90109. return '' === $str->string ? [] : [mb_ord($str->string, 'UTF-8')];
  90110. }
  90111. public function endsWith($suffix): bool
  90112. {
  90113. if ($suffix instanceof AbstractString) {
  90114. $suffix = $suffix->string;
  90115. } elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
  90116. return parent::endsWith($suffix);
  90117. } else {
  90118. $suffix = (string) $suffix;
  90119. }
  90120. if ('' === $suffix || !preg_match('//u', $suffix)) {
  90121. return false;
  90122. }
  90123. if ($this->ignoreCase) {
  90124. return preg_match('{'.preg_quote($suffix).'$}iuD', $this->string);
  90125. }
  90126. return \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix));
  90127. }
  90128. public function equalsTo($string): bool
  90129. {
  90130. if ($string instanceof AbstractString) {
  90131. $string = $string->string;
  90132. } elseif (\is_array($string) || $string instanceof \Traversable) {
  90133. return parent::equalsTo($string);
  90134. } else {
  90135. $string = (string) $string;
  90136. }
  90137. if ('' !== $string && $this->ignoreCase) {
  90138. return \strlen($string) === \strlen($this->string) && 0 === mb_stripos($this->string, $string, 0, 'UTF-8');
  90139. }
  90140. return $string === $this->string;
  90141. }
  90142. public function indexOf($needle, int $offset = 0): ?int
  90143. {
  90144. if ($needle instanceof AbstractString) {
  90145. $needle = $needle->string;
  90146. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  90147. return parent::indexOf($needle, $offset);
  90148. } else {
  90149. $needle = (string) $needle;
  90150. }
  90151. if ('' === $needle) {
  90152. return null;
  90153. }
  90154. $i = $this->ignoreCase ? mb_stripos($this->string, $needle, $offset, 'UTF-8') : mb_strpos($this->string, $needle, $offset, 'UTF-8');
  90155. return false === $i ? null : $i;
  90156. }
  90157. public function indexOfLast($needle, int $offset = 0): ?int
  90158. {
  90159. if ($needle instanceof AbstractString) {
  90160. $needle = $needle->string;
  90161. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  90162. return parent::indexOfLast($needle, $offset);
  90163. } else {
  90164. $needle = (string) $needle;
  90165. }
  90166. if ('' === $needle) {
  90167. return null;
  90168. }
  90169. $i = $this->ignoreCase ? mb_strripos($this->string, $needle, $offset, 'UTF-8') : mb_strrpos($this->string, $needle, $offset, 'UTF-8');
  90170. return false === $i ? null : $i;
  90171. }
  90172. public function length(): int
  90173. {
  90174. return mb_strlen($this->string, 'UTF-8');
  90175. }
  90176. public function prepend(string ...$prefix): AbstractString
  90177. {
  90178. $str = clone $this;
  90179. $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
  90180. if (!preg_match('//u', $str->string)) {
  90181. throw new InvalidArgumentException('Invalid UTF-8 string.');
  90182. }
  90183. return $str;
  90184. }
  90185. public function replace(string $from, string $to): AbstractString
  90186. {
  90187. $str = clone $this;
  90188. if ('' === $from || !preg_match('//u', $from)) {
  90189. return $str;
  90190. }
  90191. if ('' !== $to && !preg_match('//u', $to)) {
  90192. throw new InvalidArgumentException('Invalid UTF-8 string.');
  90193. }
  90194. if ($this->ignoreCase) {
  90195. $str->string = implode($to, preg_split('{'.preg_quote($from).'}iuD', $this->string));
  90196. } else {
  90197. $str->string = str_replace($from, $to, $this->string);
  90198. }
  90199. return $str;
  90200. }
  90201. public function slice(int $start = 0, ?int $length = null): AbstractString
  90202. {
  90203. $str = clone $this;
  90204. $str->string = mb_substr($this->string, $start, $length, 'UTF-8');
  90205. return $str;
  90206. }
  90207. public function splice(string $replacement, int $start = 0, ?int $length = null): AbstractString
  90208. {
  90209. if (!preg_match('//u', $replacement)) {
  90210. throw new InvalidArgumentException('Invalid UTF-8 string.');
  90211. }
  90212. $str = clone $this;
  90213. $start = $start ? \strlen(mb_substr($this->string, 0, $start, 'UTF-8')) : 0;
  90214. $length = $length ? \strlen(mb_substr($this->string, $start, $length, 'UTF-8')) : $length;
  90215. $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
  90216. return $str;
  90217. }
  90218. public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
  90219. {
  90220. if (1 > $limit = $limit ?? \PHP_INT_MAX) {
  90221. throw new InvalidArgumentException('Split limit must be a positive integer.');
  90222. }
  90223. if ('' === $delimiter) {
  90224. throw new InvalidArgumentException('Split delimiter is empty.');
  90225. }
  90226. if (null !== $flags) {
  90227. return parent::split($delimiter.'u', $limit, $flags);
  90228. }
  90229. if (!preg_match('//u', $delimiter)) {
  90230. throw new InvalidArgumentException('Split delimiter is not a valid UTF-8 string.');
  90231. }
  90232. $str = clone $this;
  90233. $chunks = $this->ignoreCase
  90234. ? preg_split('{'.preg_quote($delimiter).'}iuD', $this->string, $limit)
  90235. : explode($delimiter, $this->string, $limit);
  90236. foreach ($chunks as &$chunk) {
  90237. $str->string = $chunk;
  90238. $chunk = clone $str;
  90239. }
  90240. return $chunks;
  90241. }
  90242. public function startsWith($prefix): bool
  90243. {
  90244. if ($prefix instanceof AbstractString) {
  90245. $prefix = $prefix->string;
  90246. } elseif (\is_array($prefix) || $prefix instanceof \Traversable) {
  90247. return parent::startsWith($prefix);
  90248. } else {
  90249. $prefix = (string) $prefix;
  90250. }
  90251. if ('' === $prefix || !preg_match('//u', $prefix)) {
  90252. return false;
  90253. }
  90254. if ($this->ignoreCase) {
  90255. return 0 === mb_stripos($this->string, $prefix, 0, 'UTF-8');
  90256. }
  90257. return 0 === strncmp($this->string, $prefix, \strlen($prefix));
  90258. }
  90259. }
  90260. <?php
  90261. namespace Symfony\Component\String\Exception;
  90262. interface ExceptionInterface extends \Throwable
  90263. {
  90264. }
  90265. <?php
  90266. namespace Symfony\Component\String\Exception;
  90267. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  90268. {
  90269. }
  90270. <?php
  90271. namespace Symfony\Component\String\Exception;
  90272. class RuntimeException extends \RuntimeException implements ExceptionInterface
  90273. {
  90274. }
  90275. <?php
  90276. namespace Symfony\Component\String\Inflector;
  90277. final class EnglishInflector implements InflectorInterface
  90278. {
  90279. private const PLURAL_MAP = [
  90280. ['airetcab', 8, true, true, 'bacterium'],
  90281. ['aroproc', 7, true, true, 'corpus'],
  90282. ['airetirc', 8, true, true, 'criterion'],
  90283. ['alucirruc', 9, true, true, 'curriculum'],
  90284. ['areneg', 6, true, true, 'genus'],
  90285. ['aidem', 5, true, true, 'medium'],
  90286. ['adnaromem', 9, true, true, 'memorandum'],
  90287. ['anemonehp', 9, true, true, 'phenomenon'],
  90288. ['atarts', 6, true, true, 'stratum'],
  90289. ['ea', 2, true, true, 'a'],
  90290. ['secivres', 8, true, true, 'service'],
  90291. ['eci', 3, false, true, 'ouse'],
  90292. ['esee', 4, false, true, 'oose'],
  90293. ['i', 1, true, true, 'us'],
  90294. ['nem', 3, true, true, 'man'],
  90295. ['nerdlihc', 8, true, true, 'child'],
  90296. ['nexo', 4, false, false, 'ox'],
  90297. ['seci', 4, false, true, ['ex', 'ix', 'ice']],
  90298. ['sedoc', 5, false, true, 'code'],
  90299. ['seifles', 7, true, true, 'selfie'],
  90300. ['seibmoz', 7, true, true, 'zombie'],
  90301. ['seivom', 6, true, true, 'movie'],
  90302. ['seman', 5, true, false, 'name'],
  90303. ['sesutcep', 8, true, true, 'pectus'],
  90304. ['teef', 4, true, true, 'foot'],
  90305. ['eseeg', 5, true, true, 'goose'],
  90306. ['hteet', 5, true, true, 'tooth'],
  90307. ['swen', 4, true, true, 'news'],
  90308. ['seires', 6, true, true, 'series'],
  90309. ['sei', 3, false, true, 'y'],
  90310. ['sess', 4, true, false, 'ss'],
  90311. ['sesutats', 8, true, true, 'status'],
  90312. ['sel', 3, true, true, 'le'],
  90313. ['ses', 3, true, true, ['s', 'se', 'sis']],
  90314. ['sevit', 5, true, true, 'tive'],
  90315. ['sevird', 6, false, true, 'drive'],
  90316. ['sevi', 4, false, true, 'ife'],
  90317. ['sevom', 5, true, true, 'move'],
  90318. ['sev', 3, true, true, ['f', 've', 'ff']],
  90319. ['sexa', 4, false, false, ['ax', 'axe', 'axis']],
  90320. ['sex', 3, true, false, 'x'],
  90321. ['sezz', 4, true, false, 'z'],
  90322. ['suae', 4, false, true, 'eau'],
  90323. ['see', 3, true, true, 'ee'],
  90324. ['segd', 4, true, true, 'dge'],
  90325. ['se', 2, true, true, ['', 'e']],
  90326. ['sutats', 6, true, true, 'status'],
  90327. ['s', 1, true, true, ''],
  90328. ['xuae', 4, false, true, 'eau'],
  90329. ['elpoep', 6, true, true, 'person'],
  90330. ];
  90331. private const SINGULAR_MAP = [
  90332. ['sixa', 4, false, false, 'axes'],
  90333. ['airetirc', 8, false, false, 'criterion'],
  90334. ['aluben', 6, false, false, 'nebulae'],
  90335. ['dlihc', 5, true, true, 'children'],
  90336. ['eci', 3, false, true, 'ices'],
  90337. ['ecivres', 7, true, true, 'services'],
  90338. ['efi', 3, false, true, 'ives'],
  90339. ['eifles', 6, true, true, 'selfies'],
  90340. ['eivom', 5, true, true, 'movies'],
  90341. ['esuol', 5, false, true, 'lice'],
  90342. ['esuom', 5, false, true, 'mice'],
  90343. ['esoo', 4, false, true, 'eese'],
  90344. ['es', 2, true, true, 'ses'],
  90345. ['esoog', 5, true, true, 'geese'],
  90346. ['ev', 2, true, true, 'ves'],
  90347. ['evird', 5, false, true, 'drives'],
  90348. ['evit', 4, true, true, 'tives'],
  90349. ['evom', 4, true, true, 'moves'],
  90350. ['ffats', 5, true, true, 'staves'],
  90351. ['ff', 2, true, true, 'ffs'],
  90352. ['f', 1, true, true, ['fs', 'ves']],
  90353. ['hc', 2, true, true, 'ches'],
  90354. ['hs', 2, true, true, 'shes'],
  90355. ['htoot', 5, true, true, 'teeth'],
  90356. ['mubla', 5, true, true, 'albums'],
  90357. ['mu', 2, true, true, 'a'],
  90358. ['nam', 3, true, true, 'men'],
  90359. ['nosrep', 6, true, true, ['persons', 'people']],
  90360. ['noiretirc', 9, true, true, 'criteria'],
  90361. ['nonemonehp', 10, true, true, 'phenomena'],
  90362. ['ohce', 4, true, true, 'echoes'],
  90363. ['oreh', 4, true, true, 'heroes'],
  90364. ['salta', 5, true, true, 'atlases'],
  90365. ['saila', 5, true, true, 'aliases'],
  90366. ['siri', 4, true, true, 'irises'],
  90367. ['sis', 3, true, true, 'ses'],
  90368. ['ss', 2, true, false, 'sses'],
  90369. ['suballys', 8, true, true, 'syllabi'],
  90370. ['sub', 3, true, true, 'buses'],
  90371. ['suc', 3, true, true, 'cuses'],
  90372. ['supmacoppih', 11, false, false, 'hippocampi'],
  90373. ['sup', 3, true, true, 'puses'],
  90374. ['sutats', 6, true, true, ['status', 'statuses']],
  90375. ['sutcep', 6, true, true, 'pectuses'],
  90376. ['su', 2, true, true, 'i'],
  90377. ['swen', 4, true, true, 'news'],
  90378. ['toof', 4, true, true, 'feet'],
  90379. ['uae', 3, false, true, ['eaus', 'eaux']],
  90380. ['xo', 2, false, false, 'oxen'],
  90381. ['xaoh', 4, true, false, 'hoaxes'],
  90382. ['xedni', 5, false, true, ['indicies', 'indexes']],
  90383. ['xaf', 3, true, true, ['faxes', 'faxxes']],
  90384. ['xo', 2, false, true, 'oxes'],
  90385. ['x', 1, true, false, ['ces', 'xes']],
  90386. ['y', 1, false, true, 'ies'],
  90387. ['ziuq', 4, true, false, 'quizzes'],
  90388. ['z', 1, true, true, 'zes'],
  90389. ];
  90390. private const UNINFLECTED = [
  90391. '',
  90392. 'atad',
  90393. 'reed',
  90394. 'tnempiuqe',
  90395. 'kcabdeef',
  90396. 'hsif',
  90397. 'htlaeh',
  90398. 'yrotsih',
  90399. 'ofni',
  90400. 'noitamrofni',
  90401. 'yenom',
  90402. 'esoom',
  90403. 'seires',
  90404. 'peehs',
  90405. 'seiceps',
  90406. 'ciffart',
  90407. 'tfarcria',
  90408. 'erawdrah',
  90409. ];
  90410. public function singularize(string $plural): array
  90411. {
  90412. $pluralRev = strrev($plural);
  90413. $lowerPluralRev = strtolower($pluralRev);
  90414. $pluralLength = \strlen($lowerPluralRev);
  90415. if (\in_array($lowerPluralRev, self::UNINFLECTED, true)) {
  90416. return [$plural];
  90417. }
  90418. foreach (self::PLURAL_MAP as $map) {
  90419. $suffix = $map[0];
  90420. $suffixLength = $map[1];
  90421. $j = 0;
  90422. while ($suffix[$j] === $lowerPluralRev[$j]) {
  90423. ++$j;
  90424. if ($j === $suffixLength) {
  90425. if ($j < $pluralLength) {
  90426. $nextIsVowel = str_contains('aeiou', $lowerPluralRev[$j]);
  90427. if (!$map[2] && $nextIsVowel) {
  90428. break;
  90429. }
  90430. if (!$map[3] && !$nextIsVowel) {
  90431. break;
  90432. }
  90433. }
  90434. $newBase = substr($plural, 0, $pluralLength - $suffixLength);
  90435. $newSuffix = $map[4];
  90436. $firstUpper = ctype_upper($pluralRev[$j - 1]);
  90437. if (\is_array($newSuffix)) {
  90438. $singulars = [];
  90439. foreach ($newSuffix as $newSuffixEntry) {
  90440. $singulars[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
  90441. }
  90442. return $singulars;
  90443. }
  90444. return [$newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix)];
  90445. }
  90446. if ($j === $pluralLength) {
  90447. break;
  90448. }
  90449. }
  90450. }
  90451. return [$plural];
  90452. }
  90453. public function pluralize(string $singular): array
  90454. {
  90455. $singularRev = strrev($singular);
  90456. $lowerSingularRev = strtolower($singularRev);
  90457. $singularLength = \strlen($lowerSingularRev);
  90458. if (\in_array($lowerSingularRev, self::UNINFLECTED, true)) {
  90459. return [$singular];
  90460. }
  90461. foreach (self::SINGULAR_MAP as $map) {
  90462. $suffix = $map[0];
  90463. $suffixLength = $map[1];
  90464. $j = 0;
  90465. while ($suffix[$j] === $lowerSingularRev[$j]) {
  90466. ++$j;
  90467. if ($j === $suffixLength) {
  90468. if ($j < $singularLength) {
  90469. $nextIsVowel = str_contains('aeiou', $lowerSingularRev[$j]);
  90470. if (!$map[2] && $nextIsVowel) {
  90471. break;
  90472. }
  90473. if (!$map[3] && !$nextIsVowel) {
  90474. break;
  90475. }
  90476. }
  90477. $newBase = substr($singular, 0, $singularLength - $suffixLength);
  90478. $newSuffix = $map[4];
  90479. $firstUpper = ctype_upper($singularRev[$j - 1]);
  90480. if (\is_array($newSuffix)) {
  90481. $plurals = [];
  90482. foreach ($newSuffix as $newSuffixEntry) {
  90483. $plurals[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
  90484. }
  90485. return $plurals;
  90486. }
  90487. return [$newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix)];
  90488. }
  90489. if ($j === $singularLength) {
  90490. break;
  90491. }
  90492. }
  90493. }
  90494. return [$singular.'s'];
  90495. }
  90496. }
  90497. <?php
  90498. namespace Symfony\Component\String\Inflector;
  90499. final class FrenchInflector implements InflectorInterface
  90500. {
  90501. private const PLURALIZE_REGEXP = [
  90502. ['/(s|x|z)$/i', '\1'],
  90503. ['/(eau)$/i', '\1x'],
  90504. ['/^(landau)$/i', '\1s'],
  90505. ['/(au)$/i', '\1x'],
  90506. ['/^(pneu|bleu|émeu)$/i', '\1s'],
  90507. ['/(eu)$/i', '\1x'],
  90508. ['/^(bal|carnaval|caracal|chacal|choral|corral|étal|festival|récital|val)$/i', '\1s'],
  90509. ['/al$/i', '\1aux'],
  90510. ['/^(aspir|b|cor|ém|ferm|soupir|trav|vant|vitr)ail$/i', '\1aux'],
  90511. ['/^(bij|caill|ch|gen|hib|jouj|p)ou$/i', '\1oux'],
  90512. ['/^(cinquante|soixante|mille)$/i', '\1'],
  90513. ['/^(mon|ma)(sieur|dame|demoiselle|seigneur)$/', 'mes\2s'],
  90514. ['/^(Mon|Ma)(sieur|dame|demoiselle|seigneur)$/', 'Mes\2s'],
  90515. ];
  90516. private const SINGULARIZE_REGEXP = [
  90517. ['/((aspir|b|cor|ém|ferm|soupir|trav|vant|vitr))aux$/i', '\1ail'],
  90518. ['/(eau)x$/i', '\1'],
  90519. ['/(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'],
  90520. ['/(au)x$/i', '\1'],
  90521. ['/(eu)x$/i', '\1'],
  90522. ['/(bij|caill|ch|gen|hib|jouj|p)oux$/i', '\1ou'],
  90523. ['/^mes(dame|demoiselle)s$/', 'ma\1'],
  90524. ['/^Mes(dame|demoiselle)s$/', 'Ma\1'],
  90525. ['/^mes(sieur|seigneur)s$/', 'mon\1'],
  90526. ['/^Mes(sieur|seigneur)s$/', 'Mon\1'],
  90527. ['/s$/i', ''],
  90528. ];
  90529. 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';
  90530. public function singularize(string $plural): array
  90531. {
  90532. if ($this->isInflectedWord($plural)) {
  90533. return [$plural];
  90534. }
  90535. foreach (self::SINGULARIZE_REGEXP as $rule) {
  90536. [$regexp, $replace] = $rule;
  90537. if (1 === preg_match($regexp, $plural)) {
  90538. return [preg_replace($regexp, $replace, $plural)];
  90539. }
  90540. }
  90541. return [$plural];
  90542. }
  90543. public function pluralize(string $singular): array
  90544. {
  90545. if ($this->isInflectedWord($singular)) {
  90546. return [$singular];
  90547. }
  90548. foreach (self::PLURALIZE_REGEXP as $rule) {
  90549. [$regexp, $replace] = $rule;
  90550. if (1 === preg_match($regexp, $singular)) {
  90551. return [preg_replace($regexp, $replace, $singular)];
  90552. }
  90553. }
  90554. return [$singular.'s'];
  90555. }
  90556. private function isInflectedWord(string $word): bool
  90557. {
  90558. return 1 === preg_match(self::UNINFLECTED, $word);
  90559. }
  90560. }
  90561. <?php
  90562. namespace Symfony\Component\String\Inflector;
  90563. interface InflectorInterface
  90564. {
  90565. public function singularize(string $plural): array;
  90566. public function pluralize(string $singular): array;
  90567. }
  90568. Copyright (c) 2019-present Fabien Potencier
  90569. Permission is hereby granted, free of charge, to any person obtaining a copy
  90570. of this software and associated documentation files (the "Software"), to deal
  90571. in the Software without restriction, including without limitation the rights
  90572. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  90573. copies of the Software, and to permit persons to whom the Software is furnished
  90574. to do so, subject to the following conditions:
  90575. The above copyright notice and this permission notice shall be included in all
  90576. copies or substantial portions of the Software.
  90577. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  90578. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  90579. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  90580. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  90581. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  90582. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  90583. THE SOFTWARE.
  90584. <?php
  90585. namespace Symfony\Component\String;
  90586. class LazyString implements \Stringable, \JsonSerializable
  90587. {
  90588. private $value;
  90589. public static function fromCallable($callback, ...$arguments): self
  90590. {
  90591. if (!\is_callable($callback) && !(\is_array($callback) && isset($callback[0]) && $callback[0] instanceof \Closure && 2 >= \count($callback))) {
  90592. 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)));
  90593. }
  90594. $lazyString = new static();
  90595. $lazyString->value = static function () use (&$callback, &$arguments, &$value): string {
  90596. if (null !== $arguments) {
  90597. if (!\is_callable($callback)) {
  90598. $callback[0] = $callback[0]();
  90599. $callback[1] = $callback[1] ?? '__invoke';
  90600. }
  90601. $value = $callback(...$arguments);
  90602. $callback = self::getPrettyName($callback);
  90603. $arguments = null;
  90604. }
  90605. return $value ?? '';
  90606. };
  90607. return $lazyString;
  90608. }
  90609. public static function fromStringable($value): self
  90610. {
  90611. if (!self::isStringable($value)) {
  90612. throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a scalar or a stringable object, "%s" given.', __METHOD__, get_debug_type($value)));
  90613. }
  90614. if (\is_object($value)) {
  90615. return static::fromCallable([$value, '__toString']);
  90616. }
  90617. $lazyString = new static();
  90618. $lazyString->value = (string) $value;
  90619. return $lazyString;
  90620. }
  90621. final public static function isStringable($value): bool
  90622. {
  90623. return \is_string($value) || $value instanceof self || (\is_object($value) ? method_exists($value, '__toString') : \is_scalar($value));
  90624. }
  90625. final public static function resolve($value): string
  90626. {
  90627. return $value;
  90628. }
  90629. public function __toString()
  90630. {
  90631. if (\is_string($this->value)) {
  90632. return $this->value;
  90633. }
  90634. try {
  90635. return $this->value = ($this->value)();
  90636. } catch (\Throwable $e) {
  90637. if (\TypeError::class === \get_class($e) && __FILE__ === $e->getFile()) {
  90638. $type = explode(', ', $e->getMessage());
  90639. $type = substr(array_pop($type), 0, -\strlen(' returned'));
  90640. $r = new \ReflectionFunction($this->value);
  90641. $callback = $r->getStaticVariables()['callback'];
  90642. $e = new \TypeError(sprintf('Return value of %s() passed to %s::fromCallable() must be of the type string, %s returned.', $callback, static::class, $type));
  90643. }
  90644. if (\PHP_VERSION_ID < 70400) {
  90645. return trigger_error($e, \E_USER_ERROR);
  90646. }
  90647. throw $e;
  90648. }
  90649. }
  90650. public function __sleep(): array
  90651. {
  90652. $this->__toString();
  90653. return ['value'];
  90654. }
  90655. public function jsonSerialize(): string
  90656. {
  90657. return $this->__toString();
  90658. }
  90659. private function __construct()
  90660. {
  90661. }
  90662. private static function getPrettyName(callable $callback): string
  90663. {
  90664. if (\is_string($callback)) {
  90665. return $callback;
  90666. }
  90667. if (\is_array($callback)) {
  90668. $class = \is_object($callback[0]) ? get_debug_type($callback[0]) : $callback[0];
  90669. $method = $callback[1];
  90670. } elseif ($callback instanceof \Closure) {
  90671. $r = new \ReflectionFunction($callback);
  90672. if (str_contains($r->name, '{closure') || !$class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
  90673. return $r->name;
  90674. }
  90675. $class = $class->name;
  90676. $method = $r->name;
  90677. } else {
  90678. $class = get_debug_type($callback);
  90679. $method = '__invoke';
  90680. }
  90681. return $class.'::'.$method;
  90682. }
  90683. }
  90684. <?php
  90685. return [
  90686. [
  90687. 4352,
  90688. 4447,
  90689. ],
  90690. [
  90691. 8986,
  90692. 8987,
  90693. ],
  90694. [
  90695. 9001,
  90696. 9001,
  90697. ],
  90698. [
  90699. 9002,
  90700. 9002,
  90701. ],
  90702. [
  90703. 9193,
  90704. 9196,
  90705. ],
  90706. [
  90707. 9200,
  90708. 9200,
  90709. ],
  90710. [
  90711. 9203,
  90712. 9203,
  90713. ],
  90714. [
  90715. 9725,
  90716. 9726,
  90717. ],
  90718. [
  90719. 9748,
  90720. 9749,
  90721. ],
  90722. [
  90723. 9776,
  90724. 9783,
  90725. ],
  90726. [
  90727. 9800,
  90728. 9811,
  90729. ],
  90730. [
  90731. 9855,
  90732. 9855,
  90733. ],
  90734. [
  90735. 9866,
  90736. 9871,
  90737. ],
  90738. [
  90739. 9875,
  90740. 9875,
  90741. ],
  90742. [
  90743. 9889,
  90744. 9889,
  90745. ],
  90746. [
  90747. 9898,
  90748. 9899,
  90749. ],
  90750. [
  90751. 9917,
  90752. 9918,
  90753. ],
  90754. [
  90755. 9924,
  90756. 9925,
  90757. ],
  90758. [
  90759. 9934,
  90760. 9934,
  90761. ],
  90762. [
  90763. 9940,
  90764. 9940,
  90765. ],
  90766. [
  90767. 9962,
  90768. 9962,
  90769. ],
  90770. [
  90771. 9970,
  90772. 9971,
  90773. ],
  90774. [
  90775. 9973,
  90776. 9973,
  90777. ],
  90778. [
  90779. 9978,
  90780. 9978,
  90781. ],
  90782. [
  90783. 9981,
  90784. 9981,
  90785. ],
  90786. [
  90787. 9989,
  90788. 9989,
  90789. ],
  90790. [
  90791. 9994,
  90792. 9995,
  90793. ],
  90794. [
  90795. 10024,
  90796. 10024,
  90797. ],
  90798. [
  90799. 10060,
  90800. 10060,
  90801. ],
  90802. [
  90803. 10062,
  90804. 10062,
  90805. ],
  90806. [
  90807. 10067,
  90808. 10069,
  90809. ],
  90810. [
  90811. 10071,
  90812. 10071,
  90813. ],
  90814. [
  90815. 10133,
  90816. 10135,
  90817. ],
  90818. [
  90819. 10160,
  90820. 10160,
  90821. ],
  90822. [
  90823. 10175,
  90824. 10175,
  90825. ],
  90826. [
  90827. 11035,
  90828. 11036,
  90829. ],
  90830. [
  90831. 11088,
  90832. 11088,
  90833. ],
  90834. [
  90835. 11093,
  90836. 11093,
  90837. ],
  90838. [
  90839. 11904,
  90840. 11929,
  90841. ],
  90842. [
  90843. 11931,
  90844. 12019,
  90845. ],
  90846. [
  90847. 12032,
  90848. 12245,
  90849. ],
  90850. [
  90851. 12272,
  90852. 12287,
  90853. ],
  90854. [
  90855. 12288,
  90856. 12288,
  90857. ],
  90858. [
  90859. 12289,
  90860. 12291,
  90861. ],
  90862. [
  90863. 12292,
  90864. 12292,
  90865. ],
  90866. [
  90867. 12293,
  90868. 12293,
  90869. ],
  90870. [
  90871. 12294,
  90872. 12294,
  90873. ],
  90874. [
  90875. 12295,
  90876. 12295,
  90877. ],
  90878. [
  90879. 12296,
  90880. 12296,
  90881. ],
  90882. [
  90883. 12297,
  90884. 12297,
  90885. ],
  90886. [
  90887. 12298,
  90888. 12298,
  90889. ],
  90890. [
  90891. 12299,
  90892. 12299,
  90893. ],
  90894. [
  90895. 12300,
  90896. 12300,
  90897. ],
  90898. [
  90899. 12301,
  90900. 12301,
  90901. ],
  90902. [
  90903. 12302,
  90904. 12302,
  90905. ],
  90906. [
  90907. 12303,
  90908. 12303,
  90909. ],
  90910. [
  90911. 12304,
  90912. 12304,
  90913. ],
  90914. [
  90915. 12305,
  90916. 12305,
  90917. ],
  90918. [
  90919. 12306,
  90920. 12307,
  90921. ],
  90922. [
  90923. 12308,
  90924. 12308,
  90925. ],
  90926. [
  90927. 12309,
  90928. 12309,
  90929. ],
  90930. [
  90931. 12310,
  90932. 12310,
  90933. ],
  90934. [
  90935. 12311,
  90936. 12311,
  90937. ],
  90938. [
  90939. 12312,
  90940. 12312,
  90941. ],
  90942. [
  90943. 12313,
  90944. 12313,
  90945. ],
  90946. [
  90947. 12314,
  90948. 12314,
  90949. ],
  90950. [
  90951. 12315,
  90952. 12315,
  90953. ],
  90954. [
  90955. 12316,
  90956. 12316,
  90957. ],
  90958. [
  90959. 12317,
  90960. 12317,
  90961. ],
  90962. [
  90963. 12318,
  90964. 12319,
  90965. ],
  90966. [
  90967. 12320,
  90968. 12320,
  90969. ],
  90970. [
  90971. 12321,
  90972. 12329,
  90973. ],
  90974. [
  90975. 12330,
  90976. 12333,
  90977. ],
  90978. [
  90979. 12334,
  90980. 12335,
  90981. ],
  90982. [
  90983. 12336,
  90984. 12336,
  90985. ],
  90986. [
  90987. 12337,
  90988. 12341,
  90989. ],
  90990. [
  90991. 12342,
  90992. 12343,
  90993. ],
  90994. [
  90995. 12344,
  90996. 12346,
  90997. ],
  90998. [
  90999. 12347,
  91000. 12347,
  91001. ],
  91002. [
  91003. 12348,
  91004. 12348,
  91005. ],
  91006. [
  91007. 12349,
  91008. 12349,
  91009. ],
  91010. [
  91011. 12350,
  91012. 12350,
  91013. ],
  91014. [
  91015. 12353,
  91016. 12438,
  91017. ],
  91018. [
  91019. 12441,
  91020. 12442,
  91021. ],
  91022. [
  91023. 12443,
  91024. 12444,
  91025. ],
  91026. [
  91027. 12445,
  91028. 12446,
  91029. ],
  91030. [
  91031. 12447,
  91032. 12447,
  91033. ],
  91034. [
  91035. 12448,
  91036. 12448,
  91037. ],
  91038. [
  91039. 12449,
  91040. 12538,
  91041. ],
  91042. [
  91043. 12539,
  91044. 12539,
  91045. ],
  91046. [
  91047. 12540,
  91048. 12542,
  91049. ],
  91050. [
  91051. 12543,
  91052. 12543,
  91053. ],
  91054. [
  91055. 12549,
  91056. 12591,
  91057. ],
  91058. [
  91059. 12593,
  91060. 12686,
  91061. ],
  91062. [
  91063. 12688,
  91064. 12689,
  91065. ],
  91066. [
  91067. 12690,
  91068. 12693,
  91069. ],
  91070. [
  91071. 12694,
  91072. 12703,
  91073. ],
  91074. [
  91075. 12704,
  91076. 12735,
  91077. ],
  91078. [
  91079. 12736,
  91080. 12773,
  91081. ],
  91082. [
  91083. 12783,
  91084. 12783,
  91085. ],
  91086. [
  91087. 12784,
  91088. 12799,
  91089. ],
  91090. [
  91091. 12800,
  91092. 12830,
  91093. ],
  91094. [
  91095. 12832,
  91096. 12841,
  91097. ],
  91098. [
  91099. 12842,
  91100. 12871,
  91101. ],
  91102. [
  91103. 12880,
  91104. 12880,
  91105. ],
  91106. [
  91107. 12881,
  91108. 12895,
  91109. ],
  91110. [
  91111. 12896,
  91112. 12927,
  91113. ],
  91114. [
  91115. 12928,
  91116. 12937,
  91117. ],
  91118. [
  91119. 12938,
  91120. 12976,
  91121. ],
  91122. [
  91123. 12977,
  91124. 12991,
  91125. ],
  91126. [
  91127. 12992,
  91128. 13055,
  91129. ],
  91130. [
  91131. 13056,
  91132. 13311,
  91133. ],
  91134. [
  91135. 13312,
  91136. 19903,
  91137. ],
  91138. [
  91139. 19904,
  91140. 19967,
  91141. ],
  91142. [
  91143. 19968,
  91144. 40959,
  91145. ],
  91146. [
  91147. 40960,
  91148. 40980,
  91149. ],
  91150. [
  91151. 40981,
  91152. 40981,
  91153. ],
  91154. [
  91155. 40982,
  91156. 42124,
  91157. ],
  91158. [
  91159. 42128,
  91160. 42182,
  91161. ],
  91162. [
  91163. 43360,
  91164. 43388,
  91165. ],
  91166. [
  91167. 44032,
  91168. 55203,
  91169. ],
  91170. [
  91171. 63744,
  91172. 64109,
  91173. ],
  91174. [
  91175. 64110,
  91176. 64111,
  91177. ],
  91178. [
  91179. 64112,
  91180. 64217,
  91181. ],
  91182. [
  91183. 64218,
  91184. 64255,
  91185. ],
  91186. [
  91187. 65040,
  91188. 65046,
  91189. ],
  91190. [
  91191. 65047,
  91192. 65047,
  91193. ],
  91194. [
  91195. 65048,
  91196. 65048,
  91197. ],
  91198. [
  91199. 65049,
  91200. 65049,
  91201. ],
  91202. [
  91203. 65072,
  91204. 65072,
  91205. ],
  91206. [
  91207. 65073,
  91208. 65074,
  91209. ],
  91210. [
  91211. 65075,
  91212. 65076,
  91213. ],
  91214. [
  91215. 65077,
  91216. 65077,
  91217. ],
  91218. [
  91219. 65078,
  91220. 65078,
  91221. ],
  91222. [
  91223. 65079,
  91224. 65079,
  91225. ],
  91226. [
  91227. 65080,
  91228. 65080,
  91229. ],
  91230. [
  91231. 65081,
  91232. 65081,
  91233. ],
  91234. [
  91235. 65082,
  91236. 65082,
  91237. ],
  91238. [
  91239. 65083,
  91240. 65083,
  91241. ],
  91242. [
  91243. 65084,
  91244. 65084,
  91245. ],
  91246. [
  91247. 65085,
  91248. 65085,
  91249. ],
  91250. [
  91251. 65086,
  91252. 65086,
  91253. ],
  91254. [
  91255. 65087,
  91256. 65087,
  91257. ],
  91258. [
  91259. 65088,
  91260. 65088,
  91261. ],
  91262. [
  91263. 65089,
  91264. 65089,
  91265. ],
  91266. [
  91267. 65090,
  91268. 65090,
  91269. ],
  91270. [
  91271. 65091,
  91272. 65091,
  91273. ],
  91274. [
  91275. 65092,
  91276. 65092,
  91277. ],
  91278. [
  91279. 65093,
  91280. 65094,
  91281. ],
  91282. [
  91283. 65095,
  91284. 65095,
  91285. ],
  91286. [
  91287. 65096,
  91288. 65096,
  91289. ],
  91290. [
  91291. 65097,
  91292. 65100,
  91293. ],
  91294. [
  91295. 65101,
  91296. 65103,
  91297. ],
  91298. [
  91299. 65104,
  91300. 65106,
  91301. ],
  91302. [
  91303. 65108,
  91304. 65111,
  91305. ],
  91306. [
  91307. 65112,
  91308. 65112,
  91309. ],
  91310. [
  91311. 65113,
  91312. 65113,
  91313. ],
  91314. [
  91315. 65114,
  91316. 65114,
  91317. ],
  91318. [
  91319. 65115,
  91320. 65115,
  91321. ],
  91322. [
  91323. 65116,
  91324. 65116,
  91325. ],
  91326. [
  91327. 65117,
  91328. 65117,
  91329. ],
  91330. [
  91331. 65118,
  91332. 65118,
  91333. ],
  91334. [
  91335. 65119,
  91336. 65121,
  91337. ],
  91338. [
  91339. 65122,
  91340. 65122,
  91341. ],
  91342. [
  91343. 65123,
  91344. 65123,
  91345. ],
  91346. [
  91347. 65124,
  91348. 65126,
  91349. ],
  91350. [
  91351. 65128,
  91352. 65128,
  91353. ],
  91354. [
  91355. 65129,
  91356. 65129,
  91357. ],
  91358. [
  91359. 65130,
  91360. 65131,
  91361. ],
  91362. [
  91363. 65281,
  91364. 65283,
  91365. ],
  91366. [
  91367. 65284,
  91368. 65284,
  91369. ],
  91370. [
  91371. 65285,
  91372. 65287,
  91373. ],
  91374. [
  91375. 65288,
  91376. 65288,
  91377. ],
  91378. [
  91379. 65289,
  91380. 65289,
  91381. ],
  91382. [
  91383. 65290,
  91384. 65290,
  91385. ],
  91386. [
  91387. 65291,
  91388. 65291,
  91389. ],
  91390. [
  91391. 65292,
  91392. 65292,
  91393. ],
  91394. [
  91395. 65293,
  91396. 65293,
  91397. ],
  91398. [
  91399. 65294,
  91400. 65295,
  91401. ],
  91402. [
  91403. 65296,
  91404. 65305,
  91405. ],
  91406. [
  91407. 65306,
  91408. 65307,
  91409. ],
  91410. [
  91411. 65308,
  91412. 65310,
  91413. ],
  91414. [
  91415. 65311,
  91416. 65312,
  91417. ],
  91418. [
  91419. 65313,
  91420. 65338,
  91421. ],
  91422. [
  91423. 65339,
  91424. 65339,
  91425. ],
  91426. [
  91427. 65340,
  91428. 65340,
  91429. ],
  91430. [
  91431. 65341,
  91432. 65341,
  91433. ],
  91434. [
  91435. 65342,
  91436. 65342,
  91437. ],
  91438. [
  91439. 65343,
  91440. 65343,
  91441. ],
  91442. [
  91443. 65344,
  91444. 65344,
  91445. ],
  91446. [
  91447. 65345,
  91448. 65370,
  91449. ],
  91450. [
  91451. 65371,
  91452. 65371,
  91453. ],
  91454. [
  91455. 65372,
  91456. 65372,
  91457. ],
  91458. [
  91459. 65373,
  91460. 65373,
  91461. ],
  91462. [
  91463. 65374,
  91464. 65374,
  91465. ],
  91466. [
  91467. 65375,
  91468. 65375,
  91469. ],
  91470. [
  91471. 65376,
  91472. 65376,
  91473. ],
  91474. [
  91475. 65504,
  91476. 65505,
  91477. ],
  91478. [
  91479. 65506,
  91480. 65506,
  91481. ],
  91482. [
  91483. 65507,
  91484. 65507,
  91485. ],
  91486. [
  91487. 65508,
  91488. 65508,
  91489. ],
  91490. [
  91491. 65509,
  91492. 65510,
  91493. ],
  91494. [
  91495. 94176,
  91496. 94177,
  91497. ],
  91498. [
  91499. 94178,
  91500. 94178,
  91501. ],
  91502. [
  91503. 94179,
  91504. 94179,
  91505. ],
  91506. [
  91507. 94180,
  91508. 94180,
  91509. ],
  91510. [
  91511. 94192,
  91512. 94193,
  91513. ],
  91514. [
  91515. 94208,
  91516. 100343,
  91517. ],
  91518. [
  91519. 100352,
  91520. 101119,
  91521. ],
  91522. [
  91523. 101120,
  91524. 101589,
  91525. ],
  91526. [
  91527. 101631,
  91528. 101631,
  91529. ],
  91530. [
  91531. 101632,
  91532. 101640,
  91533. ],
  91534. [
  91535. 110576,
  91536. 110579,
  91537. ],
  91538. [
  91539. 110581,
  91540. 110587,
  91541. ],
  91542. [
  91543. 110589,
  91544. 110590,
  91545. ],
  91546. [
  91547. 110592,
  91548. 110847,
  91549. ],
  91550. [
  91551. 110848,
  91552. 110882,
  91553. ],
  91554. [
  91555. 110898,
  91556. 110898,
  91557. ],
  91558. [
  91559. 110928,
  91560. 110930,
  91561. ],
  91562. [
  91563. 110933,
  91564. 110933,
  91565. ],
  91566. [
  91567. 110948,
  91568. 110951,
  91569. ],
  91570. [
  91571. 110960,
  91572. 111355,
  91573. ],
  91574. [
  91575. 119552,
  91576. 119638,
  91577. ],
  91578. [
  91579. 119648,
  91580. 119670,
  91581. ],
  91582. [
  91583. 126980,
  91584. 126980,
  91585. ],
  91586. [
  91587. 127183,
  91588. 127183,
  91589. ],
  91590. [
  91591. 127374,
  91592. 127374,
  91593. ],
  91594. [
  91595. 127377,
  91596. 127386,
  91597. ],
  91598. [
  91599. 127488,
  91600. 127490,
  91601. ],
  91602. [
  91603. 127504,
  91604. 127547,
  91605. ],
  91606. [
  91607. 127552,
  91608. 127560,
  91609. ],
  91610. [
  91611. 127568,
  91612. 127569,
  91613. ],
  91614. [
  91615. 127584,
  91616. 127589,
  91617. ],
  91618. [
  91619. 127744,
  91620. 127776,
  91621. ],
  91622. [
  91623. 127789,
  91624. 127797,
  91625. ],
  91626. [
  91627. 127799,
  91628. 127868,
  91629. ],
  91630. [
  91631. 127870,
  91632. 127891,
  91633. ],
  91634. [
  91635. 127904,
  91636. 127946,
  91637. ],
  91638. [
  91639. 127951,
  91640. 127955,
  91641. ],
  91642. [
  91643. 127968,
  91644. 127984,
  91645. ],
  91646. [
  91647. 127988,
  91648. 127988,
  91649. ],
  91650. [
  91651. 127992,
  91652. 127994,
  91653. ],
  91654. [
  91655. 127995,
  91656. 127999,
  91657. ],
  91658. [
  91659. 128000,
  91660. 128062,
  91661. ],
  91662. [
  91663. 128064,
  91664. 128064,
  91665. ],
  91666. [
  91667. 128066,
  91668. 128252,
  91669. ],
  91670. [
  91671. 128255,
  91672. 128317,
  91673. ],
  91674. [
  91675. 128331,
  91676. 128334,
  91677. ],
  91678. [
  91679. 128336,
  91680. 128359,
  91681. ],
  91682. [
  91683. 128378,
  91684. 128378,
  91685. ],
  91686. [
  91687. 128405,
  91688. 128406,
  91689. ],
  91690. [
  91691. 128420,
  91692. 128420,
  91693. ],
  91694. [
  91695. 128507,
  91696. 128511,
  91697. ],
  91698. [
  91699. 128512,
  91700. 128591,
  91701. ],
  91702. [
  91703. 128640,
  91704. 128709,
  91705. ],
  91706. [
  91707. 128716,
  91708. 128716,
  91709. ],
  91710. [
  91711. 128720,
  91712. 128722,
  91713. ],
  91714. [
  91715. 128725,
  91716. 128727,
  91717. ],
  91718. [
  91719. 128732,
  91720. 128735,
  91721. ],
  91722. [
  91723. 128747,
  91724. 128748,
  91725. ],
  91726. [
  91727. 128756,
  91728. 128764,
  91729. ],
  91730. [
  91731. 128992,
  91732. 129003,
  91733. ],
  91734. [
  91735. 129008,
  91736. 129008,
  91737. ],
  91738. [
  91739. 129292,
  91740. 129338,
  91741. ],
  91742. [
  91743. 129340,
  91744. 129349,
  91745. ],
  91746. [
  91747. 129351,
  91748. 129535,
  91749. ],
  91750. [
  91751. 129648,
  91752. 129660,
  91753. ],
  91754. [
  91755. 129664,
  91756. 129673,
  91757. ],
  91758. [
  91759. 129679,
  91760. 129734,
  91761. ],
  91762. [
  91763. 129742,
  91764. 129756,
  91765. ],
  91766. [
  91767. 129759,
  91768. 129769,
  91769. ],
  91770. [
  91771. 129776,
  91772. 129784,
  91773. ],
  91774. [
  91775. 131072,
  91776. 173791,
  91777. ],
  91778. [
  91779. 173792,
  91780. 173823,
  91781. ],
  91782. [
  91783. 173824,
  91784. 177977,
  91785. ],
  91786. [
  91787. 177978,
  91788. 177983,
  91789. ],
  91790. [
  91791. 177984,
  91792. 178205,
  91793. ],
  91794. [
  91795. 178206,
  91796. 178207,
  91797. ],
  91798. [
  91799. 178208,
  91800. 183969,
  91801. ],
  91802. [
  91803. 183970,
  91804. 183983,
  91805. ],
  91806. [
  91807. 183984,
  91808. 191456,
  91809. ],
  91810. [
  91811. 191457,
  91812. 191471,
  91813. ],
  91814. [
  91815. 191472,
  91816. 192093,
  91817. ],
  91818. [
  91819. 192094,
  91820. 194559,
  91821. ],
  91822. [
  91823. 194560,
  91824. 195101,
  91825. ],
  91826. [
  91827. 195102,
  91828. 195103,
  91829. ],
  91830. [
  91831. 195104,
  91832. 196605,
  91833. ],
  91834. [
  91835. 196608,
  91836. 201546,
  91837. ],
  91838. [
  91839. 201547,
  91840. 201551,
  91841. ],
  91842. [
  91843. 201552,
  91844. 205743,
  91845. ],
  91846. [
  91847. 205744,
  91848. 262141,
  91849. ],
  91850. ];
  91851. <?php
  91852. return [
  91853. [
  91854. 768,
  91855. 879,
  91856. ],
  91857. [
  91858. 1155,
  91859. 1159,
  91860. ],
  91861. [
  91862. 1160,
  91863. 1161,
  91864. ],
  91865. [
  91866. 1425,
  91867. 1469,
  91868. ],
  91869. [
  91870. 1471,
  91871. 1471,
  91872. ],
  91873. [
  91874. 1473,
  91875. 1474,
  91876. ],
  91877. [
  91878. 1476,
  91879. 1477,
  91880. ],
  91881. [
  91882. 1479,
  91883. 1479,
  91884. ],
  91885. [
  91886. 1552,
  91887. 1562,
  91888. ],
  91889. [
  91890. 1611,
  91891. 1631,
  91892. ],
  91893. [
  91894. 1648,
  91895. 1648,
  91896. ],
  91897. [
  91898. 1750,
  91899. 1756,
  91900. ],
  91901. [
  91902. 1759,
  91903. 1764,
  91904. ],
  91905. [
  91906. 1767,
  91907. 1768,
  91908. ],
  91909. [
  91910. 1770,
  91911. 1773,
  91912. ],
  91913. [
  91914. 1809,
  91915. 1809,
  91916. ],
  91917. [
  91918. 1840,
  91919. 1866,
  91920. ],
  91921. [
  91922. 1958,
  91923. 1968,
  91924. ],
  91925. [
  91926. 2027,
  91927. 2035,
  91928. ],
  91929. [
  91930. 2045,
  91931. 2045,
  91932. ],
  91933. [
  91934. 2070,
  91935. 2073,
  91936. ],
  91937. [
  91938. 2075,
  91939. 2083,
  91940. ],
  91941. [
  91942. 2085,
  91943. 2087,
  91944. ],
  91945. [
  91946. 2089,
  91947. 2093,
  91948. ],
  91949. [
  91950. 2137,
  91951. 2139,
  91952. ],
  91953. [
  91954. 2199,
  91955. 2207,
  91956. ],
  91957. [
  91958. 2250,
  91959. 2273,
  91960. ],
  91961. [
  91962. 2275,
  91963. 2306,
  91964. ],
  91965. [
  91966. 2362,
  91967. 2362,
  91968. ],
  91969. [
  91970. 2364,
  91971. 2364,
  91972. ],
  91973. [
  91974. 2369,
  91975. 2376,
  91976. ],
  91977. [
  91978. 2381,
  91979. 2381,
  91980. ],
  91981. [
  91982. 2385,
  91983. 2391,
  91984. ],
  91985. [
  91986. 2402,
  91987. 2403,
  91988. ],
  91989. [
  91990. 2433,
  91991. 2433,
  91992. ],
  91993. [
  91994. 2492,
  91995. 2492,
  91996. ],
  91997. [
  91998. 2497,
  91999. 2500,
  92000. ],
  92001. [
  92002. 2509,
  92003. 2509,
  92004. ],
  92005. [
  92006. 2530,
  92007. 2531,
  92008. ],
  92009. [
  92010. 2558,
  92011. 2558,
  92012. ],
  92013. [
  92014. 2561,
  92015. 2562,
  92016. ],
  92017. [
  92018. 2620,
  92019. 2620,
  92020. ],
  92021. [
  92022. 2625,
  92023. 2626,
  92024. ],
  92025. [
  92026. 2631,
  92027. 2632,
  92028. ],
  92029. [
  92030. 2635,
  92031. 2637,
  92032. ],
  92033. [
  92034. 2641,
  92035. 2641,
  92036. ],
  92037. [
  92038. 2672,
  92039. 2673,
  92040. ],
  92041. [
  92042. 2677,
  92043. 2677,
  92044. ],
  92045. [
  92046. 2689,
  92047. 2690,
  92048. ],
  92049. [
  92050. 2748,
  92051. 2748,
  92052. ],
  92053. [
  92054. 2753,
  92055. 2757,
  92056. ],
  92057. [
  92058. 2759,
  92059. 2760,
  92060. ],
  92061. [
  92062. 2765,
  92063. 2765,
  92064. ],
  92065. [
  92066. 2786,
  92067. 2787,
  92068. ],
  92069. [
  92070. 2810,
  92071. 2815,
  92072. ],
  92073. [
  92074. 2817,
  92075. 2817,
  92076. ],
  92077. [
  92078. 2876,
  92079. 2876,
  92080. ],
  92081. [
  92082. 2879,
  92083. 2879,
  92084. ],
  92085. [
  92086. 2881,
  92087. 2884,
  92088. ],
  92089. [
  92090. 2893,
  92091. 2893,
  92092. ],
  92093. [
  92094. 2901,
  92095. 2902,
  92096. ],
  92097. [
  92098. 2914,
  92099. 2915,
  92100. ],
  92101. [
  92102. 2946,
  92103. 2946,
  92104. ],
  92105. [
  92106. 3008,
  92107. 3008,
  92108. ],
  92109. [
  92110. 3021,
  92111. 3021,
  92112. ],
  92113. [
  92114. 3072,
  92115. 3072,
  92116. ],
  92117. [
  92118. 3076,
  92119. 3076,
  92120. ],
  92121. [
  92122. 3132,
  92123. 3132,
  92124. ],
  92125. [
  92126. 3134,
  92127. 3136,
  92128. ],
  92129. [
  92130. 3142,
  92131. 3144,
  92132. ],
  92133. [
  92134. 3146,
  92135. 3149,
  92136. ],
  92137. [
  92138. 3157,
  92139. 3158,
  92140. ],
  92141. [
  92142. 3170,
  92143. 3171,
  92144. ],
  92145. [
  92146. 3201,
  92147. 3201,
  92148. ],
  92149. [
  92150. 3260,
  92151. 3260,
  92152. ],
  92153. [
  92154. 3263,
  92155. 3263,
  92156. ],
  92157. [
  92158. 3270,
  92159. 3270,
  92160. ],
  92161. [
  92162. 3276,
  92163. 3277,
  92164. ],
  92165. [
  92166. 3298,
  92167. 3299,
  92168. ],
  92169. [
  92170. 3328,
  92171. 3329,
  92172. ],
  92173. [
  92174. 3387,
  92175. 3388,
  92176. ],
  92177. [
  92178. 3393,
  92179. 3396,
  92180. ],
  92181. [
  92182. 3405,
  92183. 3405,
  92184. ],
  92185. [
  92186. 3426,
  92187. 3427,
  92188. ],
  92189. [
  92190. 3457,
  92191. 3457,
  92192. ],
  92193. [
  92194. 3530,
  92195. 3530,
  92196. ],
  92197. [
  92198. 3538,
  92199. 3540,
  92200. ],
  92201. [
  92202. 3542,
  92203. 3542,
  92204. ],
  92205. [
  92206. 3633,
  92207. 3633,
  92208. ],
  92209. [
  92210. 3636,
  92211. 3642,
  92212. ],
  92213. [
  92214. 3655,
  92215. 3662,
  92216. ],
  92217. [
  92218. 3761,
  92219. 3761,
  92220. ],
  92221. [
  92222. 3764,
  92223. 3772,
  92224. ],
  92225. [
  92226. 3784,
  92227. 3790,
  92228. ],
  92229. [
  92230. 3864,
  92231. 3865,
  92232. ],
  92233. [
  92234. 3893,
  92235. 3893,
  92236. ],
  92237. [
  92238. 3895,
  92239. 3895,
  92240. ],
  92241. [
  92242. 3897,
  92243. 3897,
  92244. ],
  92245. [
  92246. 3953,
  92247. 3966,
  92248. ],
  92249. [
  92250. 3968,
  92251. 3972,
  92252. ],
  92253. [
  92254. 3974,
  92255. 3975,
  92256. ],
  92257. [
  92258. 3981,
  92259. 3991,
  92260. ],
  92261. [
  92262. 3993,
  92263. 4028,
  92264. ],
  92265. [
  92266. 4038,
  92267. 4038,
  92268. ],
  92269. [
  92270. 4141,
  92271. 4144,
  92272. ],
  92273. [
  92274. 4146,
  92275. 4151,
  92276. ],
  92277. [
  92278. 4153,
  92279. 4154,
  92280. ],
  92281. [
  92282. 4157,
  92283. 4158,
  92284. ],
  92285. [
  92286. 4184,
  92287. 4185,
  92288. ],
  92289. [
  92290. 4190,
  92291. 4192,
  92292. ],
  92293. [
  92294. 4209,
  92295. 4212,
  92296. ],
  92297. [
  92298. 4226,
  92299. 4226,
  92300. ],
  92301. [
  92302. 4229,
  92303. 4230,
  92304. ],
  92305. [
  92306. 4237,
  92307. 4237,
  92308. ],
  92309. [
  92310. 4253,
  92311. 4253,
  92312. ],
  92313. [
  92314. 4957,
  92315. 4959,
  92316. ],
  92317. [
  92318. 5906,
  92319. 5908,
  92320. ],
  92321. [
  92322. 5938,
  92323. 5939,
  92324. ],
  92325. [
  92326. 5970,
  92327. 5971,
  92328. ],
  92329. [
  92330. 6002,
  92331. 6003,
  92332. ],
  92333. [
  92334. 6068,
  92335. 6069,
  92336. ],
  92337. [
  92338. 6071,
  92339. 6077,
  92340. ],
  92341. [
  92342. 6086,
  92343. 6086,
  92344. ],
  92345. [
  92346. 6089,
  92347. 6099,
  92348. ],
  92349. [
  92350. 6109,
  92351. 6109,
  92352. ],
  92353. [
  92354. 6155,
  92355. 6157,
  92356. ],
  92357. [
  92358. 6159,
  92359. 6159,
  92360. ],
  92361. [
  92362. 6277,
  92363. 6278,
  92364. ],
  92365. [
  92366. 6313,
  92367. 6313,
  92368. ],
  92369. [
  92370. 6432,
  92371. 6434,
  92372. ],
  92373. [
  92374. 6439,
  92375. 6440,
  92376. ],
  92377. [
  92378. 6450,
  92379. 6450,
  92380. ],
  92381. [
  92382. 6457,
  92383. 6459,
  92384. ],
  92385. [
  92386. 6679,
  92387. 6680,
  92388. ],
  92389. [
  92390. 6683,
  92391. 6683,
  92392. ],
  92393. [
  92394. 6742,
  92395. 6742,
  92396. ],
  92397. [
  92398. 6744,
  92399. 6750,
  92400. ],
  92401. [
  92402. 6752,
  92403. 6752,
  92404. ],
  92405. [
  92406. 6754,
  92407. 6754,
  92408. ],
  92409. [
  92410. 6757,
  92411. 6764,
  92412. ],
  92413. [
  92414. 6771,
  92415. 6780,
  92416. ],
  92417. [
  92418. 6783,
  92419. 6783,
  92420. ],
  92421. [
  92422. 6832,
  92423. 6845,
  92424. ],
  92425. [
  92426. 6846,
  92427. 6846,
  92428. ],
  92429. [
  92430. 6847,
  92431. 6862,
  92432. ],
  92433. [
  92434. 6912,
  92435. 6915,
  92436. ],
  92437. [
  92438. 6964,
  92439. 6964,
  92440. ],
  92441. [
  92442. 6966,
  92443. 6970,
  92444. ],
  92445. [
  92446. 6972,
  92447. 6972,
  92448. ],
  92449. [
  92450. 6978,
  92451. 6978,
  92452. ],
  92453. [
  92454. 7019,
  92455. 7027,
  92456. ],
  92457. [
  92458. 7040,
  92459. 7041,
  92460. ],
  92461. [
  92462. 7074,
  92463. 7077,
  92464. ],
  92465. [
  92466. 7080,
  92467. 7081,
  92468. ],
  92469. [
  92470. 7083,
  92471. 7085,
  92472. ],
  92473. [
  92474. 7142,
  92475. 7142,
  92476. ],
  92477. [
  92478. 7144,
  92479. 7145,
  92480. ],
  92481. [
  92482. 7149,
  92483. 7149,
  92484. ],
  92485. [
  92486. 7151,
  92487. 7153,
  92488. ],
  92489. [
  92490. 7212,
  92491. 7219,
  92492. ],
  92493. [
  92494. 7222,
  92495. 7223,
  92496. ],
  92497. [
  92498. 7376,
  92499. 7378,
  92500. ],
  92501. [
  92502. 7380,
  92503. 7392,
  92504. ],
  92505. [
  92506. 7394,
  92507. 7400,
  92508. ],
  92509. [
  92510. 7405,
  92511. 7405,
  92512. ],
  92513. [
  92514. 7412,
  92515. 7412,
  92516. ],
  92517. [
  92518. 7416,
  92519. 7417,
  92520. ],
  92521. [
  92522. 7616,
  92523. 7679,
  92524. ],
  92525. [
  92526. 8400,
  92527. 8412,
  92528. ],
  92529. [
  92530. 8413,
  92531. 8416,
  92532. ],
  92533. [
  92534. 8417,
  92535. 8417,
  92536. ],
  92537. [
  92538. 8418,
  92539. 8420,
  92540. ],
  92541. [
  92542. 8421,
  92543. 8432,
  92544. ],
  92545. [
  92546. 11503,
  92547. 11505,
  92548. ],
  92549. [
  92550. 11647,
  92551. 11647,
  92552. ],
  92553. [
  92554. 11744,
  92555. 11775,
  92556. ],
  92557. [
  92558. 12330,
  92559. 12333,
  92560. ],
  92561. [
  92562. 12441,
  92563. 12442,
  92564. ],
  92565. [
  92566. 42607,
  92567. 42607,
  92568. ],
  92569. [
  92570. 42608,
  92571. 42610,
  92572. ],
  92573. [
  92574. 42612,
  92575. 42621,
  92576. ],
  92577. [
  92578. 42654,
  92579. 42655,
  92580. ],
  92581. [
  92582. 42736,
  92583. 42737,
  92584. ],
  92585. [
  92586. 43010,
  92587. 43010,
  92588. ],
  92589. [
  92590. 43014,
  92591. 43014,
  92592. ],
  92593. [
  92594. 43019,
  92595. 43019,
  92596. ],
  92597. [
  92598. 43045,
  92599. 43046,
  92600. ],
  92601. [
  92602. 43052,
  92603. 43052,
  92604. ],
  92605. [
  92606. 43204,
  92607. 43205,
  92608. ],
  92609. [
  92610. 43232,
  92611. 43249,
  92612. ],
  92613. [
  92614. 43263,
  92615. 43263,
  92616. ],
  92617. [
  92618. 43302,
  92619. 43309,
  92620. ],
  92621. [
  92622. 43335,
  92623. 43345,
  92624. ],
  92625. [
  92626. 43392,
  92627. 43394,
  92628. ],
  92629. [
  92630. 43443,
  92631. 43443,
  92632. ],
  92633. [
  92634. 43446,
  92635. 43449,
  92636. ],
  92637. [
  92638. 43452,
  92639. 43453,
  92640. ],
  92641. [
  92642. 43493,
  92643. 43493,
  92644. ],
  92645. [
  92646. 43561,
  92647. 43566,
  92648. ],
  92649. [
  92650. 43569,
  92651. 43570,
  92652. ],
  92653. [
  92654. 43573,
  92655. 43574,
  92656. ],
  92657. [
  92658. 43587,
  92659. 43587,
  92660. ],
  92661. [
  92662. 43596,
  92663. 43596,
  92664. ],
  92665. [
  92666. 43644,
  92667. 43644,
  92668. ],
  92669. [
  92670. 43696,
  92671. 43696,
  92672. ],
  92673. [
  92674. 43698,
  92675. 43700,
  92676. ],
  92677. [
  92678. 43703,
  92679. 43704,
  92680. ],
  92681. [
  92682. 43710,
  92683. 43711,
  92684. ],
  92685. [
  92686. 43713,
  92687. 43713,
  92688. ],
  92689. [
  92690. 43756,
  92691. 43757,
  92692. ],
  92693. [
  92694. 43766,
  92695. 43766,
  92696. ],
  92697. [
  92698. 44005,
  92699. 44005,
  92700. ],
  92701. [
  92702. 44008,
  92703. 44008,
  92704. ],
  92705. [
  92706. 44013,
  92707. 44013,
  92708. ],
  92709. [
  92710. 64286,
  92711. 64286,
  92712. ],
  92713. [
  92714. 65024,
  92715. 65039,
  92716. ],
  92717. [
  92718. 65056,
  92719. 65071,
  92720. ],
  92721. [
  92722. 66045,
  92723. 66045,
  92724. ],
  92725. [
  92726. 66272,
  92727. 66272,
  92728. ],
  92729. [
  92730. 66422,
  92731. 66426,
  92732. ],
  92733. [
  92734. 68097,
  92735. 68099,
  92736. ],
  92737. [
  92738. 68101,
  92739. 68102,
  92740. ],
  92741. [
  92742. 68108,
  92743. 68111,
  92744. ],
  92745. [
  92746. 68152,
  92747. 68154,
  92748. ],
  92749. [
  92750. 68159,
  92751. 68159,
  92752. ],
  92753. [
  92754. 68325,
  92755. 68326,
  92756. ],
  92757. [
  92758. 68900,
  92759. 68903,
  92760. ],
  92761. [
  92762. 68969,
  92763. 68973,
  92764. ],
  92765. [
  92766. 69291,
  92767. 69292,
  92768. ],
  92769. [
  92770. 69372,
  92771. 69375,
  92772. ],
  92773. [
  92774. 69446,
  92775. 69456,
  92776. ],
  92777. [
  92778. 69506,
  92779. 69509,
  92780. ],
  92781. [
  92782. 69633,
  92783. 69633,
  92784. ],
  92785. [
  92786. 69688,
  92787. 69702,
  92788. ],
  92789. [
  92790. 69744,
  92791. 69744,
  92792. ],
  92793. [
  92794. 69747,
  92795. 69748,
  92796. ],
  92797. [
  92798. 69759,
  92799. 69761,
  92800. ],
  92801. [
  92802. 69811,
  92803. 69814,
  92804. ],
  92805. [
  92806. 69817,
  92807. 69818,
  92808. ],
  92809. [
  92810. 69826,
  92811. 69826,
  92812. ],
  92813. [
  92814. 69888,
  92815. 69890,
  92816. ],
  92817. [
  92818. 69927,
  92819. 69931,
  92820. ],
  92821. [
  92822. 69933,
  92823. 69940,
  92824. ],
  92825. [
  92826. 70003,
  92827. 70003,
  92828. ],
  92829. [
  92830. 70016,
  92831. 70017,
  92832. ],
  92833. [
  92834. 70070,
  92835. 70078,
  92836. ],
  92837. [
  92838. 70089,
  92839. 70092,
  92840. ],
  92841. [
  92842. 70095,
  92843. 70095,
  92844. ],
  92845. [
  92846. 70191,
  92847. 70193,
  92848. ],
  92849. [
  92850. 70196,
  92851. 70196,
  92852. ],
  92853. [
  92854. 70198,
  92855. 70199,
  92856. ],
  92857. [
  92858. 70206,
  92859. 70206,
  92860. ],
  92861. [
  92862. 70209,
  92863. 70209,
  92864. ],
  92865. [
  92866. 70367,
  92867. 70367,
  92868. ],
  92869. [
  92870. 70371,
  92871. 70378,
  92872. ],
  92873. [
  92874. 70400,
  92875. 70401,
  92876. ],
  92877. [
  92878. 70459,
  92879. 70460,
  92880. ],
  92881. [
  92882. 70464,
  92883. 70464,
  92884. ],
  92885. [
  92886. 70502,
  92887. 70508,
  92888. ],
  92889. [
  92890. 70512,
  92891. 70516,
  92892. ],
  92893. [
  92894. 70587,
  92895. 70592,
  92896. ],
  92897. [
  92898. 70606,
  92899. 70606,
  92900. ],
  92901. [
  92902. 70608,
  92903. 70608,
  92904. ],
  92905. [
  92906. 70610,
  92907. 70610,
  92908. ],
  92909. [
  92910. 70625,
  92911. 70626,
  92912. ],
  92913. [
  92914. 70712,
  92915. 70719,
  92916. ],
  92917. [
  92918. 70722,
  92919. 70724,
  92920. ],
  92921. [
  92922. 70726,
  92923. 70726,
  92924. ],
  92925. [
  92926. 70750,
  92927. 70750,
  92928. ],
  92929. [
  92930. 70835,
  92931. 70840,
  92932. ],
  92933. [
  92934. 70842,
  92935. 70842,
  92936. ],
  92937. [
  92938. 70847,
  92939. 70848,
  92940. ],
  92941. [
  92942. 70850,
  92943. 70851,
  92944. ],
  92945. [
  92946. 71090,
  92947. 71093,
  92948. ],
  92949. [
  92950. 71100,
  92951. 71101,
  92952. ],
  92953. [
  92954. 71103,
  92955. 71104,
  92956. ],
  92957. [
  92958. 71132,
  92959. 71133,
  92960. ],
  92961. [
  92962. 71219,
  92963. 71226,
  92964. ],
  92965. [
  92966. 71229,
  92967. 71229,
  92968. ],
  92969. [
  92970. 71231,
  92971. 71232,
  92972. ],
  92973. [
  92974. 71339,
  92975. 71339,
  92976. ],
  92977. [
  92978. 71341,
  92979. 71341,
  92980. ],
  92981. [
  92982. 71344,
  92983. 71349,
  92984. ],
  92985. [
  92986. 71351,
  92987. 71351,
  92988. ],
  92989. [
  92990. 71453,
  92991. 71453,
  92992. ],
  92993. [
  92994. 71455,
  92995. 71455,
  92996. ],
  92997. [
  92998. 71458,
  92999. 71461,
  93000. ],
  93001. [
  93002. 71463,
  93003. 71467,
  93004. ],
  93005. [
  93006. 71727,
  93007. 71735,
  93008. ],
  93009. [
  93010. 71737,
  93011. 71738,
  93012. ],
  93013. [
  93014. 71995,
  93015. 71996,
  93016. ],
  93017. [
  93018. 71998,
  93019. 71998,
  93020. ],
  93021. [
  93022. 72003,
  93023. 72003,
  93024. ],
  93025. [
  93026. 72148,
  93027. 72151,
  93028. ],
  93029. [
  93030. 72154,
  93031. 72155,
  93032. ],
  93033. [
  93034. 72160,
  93035. 72160,
  93036. ],
  93037. [
  93038. 72193,
  93039. 72202,
  93040. ],
  93041. [
  93042. 72243,
  93043. 72248,
  93044. ],
  93045. [
  93046. 72251,
  93047. 72254,
  93048. ],
  93049. [
  93050. 72263,
  93051. 72263,
  93052. ],
  93053. [
  93054. 72273,
  93055. 72278,
  93056. ],
  93057. [
  93058. 72281,
  93059. 72283,
  93060. ],
  93061. [
  93062. 72330,
  93063. 72342,
  93064. ],
  93065. [
  93066. 72344,
  93067. 72345,
  93068. ],
  93069. [
  93070. 72752,
  93071. 72758,
  93072. ],
  93073. [
  93074. 72760,
  93075. 72765,
  93076. ],
  93077. [
  93078. 72767,
  93079. 72767,
  93080. ],
  93081. [
  93082. 72850,
  93083. 72871,
  93084. ],
  93085. [
  93086. 72874,
  93087. 72880,
  93088. ],
  93089. [
  93090. 72882,
  93091. 72883,
  93092. ],
  93093. [
  93094. 72885,
  93095. 72886,
  93096. ],
  93097. [
  93098. 73009,
  93099. 73014,
  93100. ],
  93101. [
  93102. 73018,
  93103. 73018,
  93104. ],
  93105. [
  93106. 73020,
  93107. 73021,
  93108. ],
  93109. [
  93110. 73023,
  93111. 73029,
  93112. ],
  93113. [
  93114. 73031,
  93115. 73031,
  93116. ],
  93117. [
  93118. 73104,
  93119. 73105,
  93120. ],
  93121. [
  93122. 73109,
  93123. 73109,
  93124. ],
  93125. [
  93126. 73111,
  93127. 73111,
  93128. ],
  93129. [
  93130. 73459,
  93131. 73460,
  93132. ],
  93133. [
  93134. 73472,
  93135. 73473,
  93136. ],
  93137. [
  93138. 73526,
  93139. 73530,
  93140. ],
  93141. [
  93142. 73536,
  93143. 73536,
  93144. ],
  93145. [
  93146. 73538,
  93147. 73538,
  93148. ],
  93149. [
  93150. 73562,
  93151. 73562,
  93152. ],
  93153. [
  93154. 78912,
  93155. 78912,
  93156. ],
  93157. [
  93158. 78919,
  93159. 78933,
  93160. ],
  93161. [
  93162. 90398,
  93163. 90409,
  93164. ],
  93165. [
  93166. 90413,
  93167. 90415,
  93168. ],
  93169. [
  93170. 92912,
  93171. 92916,
  93172. ],
  93173. [
  93174. 92976,
  93175. 92982,
  93176. ],
  93177. [
  93178. 94031,
  93179. 94031,
  93180. ],
  93181. [
  93182. 94095,
  93183. 94098,
  93184. ],
  93185. [
  93186. 94180,
  93187. 94180,
  93188. ],
  93189. [
  93190. 113821,
  93191. 113822,
  93192. ],
  93193. [
  93194. 118528,
  93195. 118573,
  93196. ],
  93197. [
  93198. 118576,
  93199. 118598,
  93200. ],
  93201. [
  93202. 119143,
  93203. 119145,
  93204. ],
  93205. [
  93206. 119163,
  93207. 119170,
  93208. ],
  93209. [
  93210. 119173,
  93211. 119179,
  93212. ],
  93213. [
  93214. 119210,
  93215. 119213,
  93216. ],
  93217. [
  93218. 119362,
  93219. 119364,
  93220. ],
  93221. [
  93222. 121344,
  93223. 121398,
  93224. ],
  93225. [
  93226. 121403,
  93227. 121452,
  93228. ],
  93229. [
  93230. 121461,
  93231. 121461,
  93232. ],
  93233. [
  93234. 121476,
  93235. 121476,
  93236. ],
  93237. [
  93238. 121499,
  93239. 121503,
  93240. ],
  93241. [
  93242. 121505,
  93243. 121519,
  93244. ],
  93245. [
  93246. 122880,
  93247. 122886,
  93248. ],
  93249. [
  93250. 122888,
  93251. 122904,
  93252. ],
  93253. [
  93254. 122907,
  93255. 122913,
  93256. ],
  93257. [
  93258. 122915,
  93259. 122916,
  93260. ],
  93261. [
  93262. 122918,
  93263. 122922,
  93264. ],
  93265. [
  93266. 123023,
  93267. 123023,
  93268. ],
  93269. [
  93270. 123184,
  93271. 123190,
  93272. ],
  93273. [
  93274. 123566,
  93275. 123566,
  93276. ],
  93277. [
  93278. 123628,
  93279. 123631,
  93280. ],
  93281. [
  93282. 124140,
  93283. 124143,
  93284. ],
  93285. [
  93286. 124398,
  93287. 124399,
  93288. ],
  93289. [
  93290. 125136,
  93291. 125142,
  93292. ],
  93293. [
  93294. 125252,
  93295. 125258,
  93296. ],
  93297. [
  93298. 917760,
  93299. 917999,
  93300. ],
  93301. ];
  93302. <?php
  93303. namespace Symfony\Component\String;
  93304. if (!\function_exists(u::class)) {
  93305. function u(?string $string = ''): UnicodeString
  93306. {
  93307. return new UnicodeString($string ?? '');
  93308. }
  93309. }
  93310. if (!\function_exists(b::class)) {
  93311. function b(?string $string = ''): ByteString
  93312. {
  93313. return new ByteString($string ?? '');
  93314. }
  93315. }
  93316. if (!\function_exists(s::class)) {
  93317. function s(?string $string = ''): AbstractString
  93318. {
  93319. $string = $string ?? '';
  93320. return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string);
  93321. }
  93322. }
  93323. <?php
  93324. namespace Symfony\Component\String\Slugger;
  93325. use Symfony\Component\String\AbstractUnicodeString;
  93326. use Symfony\Component\String\UnicodeString;
  93327. use Symfony\Contracts\Translation\LocaleAwareInterface;
  93328. if (!interface_exists(LocaleAwareInterface::class)) {
  93329. 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".');
  93330. }
  93331. class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
  93332. {
  93333. private const LOCALE_TO_TRANSLITERATOR_ID = [
  93334. 'am' => 'Amharic-Latin',
  93335. 'ar' => 'Arabic-Latin',
  93336. 'az' => 'Azerbaijani-Latin',
  93337. 'be' => 'Belarusian-Latin',
  93338. 'bg' => 'Bulgarian-Latin',
  93339. 'bn' => 'Bengali-Latin',
  93340. 'de' => 'de-ASCII',
  93341. 'el' => 'Greek-Latin',
  93342. 'fa' => 'Persian-Latin',
  93343. 'he' => 'Hebrew-Latin',
  93344. 'hy' => 'Armenian-Latin',
  93345. 'ka' => 'Georgian-Latin',
  93346. 'kk' => 'Kazakh-Latin',
  93347. 'ky' => 'Kirghiz-Latin',
  93348. 'ko' => 'Korean-Latin',
  93349. 'mk' => 'Macedonian-Latin',
  93350. 'mn' => 'Mongolian-Latin',
  93351. 'or' => 'Oriya-Latin',
  93352. 'ps' => 'Pashto-Latin',
  93353. 'ru' => 'Russian-Latin',
  93354. 'sr' => 'Serbian-Latin',
  93355. 'sr_Cyrl' => 'Serbian-Latin',
  93356. 'th' => 'Thai-Latin',
  93357. 'tk' => 'Turkmen-Latin',
  93358. 'uk' => 'Ukrainian-Latin',
  93359. 'uz' => 'Uzbek-Latin',
  93360. 'zh' => 'Han-Latin',
  93361. ];
  93362. private $defaultLocale;
  93363. private $symbolsMap = [
  93364. 'en' => ['@' => 'at', '&' => 'and'],
  93365. ];
  93366. private $transliterators = [];
  93367. public function __construct(?string $defaultLocale = null, $symbolsMap = null)
  93368. {
  93369. if (null !== $symbolsMap && !\is_array($symbolsMap) && !$symbolsMap instanceof \Closure) {
  93370. throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be array, Closure or null, "%s" given.', __METHOD__, \gettype($symbolsMap)));
  93371. }
  93372. $this->defaultLocale = $defaultLocale;
  93373. $this->symbolsMap = $symbolsMap ?? $this->symbolsMap;
  93374. }
  93375. public function setLocale($locale)
  93376. {
  93377. $this->defaultLocale = $locale;
  93378. }
  93379. public function getLocale()
  93380. {
  93381. return $this->defaultLocale;
  93382. }
  93383. public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString
  93384. {
  93385. $locale = $locale ?? $this->defaultLocale;
  93386. $transliterator = [];
  93387. if ($locale && ('de' === $locale || 0 === strpos($locale, 'de_'))) {
  93388. $transliterator = ['de-ASCII'];
  93389. } elseif (\function_exists('transliterator_transliterate') && $locale) {
  93390. $transliterator = (array) $this->createTransliterator($locale);
  93391. }
  93392. if ($this->symbolsMap instanceof \Closure) {
  93393. $symbolsMap = $this->symbolsMap;
  93394. array_unshift($transliterator, static function ($s) use ($symbolsMap, $locale) {
  93395. return $symbolsMap($s, $locale);
  93396. });
  93397. }
  93398. $unicodeString = (new UnicodeString($string))->ascii($transliterator);
  93399. if (\is_array($this->symbolsMap)) {
  93400. $map = null;
  93401. if (isset($this->symbolsMap[$locale])) {
  93402. $map = $this->symbolsMap[$locale];
  93403. } else {
  93404. $parent = self::getParentLocale($locale);
  93405. if ($parent && isset($this->symbolsMap[$parent])) {
  93406. $map = $this->symbolsMap[$parent];
  93407. }
  93408. }
  93409. if ($map) {
  93410. foreach ($map as $char => $replace) {
  93411. $unicodeString = $unicodeString->replace($char, ' '.$replace.' ');
  93412. }
  93413. }
  93414. }
  93415. return $unicodeString
  93416. ->replaceMatches('/[^A-Za-z0-9]++/', $separator)
  93417. ->trim($separator)
  93418. ;
  93419. }
  93420. private function createTransliterator(string $locale): ?\Transliterator
  93421. {
  93422. if (\array_key_exists($locale, $this->transliterators)) {
  93423. return $this->transliterators[$locale];
  93424. }
  93425. if ($id = self::LOCALE_TO_TRANSLITERATOR_ID[$locale] ?? null) {
  93426. return $this->transliterators[$locale] = \Transliterator::create($id.'/BGN') ?? \Transliterator::create($id);
  93427. }
  93428. if (!$parent = self::getParentLocale($locale)) {
  93429. return $this->transliterators[$locale] = null;
  93430. }
  93431. if ($id = self::LOCALE_TO_TRANSLITERATOR_ID[$parent] ?? null) {
  93432. $transliterator = \Transliterator::create($id.'/BGN') ?? \Transliterator::create($id);
  93433. }
  93434. return $this->transliterators[$locale] = $this->transliterators[$parent] = $transliterator ?? null;
  93435. }
  93436. private static function getParentLocale(?string $locale): ?string
  93437. {
  93438. if (!$locale) {
  93439. return null;
  93440. }
  93441. if (false === $str = strrchr($locale, '_')) {
  93442. return null;
  93443. }
  93444. return substr($locale, 0, -\strlen($str));
  93445. }
  93446. }
  93447. <?php
  93448. namespace Symfony\Component\String\Slugger;
  93449. use Symfony\Component\String\AbstractUnicodeString;
  93450. interface SluggerInterface
  93451. {
  93452. public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString;
  93453. }
  93454. <?php
  93455. namespace Symfony\Component\String;
  93456. use Symfony\Component\String\Exception\ExceptionInterface;
  93457. use Symfony\Component\String\Exception\InvalidArgumentException;
  93458. class UnicodeString extends AbstractUnicodeString
  93459. {
  93460. public function __construct(string $string = '')
  93461. {
  93462. $this->string = normalizer_is_normalized($string) ? $string : normalizer_normalize($string);
  93463. if (false === $this->string) {
  93464. throw new InvalidArgumentException('Invalid UTF-8 string.');
  93465. }
  93466. }
  93467. public function append(string ...$suffix): AbstractString
  93468. {
  93469. $str = clone $this;
  93470. $str->string = $this->string.(1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix));
  93471. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  93472. if (false === $str->string) {
  93473. throw new InvalidArgumentException('Invalid UTF-8 string.');
  93474. }
  93475. return $str;
  93476. }
  93477. public function chunk(int $length = 1): array
  93478. {
  93479. if (1 > $length) {
  93480. throw new InvalidArgumentException('The chunk length must be greater than zero.');
  93481. }
  93482. if ('' === $this->string) {
  93483. return [];
  93484. }
  93485. $rx = '/(';
  93486. while (65535 < $length) {
  93487. $rx .= '\X{65535}';
  93488. $length -= 65535;
  93489. }
  93490. $rx .= '\X{'.$length.'})/u';
  93491. $str = clone $this;
  93492. $chunks = [];
  93493. foreach (preg_split($rx, $this->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY) as $chunk) {
  93494. $str->string = $chunk;
  93495. $chunks[] = clone $str;
  93496. }
  93497. return $chunks;
  93498. }
  93499. public function endsWith($suffix): bool
  93500. {
  93501. if ($suffix instanceof AbstractString) {
  93502. $suffix = $suffix->string;
  93503. } elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
  93504. return parent::endsWith($suffix);
  93505. } else {
  93506. $suffix = (string) $suffix;
  93507. }
  93508. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  93509. normalizer_is_normalized($suffix, $form) ?: $suffix = normalizer_normalize($suffix, $form);
  93510. if ('' === $suffix || false === $suffix) {
  93511. return false;
  93512. }
  93513. if ($this->ignoreCase) {
  93514. return 0 === mb_stripos(grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix)), $suffix, 0, 'UTF-8');
  93515. }
  93516. return $suffix === grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix));
  93517. }
  93518. public function equalsTo($string): bool
  93519. {
  93520. if ($string instanceof AbstractString) {
  93521. $string = $string->string;
  93522. } elseif (\is_array($string) || $string instanceof \Traversable) {
  93523. return parent::equalsTo($string);
  93524. } else {
  93525. $string = (string) $string;
  93526. }
  93527. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  93528. normalizer_is_normalized($string, $form) ?: $string = normalizer_normalize($string, $form);
  93529. if ('' !== $string && false !== $string && $this->ignoreCase) {
  93530. return \strlen($string) === \strlen($this->string) && 0 === mb_stripos($this->string, $string, 0, 'UTF-8');
  93531. }
  93532. return $string === $this->string;
  93533. }
  93534. public function indexOf($needle, int $offset = 0): ?int
  93535. {
  93536. if ($needle instanceof AbstractString) {
  93537. $needle = $needle->string;
  93538. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  93539. return parent::indexOf($needle, $offset);
  93540. } else {
  93541. $needle = (string) $needle;
  93542. }
  93543. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  93544. normalizer_is_normalized($needle, $form) ?: $needle = normalizer_normalize($needle, $form);
  93545. if ('' === $needle || false === $needle) {
  93546. return null;
  93547. }
  93548. try {
  93549. $i = $this->ignoreCase ? grapheme_stripos($this->string, $needle, $offset) : grapheme_strpos($this->string, $needle, $offset);
  93550. } catch (\ValueError $e) {
  93551. return null;
  93552. }
  93553. return false === $i ? null : $i;
  93554. }
  93555. public function indexOfLast($needle, int $offset = 0): ?int
  93556. {
  93557. if ($needle instanceof AbstractString) {
  93558. $needle = $needle->string;
  93559. } elseif (\is_array($needle) || $needle instanceof \Traversable) {
  93560. return parent::indexOfLast($needle, $offset);
  93561. } else {
  93562. $needle = (string) $needle;
  93563. }
  93564. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  93565. normalizer_is_normalized($needle, $form) ?: $needle = normalizer_normalize($needle, $form);
  93566. if ('' === $needle || false === $needle) {
  93567. return null;
  93568. }
  93569. $string = $this->string;
  93570. if (0 > $offset) {
  93571. if (0 > $offset += grapheme_strlen($needle)) {
  93572. $string = grapheme_substr($string, 0, $offset);
  93573. }
  93574. $offset = 0;
  93575. }
  93576. $i = $this->ignoreCase ? grapheme_strripos($string, $needle, $offset) : grapheme_strrpos($string, $needle, $offset);
  93577. return false === $i ? null : $i;
  93578. }
  93579. public function join(array $strings, ?string $lastGlue = null): AbstractString
  93580. {
  93581. $str = parent::join($strings, $lastGlue);
  93582. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  93583. return $str;
  93584. }
  93585. public function length(): int
  93586. {
  93587. return grapheme_strlen($this->string);
  93588. }
  93589. public function normalize(int $form = self::NFC): parent
  93590. {
  93591. $str = clone $this;
  93592. if (\in_array($form, [self::NFC, self::NFKC], true)) {
  93593. normalizer_is_normalized($str->string, $form) ?: $str->string = normalizer_normalize($str->string, $form);
  93594. } elseif (!\in_array($form, [self::NFD, self::NFKD], true)) {
  93595. throw new InvalidArgumentException('Unsupported normalization form.');
  93596. } elseif (!normalizer_is_normalized($str->string, $form)) {
  93597. $str->string = normalizer_normalize($str->string, $form);
  93598. $str->ignoreCase = null;
  93599. }
  93600. return $str;
  93601. }
  93602. public function prepend(string ...$prefix): AbstractString
  93603. {
  93604. $str = clone $this;
  93605. $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
  93606. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  93607. if (false === $str->string) {
  93608. throw new InvalidArgumentException('Invalid UTF-8 string.');
  93609. }
  93610. return $str;
  93611. }
  93612. public function replace(string $from, string $to): AbstractString
  93613. {
  93614. $str = clone $this;
  93615. normalizer_is_normalized($from) ?: $from = normalizer_normalize($from);
  93616. if ('' !== $from && false !== $from) {
  93617. $tail = $str->string;
  93618. $result = '';
  93619. $indexOf = $this->ignoreCase ? 'grapheme_stripos' : 'grapheme_strpos';
  93620. while ('' !== $tail && false !== $i = $indexOf($tail, $from)) {
  93621. $slice = grapheme_substr($tail, 0, $i);
  93622. $result .= $slice.$to;
  93623. $tail = substr($tail, \strlen($slice) + \strlen($from));
  93624. }
  93625. $str->string = $result.$tail;
  93626. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  93627. if (false === $str->string) {
  93628. throw new InvalidArgumentException('Invalid UTF-8 string.');
  93629. }
  93630. }
  93631. return $str;
  93632. }
  93633. public function replaceMatches(string $fromRegexp, $to): AbstractString
  93634. {
  93635. $str = parent::replaceMatches($fromRegexp, $to);
  93636. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  93637. return $str;
  93638. }
  93639. public function slice(int $start = 0, ?int $length = null): AbstractString
  93640. {
  93641. $str = clone $this;
  93642. if (\PHP_VERSION_ID < 80000 && 0 > $start && grapheme_strlen($this->string) < -$start) {
  93643. $start = 0;
  93644. }
  93645. $str->string = (string) grapheme_substr($this->string, $start, $length ?? 2147483647);
  93646. return $str;
  93647. }
  93648. public function splice(string $replacement, int $start = 0, ?int $length = null): AbstractString
  93649. {
  93650. $str = clone $this;
  93651. if (\PHP_VERSION_ID < 80000 && 0 > $start && grapheme_strlen($this->string) < -$start) {
  93652. $start = 0;
  93653. }
  93654. $start = $start ? \strlen(grapheme_substr($this->string, 0, $start)) : 0;
  93655. $length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? 2147483647)) : $length;
  93656. $str->string = substr_replace($this->string, $replacement, $start, $length ?? 2147483647);
  93657. normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
  93658. if (false === $str->string) {
  93659. throw new InvalidArgumentException('Invalid UTF-8 string.');
  93660. }
  93661. return $str;
  93662. }
  93663. public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
  93664. {
  93665. if (1 > $limit = $limit ?? 2147483647) {
  93666. throw new InvalidArgumentException('Split limit must be a positive integer.');
  93667. }
  93668. if ('' === $delimiter) {
  93669. throw new InvalidArgumentException('Split delimiter is empty.');
  93670. }
  93671. if (null !== $flags) {
  93672. return parent::split($delimiter.'u', $limit, $flags);
  93673. }
  93674. normalizer_is_normalized($delimiter) ?: $delimiter = normalizer_normalize($delimiter);
  93675. if (false === $delimiter) {
  93676. throw new InvalidArgumentException('Split delimiter is not a valid UTF-8 string.');
  93677. }
  93678. $str = clone $this;
  93679. $tail = $this->string;
  93680. $chunks = [];
  93681. $indexOf = $this->ignoreCase ? 'grapheme_stripos' : 'grapheme_strpos';
  93682. while (1 < $limit && false !== $i = $indexOf($tail, $delimiter)) {
  93683. $str->string = grapheme_substr($tail, 0, $i);
  93684. $chunks[] = clone $str;
  93685. $tail = substr($tail, \strlen($str->string) + \strlen($delimiter));
  93686. --$limit;
  93687. }
  93688. $str->string = $tail;
  93689. $chunks[] = clone $str;
  93690. return $chunks;
  93691. }
  93692. public function startsWith($prefix): bool
  93693. {
  93694. if ($prefix instanceof AbstractString) {
  93695. $prefix = $prefix->string;
  93696. } elseif (\is_array($prefix) || $prefix instanceof \Traversable) {
  93697. return parent::startsWith($prefix);
  93698. } else {
  93699. $prefix = (string) $prefix;
  93700. }
  93701. $form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
  93702. normalizer_is_normalized($prefix, $form) ?: $prefix = normalizer_normalize($prefix, $form);
  93703. if ('' === $prefix || false === $prefix) {
  93704. return false;
  93705. }
  93706. if ($this->ignoreCase) {
  93707. return 0 === mb_stripos(grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES), $prefix, 0, 'UTF-8');
  93708. }
  93709. return $prefix === grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES);
  93710. }
  93711. public function __wakeup()
  93712. {
  93713. if (!\is_string($this->string)) {
  93714. throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
  93715. }
  93716. normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string);
  93717. }
  93718. public function __clone()
  93719. {
  93720. if (null === $this->ignoreCase) {
  93721. normalizer_is_normalized($this->string) ?: $this->string = normalizer_normalize($this->string);
  93722. }
  93723. $this->ignoreCase = false;
  93724. }
  93725. }
  93726. <?php
  93727. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  93728. if (0 === strpos(__FILE__, 'phar:') && ini_get('register_argc_argv')) {
  93729. echo 'Composer cannot be run safely on non-CLI SAPIs with register_argc_argv=On. Aborting.'.PHP_EOL;
  93730. exit(1);
  93731. }
  93732. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  93733. }
  93734. if (PHP_VERSION_ID < 70205) {
  93735. 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;
  93736. exit(1);
  93737. }
  93738. setlocale(LC_ALL, 'C');
  93739. require __DIR__.'/../src/bootstrap.php';
  93740. use Composer\Console\Application;
  93741. use Composer\XdebugHandler\XdebugHandler;
  93742. use Composer\Util\Platform;
  93743. use Composer\Util\ErrorHandler;
  93744. error_reporting(-1);
  93745. // Restart without Xdebug
  93746. $xdebug = new XdebugHandler('Composer');
  93747. $xdebug->check();
  93748. unset($xdebug);
  93749. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
  93750. echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
  93751. exit(1);
  93752. }
  93753. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  93754. echo 'The iconv OR mbstring extension is required and both are missing.'
  93755. .PHP_EOL.'Install either of them or recompile php without --disable-iconv.'
  93756. .PHP_EOL.'Aborting.'.PHP_EOL;
  93757. exit(1);
  93758. }
  93759. if (function_exists('ini_set')) {
  93760. // check if error logging is on, but to an empty destination - for the CLI SAPI, that means stderr
  93761. $logsToSapiDefault = ('' === ini_get('error_log') && (bool) ini_get('log_errors'));
  93762. // on the CLI SAPI, ensure errors are displayed on stderr, either via display_errors or via error_log
  93763. if (PHP_SAPI === 'cli') {
  93764. @ini_set('display_errors', $logsToSapiDefault ? '0' : 'stderr');
  93765. }
  93766. // Set user defined memory limit
  93767. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  93768. @ini_set('memory_limit', $memoryLimit);
  93769. } else {
  93770. $memoryInBytes = function ($value) {
  93771. $unit = strtolower(substr($value, -1, 1));
  93772. $value = (int) $value;
  93773. switch($unit) {
  93774. case 'g':
  93775. $value *= 1024;
  93776. // no break (cumulative multiplier)
  93777. case 'm':
  93778. $value *= 1024;
  93779. // no break (cumulative multiplier)
  93780. case 'k':
  93781. $value *= 1024;
  93782. }
  93783. return $value;
  93784. };
  93785. $memoryLimit = trim(ini_get('memory_limit'));
  93786. // Increase memory_limit if it is lower than 1.5GB
  93787. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  93788. @ini_set('memory_limit', '1536M');
  93789. }
  93790. unset($memoryInBytes);
  93791. }
  93792. unset($memoryLimit);
  93793. }
  93794. // Workaround PHP bug on Windows where env vars containing Unicode chars are mangled in $_SERVER
  93795. // see https://github.com/php/php-src/issues/7896
  93796. if (PHP_VERSION_ID >= 70113 && (PHP_VERSION_ID < 80016 || (PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80103)) && Platform::isWindows()) {
  93797. foreach ($_SERVER as $serverVar => $serverVal) {
  93798. if (($serverVal = getenv($serverVar)) !== false) {
  93799. $_SERVER[$serverVar] = $serverVal;
  93800. }
  93801. }
  93802. }
  93803. Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0]));
  93804. ErrorHandler::register();
  93805. // run the command application
  93806. $application = new Application();
  93807. $application->run();
  93808. Copyright (c) Nils Adermann, Jordi Boggiano
  93809. Permission is hereby granted, free of charge, to any person obtaining a copy
  93810. of this software and associated documentation files (the "Software"), to deal
  93811. in the Software without restriction, including without limitation the rights
  93812. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  93813. copies of the Software, and to permit persons to whom the Software is furnished
  93814. to do so, subject to the following conditions:
  93815. The above copyright notice and this permission notice shall be included in all
  93816. copies or substantial portions of the Software.
  93817. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  93818. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  93819. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  93820. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  93821. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  93822. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  93823. THE SOFTWARE.
  93824. ’Ø"µm&‘Úˆ·nƒõ"¼ÿ!ƒFÆI!¹oLÆÊ–b–Ê\F˾ ¡ÂÞŽ¼í^c^v†õðkÅad…;øk���GBMB