nilportugues/php_forbidden

Looks into the code using a user-defined list of forbidden function in a given path.

1.0.5 2015-11-09 12:49 UTC

This package is not auto-updated.

Last update: 2024-04-27 15:42:26 UTC


README

Scrutinizer Code Quality SensioLabsInsight Latest Stable Version Total Downloads License Donate

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!

Support

Get in touch with me using one of the following means:

Authors

License

The code base is licensed under the MIT license.