PHPerKaigi 2020 ã«åå ãã¾ããã2 æ 9 æ¥ (æ¥) ãã 2 æ 11 æ¥ (ç«ã»ç¥) ã®éå¬ã§ãä¼å ´ã¯ä¾å¹´ã¨åãã 練馬区立 区民・産業プラザ Coconeri ãã¼ã«ã§ãããåå è
å士ã®äº¤æµããã¼ãã«ãã¦ããã«ã³ãã¡ã¬ã³ã¹ã§ãæè¡ã»ãã·ã§ã³ã®ã»ãã«ãæ§ã
ãªä¼ç»ãç¨æããã¦ããã楽ãã 3 æ¥éåå ããã¦ãããã¾ãããã¹ã¿ãããçºè¡¨è
ãã¹ãã³ãµã¼ä¼æ¥å社ãçæ§ãããã¨ããããã¾ãããè´è¬ããã»ãã·ã§ã³ã®ããã¤ãã«ã¤ãã¦ã®ææ³ããã®ä»ã«ç§ãåå ããä¼ç»ãªã©ãä¸å¿ã«å ±åãã¾ãã
phperkaigi.jp
Deep Module in PHP
ããã°ã©ã ã®è¨è¨ã«ã¤ãã¦æ¹ãã¦èããããããå 容ã§ãããDeep Module ã¨ããèãæ¹ã¯ããåãã£ãã®ã§ããããããä¸æãå®ç¾ããã®ã¯ãªããªãé£ãããã ã¨ããææ³ãæã¡ã¾ãããçºè¡¨ã§ç¤ºããã CakePHP ã® save() ã¡ã½ãããä¾ã«æããã¨ãããã¯å¼æ°ã® $entity ãå¤æ©è½ã ããå®ç¾ã§ãã¦ããããã«æãã¾ããçºè¡¨ã§ç´¹ä»ãããæç§æ¸ã¯æªèªãªã®ã§ãããDeep Module ãå®è·µãããã¨ããã¨ãããç¨åº¦æåã«å ¨ä½åãè¦éããããããã¦ã³ãªè¨è¨ãå¿ è¦ã«ãªãããã ã¨ããå°è±¡ã§ãã
ãã£ã¨æ°è»½ã«OSSã« Pull Requestãåºããï¼
OSS ã¸ã®ç©æ¥µçãªã³ã³ããªãã¥ã¼ã·ã§ã³ãå¾æ¼ãããçºè¡¨ã§ããããã¹ãã³ã¼ããããã¥ã¡ã³ãã«ãæ¹åã§ããç®æãæ®ã£ã¦ãããæªä½¿ç¨å¤æ°ã®é¤å»ã¨ãã£ãå°ããªæ¹åã§ãé æ ®ãããã«ãªã¯ã¨ã¹ããéãã¨ãã£ãå ·ä½çãªçµé¨è«ãç´¹ä»ããã¾ãããç§ã OSS ã«ããã¤ããã«ãªã¯ã¨ã¹ããéã£ãçµé¨ã¯ããã¾ãããå 容ã¨ãã¦ã¯ãã°å ±åã¨ãã®ä¿®æ£ã¨ãããã®ã§ãããç´¹ä»ãããä¾ã®ãªãã§ãReact ã®ããã¥ã¡ã³ãã® "mandatory" ã "required" ã«å¤æ´ããã話ã¯ããã«ãªã¯ã¨ã¹ããéãå 容ã¨ãã¦ç§ããã¾ãæ³å®ãã¦ããªãã£ããã®ã§ãç¹ã«é¢ç½ãã£ãã§ãã
PHPer Code Golf
ã³ã¼ãã´ã«ãã¯ãè¦ä»¶ãæºããããã°ã©ã ãã©ãã ãçãå®è£
ã§ãããã競ãéã³ã§ããã«ã³ãã¡ã¬ã³ã¹æéä¸ã«åºé¡ãããã®ã§ãç§ãåãçµãã§ã¿ã¾ãããåé¡ã¨åªåè
ã®åçã¯ãåªåãã tenkoma ããã®ããã°ã«è¨è¼ããã¦ãã¾ãããªããä¸è¬çãªã³ã¼ãã´ã«ãã¨ã¯ç°ãªããã³ã¼ããã©ã¼ããã¿ãéããããã§è¡æ°ãæ§æè¦ç´ ã®æ°ã¨ãã£ãè¤æ°ã®ææ¨ã§è©ä¾¡ãããã¨ããã¬ã®ã¥ã¬ã¼ã·ã§ã³ã§ããã
⛳ PHPer Code Golf by pixiv(PHPerKaigi 2020) 上級編の回答について解説 - こもろぐ @tenkoma
ç§ã®åç㯠eval ã使ããã®ã§ãã¡ããã¨æ¹è¡ãã¤ã³ãã³ããã¦æ¸ãã¨ä»¥ä¸ã®å 容ã§ãããå ¥åã® JSON ã® key ã左辺ãvalue ãå³è¾ºã¨ããä»£å ¥æãè©ä¾¡ãã¦ããã°ããã¨ããçºæ³ã§ãããã®ã¾ã¾ä»£å ¥ããã¨åå¤æ°ãã°ãã¼ãã«å¤æ°ã«æ£ãã°ãæ±ãã«ããã®ã§ããªãã¸ã§ã¯ãã®ããããã£ã¨ãã¦è§£æ±ºãã¾ããã
<?php $o = new stdClass(); foreach (json_decode(fgets(STDIN)) as $k => $v) { eval("\$o->$k = '$v';"); } echo json_encode($o);
å®éã«ç§ãæåºããåçã¯ä»¥ä¸ã®ã¨ããã§ããç§ã¯ãã£ããã¬ã®ã¥ã¬ã¼ã·ã§ã³ã確èªãããæ®éã«ã³ã¼ãã´ã«ãããã¦ãã¾ã£ãã®ã§ãä¸è¡ã«ããããã§ä¸è¦ãªç©ºç½ãæ¬å¼§ã¯åã£ã¦ãã¾ãã$o ã®å®ç¾©ãåé¤ããããã«ããè¦å㯠@ ã§æå¶ãã¦ãã¾ã*1ãå½æ¥ã¯ãå å¿ãããã¯ãããããã¨åã£ãããããªãããªãã¨æã£ã¦ããã®ã§ããæ®å¿µã§ããã
<?php foreach(json_decode(fgets(STDIN))as$k=>$v)eval("@\$o->$k='$v';");echo json_encode($o);
ä»åã®ã³ã¼ãã´ã«ãã¯æºåã®ãã©ãã«ããã£ãããã§ä¸è¨ã®åé¡ã¯å®è³ªçã« 1 æéãããã®åè² ã ã£ãã®ã§ãããæå³çã§ãªãã£ãã¨ã¯ãããããããçææ¦ã¯æ¥é ã®ãå¼ãåºããã§åè² ãããã¨ã«ãªãé¢ç½ãã¨æãã¾ãããç§ã¯ (æ¯å¹´ PHP é¢é£ã®ã«ã³ãã¡ã¬ã³ã¹ã«åå ãã¦ããªããï¼) Web ã®æè¡ã«ã¯è©³ãããªã PHP ã§ã³ã¼ããæ¸ããã¨ãå°ãªãã®ã§ãparse_str é¢æ°ã¯åªåè ã®åçãè¦ãã¾ã§å ¨ãæãæµ®ãã³ã¾ããã§ããã
åå è ã¨ã®äº¤æµãªã©
ã»ãã·ã§ã³ä¼å ´ã¨ã¯å¥ã«ãTrack C ã¨ãã¦åå è å士ã®äº¤æµãç®çã¨ããã¹ãã¼ã¹ãç¨æããã¦ãã¾ãããä»å¹´ã¯ãªã¼ãã³ã¹ãã¼ã¹ã«ãªã£ã¦ãã¦ã¨ã¦ãå©ç¨ãããããä»ã®åå è ã®æ¹ã¨è©±ãããããããã¯åã«ä¼æ©ãããã¨æ´»ç¨ããã¦ãããã¾ãããä»å¹´ã¯ååå è ã® Twitter ã¢ã¤ã³ã³ãåãè¾¼ãã ãã¬ã¼ãã£ã³ã°ã«ã¼ããé å¸ããã¦ãã¦ãååºä»£ããã«æ°è»½ã«äº¤æã§ããã®ã楽ããä¼ç»ã§ãããPHPerKaigi ã«ã¯ 2018 å¹´ã®ååããæ¯å¹´åå ãã¦ãã¾ããããããã工夫ãå¹´ã ç©ã¿éãããã¦ãã¦ã次åã楽ãã¿ã«ãªãã¾ãã
*1:æåæ°ã®è¦³ç¹ã§ã¯ãå®è¡ç°å¢ã§ã¯ short open tag ãæå¹ã ã£ããããªã®ã§ãã㨠4 æååãã¾ãããã¾ãæ¨æºã¨ã©ã¼åºåãèæ ®ããããã¯ç¢ºèªãã¾ããã§ããããããèæ ®ãããªããªã @ ã«ããæå¶ãä¸è¦ãªã®ã§ãããã« 1 æååãã¾ãã