Features provided by plugins
Additional analysis features have been provided by plugins.
- Checking for syntactically unreachable statements (E.g.
{ throw new Exception("Message"); return $value; }
) - Checking
*printf()
format strings against the provided arguments (as well as checking for common errors) - Checking that PCRE regexes passed to
preg_*()
are valid - Checking for
@suppress
annotations that are no longer needed. - Checking for duplicate or missing array keys.
- Checking coding style conventions
- Others
Example: Phan’s plugins for self-analysis.
Generating a file list
This static analyzer does not track includes or try to figure out autoloader magic. It treats
all the files you throw at it as one big application. For code encapsulated in classes this
works well. For code running in the global scope it gets a bit tricky because order
matters. If you have an index.php
including a file that sets a bunch of global variables and
you then try to access those after the include(...)
in index.php
the static analyzer won’t
know anything about these.
In practical terms this simply means that you should put your entry points and any files
setting things in the global scope at the top of your file list. If you have a config.php
that sets global variables that everything else needs, then you should put that first in the list followed by your
various entry points, then all your library files containing your classes.
Development
Take a look at [Developer’s Guide to Phan](https://github.com/phan/phan/wiki/Developer’s-Guide-To-Phan) for help getting started hacking on Phan.
When you find an issue, please take the time to create a tiny reproducing code snippet that illustrates
the bug. And once you have done that, fix it. Then turn your code snippet into a test and add it to
tests then ./test
and send a PR with your fix and test. Alternatively, you can open an Issue with
details.
To run Phan’s unit tests, just run ./test
.
To run all of Phan’s unit tests and integration tests, run ./tests/run_all_tests.sh
Code of Conduct
We are committed to fostering a welcoming community. Any participant and contributor is required to adhere to our Code of Conduct.
Online Demo
This requires an up to date version of Firefox/Chrome and at least 4 GB of free RAM. (this is a 10 MB download)