Major new features 🚀
- Support for PHP 8.1 Enums - RFC
- Thanks to @kukulich for custom Enum rules!
- Upgraded Roave/BetterReflection to 5.0.0
- PHP 7.1+ is still supported because the dependency is downgraded automatically in our own fork
- This brings plenty of bugfixes, for example PHP 8.0 Attributes can now be read in static reflection context
- PHPStan now works when OPCache is enabled!
- Thanks to this commit: phpstan/phpstan-src@e30f446
- The development repository
phpstan/phpstan-src
is now PHP 8.0+ only, while the distribution packagephpstan/phpstan
still supports PHP 7.1+.- This is achieved thanks to automatic downgrade of source code using Rector during PHAR compilation
- PHPStan now ships with Symfony PHP polyfills for PHP 7.2-8.0.
Improvements 🔧
- Update
nikic/php-parser
to 4.13.2 (phpstan/phpstan-src@8939964) - Update to Symfony 5.4 (#863)
- CLI option
--allow-empty-baseline
to allow generating empty baseline (#776), thanks @Lctrs! - Support for
@phpstan-property
,@phpstan-property-read
, and@phpstan-property-write
(#775), thanks @mad-briller! - Add support for the
key-of<...>
andvalue-of<...>
types (#800), thanks @ste93cry! - GithubErrorFormatter > Allow any
ErrorFormatter
(#854), thanks @ruudk! - Array unpacking support for string-keyed arrays (#803), thanks @canvural!
- Moved some classes from ClassBlacklistReflectionProvider to staticReflectionClassNamePatterns config so that they are in effect for ClassBlacklistSourceLocator too (phpstan/phpstan-src@e40ba15)
- PHPStanTestCase: Added a helper method to assert no errors happend (#894), thanks @staabm!
Bugfixes 🐛
- Resolve deprecated tag also from parents (#792), thanks @eiriksm!
echo
isn't callable either. (#777), thanks @johnbillion!- Resolve object type by class const fetch in switch statement (#745), thanks @marmichalski!
- Allow also
$object::class
with Identical (#745), thanks @marmichalski! - Fixed ErrorFormatter tests in terminals with console support (#805), thanks @kukulich!
- Copy all environment variables when running PHPStan Pro (phpstan/phpstan-src@e61ad95), #5433
- Allow destructuring of objects implementing ArrayAccess (#819), thanks @herndlm!
- Spreading of general arrays should not lead to a non-empty-array (#818), thanks @herndlm!
- Simplify FileTypeMapper (phpstan/phpstan-src@256d11b)
- Make FileTypeMapper more deterministic (phpstan/phpstan-src@ae6dca5)
- Fix normal vs. stub PHPDoc (phpstan/phpstan-src@e9dd3a3)
- ReflectionAttribute is no longer final class (phpstan/phpstan-src@97e153c)
- ReflectionAttribute stub - IS_INSTANCEOF constant (phpstan/phpstan-src@cfb6fad)
- DependencyResolver - cause autoloading less often when looking at literal arrays (phpstan/phpstan-src@b927c87), #6187, #6096
- MemoizingReflectionProvider - cache
hasClass()
as case-sensitive (phpstan/phpstan-src@792ce0a), #6096 - XdebugHandler - setPersistent (#726), #5809, thanks @fsmoak!
- Simplify AutoloadSourceLocator - let it actually autoload the file (phpstan/phpstan-src@e30f446)
- AutoloadSourceLocator - filter classes by startLine only if there are multiple of them (#882)
- ComposerJsonAndInstalledJsonSourceLocatorMaker - fix for autoload-dev section (#882)
- TestCaseSourceLocatorFactory - skip invalid Composer locations (#882)
- Fix ReturnTypeRule (#882)
- Silent
@
operator should use& $errno
check (#889), thanks @samsonasik! - ClassTemplateTypeRule should not be executed for interfaces (phpstan/phpstan-src@9adf6bf)
- MixinRule - check interfaces and enums (phpstan/phpstan-src@8519cca)
Function signature fixes 🤖
- Added DynamicReturnTypeExtension for
trigger_error
(#766), thanks @staabm! - The array returned by
array_count_values()
can never contain a zero. (#773), thanks @johnbillion! - Add ThrowableReturnTypeExtension (#795), thanks @herndlm!
- Update functionMap for XSLTProcessor (#797), thanks @hbrecht!
- imap_delete / imap_undelete: correction (#799), thanks @hbrecht!
- Fix the signature of the value returned from the
date_parse
anddate_parse_from_format
functions (#807), thanks @ste93cry! - Fix the signature of
get_resources()
(#837), thanks @MidnightDesign! - Fix preg_filter function signature (#826), thanks @johnstevenson!
- Fix ldap_set_rebind_proc signature (#851), thanks @villfa!
restore_error_handler
andrestore_exception_handler
always return booleantrue
. (#850), thanks @johnbillion!- More specific return types for some
DateTimeZone
methods (#857), thanks @johnbillion! - Add missing
Set::map()
method toext-ds
stub (#855), thanks @simPod! - Support variable constant flags in
preg_split
(phpstan/phpstan-src@a16c7ae), thanks @clxmstaab!