PHP Static Analysis Tool - discover bugs in your code without running it!
Read the article about PHPStan 1.11 on phpstan.org ยป
@phpstan-ignore
comment (uses current or next line automatically)ignoreErrors
section of your configuration file (phpstan.neon)-v
@phpstan-ignore-line
and @phpstan-ignore-next-line
to the new @phpstan-ignore
comment style with error identifiers. The old comment style is dangerous because it ignores all errors, current and future, on that line.ignoreErrors
, from your baseline and also ignored locally in source code using comments--pro
CLI option@param-immediately-invoked-callable
, @param-later-invoked-callable
@phpstan-pure
@param-closure-this
to describe what $this
is bound to in a passed closurereportPossiblyNonexistentGeneralArrayOffset
reportPossiblyNonexistentConstantArrayOffset
@phpstan-pure
above functions and methodsnew
/function call/method call/static method call on a separate line without any side effects even without @phpstan-pure
PHPDoc tag on the declaration side
@param-out
(https://github.com/phpstan/phpstan-src/commit/56b20024386d983927c64dfa895ff026bed2798c)If you want to see the shape of things to come and adopt bleeding edge features early, you can include this config file in your project's phpstan.neon
:
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
Of course, there are no backwards compatibility guarantees when you include this file. The behaviour and reported errors can change in minor versions with this file included. Learn more
checkMissingIterableValueType: false
and checkGenericClassInNonGenericObjectType: false
in favour of ignoring via identifiers (https://github.com/phpstan/phpstan-src/commit/a64998108b318581b0203e84582711c3e4d1e43c)new
type (#3050), #9704, thanks @ruudk!RuleErrorBuilder::file()
- file path needs to exist (https://github.com/phpstan/phpstan-src/commit/c453f29f60992167a5aa46d4926c18a420ae7b26)$this
and used variables after invoking closure (#2980)@phan-
prefixes on recognized PHPDoc tags (#3000), thanks @anomiex!pure-callable
and pure-Closure
PHPDoc types (https://github.com/phpstan/phpstan-src/commit/cdaff5f00d621c3a94e048b8bd9fa864d47b3228)highlight_string()
flips side-effects depending on $return (#3021), thanks @staabm!AccessoryNonFalsyStringType::toInteger()
return IntegerType
instead of non-zero (#3018), #10893, thanks @zonuexe!polluteScopeWithAlwaysIterableForeach
(#3029), #10922, thanks @VincentLanglet!count($x) > $n === true
negation (#3037), #10952, thanks @rvanvelzen!new
with wrong name case (https://github.com/phpstan/phpstan-src/commit/59ac31a554203a7ae3fb9449bbd5b61f3afe2e20)preg_match_all
behaviour with no flags (https://github.com/phpstan/phpstan-src/commit/a856ec7ab5540cb4a8d30e9e170958a32a7165b2)file_get_contents
is an impure function (https://github.com/phpstan/phpstan-src/commit/2b5b3174c7f00e56b7692b4c26552b2ad13c73d5)ClosureType::equals()
(https://github.com/phpstan/phpstan-src/commit/29c35b584a948e9a3c90e2d56312069ce073e6e6)exceptions.implicitThrows: false
(#3016), thanks @janedbal!ConstantArrayType::hasOffsetValueType()
for offset union type where all types are valid (https://github.com/phpstan/phpstan-src/commit/26e949b0d093751c98e9a106f680092abf3b28d9)non-empty-list
always has offset 0 (https://github.com/phpstan/phpstan-src/commit/f4d1d481472b45c56ba2cd49ae98065092217f36)non-empty-string
/non-falsey-string
after mb_strlen()
(#3038), thanks @staabm!Type::isOffsetAccessLegal()
to detect offset access that crashes even in isset()
(#3045), #8393, #10926, thanks @rajyan!match()
condition correctly (#3053), #10974, #9694, thanks @rvanvelzen!json_decode
with force array flag: subtract all objects, not just stdClass (#3052), thanks @rajyan!strlen($x) > $n === true
negation (#3040), thanks @staabm!Continue_
points should not be used for while (true)
(#3057), #10980, thanks @greew!stream_get_meta_data()
optional (#3024), #10887, thanks @hirokinoue!Closure::bind
$newScope
param (#2817), thanks @mvorisek!Imagick::identifyImage()
return type (#3017), thanks @SVillette!ClassReflection::getClassTypeDescription()
(https://github.com/phpstan/phpstan-src/commit/dec9e435a7e0cea96079eb08c799df6b49b92e82)RuleErrorBuilder::treatPhpDocTypesAsCertainTip()
for a bit more DRYness (#3035), thanks @axlon!This is the last release, or one of the last releases, in 1.10.x series. The next one is going to be PHPStan 1.11, and it's going to be released at some point in May 2024.
date()
return types (#2888), #10468, #6613, thanks @zonuexe!get_defined_vars()
as using constructor arguments (#3012), #10865, thanks @rvanvelzen!gc_status()
signature for PHP8.3+ (#2996), thanks @staabm!mysqli_result::fetch_fields
(#3005), thanks @schlndh!array_push
preserves list (https://github.com/phpstan/phpstan-src/commit/5473b6701c1a9dd3ca1eb676b3b2c0dec43f2535)redis::get
signature (#2990), thanks @VincentLanglet!TrinaryLogic::describe()
in test (https://github.com/phpstan/phpstan-src/commit/222a66cdbf67f2ae367b251ed56acda53a3d8286)If you want to see the shape of things to come and adopt bleeding edge features early, you can include this config file in your project's phpstan.neon
:
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
Of course, there are no backwards compatibility guarantees when you include this file. The behaviour and reported errors can change in minor versions with this file included. Learn more
ForbiddenClassNameExtension
for append additional forbidden class prefixes (#2979), thanks @kamil-zacek!AlwaysUsedMethodExtension
(#2927), thanks @axlon!getIterableKeyType()
, it preserves array-key (https://github.com/phpstan/phpstan-src/commit/d5bf23b18f0c7484771c0298a6cd5359345eab94), #9307exec()
(#2974), thanks @VincentLanglet!@param-out
work even if it is the only conditional type in a function signature (https://github.com/phpstan/phpstan-src/commit/787c1e2b46a40ccac9bb254fd45204a310f6ff2f)@param-out
- fix for conditional types (https://github.com/phpstan/phpstan-src/commit/5a4789339e5768628bf9bb2abdf38eff135553cd)final
modifier in traits (https://github.com/Roave/BetterReflection/pull/1383), thanks @kukulich!@param-out
(https://github.com/phpstan/phpstan-src/commit/effad95da555c2b6c7b305178a221e84c831df61), #10699@param-out
(https://github.com/phpstan/phpstan-src/commit/67f9420cba9fa45501cdca87770d50c5c22bd508)@param-out
type - consider all execution ends at once (https://github.com/phpstan/phpstan-src/commit/d1bcf786eedbce9fee74f43f080678fa7788e4e3), #10687, #10684Learn more about this release in an article on phpstan.org!
@method
tags: @method T doFoo<T>(T $p)
, #6371
callable<T>(T): T
, #8964
reportAnyTypeWideningInVarTag
(#2840), thanks @janedbal!If you want to see the shape of things to come and adopt bleeding edge features early, you can include this config file in your project's phpstan.neon
:
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
Of course, there are no backwards compatibility guarantees when you include this file. The behaviour and reported errors can change in minor versions with this file included. Learn more
$a?->b::c()
and $a?->b::$c
(#2933), thanks @schlndh!fn() => __FUNCTION__
and __METHOD__
(#2934), thanks @schlndh!T of mixed&Foo
and T of mixed|Foo
(#2940), thanks @schlndh!isSuperTypeOf
of callable/Closure when parameter count differ (#2949), #10594, thanks @takaram!ReflectionFunctionAbstract::getExtension
return type (https://github.com/phpstan/phpstan-src/commit/2ece1f82b0e95541908f052d74a1cb29f2a4b4b7)date_sun_info()
function (#2947), thanks @zonuexe!mysqli get_warnings
(#2929), thanks @janedbal!array_values
rule (report when a list
type is always passed in) (#2917), thanks @kamil-zacek!If you want to see the shape of things to come and adopt bleeding edge features early, you can include this config file in your project's phpstan.neon
:
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
Of course, there are no backwards compatibility guarantees when you include this file. The behaviour and reported errors can change in minor versions with this file included. Learn more
treatPhpDocTypesAsCertain
(https://github.com/phpstan/phpstan-src/commit/f5b198c9801282d7002f5310d5ff5318eec54465)settype()
(#2920), thanks @ChrisBrenton!FunctionReflection::isPure()
and ExtendedMethodReflection::isPure()
(https://github.com/phpstan/phpstan-src/commit/03d01eae4a59592f7388bc46b14e5db8eff57df8)