Detected banned code using PHPStan

Installs: 165 643

Dependents: 15

Suggesters: 0

Security: 0

Stars: 117

Watchers: 15

Forks: 12

Open Issues: 4


v0.3.1 2020-01-17 13:08 UTC

This package is auto-updated.

Last update: 2020-10-06 13:39:52 UTC


Latest Stable Version Build Status Coverage Status Total Downloads

This library is based on PHPStan to detect calls to specific functions you don't want in your project. For instance, you can add it in your CI process to make sure there is no debug/non standard code (like var_dump, exit, ...).

Basic usage

To use this extension, require it using Composer:

composer require --dev ekino/phpstan-banned-code

When you use https://github.com/phpstan/extension-installer you are done.

If not, include extension.neon in your project's PHPStan config:

	- vendor/ekino/phpstan-banned-code/extension.neon

Advanced usage

You can configure this library with parameters:

			# enable detection of echo
				type: Stmt_Echo
				functions: null

			# enable detection of eval
				type: Expr_Eval
				functions: null

			# enable detection of die/exit
				type: Expr_Exit
				functions: null

			# enable detection of a set of functions
				type: Expr_FuncCall
					- dd
					- debug_backtrace
					- dump
					- exec
					- passthru
					- phpinfo
					- print_r
					- proc_open
					- shell_exec
					- system
					- var_dump

		# enable detection of `use Tests\Foo\Bar` in a non-test file
		use_from_tests: true

type is the returned value of a node, see the method getType().