1.7.0
This release closes 25 issues! 🥳
Major new features 🚀
- Fully static reflection! (#1265)
- PHPStan used runtime reflection before June 2020 (https://phpstan.org/blog/zero-config-analysis-with-static-reflection) and hybrid reflection after that
- Analysed code is no longer executed, except for files referenced in
bootstrapFiles
andfiles
sections in Composerautoload
configuration - This prevents various fatal errors during analysis
- Also solves edge cases like #7077, #7019
- Native reflection is always
BetterReflection
adapter (phpstan/phpstan-src@ef60339) - Global constants no longer have to be defined in
bootstrapFiles
(#1277, #1282), thanks @kukulich!
- Implement
@phpstan-consistent-constructor
and add a new rule as another way to supressnew static()
issues (#1296), thanks @canvural!- See the update article: https://phpstan.org/blog/solving-phpstan-error-unsafe-usage-of-new-static
- Offset/index access PHPDoc type (phpstan/phpdoc-parser#119, #1318), #7094, thanks @rvanvelzen!
Bleeding edge 🔪
- Unresolvable parameters (#1319), thanks @rvanvelzen!
- Support
@readonly
property and@immutable
class PHPDoc (#1295, #1335), #4082, thanks @herndlm!
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 🔧
- Allow setting error format in configuration file (#841), thanks @ruudk!
- Deprecated
PHPStan\Type\ConstantTypeHelper::getTypeFromValue()
. Instead of going from runtime value -> PHPStan type, usePHPStan\Reflection\InitializerExprTypeResolver::getType()
to go from Expr -> PHPStan type. In case you haveScope
available, useScope::getType()
. - Read default values from php-8-stubs and jetbrains/phpstorm-stubs (phpstan/phpstan-src@7ce177e)
- Normalize named arguments when calling extensions (#1301, #1313), #5866, thanks @staabm!
- implement str-case functions return type extension (#1325), thanks @staabm!
- ClearResultCacheCommand: allow
--debug
flag (phpstan/phpstan-src@5f5b96d)
Bugfixes 🐛
- Fix
get_class
on enum case (#1272), #7167, thanks @olsavmic! - Keep template types when using
::class
(#1271), #6864, #6986, thanks @olsavmic! - Fix supertype checks for conditional types (#1287), thanks @rvanvelzen!
- Fix using
value-of
/key-of
with template types (#1288), thanks @rvanvelzen! - Invalidate
openssl_error_string
after openssl function calls (#1292), #7106, thanks @pbourdet! - Fix initializer expr ConstFetch (phpstan/phpstan-src@761d116), #4950
- Fix various things around
isset()
andArrayDimFetch
(#1307), #6508, #7000, #7190, #7144, thanks @rajyan! - Fix call to
DatePeriod
constructor with named arguments (phpstan/phpstan-src@5945367), #7048, #5553 - Prevent redundant messages about missing iterable types in conditional target/subject (#1314), #7215, thanks @rvanvelzen!
- StubSourceLocatorFactory - read files from StubFilesExtension (phpstan/phpstan-src@0ecddcc)
- improve
is_subclass_of
type checks (#1321), #2755, thanks @staabm! - allow
$isOffsetAccessible->maybe()
for isUndefinedExpressionAllowed and isSpecified expression (#1312), #7229, thanks @rajyan! - Fix constant array comparison for optional keys (#1324), #7248, thanks @rvanvelzen!
- Simplify resolving constant scalar identical expressions (#1329), thanks @rvanvelzen!
- Use
ConstructorsHelper
inReadOnlyByPhpDocPropertyAssignRule
andReadOnlyPropertyAssignRule
(#1328), #6612, thanks @herndlm! - Class attributes should also be included in class statements (#1338), #7116, thanks @bartv2!
- Use trait properties in uninitialized props checks (#1340), #7219, thanks @herndlm!
- Improve
array_reverse
with constant arrays (#1337), #7278, thanks @herndlm!
Function signature fixes 🤖
- Replace
var_export()
extension with conditional-type stub (#1244), thanks @staabm! - Use conditional types for
is_a()
via stub (#1310) (#1310, #1311), #4371, thanks @staabm! - Narrow the type for the
mb_ereg_replace_callback()
callable. (#1316), thanks @johnbillion! - Add an array shape for the elements returned by
DateTimeZone::getTransitions()
. (#1315), thanks @johnbillion! - Fix incorrect argument for
RedisCluster::getOption()
andRedisCluster::setOption()
(#1334), thanks @taka-oyama!