PHPackages                             ekino/phpstan-banned-code - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. ekino/phpstan-banned-code

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

ekino/phpstan-banned-code
=========================

Detected banned code using PHPStan

v3.2.0(2mo ago)2925.6M—1.7%25[3 PRs](https://github.com/ekino/phpstan-banned-code/pulls)20MITPHPPHP ^8.2CI passing

Since Jan 2Pushed 2mo ago13 watchersCompare

[ Source](https://github.com/ekino/phpstan-banned-code)[ Packagist](https://packagist.org/packages/ekino/phpstan-banned-code)[ Docs](https://github.com/ekino/phpstan-banned-code)[ RSS](/packages/ekino-phpstan-banned-code/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (20)Used By (20)

PHPStan Banned Code
===================

[](#phpstan-banned-code)

[![Latest Stable Version](https://camo.githubusercontent.com/8900b6a310958302badbf97e3388413dde38890f796f288159c29a5bd9a1303e/68747470733a2f2f706f7365722e707567782e6f72672f656b696e6f2f7068707374616e2d62616e6e65642d636f64652f762f737461626c65)](https://packagist.org/packages/ekino/phpstan-banned-code)[![Build Status](https://camo.githubusercontent.com/79c6f3abe470f224db92b0147c5d67a3cdbec60608a6e2e83806aa532f77fb7a/68747470733a2f2f7472617669732d63692e6f72672f656b696e6f2f7068707374616e2d62616e6e65642d636f64652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ekino/phpstan-banned-code)[![Coverage Status](https://camo.githubusercontent.com/13d781a384753dcff927eed1a7b400cbea1646934ab74047bd52cbdd075e0fdd/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f656b696e6f2f7068707374616e2d62616e6e65642d636f64652f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/ekino/phpstan-banned-code?branch=master)[![Total Downloads](https://camo.githubusercontent.com/9db6b68c4fcc4155e6d4a943e0755bd32bd48b17a9136691d0fdd7925acf5dc1/68747470733a2f2f706f7365722e707567782e6f72672f656b696e6f2f7068707374616e2d62616e6e65642d636f64652f646f776e6c6f616473)](https://packagist.org/packages/ekino/phpstan-banned-code)

This library is based on [PHPStan](https://phpstan.org/) 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](https://www.php.net/manual/en/function.var-dump.php), [exit](https://www.php.net/manual/en/function.exit.php), ...).

Basic usage
-----------

[](#basic-usage)

To use this extension, require it using [Composer](https://getcomposer.org/):

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

When you use  you are done.

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

```
includes:
	- vendor/ekino/phpstan-banned-code/extension.neon

```

Advanced usage
--------------

[](#advanced-usage)

You can configure this library with parameters:

```
parameters:
	banned_code:
		nodes:
			# 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
				functions:
					- dd
					- debug_backtrace
					- dump
					- exec
					- passthru
					- phpinfo
					- print_r
					- proc_open
					- shell_exec
					- system
					- var_dump

			# enable detection of print statements
			-
				type: Expr_Print
				functions: null

			# enable detection of shell execution by backticks
			-
				type: Expr_ShellExec
				functions: null

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

		# errors emitted by the extension are non-ignorable by default, so they cannot accidentally be put into the baseline.
		non_ignorable: false # default is true

```

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

###  Health Score

71

—

ExcellentBetter than 100% of packages

Maintenance86

Actively maintained with recent releases

Popularity63

Solid adoption and visibility

Community43

Growing community involvement

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 65.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~187 days

Recently: every ~147 days

Total

15

Last Release

66d ago

Major Versions

v0.5.0 → v1.0.02021-11-02

v1.0.0 → v2.0.02024-08-01

v2.1.0 → v3.0.02024-11-13

PHP version history (5 changes)v0.0.1PHP ^7.1

v0.4.0PHP ^7.2 || ^8.0

v1.0.0PHP ^7.3 || ^8.0

v2.0.0PHP ^8.1

v3.1.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/574481?v=4)[Ekino](/maintainers/ekino)[@ekino](https://github.com/ekino)

---

Top Contributors

[![mremi](https://avatars.githubusercontent.com/u/548536?v=4)](https://github.com/mremi "mremi (74 commits)")[![vladsolntsev](https://avatars.githubusercontent.com/u/71027725?v=4)](https://github.com/vladsolntsev "vladsolntsev (7 commits)")[![Daric971](https://avatars.githubusercontent.com/u/24455611?v=4)](https://github.com/Daric971 "Daric971 (6 commits)")[![vincentlaurier](https://avatars.githubusercontent.com/u/157579630?v=4)](https://github.com/vincentlaurier "vincentlaurier (4 commits)")[![bdejacobet](https://avatars.githubusercontent.com/u/1875787?v=4)](https://github.com/bdejacobet "bdejacobet (2 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (2 commits)")[![rande](https://avatars.githubusercontent.com/u/14672?v=4)](https://github.com/rande "rande (2 commits)")[![spawnia](https://avatars.githubusercontent.com/u/12158000?v=4)](https://github.com/spawnia "spawnia (2 commits)")[![jdecool](https://avatars.githubusercontent.com/u/433926?v=4)](https://github.com/jdecool "jdecool (1 commits)")[![nanofelis](https://avatars.githubusercontent.com/u/3204875?v=4)](https://github.com/nanofelis "nanofelis (1 commits)")[![nauxliu](https://avatars.githubusercontent.com/u/9570112?v=4)](https://github.com/nauxliu "nauxliu (1 commits)")[![ondrejmirtes](https://avatars.githubusercontent.com/u/104888?v=4)](https://github.com/ondrejmirtes "ondrejmirtes (1 commits)")[![PierreEkino](https://avatars.githubusercontent.com/u/67899611?v=4)](https://github.com/PierreEkino "PierreEkino (1 commits)")[![raing3](https://avatars.githubusercontent.com/u/3496137?v=4)](https://github.com/raing3 "raing3 (1 commits)")[![fabienChaillou](https://avatars.githubusercontent.com/u/42312426?v=4)](https://github.com/fabienChaillou "fabienChaillou (1 commits)")[![raphaelstolt](https://avatars.githubusercontent.com/u/48225?v=4)](https://github.com/raphaelstolt "raphaelstolt (1 commits)")[![simbig](https://avatars.githubusercontent.com/u/26680884?v=4)](https://github.com/simbig "simbig (1 commits)")[![brociani](https://avatars.githubusercontent.com/u/60506014?v=4)](https://github.com/brociani "brociani (1 commits)")[![Spomky](https://avatars.githubusercontent.com/u/1091072?v=4)](https://github.com/Spomky "Spomky (1 commits)")[![valentinloiseau](https://avatars.githubusercontent.com/u/27896270?v=4)](https://github.com/valentinloiseau "valentinloiseau (1 commits)")

---

Tags

phpphpstan-extensionqualityPHPStanstatic analysiscode quality

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/ekino-phpstan-banned-code/health.svg)

```
[![Health](https://phpackages.com/badges/ekino-phpstan-banned-code/health.svg)](https://phpackages.com/packages/ekino-phpstan-banned-code)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[staabm/phpstan-dba

2912.3M2](/packages/staabm-phpstan-dba)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

3462.2M52](/packages/shipmonk-dead-code-detector)[szepeviktor/phpstan-wordpress

WordPress extensions for PHPStan

3287.8M898](/packages/szepeviktor-phpstan-wordpress)[staabm/phpstan-todo-by

1991.8M55](/packages/staabm-phpstan-todo-by)[shipmonk/phpstan-rules

Various extra strict PHPStan rules we found useful in ShipMonk.

1491.7M114](/packages/shipmonk-phpstan-rules)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
