nilportugues / php_forbidden
Looks into the code using a user-defined list of forbidden function in a given path.
Requires
- php: >=5.4
- symfony/console: ~2.2
- symfony/yaml: ^2.7
Requires (Dev)
- fabpot/php-cs-fixer: 1.4.2
This package is not auto-updated.
Last update: 2024-12-21 19:37:13 UTC
README
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.
Installation
Use Composer to install the package:
$ composer require --dev nilportugues/php_forbidden
Usage
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
Configuration file
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/
Contribute
Contributions to the package are always welcome!
- Report any bugs or issues you find on the issue tracker.
- You can grab the source code at the package's Git repository.
Support
Get in touch with me using one of the following means:
- Emailing me at contact@nilportugues.com
- Opening an Issue
Authors
License
The code base is licensed under the MIT license.