Running Phan against Slim 3
Having installed Phan, I decided to use it against the upcoming Slim 3 codebase.
Phan needs a list of files to scan, and the place I started was with Lorna’s article on Generating a file list for Phan.
I started by removing all the developer dependencies:
$ composer update --no-dev
and then built the file list for the vendor and Slim directories. I started by using Lorna’s grep statement, but that found too many non-PHP files in vendor, so I ended up with:
$ grep -R -l " phpfiles.txt
I then reorganised the list to put interfaces and traits at the top as order matters & then ran Phan:
$ phan -f phpfiles.txt Files scanned: 39 Time: 0.39s Classes: 39 Methods: 297 Functions: 0 Closures: 18 Traits: 4 Conditionals: 197 Issues found: 111 Slim/Http/Request.php:116 TypeError property is declared to be string but was assigned int Slim/Http/Message.php:25 UndefError Trying to implement unknown interface Psr\Http\Message\MessageInterface Slim/Http/Stream.php:20 UndefError Trying to implement unknown interface Psr\Http\Message\StreamInterface Slim/Http/Uri.php:35 UndefError Trying to implement unknown interface Psr\Http\Message\UriInterface Slim/Http/Request.php:32 UndefError Trying to implement unknown interface Psr\Http\Message\ServerRequestInterface …
A lot of issues have been found – most of them due to missing dependent classes & interfaces, so I ignored those when working through the list. Next time, I’ll add the relevant vendor files to see if that catches anything else.
The remaining issues found were all type errors related to the docblock saying one thing and the code doing another. These will need tidying up.
It was an interesting exercise and I encourage you to run Phan or a similar tool over your own codebase.