briedis Posted May 20, 2016 Report Share Posted May 20, 2016 Es jau par to, ka funkcijas parametros nodefinē, ka $handler ir string un pēc tam $handler izsauc statisko metodi. Cik zinu string tipam nav statisko metožu Acīmredzot, sūdīgi zini php... https://eval.in/574428 Konkrētais warnings ir viegli aizvācams ar /** @var MyClass $handler **/ Tad pat storms arī pateiktu, ka eksistē tāda statiska metode. Link to comment Share on other sites More sharing options...
F3llony Posted May 20, 2016 Report Share Posted May 20, 2016 (edited) class Foo { public static function boo() { echo 'moo'; } } $thing = 'Foo'; $otherThing = 'boo'; $thing::$otherThing(); moo Hue hue hue hue... :> Iemesls, kāpēc storms nezina, kas tajā $handler ir jo storms nezina ar kādu vērtību metode tiks izsaukta. Edit: perfectly valids PHP7 kods: class Foo { public static function boo() { echo 'moo'; } public static function huh() { return 'Foo'; } } $thing = 'Foo'; $otherThing = 'b'; $rekt = 'oo'; $wat = 'huh'; $thing::$wat()::{$otherThing.$rekt}(); Edited May 20, 2016 by F3llony Link to comment Share on other sites More sharing options...
Kasspars Posted May 20, 2016 Report Share Posted May 20, 2016 Jums reāli sūdīgi ar common sense! Ja metodes definīcijā būtu norādīts, ka $handler jābūt konkrētas klases instancei nevis string, tad ne Stormam ne citam programmētājam nevajadzētu zīlēt, kāds objekts tagad būs $handler Briedi. Pēc tavas loģikas sanāk, ka labāk sūdu apklāt ar tepiķi nevis izmest podā :D Link to comment Share on other sites More sharing options...
F3llony Posted May 20, 2016 Report Share Posted May 20, 2016 Kāda velna pēc STATISKAS METODES izsaukšanai būtu nepieciešama objekta instance? Common sense my ass. Link to comment Share on other sites More sharing options...
Mr.Key Posted May 20, 2016 Report Share Posted May 20, 2016 (edited) Manuprāt, call_user_func() FTW. Un listMethods() vietā vajadzētu reflection, kurš atfiltrē metodes, kuras sākas ar handler (handlerFoo(), handlerBoo()). Edited May 20, 2016 by Mr.Key Link to comment Share on other sites More sharing options...
F3llony Posted May 20, 2016 Report Share Posted May 20, 2016 (edited) Nu ja tā nopietni domā par tieši to kodu ne konkrēto piemēru ar static call, tad viss tas kods ir tāds diezgan pabriesmīgs... Kāda velna pēc vispār vienai konsoles komandai būtu vajadzīgi N entrypointi. SRP or naah? Un ja jau konsoles handleris vienalga tiek reģistrēts kaut kā, tad nafig nepadot jau instanci kas implementē kaut kādu komandas interfeisu? Sentence: rm -rf un composer install symfony/console... Edited May 20, 2016 by F3llony Link to comment Share on other sites More sharing options...
jurchiks Posted May 20, 2016 Report Share Posted May 20, 2016 Kāda velna pēc vispār vienai konsoles komandai būtu vajadzīgi N entrypointi. ? Kur tur ir N entrypointi? Un ja jau konsoles handleris vienalga tiek reģistrēts kaut kā, tad nafig nepadot jau instanci kas implementē kaut kādu komandas interfeisu? Because this is way simpler. Priekš kam tu tur kaut kādu interfeisu gribi iebāzt? Ko tas interfeiss REĀLI uzlabos? Sentence: rm -rf un composer install symfony/console... Yep, 10k lines of code for what I could do with 10. Link to comment Share on other sites More sharing options...
jurchiks Posted May 20, 2016 Report Share Posted May 20, 2016 Manuprāt, call_user_func() FTW. Un listMethods() vietā vajadzētu reflection, kurš atfiltrē metodes, kuras sākas ar handler (handlerFoo(), handlerBoo()). call_user_func() ir lēnāks, kaut dara to pašu. Reflection ir vēl lēnāks, un filtrēšana ir VĒL lēnāka. Priekš kam to visu darīt, ja rezultāts ir identisks? Link to comment Share on other sites More sharing options...
F3llony Posted May 20, 2016 Report Share Posted May 20, 2016 Juri, es netaisos ar Tevi diskutēt par programmēšanu, ne vairāk kā ar āzi aiz sētas par Šveices nacionālo nodokļu politiku. Goda vārds. Link to comment Share on other sites More sharing options...
jurchiks Posted May 20, 2016 Report Share Posted May 20, 2016 (edited) Jurchik, izskaidro šito Ja tu izlasītu visu metodi, tad pamanītu, ka ir iespējams piereģistrēt kā konsoles handleri arī parastu funkciju, i.e.: App::registerConsoleHandler('var_dump', 'dumpThis'); `php index.php dumpThis arg1 arg2 arg3` Edited May 20, 2016 by jurchiks Link to comment Share on other sites More sharing options...
jurchiks Posted May 20, 2016 Report Share Posted May 20, 2016 Juri, es netaisos ar Tevi diskutēt par programmēšanu, ne vairāk kā ar āzi aiz sētas par Šveices nacionālo nodokļu politiku. Goda vārds. Tad kāpēc tu diskutē? Link to comment Share on other sites More sharing options...
F3llony Posted May 20, 2016 Report Share Posted May 20, 2016 Tu zini vārda "diskusija" nozīmi? Un atšķirību no verbāla vidējā pirksta Tavā virzienā? :P Link to comment Share on other sites More sharing options...
jurchiks Posted May 20, 2016 Report Share Posted May 20, 2016 Mēs visi labi zinām, ka REĀLA diskusija ar tevi gandrīz nekad nenotiek, tu nodirs, un citi atbild. Tāpēc es pieņemu, ka tāds ir tavs "diskusijas" stils. Link to comment Share on other sites More sharing options...
F3llony Posted May 20, 2016 Report Share Posted May 20, 2016 Pfff. Wut? Link to comment Share on other sites More sharing options...
Mr.Key Posted May 21, 2016 Report Share Posted May 21, 2016 (edited) Yep, 10k lines of code for what I could do with 10. Tīri vispārīgi, ne par šo gadījumu (jo šeit mērķis ir pašam savu konsoli uztaisīt) - ja tā ir viena komanda un pēc tās izpildes gatavs konsoles supports, why not? Šodien taču neviens neskaita diska vietu un tā tālāk. Bet vēlreiz - protams, ja mērķis ir uztaisīt pašam savu, tad jā. Man, piemēram, tāda mērķa nav un es nedomājot ielikšu gatavu konsoli un, visai ticams, nekad neskatīšos tajās 10k rindās, jo risināšu citus uzdevumus. Kāpēc to gribu teikt. Vēlreiz un vēlreiz - apkārt viss mainās, un jāiet līdzi. Man pašam nepatīk (vai nepatika) tas composer, jo ir WTF, es varu taču uztaisīt download, unzip un iekopēt vajadzīgajā direktorijā, bez visādiem tur lock failiem, dependensijiem, utt. Pieņemsim, ka šis izdodas sekmīgi, tāpēc sāku ignorēt arī citus pavērsienus un, skat – esmu jau īpatnis ar irrelevantām zināšanām, kura projekti virzās tik lēni, ka nevienu tas neinteresē. Edited May 21, 2016 by Mr.Key Link to comment Share on other sites More sharing options...
Recommended Posts