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

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

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

003f59d1b2e3b864c744f8eb21f68e82?s=128

Atsushi Takayama

December 15, 2016
Tweet

Transcript

  1. 6.
  2. 8.
  3. 14.
  4. 16.

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

    // OK assert(“$b !== 1”); // NG assert(someFunction($a)); // ?
  5. 18.

    $ phan some.php
 some.php:5 PhanTypeMismatchArgumentInternal Argument 1 (assertion) is int

    but \assert() takes bool|string PHPͷඪ४ؔ਺ͷҾ਺ͱฦΓ஋ͷܕͷҰཡΛ࣋ͬͯ ͍ͯɺܕਪ࿦ͯ͘͠ΕΔ
  6. 20.

    →PhanϓϥάΠϯͰ % tree -a
 .
 !"" .phan
 # !"" config.php


    # $"" plugins
 # $"" NonBoolAssertPlugin.php
 $"" some.php
  7. 21.
  8. 22.

    $ 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