[Git hook] Command line to look for functions that should be avoided
MIT License
Why? Because someone should look for forbidden functions that should be avoided in production.
Typical examples are print_r
, var_dump
, exit
and die
function calls.
Use Composer to install the package:
$ composer require --dev nilportugues/php_forbidden
It is really this simple:
$ php bin/php_forbidden check <path/to/directory>
$ php bin/php_forbidden check <path/to/file>
You can also pipe STDIN in, if you want to use this tool with Gulp for instance:
$ cat <path/to/file> | php bin/php_forbidden check
which means that this also works writing code directly from the shell (if you have some reason to do it):
$ php bin/php_forbidden check
<?php
// Insert your code
// and press CTRL+D to send EOF
When run the first time, if no php_forbidden_function.yml
file is found, it will be generated.
A configuration for instance, should formatted as follows:
forbidden:
- file_get_contents
- fopen
- die
- var_dump
- print_r
You can specify an alternate location for the configuration file by passing in the -c
parameter. Example:
$ php bin/php_forbidden check -c configs/php_forbidden_function.yml src/
Contributions to the package are always welcome!
Get in touch with me using one of the following means:
The code base is licensed under the MIT license.