<slide title="" section="phan">

<blurb fontsize="20em" align="center">Static Analysis</blurb>
<break lines="2"/>
<link fontsize="2em" align="center" href="https://github.com/phan/phan">github.com/phan/phan</link>
<break lines="1" section="phan0"/>
<blurb fontsize="1.5em" align="left">Install with composer</blurb>
<example fontsize="1em" result='0' title="" type="shell nohighlight"><![CDATA[
$ composer require --dev phan/phan
]]></example>
<blurb fontsize="1.5em" align="left">Create .phan/config.php</blurb>
<example fontsize="1em" result='0' title="" type="shell nohighlight"><![CDATA[
<?php
return [
    'target_php_version' => '7.2',
    'directory_list' => [ 'src/' ],
    "exclude_analysis_directory_list" => [ 'vendor/' ],
];
]]></example>
<example fontsize="1em" result='0' title="" type="shell nohighlight"><![CDATA[
$ ./vendor/bin/phan
]]></example>

<break lines="1" section="phan1"/>
<blurb fontsize="2em" align="left">Checks</blurb>
<list>
<bullet>enhanced phpdoc type annotations</bullet>
<bullet>Everything is defined and accessible</bullet>
<bullet>Type safety</bullet>
<bullet>PHP version compatibility</bullet>
<bullet>No-ops</bullet>
<bullet>Unreachable code</bullet>
<bullet>Unused use statements</bullet>
<bullet>Redefinitions</bullet>
<bullet>Signature compatibility and final on inheritance</bullet>
<bullet>and many more</bullet>
</list>

<break lines="1" section="phan2"/>
<blurb fontsize="1em" align="left">Enhanced PHPDoc type annotations</blurb>
<example fontsize="1em" result='0' title="" type=""><![CDATA[
<?php
class C {
  /**
   * @param string|int $union
   * @param int[] $generic
   * @param array{mode:string,max:int} $shaped
   */
  static function fn($union, array $generic, $shaped) { }
}
C::fn("test", [1,2,3], ['mode'=>"test", 'max'=>10]);
C::fn(1, [1,2,3], ['mode'=>"test", 'max'=>10]);
C::fn("test", [1,2,3], ['max'=>10,'mode'=>"test"]);

C::fn([1], [1,2,3], ['mode'=>"test", 'max'=>10]);
// PhanTypeMismatchArgument Argument 1 (union) is array{0:1}
// but \C::fn() takes int|string

C::fn("test", [1,2,3], ['max'=>10]);
// PhanTypeMismatchArgument Argument 3 (shaped) is array{max:10}
// but \C::fn() takes array{mode:string,max:int}
]]></example>

<break lines="1" section="phan3"/>
<blurb fontsize="1.5em" align="left">User plugins</blurb>
<link fontsize="1.5em" align="center" href="https://github.com/phan/phan/wiki/Writing-Plugins-for-Phan">Writing Plugins for Phan</link>
<blurb fontsize="1.5em" align="left">Included sample plugins</blurb>
<list style="column-count:2;column-gap:1.8em;font-size:0.8em">
<bullet>Demo Plugin</bullet>
<bullet>Preg Regex Checker</bullet>
<bullet>Printf Checker</bullet>
<bullet>Unreachable Code</bullet>
<bullet>DollarDollar</bullet>
<bullet>NonBool Branch</bullet>
<bullet>Numerical Comparison</bullet>
<bullet>Has PHPDoc</bullet>
<bullet>Duplicate Expression</bullet>
</list>
<break lines="1" section="phan4"/>
<blurb fontsize="2em" align="left">Daemon mode</blurb>
<example fontsize="1em" result='0' title="" type="shell nohighlight"><![CDATA[
$ phan --daemonize-tcp-port default &
[1] 28610
Listening for Phan analysis requests at tcp://127.0.0.1:4846
Awaiting analysis requests for directory '/home/rasmus/phan_demo'

$ vi src/script.php
]]></example>
<example fontsize="1em" result='0' title="" type="shell nohighlight"><![CDATA[
$ phan_client -l src/script.php
Phan error: TypeError: PhanTypeMismatchArgument: Argument 1 (union) is array{0:1} but \C::fn() takes int|string defined at src/script.php:8 in src/script.php on line 14
Phan error: TypeError: PhanTypeMismatchArgument: Argument 3 (shaped) is array{max:10} but \C::fn() takes array{mode:string,max:int} defined at src/script.php:8 in src/script.php on line 16
]]></example>

<break lines="1" section="phan5"/>
<blurb fontsize="1.5em" align="left">vim integration</blurb>
<movie filename="phanvid.mp4" align="center" width="1848" height="1008" autoplay="false" replay="0"/>
</slide>
