Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

PHPのアノテーションの仕組みとメリット・デメリット / About PHP annotations

PHPのアノテーションの仕組みとメリット・デメリット / About PHP annotations

2020年2月9日、PHPerKaigi 2020・Day 0での発表資料です。
https://phperkaigi.jp/2020/

YAMAOKA Hiroyuki

February 09, 2020
Tweet

More Decks by YAMAOKA Hiroyuki

Other Decks in Programming

Transcript

  1. PHP

  2. PHP /** * @param string $input * @param int $expectedLength

    * @testWith ["test", 4]["longer-string", 13] */ public function testStringLength(string $input, int $expectedLength): void { $this->assertEquals($expectedLength, \strlen($input)); }
  3. Java : Javadoc /** * αϯϓϧΫϥε * @author Hiroyuki YAMAOKA

    * @version 1.0 */ public class Sample { /** * @param width ෯ * @param height ߴ͞ */ public void setSize(int width, int height) { } }
  4. : Servlet @WebServlet(urlPatterns = {"/hello"}) public class HelloServlet extends HttpServlet

    { @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // ॲཧΛॻ͘… } }
  5. :

  6. PHP

  7. : PHPDoc /** * ച্ֹΛܭࢉ͢Δɻ * * @param int $price

    ୯Ձ * @param int $unit ചΕͨݸ਺ * @return int ച্ֹ */ public function int calcSales(int $price, int $unit): int {
  8. : PSR- & - PSR- PHPDoc Standard (DRAFT) https://github.com/php- g/

    g-standards/blob/master/proposed/phpdoc.md - PSR- PHPDoc tags (DRAFT) https://github.com/php- g/ g-standards/blob/master/proposed/phpdoc-tags.md
  9. PSR- & - 2018 PHPDoc PSR- - Qiita https://qiita.com/tadsan/items/ b

    d ca d - PSR- : PHPDoc tags - BASE https://devblog.thebase.in/entry/ / / /
  10. PHP - Re ection API https://www.php.net/manual/ja/book.re ection.php - Re ectionClass::getDocComment

    - - : Doctrine/annotations https://github.com/doctrine/annotations