Learn more about this release in an article on phpstan.org!
Major new features 🚀
- Generic
@method
tags:@method T doFoo<T>(T $p)
, #6371- Learn more
- #2931, #2935, thanks @mad-briller!
- Generic callable types:
callable<T>(T): T
, #8964- #2938, #2945, #2946, thanks @mad-briller!
- Error on references of prefixed internal class names from PHAR files (#2932), thanks @staabm!
Bleeding edge 🔪
- Enhancements in Handling Parameters Passed by Reference
- Learn more on phpstan.org
- #2941, thanks @ljmaskey!
- Add option
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
Improvements 🔧
- Add support for constructor assertions (#2950), #10645, thanks @axlon!
- Report uses of deprecated constants (#2953), thanks @staabm!
Bugfixes 🐛
- Fix how union of callables is understood (#2902), #10442, thanks @mad-briller!
- Fix for inferring closure parameter type from callable union (phpstan/phpstan-src@c10476d)
- ArrayType - string offset might exist as integer offset (#2928), #10610, thanks @michalbundyra!
- Truncate description of huge UnionType (phpstan/phpstan-src@039a3dc), #10614
- fix type of
$a?->b::c()
and$a?->b::$c
(#2933), thanks @schlndh! - fix
fn() => __FUNCTION__
and__METHOD__
(#2934), thanks @schlndh! - Some sort functions do not preserve a list (phpstan/phpstan-src@034f731, phpstan/phpstan-src@0977a7b), #10627
- ArgumentsNormalizer - keep named arguments for unknown parameters (phpstan/phpstan-src@ad34452), #10628
- Check
T of mixed&Foo
andT of mixed|Foo
(#2940), thanks @schlndh! - Use narrowed conditional type if/else types for subtype checks (#2948), #10622, thanks @rvanvelzen!
- Fix
isSuperTypeOf
of callable/Closure when parameter count differ (#2949), #10594, thanks @takaram!
Function signature fixes 🤖
- Fix
ReflectionFunctionAbstract::getExtension
return type (phpstan/phpstan-src@2ece1f8) - Correct return type of
date_sun_info()
function (#2947), thanks @zonuexe! - Fix return values of
mysqli get_warnings
(#2929), thanks @janedbal!