Generating a File List for Phan

Phan is the PHP Analyzer for PHP 7 code. I’ve been using it, partly out of curiosity, and partly to look at what the implications of upgrading my various projects will be. The simplest usage instructions are:

phan -f filelist.txt

I generated my filelist.txt files with a little help from grep – by looking for all files with opening PHP tags in, and putting that list of filenames into a file. My command looks like this:

grep -R -l "<?php" * > filelist.txt

This simply greps recursively (the -R switch) in all files looking for <?php and when it finds it, outputs only the filename (the -l switch does that bit). Then I just put all the output into my filelist.txt file.

Phan is in its early stages but it’s ready for you to run on your own projects. Look out that you may need to put your bootstrap or other include files first in the filelist.txt file if phan isn’t finding things in the right order – luckily with it all in one file, it’s relatively easy to move things around if you need to.

2 thoughts on “Generating a File List for Phan

  1. Phan looks really interesting, and I need to look deeper into it as stuff moves over to PHP 7.

    For your file list, though, I’d add the -i case-insensitive flag to your grep command, since <?PHP Is still valid, and otherwise you're likely to miss things.

  2. Pingback: Running Phan against Slim 3 | Rob Allen's DevNotes

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.