Releases: spaze/phpstan-disallowed-calls
Callable param variant fix
Can disallow `isset` & `unset`
Detect callables and dynamic calls
This version replaces 4.1.0 in which callables were not detected in constructors. The notes below are taken from 4.1.0.
This release adds new detections listed below, meaning it's possible that you'll see new error messages.
First class callable syntax (#279), for example:
$func = print_r(...);
Dynamic calls (#276, #278), for example:
$func('foo');
$object->$method();
Test anonymous class usages (#277), for example:
$foo = new class implements ...
$foo = new class extends ...
Anonymous class usages (when the anonymous class extends DisallowedClass
for example) were detected before, however the detection is now tested.
Detect callable parameters (#281, #283, #285), for example:
array_map('function', []);
array_map([$object, 'method'], []);
array_map([Class::class, 'staticMethod']);
Detect callables and dynamic calls (replaced by 4.1.1)
This release has been replaced by 4.1.1 which also detects callables in constructors, unlike this version.
Support both PHPStan 1.12 & 2.0
The 4.0 release removed support for PHPStan 1.x, and this release brings it back. Both PHPStan 1.12 and PHPStan 2.0 are supported (#273).
You can learn more about PHPStan 2.0 in the release notes or in the blog post and don't forget to get yourself an elephpant and a t-shirt!
Support & require PHPStan 2.0
This major release supports and requires PHPStan 2.0 (#267) (update: the 4.0.1 release adds back support for PHPStan 1.12)
As mentioned in the UPGRADING.md
guide:
It's not feasible to try to support both PHPStan 1.x and PHPStan 2.x with the same extension code.
You can learn more about PHPStan 2.0 in the release notes or in the blog post and don't forget to get yourself an elephpant and a t-shirt!
Support PHP 8.4
- Support PHP 8.4 (#270)
That's it. That's the release.
Disallow create_function and support PHPStan 1.12.6, getting ready for 2.0
- Add
create_function
as a disallowed function call (#261, thanks @BackEndTea) - Process
ClassConstFetch
where$class
isName
only for enums to correctly support PHPStan 1.12.6 (#266)
Internal changes:
- Add phpstan/phpstan-deprecation-rules in expectation of PHPStan 2.0 (#263)
- Fix test class name (#260, spotted by @szepeviktor, thanks)
Default error identifiers
- Add default error identifiers, used if not specified/overridden in your custom config (#258)
PHPStan 1.11 added error identifiers and while they were supported by this extension for quite some time (since #97), they were not added by default, only when you've specified them.
This release adds error identifiers everywhere, and they'll be used if you don't specify custom identifiers in your custom config.
The full list of identifiers is in the ErrorIdentifiers
class here https://github.com/spaze/phpstan-disallowed-calls/blob/main/src/RuleErrors/ErrorIdentifiers.php and they have a disallowed.something
format.
Disallow control structures like else, elseif, goto and others
- Can disallow control structures like
else
,elseif
,goto
(#257)
Checking params inside ( ... )
doesn't work at the moment, so you can disallow all declare()
constructs but can't re-allow e.g. declare(strict-types = 1)
.
If you try to disallow else if
with the space, an exception will be thrown, because else if
is parsed as else
followed by if
, so disallowing else if
with the space wouldn't have the desired effect and the result would be unexpected. Disallow elseif
, or don't write else if
in your code 😇