Releases: phpstan/phpstan
1.10.21
Bugfixes 🐛
- Fix defining variables in match condition (phpstan/phpstan-src@d6c2752), #9474
- Fix UnusedClosureUsesRule for already traversed match (phpstan/phpstan-src@a719486), phpstan/phpstan-phpunit#190, #9478
- Update BetterReflection (phpstan/phpstan-src@a540e44), #9477
- Fix newInstance on ReflectionAttribute adapter with enum argument (ondrejmirtes/BetterReflection@277b960)
Internals 🔍
- Cheap checks first in ObjectType (#2475), thanks @mad-briller!
1.10.20
Improvements 🔧
- PHPStan Pro: Change Cloudflare DNS for to family version (#2467), thanks @spaze!
- Add
non-zero-int
type (#2449), thanks @PrinsFrank! - Implement
gettype()
return type extension (#2437), thanks @staabm!
Bugfixes 🐛
- Allow to remember constant and impure expressions in
match
condition (phpstan/phpstan-src@0cdda0b), #4451, #6064, #9457 - Fix
gettype
inmatch
condition (phpstan/phpstan-src@e4ef00c, phpstan/phpstan-src@caa0a5b), #8614 - Fix
get_class
inmatch
condition (phpstan/phpstan-src@106526d), #1885, #8536, #8092 - Understand
get_class
compared withstatic::class
(phpstan/phpstan-src@590eb03), #1885 - Understand
gettype
when there's a union of strings on the other side (phpstan/phpstan-src@36e412f), #6294, #2580 - Treat ConstantArrayType as covariant in its keys and values (#2464), #9161, thanks @jiripudil!
- Treat ArrayType as covariant in its keys and values (#2465), thanks @jiripudil!
- Make
NonEmptyArrayType::toArray()
return$this
(#2349), #9208, thanks @zonuexe! - Retain list type via
array_push()
andarray_unshift()
(#2451), #8449, thanks @herndlm! - For
@var
above throw and return, change the type of expr only for the stmt callback (phpstan/phpstan-src@b551095), #9459
Internals 🔍
- Remove redundant conditions from RemoveUnusedCodeByPhpVersionIdVisitor. (#2459), thanks @mad-briller!
- Return early in CachingVistor to avoid always-false instanceof checks. (#2460), thanks @mad-briller!
- Introduce CombinationsHelper (phpstan/phpstan-src@175307e)
Type::getFiniteTypes()
(phpstan/phpstan-src@7912caf, phpstan/phpstan-src@fa9a951, phpstan/phpstan-src@b5cf52b)
1.10.19
Bleeding edge 🔪
- Analysis with zero files results in non-zero exit code (phpstan/phpstan-src@46ff440), #9410
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 🔧
- Detect invalid key in multi dimensional array fetch (#2445), #6315, thanks @schlndh!
- Support unions of scalars in
sprintf()
arguments (phpstan/phpstan-src@1f95570) - Update nikic/php-parser (phpstan/phpstan-src@51a284b)
- Update BetterReflection (phpstan/phpstan-src@ff8ad7e)
Bugfixes 🐛
- UnusedPrivatePropertyRule - recognize static properties fetched on expr (phpstan/phpstan-src@503978b), #9409, #8541
- Union of enum cases accepts the enum class type with negated cases (#2418), #8846, thanks @takaram!
- Fix key type of superglobal variables (#2446), #9306, thanks @schlndh!
- Do not treat definition of functions and class-likes as unreachable (#2263), #4002, #8966, #8319, thanks @takaram!
Function signature fixes 🤖
Internals 🔍
- StringAlwaysAcceptingObjectWithToStringType is supertype of Stringable objects (phpstan/phpstan-src@9de9efa)
1.10.18
Implicit throw point is enough to no longer mark multi-catch as dead (phpstan/phpstan-src@c587dd1), #9406
1.10.17
Improvements 🔧
- StubValidator - add missing rules about type aliases (phpstan/phpstan-src@8bb4537)
Bugfixes 🐛
- Fix more
in_array
issues (#2432), #6959, thanks @schlndh! - Fix overriding
__debugInfo
with covariant return type (#2435), #9391, thanks @staabm! - Improve
Map::remove()
@throws
inference (#2434), #9066, thanks @baci266! array_is_list
narrows the type even when not on Bleeding Edge (phpstan/phpstan-src@de2566a), #9381- AutoloadSourceLocator - do not execute autoloader if the class already exists but is evaled (phpstan/phpstan-src@32b889d), #7960
- EnumSanityRule - use scope inside enum (phpstan/phpstan-src@04af510), #9402
- Fix native type of array after
array_push()
(phpstan/phpstan-src@564f79f), #9403 - Refactor pieces looking for dead code for more precise detection of properties, methods, constants (phpstan/phpstan-src@d09401d, phpstan/phpstan-src@ffc0495), #8412, #8958, #8563, thanks @takaram!
- Fix param-type specification interfering with root-expression types (#2439), #9404, thanks @staabm!
Function signature fixes 🤖
- More precise
getimagesize*
return type (#2438), thanks @staabm! - base64_decode returns false only in strict mode (#2419), thanks @kamil-tekiela!
Internals 🔍
- Minor refinements to MutatingScope
empty()
and typehint helper (#2430), thanks @mad-briller!
1.10.16
Bleeding edge 🔪
- Report dead types even in multi-exception catch (#2399), thanks @JanTvrdik!
error_log
errors withmessage_type=2
(#2428), #9380, thanks @staabm!
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 🔧
CallableType
andClosureType::describe()
- use phpdoc-parser Printer for better precision (phpstan/phpstan-src@30f60c1), #9268OffsetAccessType::describe()
uses toPhpDocNode and phpdoc-parser printer (phpstan/phpstan-src@347fdbf)- Smarter
extract()
with constant arrays (#2417), #9331, thanks @MartinMystikJonas! - Detect more issues in enum declarations (#2371), #9184, thanks @kubk!
- Correct magic signature methods when typehints are missing (#2409), thanks @staabm!
Bugfixes 🐛
- Fix
SplDoublyLinkedList::offsetGet
return type (#2373), #9274, thanks @takaram! - Delegate
get_called_class()
tostatic::class
(phpstan/phpstan-src@188acf4), #7574, #5252, #4061 - Fix enum type subtracting (#2415), thanks @schlndh!
- Fix loose comparison against enum (#2410), thanks @schlndh!
Internals 🔍
- NodeScopeResolver: refactor matching throw points computation (#2399), thanks @JanTvrdik!
- ConstantArrayType -
toPhpDocNode
without keys if they are not necessary (phpstan/phpstan-src@413079d) - Test
@var
in and out of function (phpstan/phpstan-src@4e19347), #9331
1.10.15
Bleeding edge 🔪
- InvalidPhpDocTagValueRule: include PHPDoc line number in the error message (phpstan/phpstan-src@a04e0be)
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 🔧
- Update phpdoc-parser to 1.20.4
- Changelog
- Notable changes:
- CallableTypeNode - support object shape in return type
- CallableTypeNode - support
$this
in return type - CallableTypeNode - support ConstTypeNode in return type
- Implement IniGetReturnTypeExtension (#2362), #3063, thanks @staabm!
- PHPStan\Node\ClassMethod is covered by BC promise (phpstan/phpstan-src@1036d19), #9249
- Enforce magic
__serialize()
and__unserialize()
return types (#2372), thanks @staabm! - Report
?->
call on always-null (phpstan/phpstan-src@74d1c9a), #9284
Bugfixes 🐛
- Fix object shapes with interfaces and final classes (phpstan/phpstan-src@f199980)
- Fix
ConstantFloatType::toPhpDocNode()
for whole numbers ending with 0 (#2355), thanks @rvanvelzen! - Add type for ini_get() 'default_socket_timeout' and 'precision' (#2365), thanks @staabm!
- Fix Docker detection (phpstan/phpstan-src@8d0c032)
- strval accepts Stringable (phpstan/phpstan-src@3a4cd59), #9283
CURLOPT_HTTPHEADER
should not accept a dictionary (#2369), #9263, thanks @staabm!
Function signature fixes 🤖
intval()
andfloatval()
should handle non-scalar values (#2351), thanks @dravnic!- More precise
strval()
family function signatures (#2354), thanks @dravnic!
Internals 🔍
- Allow referencing StringAlwaysAcceptingObjectWithToStringType in functionMap (phpstan/phpstan-src@670d04d)
1.10.14
Bleeding edge 🔪
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 🔧
- Update phpdoc-parser
- Add extension to add additional constructors through code (#2348), thanks @raalderink!
Bugfixes 🐛
- Fix
BackedEnum::tryFrom
not being nullable (#2302), thanks @schlndh! - Specify
never
forarray_combine
with different number of elements (#2303), thanks @herndlm! - ConstantFloatType - fix
equals()
(phpstan/phpstan-src@e01ce68) - Fix INF logic (phpstan/phpstan-src@fc673ee)
- Prevent false-positive in
get_parent_class()
on interfaces (#2336), #4302, thanks @staabm!
Function signature fixes 🤖
Internals 🔍
Type::toPhpDocNode()
(phpstan/phpstan-src@8633125)- Remove
symfony/polyfill-php72
(phpstan/phpstan-src@8ff8fb0)
1.10.13
1.10.12
Major new features 🚀
- Object shapes, #2923
- Documentation
- Twitter thread about implementing it
- phpdoc-parser implementation
Bleeding edge 🔪
- Stricter function signature map (phpstan/phpstan-src@06b746d, #2163), #7239, thanks @staabm!
- Specify
Imagick
parameter types (#2334), thanks @zonuexe!
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 🔧
- Improve
filter_*
array handling, supportFILTER_REQUIRE_ARRAY
(#2318), thanks @herndlm! - Asymmetric
@property
types (#2327, #2328, #2329), #9062, thanks @jtojnar! - Specify return type for
filter_input()
(#2010), #6261, thanks @herndlm! - Improve return type precision of
filter_input
with invalid first args (#2333), thanks @herndlm! - Allow
@property
and@method
to override above the same class (phpstan/phpstan-src@3467a21) - Add
FilterVarArrayDynamicReturnTypeExtension
(#2257), thanks @zonuexe!
Bugfixes 🐛
- Fix usage of
TypeSpecifierContext::truthy()
(#2230), #3013, #7686, thanks @VincentLanglet! - Parent template type should respect child class bound when unspecified (phpstan/phpstan-src@1017dc7), phpstan/phpstan-doctrine#333
- Fix bug with match expression and
treatPhpDocTypesAsCertain
(#2250), #8937, thanks @VincentLanglet! - Generics: fix position variance of readonly-by-phpdoc properties (#2337), #9153, thanks @jiripudil!
- PHPStan Pro - show errors from CollectedData (phpstan/phpstan-src@b85a961)
- Fix methods in IntersectionTypePropertyReflection (phpstan/phpstan-src@d1c4c6d)
Function signature fixes 🤖
Internals 🔍
- Switch to
cweagans/composer-patches
(#2307), thanks @herndlm! - WritingToReadOnlyPropertiesRule - hook on better node (phpstan/phpstan-src@bddf573)
- Validate usages of
assert*
functions in TypeInferenceTestCase (#2326), thanks @staabm!