Part-DB-server/phpstan.banned_code.neon
2026-03-07 22:30:39 +01:00

86 lines
1.7 KiB
Text

# Manually configure ekino/phpstan-banned-code to detect usage of echo, eval, die/exit, print, shell execution and a set of functions that should not be used in production code.
parametersSchema:
banned_code: structure([
nodes: listOf(structure([
type: string()
functions: schema(listOf(string()), nullable())
]))
use_from_tests: bool()
non_ignorable: bool()
])
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 empty()
#-
# type: Expr_Empty
# functions: null
# enable detection of `use Tests\Foo\Bar` in a non-test file
use_from_tests: true
# when true, errors cannot be excluded
non_ignorable: false
services:
-
class: Ekino\PHPStanBannedCode\Rules\BannedNodesRule
tags:
- phpstan.rules.rule
arguments:
- '%banned_code.nodes%'
-
class: Ekino\PHPStanBannedCode\Rules\BannedUseTestRule
tags:
- phpstan.rules.rule
arguments:
- '%banned_code.use_from_tests%'
-
class: Ekino\PHPStanBannedCode\Rules\BannedNodesErrorBuilder
arguments:
- '%banned_code.non_ignorable%'