anlutro/phint

This package is abandoned and no longer maintained. No replacement package was suggested.

dev-master 2017-10-11 18:52 UTC

This package is not auto-updated.

Last update: 2020-01-24 15:34:20 UTC


README

Build Status Latest Stable Version Latest Unstable Version License

Phint is a static code analysis tool for PHP. Very much a work in progress. Currently checks for:

  • Undefined variables
  • Properties/methods being called exist
  • Classes being used in your code exist (instantiation, type-hinting, instanceof)
  • Exception being caught actually exist and are exceptions (catch (stdClass $e) will error, for example)
  • Functions being called actually exist
  • Methods and functions are called with the correct number of arguments

More features to come. Check the Github issues.

Installation

On a per-project basis:

composer require --dev anlutro/phint:dev-master@dev
./vendor/bin/phint /path/to/src

Globally:

wget https://files.lutro.me/phint.phar
chmod +x phint.phar
sudo mv phint.phar /usr/local/bin
phint /path/to/src

Usage

Note that you must be in your project's root for Phint to run. You also need a composer autoloader to be present in vendor/autoload.php.

Example output from a simple command run:

You can pass --strict or -s as an arugment to get more errors. The errors marked as strict are more prone to be wrong, but should be more accurate as time goes on.

You can also pass --debug or -d to get some debug information. Currently this isn't much, unless you hit a fatal error, in which case you might get some more info.

By default, if you pass a directory or multiple file paths to the command, Phint will analyze all of them and spit out the errors as it goes along. If you pass --exit-early or -e, Phint will exit as soon as it finds a file with errors.

Notes

This tool makes some very heavy assumptions about how you're using it and your application.

Your project must have some sort of autoloader register script present in vendor/autoload.php. This autoloader must make every class and function in your project available.

The checker works best if all the files being checked are classes with methods, nothing more.

Contributing

See the CONTRIBUTING.md file for information on contributing.

License

The contents of this repository is released under the GPL v3 license. See the LICENSE file included for more information.