NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist, #619 most downloaded on Packagist
PHPStan rules to detect disallowed method & function calls, constant, namespace, attribute, property & superglobal usages, with powerful rules to re-allow a call or a usage in places where it should be allowed.
Latest stable
v4.15.0
Last release 1 months ago
13 Oct 2026
Release timing varies
gaps range from 8 days to 4 months
Nearly every release is documented
notes for 58 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
88 releases · first in 2018
Drag across the ruler to compare, or tap a release to open it.
That's it, that's the release
That's it, that's the release (#82)
This reverts the allowCount feature (#87) introduced in 1.10, it doesn't work as expected and seems it can't be made to work as planned (#91, thanks @
This reverts the allowCount feature (#87) introduced in 1.10, it doesn't work as expected and seems it can't be made to work as planned (#91, thanks @ruudk).
No other change.
~~This release adds support for allowCount config key for disallowedMethodCalls to allow methods/functions to be called max *N* times. This might be u
Your coding agent can read these notes before it upgrades. Set up the MCP server →
This release adds support for This feature got reverted in 1.11.0.allowCount config key for disallowedMethodCalls to allow methods/functions to be called max N times. This might be useful when you have some classes you don't want to be reused for some reason (like some generated classes for example). (#87, thanks @ruudk!)
Internally, the code now uses int & bool instead of integer & boolean and uses Use PHP Parser 4.12 (#84) but not newer (newer will be supported once PHPStan 1.0 is out, real soon now)
When you want to allow the call in allowed paths/calls only when it's *not* using those params
When you want to allow the call in allowed paths/calls only when it's not using those params (#80)
Using allowInMethods (or allowInFunctions alias), one can allow a method/function when called from another method/function
allowInMethods (or allowInFunctions alias), one can allow a method/function when called from another method/function (#77)disallowed-insecure-calls.neon) with pre-disallowed (potentially) insecure calls (#78)disallowed-loose-calls.neon), some calls are better when done with some params set (e.g. in_array(..., ..., true), and this config is for those calls (#79)New config options allowParamsAnywhereAnyValue & allowParamsInAllowedAnyValue to allow previously forbidden call when a param with any value is presen
allowParamsAnywhereAnyValue & allowParamsInAllowedAnyValue to allow previously forbidden call when a param with any value is present (#75)allowExceptParams & allowExceptCaseInsensitiveParams config options, when you need to disallow a function or a method only when a param has a specified value (#74)...) is also automatically forbidden when shell_exec() is forbidden (f66118bc4e7243614ae4298e617fc462d8eb1022)allowParamsInAllowedAnyValue are checked in allowed paths even if allowParamsAnywhere exists too (823da131bc8c256904bcb42f5d946d1df28b3d72)Support for disallowing echo/print language constructs (#72, thanks @ruudk!)
echo/print language constructs (#72, thanks @ruudk!).. can be used in path in allowInCalls & Usages sub-namespaces as there's already quite a few calls that can be disallowedSupport language constructs: die/exit, empty
die/exit, empty (#70)protected (#67, thanks @peter279k)Do not absolutize path when path starts with wildcard, helps when running PHPStan from PHPStorm (#64, thanks @ruudk)
composer cs-fix command to automatically fix coding standards violationsStarting with this release, you can now disallow whole namespaces (#51, thanks @ruudk)
fnmatch greatly increasing the disallowing possibilities, so if you don't like any and all functions that end with y, you can disallow them (#53, thanks @ruudk)If I'd name releases, this one would be called Ruud 💪
Disallowing namespaces requires a new service but if you use this extension by including extension.neon as the documentation suggests, you don't need to do anything. Otherwise, check what has been added to the file, or switch to including extension.neon.
Support for disallowing (class) constants was added in v1.1.0 but it has never worked.
Support for disallowing (class) constants was added in v1.1.0 but it has never worked.
Now it should work. To disallow a class constant, you have to specify it using two keys, class & constant like:
parameters:
disallowedConstants:
-
class: 'DateTimeInterface'
constant: 'ISO8601'
message: 'use DateTimeInterface::ATOM instead'
instead of just constant: 'DateTimeInterface::ISO8601'. This is to "mask" the constant to avoid it being detected and replaced by its value.
This is released as a "patch" version only despite requiring a new config key because it has never worked with the old one anyway so I think there's no need to preserve backwards compatibility.
(#49, thanks @ruudk for the report)
Allow param overwriting (#46) You can now include the bundled config file and then allow some calls/constants by path in your local config
Allow param overwriting (#46) You can now include the bundled config file and then allow some calls/constants by path in your local config
Document this extension can be used with PHPStan but without running any other PHPStan rules (#45)
Don't crash on $string::constant (#43)
Unfortunately, some valid use cases are not supported yet and an error will be thrown for cases like
/** @var string $monster */
$monster = DateTime::class;
$monster::COOKIE;
/** @var class-string $monster */
$monster = DateTime::class;
$monster::COOKIE;
If you hit those errors, you need to add them to ignoreErrors in your phpstan.neon config file. I hope to resolve the issue in a future release, contributions welcome.
Can now disallow constant usages, both class constants (e.g. \DateTime::FOO) and regular constants (DATE_FOO)
Can now disallow constant usages, both class constants (e.g. \DateTime::FOO) and regular constants (DATE_FOO) (#41)
Because sometimes you want to avoid formatting dates with \DateTimeInterface::ISO8601 because "This format is not compatible with ISO-8601", or avoid filtering IP addresses with filter flags like FILTER_FLAG_NO_PRIV_RANGE because it doesn't recognize "IPv4-in-IPv6" addresses (called IPv4-mapped addresses) like ::ffff:192.0.2.33.
This is how you configure it in yourphpstan.neon:
disallowedConstants:
-
constant: 'DATE_ISO8601'
message: 'use DATE_ATOM instead'
-
constant: 'DateTimeInterface::ISO8601'
message: 'use DateTimeInterface::ATOM instead'
Support for PHP 8 added, relaxed requirements, newer PHPUnit supported (#39, thanks @xificurk)
Support for PHP 8 added, relaxed requirements, newer PHPUnit supported (#39, thanks @xificurk)
No other code or rules changes.
…what needs to be added This alone brings some breaking changes (see #25 for discussion) so I thought I'd bump the version number. Due to some rather p…
NewCalls and EvalCalls were added.
If you're not using includes: - vendor/spaze/phpstan-disallowed-calls/extension.neon you'd need to manually add them to your phpstan.neon's services, check extension.neon to see what needs to be added
This alone brings some breaking changes (see #25 for discussion) so I thought I'd bump the version number. Due to some rather poor choices in the past, the version is now 0.12 and I can't stay on that because of the changes. Going to 0.13 would be confusing because PHPStan 0.12 is still supported. So let's go to 1.0. I like what this does already so why not :-)Foo\Bar::__construct() even if there's no constructor defined in that particular class. Both new Foo and $a = 'Foo'; new $a; is detected. (#37, thanks @enumag for the test)method \Foo::bar() instead of just method Foo::bar()) (#38)eval() is detected, did you know it's not a function but a language construct? (#36)disallowed-execution-calls.neon includes popen()
disallowed-dangerous-calls.neon now also includes these:
apache_setenv()dl()posix_getpwuid()posix_kill()posix_mkfifo()posix_mknod()highlight_file()show_source()pfsockopen()proc_nice()putenv()socket_create_listen()socket_listen()Optional parentheses so you can use function: foo() or function: foo
function: foo() or function: foo (#34)function: pcntl_*)exec(), shell_exec() and friends: disallowed-execution-calls.neonThis release adds ability to detect more calls that you'd probably expect to be detected:
This release adds ability to detect more calls that you'd probably expect to be detected:
Thanks @enumag for writing the tests (the T in TDD)!
Also
This PHPStan extension is also PHPStan-tested and this release brings mostly internal refactoring only to beat PHPStan's max level.
This PHPStan extension is also PHPStan-tested and this release brings mostly internal refactoring only to beat PHPStan's max level.
Also checking static calls like $this->foo::bar() which has been previously crashing PHPStan, now doesn't crash it (#24)
Support for PHPStan's extension installer, more straightforward config
If you're not using the extension installer, you're fine with the configuration you already use and can continue using it as long as you wish.
If you're using the extension installer, the extension.neon where the classes are set up will be included automatically by PHPStan and you'll probably get "Multiple services found" when you'll run PHPStan. In that case you'd need to change the configuration slightly:
Spaze\PHPStan\Rules\Disallowed\DisallowedHelper from your phpstan.neonforbiddenCalls keys and values from Spaze\PHPStan\Rules\Disallowed\{Method,Static,Function}Calls definitions to parameters > disallowedMethodCalls (and disallowedStaticCalls, disallowedFunctionCalls, respectively), can even put them in a new file (e.g. disallowed-calls.neon) which you can then include manuallySpaze\PHPStan\Rules\Disallowed\{Method,Static,Function}Calls definitions from your phpstan.neon including the keys and values under arguments > forbiddenCallsIf you'd like to switch to using extension.neon even without using the extension installer, follow the steps above and manually include vendor/spaze/phpstan-disallowed-calls/extension.neon in your phpstan.neon.
Now you can allow calls with specified parameters while calls with different parameters would still be disallowed
Now you can allow calls with specified parameters while calls with different parameters would still be disallowed (#1)
Don't forget that since 0.12.2, you need to add DisallowedHelper to your services section in phpstan.neon:
services:
- Spaze\PHPStan\Rules\Disallowed\DisallowedHelper
You can also allow some previously disallowed calls using the allowIn configuration key
You can also allow some previously disallowed calls using the allowIn configuration key (#3)
You need to add DisallowedHelper to your services section in phpstan.neon:
services:
- Spaze\PHPStan\Rules\Disallowed\DisallowedHelper
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.