Upgrade to Pro — share decks privately, control downloads, hide ads and more …

assertぐらいでエバルんじゃねえ!

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

 assertぐらいでエバルんじゃねえ!

〜Phanがもたらす堅牢なPHP〜

Avatar for Atsushi Takayama

Atsushi Takayama

December 15, 2016
Tweet

More Decks by Atsushi Takayama

Other Decks in Technology

Transcript

  1. Ҿ਺Λboolඞਢʹ͍ͨ͠ assert($a === 1); // OK assert(empty($a)); // OK assert(!is_null($a));

    // OK assert(“$b !== 1”); // NG assert(someFunction($a)); // ?
  2. $ phan some.php
 some.php:5 PhanTypeMismatchArgumentInternal Argument 1 (assertion) is int

    but \assert() takes bool|string PHPͷඪ४ؔ਺ͷҾ਺ͱฦΓ஋ͷܕͷҰཡΛ࣋ͬͯ ͍ͯɺܕਪ࿦ͯ͘͠ΕΔ
  3. →PhanϓϥάΠϯͰ % tree -a
 .
 !"" .phan
 # !"" config.php


    # $"" plugins
 # $"" NonBoolAssertPlugin.php
 $"" some.php
  4. $ phan some.php
 some.php:5 PhanPluginNonBoolAssert Non bool value passed to

    assert
 some.php:5 PhanTypeMismatchArgumentInternal Argument 1 (assertion) is int but \assert() takes bool|string