Releases: phpstan/phpstan
1.11.2
Improvements 🔧
- Stricter
@phpstan-ignore
identifiers parser (#3079, #3090, #3091), thanks @janedbal!- The parser now rejects some syntax that was possible but undocumented in 1.11.0 and 1.11.1
- The parser now allows to attach comment to each single identifier in a list:
@phpstan-ignore identifier (comment), identifier2 (comment2)
- Resolving type of closure - get
$passedToType
frominFunctionCallsStack
(phpstan/phpstan-src@ca41b7d, phpstan/phpstan-src@da4fd7a), #5508, #10254, #10732 - Do not lose generic type when the closure has native return type (phpstan/phpstan-src@7e9cd45), #9086
Function signature fixes 🤖
Internals 🔍
- Fix Composer by referencing deleted tag of
nette/di
(phpstan/phpstan-src@2ab647e) - Specify
array_filter
callbacks (phpstan/phpstan-src@754b7b8) - Add
@api
annotation toAcceptsResult::__construct
(#3092), thanks @canvural!
1.11.1
Improvements 🔧
Bugfixes 🐛
- Do not complain about
impure(Function|Method).pure
if it has@phpstan-assert
tags (phpstan/phpstan-src@9544f8a) - Remove tip about deprecated config option (phpstan/phpstan-src@d603c7b), #11000
- Fix false positive with
reportPossiblyNonexistentConstantArrayOffset: true
(phpstan/phpstan-src@5277630), #10997 - Fix parent keyword case sensitivity (#3064), thanks @staabm!
- InlineHTML is an impure point (#3072), thanks @staabm!
- UnionTypeHelper - prevent infinite recursion (phpstan/phpstan-src@bb3da26), #11027
- Fix more potential for infinite recursion (phpstan/phpstan-src@1d02c4f)
- RangeFunctionReturnTypeExtension - fix internal ValueError (phpstan/phpstan-src@fe3895a), #11026
- Property unset is an impure point (phpstan/phpstan-src@702ddcd), #11001
- Fix property assign not being an impure point in arrow function (phpstan/phpstan-src@35ff689), #11001
- Fix internal error when accessing enum case by class-string (phpstan/phpstan-src@1116e03), #10985
- Fix resolving
self
andstatic
in@phpstan-closure-this
from trait stub file (phpstan/phpstan-src@9340249), #11009 - CallToMethodStatementWithoutImpurePointsRule - fix for methods called on unions (phpstan/phpstan-src@ee33f1e), #11011
Function signature fixes 🤖
- Offset
uri
instream_get_meta_data
calls is always present on PHP 8.3+ (phpstan/phpstan-src@885d46b), #11024, #10999
1.11.0
Read the article about PHPStan 1.11 on phpstan.org »
Major new features 🚀
- Error identifiers
- A way to categorize reported errors by a stable identifier. Up until now you had to use specific and ever-changing error messages
- Can be used for ignoring specific errors locally with new
@phpstan-ignore
comment (uses current or next line automatically) - Can be used for ignoring specific errors in
ignoreErrors
section of your configuration file (phpstan.neon) - Can be used in output formatters
- Can be seen in PHPStan Pro GUI or in TableErrorFormatter with
-v
- Catalogue with source code links: https://phpstan.org/error-identifiers
- PHPStan Pro Reboot
- A new migration wizard will effortlessly migrate all your
@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. - Revamped UI for much more comfortable viewing and browsing of reported errors
- The new UI also lets you browse ignored errors, from
ignoreErrors
, from your baseline and also ignored locally in source code using comments - Streaming errors during launch: You don't have to wait for the analysis to complete, you can see errors as they come in during the analysis
- Support for mapping file paths to the host filesystem when running in Docker or remotely
- Try it out by running PHPStan with
--pro
CLI option
- A new migration wizard will effortlessly migrate all your
- PHPDoc tags describing callable lifecycle:
@param-immediately-invoked-callable
,@param-later-invoked-callable
- Useful for exception analysis (https://phpstan.org/blog/bring-your-exceptions-under-control) and
@phpstan-pure
- Useful for exception analysis (https://phpstan.org/blog/bring-your-exceptions-under-control) and
- PHPDoc tag
@param-closure-this
to describe what$this
is bound to in a passed closure - Two new config options around stricter offset checks in arrays (#3028), #7553, thanks @ttomdewit!
reportPossiblyNonexistentGeneralArrayOffset
reportPossiblyNonexistentConstantArrayOffset
- Learn more in the documentation
Bleeding edge 🔪
- Checking truthiness of
@phpstan-pure
above functions and methods - Check
new
/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 - BetterNoopRule - take advantage of impure points (phpstan/phpstan-src@a647052), #10389
- Run missing type check on
@param-out
(phpstan/phpstan-src@56b2002) - CallToConstructorStatementWithoutSideEffectsRule - report class with no constructor (phpstan/phpstan-src@b116d25)
- Deprecated: returning plain strings as errors, use RuleErrorBuilder
- Deprecated: returning RuleError without identifier (phpstan/phpstan-src@969e6fa)
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
Improvements 🔧
- Generic RuleErrorBuilder (phpstan/phpstan-src@9a3ed85)
- Deprecate
checkMissingIterableValueType: false
andcheckGenericClassInNonGenericObjectType: false
in favour of ignoring via identifiers (phpstan/phpstan-src@a649981) - Deprecate old NoopRule - replaced by BetterNoopRule in bleeding edge (phpstan/phpstan-src@1090835)
- Allow ignoring errors from CollectedDataNode with local comments (phpstan/phpstan-src@dc3b75a)
- Introduce
new
type (#3050), #9704, thanks @ruudk! - RuleTestCase - fail on PHP warnings, notices etc. (#3030), thanks @janedbal!
- Check duplicate assignment of redeclared promoted readonly properties (#3049), #8101, #9863, #9864, thanks @schlndh!
- Remove line from "nikic/php-parser" error message (#2845), thanks @mvorisek!
- Stub validator - PHPStan classes are known without extra stubs (phpstan/phpstan-src@d004c23)
- Stub validator - PhpParser classes are known without extra stubs (phpstan/phpstan-src@3e498e1)
- CheckstyleErrorFormatter - include error identifier in source attribute (phpstan/phpstan-src@f66cf5b), #1205
- BaselinePhpErrorFormatter - error identifiers in comments (phpstan/phpstan-src@4b32cac)
RuleErrorBuilder::file()
- file path needs to exist (phpstan/phpstan-src@c453f29)- AbstractMethodInNonAbstractClassRule - better error message for enums (phpstan/phpstan-src@b5dd34e)
- Fixed Xdebug spelling (#2746), thanks @derickr!
- Track invalidated
$this
and used variables after invoking closure (#2980) - Support
@phan-
prefixes on recognized PHPDoc tags (#3000), thanks @anomiex! pure-callable
andpure-Closure
PHPDoc types (phpstan/phpstan-src@cdaff5f)highlight_string()
flips side-effects depending on $return (#3021), thanks @staabm!- Improve types for predefined constants (#3054), thanks @zonuexe!
Bugfixes 🐛
- Make
AccessoryNonFalsyStringType::toInteger()
returnIntegerType
instead of non-zero (#3018), #10893, thanks @zonuexe! - Filter scope by non-empty array after foreach regardless of
polluteScopeWithAlwaysIterableForeach
(#3029), #10922, thanks @VincentLanglet! - Preserve large arrays with same keys through union (#3032), #9397, #10080, thanks @schlndh!
- Fix
count($x) > $n === true
negation (#3037), #10952, thanks @rvanvelzen! - Fix NAN not accepting NAN (#3036), #10956, #10297, thanks @rvanvelzen!
- DateTimeInstantiationRule - fix error message for
new
with wrong name case (phpstan/phpstan-src@59ac31a) - Process ConstFetch (phpstan/phpstan-src@b5c63c2)
- Fix
preg_match_all
behaviour with no flags (phpstan/phpstan-src@a856ec7) file_get_contents
is an impure function (phpstan/phpstan-src@2b5b317)- Fix
ClosureType::equals()
(phpstan/phpstan-src@29c35b5) - Use statement result of analysed anonymous class to inform about throw points and impure points (phpstan/phpstan-src@70a75f6)
- Filter out implicit throw points from callables when
exceptions.implicitThrows: false
(#3016), thanks @janedbal! - Fix
ConstantArrayType::hasOffsetValueType()
for offset union type where all types are valid (phpstan/phpstan-src@26e949b) non-empty-list
always has offset 0 (phpstan/phpstan-src@f4d1d48)- Narrow to
non-empty-string
/non-falsey-string
aftermb_strlen()
(#3038), thanks @staabm! - Implement
Type::isOffsetAccessLegal()
to detect offset access that crashes even inisset()
(#3045), #8393, #10926, thanks @rajyan! - Specify types on
match()
condition correctly ([#3053](https://github.com/phpstan/phpstan-src/pul...
1.10.67
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.
Improvements 🔧
- Forbid PHPUnitPHAR prefixed classes (#3002), thanks @staabm!
- Improve error messages on unnamed parameters (#3010), #10814, thanks @takaram!
Bugfixes 🐛
- Improve
date()
return types (#2888), #10468, #6613, thanks @zonuexe! - Default value null does not make promoted property type nullable (phpstan/phpstan-src@b2177e3), #9839
- Fix socket_select array types after call (phpstan/phpstan-src@24c5249), #10285
- Fix conditional types in PHPDocs from stubs for native functions (phpstan/phpstan-src@8ae0b28)
- Fix env int key problem (phpstan/phpstan-src@e606fbe), #10833
- Fix false positives about uninitialized properties (#2897), #10523, #10822, thanks @staabm!
- Incremented numeric-string should change to int/float (#2797), #10122, #10187, thanks @staabm!
- Do not generalize big array when combined with empty array (#3003), #10834, thanks @RobertMe!
- Fix string concatenation with benevolent union type (phpstan/phpstan-src@4a4c739), #10863
- Treat
get_defined_vars()
as using constructor arguments (#3012), #10865, thanks @rvanvelzen! - Allow undefined variables passed into by-ref parameters only if the type is nullable (phpstan/phpstan-src@7f8f9cc, phpstan/phpstan-src@7961f7a), #1916
Function signature fixes 🤖
- More precise
gc_status()
signature for PHP8.3+ (#2996), thanks @staabm! - Add object shape for
mysqli_result::fetch_fields
(#3005), thanks @schlndh!
Internals 🔍
1.10.66
Improvements 🔧
- Detect mismatch between readonly/non-readonly class parent (phpstan/phpstan-src@986cbdf), #10789
- TypeInferenceTestCase - fix for performance problem with PHPUnit 11 (phpstan/phpstan-src@da87a65), #10757
Bugfixes 🐛
array_push
preserves list (phpstan/phpstan-src@5473b67)
Function signature fixes 🤖
- Fix
redis::get
signature (#2990), thanks @VincentLanglet!
Internals 🔍
1.10.65
Improvements 🔧
Bugfixes 🐛
- Update BetterReflection (#2988)
- Fix ReflectionSourceStubber compatibility before PHP 8.1 (ondrejmirtes/BetterReflection@94ca133), larastan/larastan#1882
- Fix trait method visibility (ondrejmirtes/BetterReflection@d6153d5?w=1)
Function signature fixes 🤖
Internals 🔍
1.10.64
Bleeding edge 🔪
- Fail build when project config uses custom extensions outside of analysed paths
- This will only occur after a run that uses already present and valid result cache
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
Improvements 🔧
- Introduce
ForbiddenClassNameExtension
for append additional forbidden class prefixes (#2979), thanks @kamil-zacek! - Add
AlwaysUsedMethodExtension
(#2927), thanks @axlon! - Warn about possibly stale result cache with custom extensions (phpstan/phpstan-src@9338fdf)
- This is how it looks: https://twitter.com/OndrejMirtes/status/1770024563113390437
Bugfixes 🐛
Function signature fixes 🤖
- Fix
DOMDocument::load
return type (#2975), thanks @VincentLanglet! - Fix
SplObjectStorage::removeAll/Except
(#2892), thanks @schlndh!
1.10.63
Improvements 🔧
- Resolve PHPStan issue with deprecated parameter order in PHP 8.1 and 8.3 (#2963), thanks @sayuprc!
- Update nikic/php-parser (phpstan/phpstan-src@7ceeb21, phpstan/phpstan-src@063f6a8)
- Solve duplicates in UnionType description (#2973), thanks @VincentLanglet!
Bugfixes 🐛
- Revert "Update nette/di" (phpstan/phpstan-src@969ff31), #10727
- Fix password_hash algo constant passing on PHP <7.4 (phpstan/phpstan-src@fc4e589), #9246
- ArrayType - use
getIterableKeyType()
, it preserves array-key (phpstan/phpstan-src@d5bf23b), #9307
Function signature fixes 🤖
- Add false return type to
exec()
(#2974), thanks @VincentLanglet!
Internals 🔍
1.10.62
Improvements 🔧
- Too wide return type - report for conditional return types (phpstan/phpstan-src@de1c07e)
Bugfixes 🐛
- Constants deprecation depends on PHP version in comment (#2967), #10700, thanks @staabm!
- Make
@param-out
work even if it is the only conditional type in a function signature (phpstan/phpstan-src@787c1e2) - ParameterOutAssignedTypeRule - fix for conditional types (phpstan/phpstan-src@19497ba)
- ParameterOutExecutionEndTypeRule - fix for conditional types (phpstan/phpstan-src@27c73f7)
- Too wide
@param-out
- fix for conditional types (phpstan/phpstan-src@5a47893)
1.10.61
Improvements 🔧
- Update BetterReflection to 6.25.0
- Implement PHP Version dependent deprecations for constants (Roave/BetterReflection#1396), thanks @staabm!
- Support for
final
modifier in traits (Roave/BetterReflection#1383), thanks @kukulich!
- Support for conditional types in
@param-out
(phpstan/phpstan-src@effad95), #10699 - Check conditional types in
@param-out
(phpstan/phpstan-src@67f9420)
Bugfixes 🐛
- Too wide
@param-out
type - consider all execution ends at once (phpstan/phpstan-src@d1bcf78), #10687, #10684
Internals 🔍
- MethodReturnStatementsNode - use ExtendedMethodReflection (phpstan/phpstan-src@3cc1a54)