2.1.40
This release fixes 71 issues! 🎉
It's only been 12 days since the last release, but both @staabm and @VincentLanglet have been hard at work. For the first time ever, PHPStan has more people with merge rights aside from @ondrejmirtes, and the increase in productivity is awesome!
Improvements 🔧
- Introduce
rawMessageskey in ignoreErrors (#4929), thanks @VincentLanglet! - Infer non-empty-ness after
count($a) == count($b)(#4470), thanks @staabm! - Report class.nameCase error when the wrong case is just in return type (#4890), #11470
- Allow ternary type narrowing in assert and truthy contexts (#4915), #14100
- Add
ClassConstantReflection::isFinalByKeyword()method (#5022), #14171, thanks @samsonasik!
Bugfixes 🐛
- Fix
GMP::toNumber(#4867), #12123, #13775, thanks @VincentLanglet! - Respect original variable type when using extract on optional keys (#4450), #12364, thanks @VincentLanglet!
- Fix: Switch statement does not narrow down types based on branch conditions (#4879), #13211
- Fix: Possible type loss when binding variables with 'use' in anonymous function (#4882), #12875
- Fix: Calling ReflectionClass::isSubclassOf() multiple times doesn't narrow types correctly in 8.4 (#4883), #13783
- Fix: False positive error for 'match' operator (#4888), #5191
- Fix: Variadic arrow function argument triggers "Cannot access offset 0 on mixed" and related errors (#4887), #10671
- Fix: Existing function used in Closure::bind leads to "Call to an undefined method" error (#4886), #4865
- Fix: Loadable classes not recognized since 2.1.34 release (#4891), #14036, #14099, thanks @staabm!
- Fix invokable objects incorrectly labeled as instances of
Closure(#4797), #13975, thanks @HypeMC! - Fix: match.unhandled on multiple booleans (#4881), #13303, #11903, #7008, thanks @staabm!
- Preserve HasOffsetValueType for constant array spreads in degraded array literals (#4897), #13805
- Don't invalidate private property expressions of different classes (#4896), #13736, #6623
- Fix match exhaustiveness for class-string with union of final classes (#4894), #9534, #12998
- Allow passing return values of by-reference functions/methods as by-ref args (#4895), #757, #13711
- Downgrade $this to static when calling methods on static type (#4902), #5946
- Fix
@phpstan-assertnot working with union types (#4900), #11441, #13358, thanks @staabm! - Fix: Unnecessary nullsafe operator reported on nullable array index(#4889), #12222
- Revert "Respect sys_get_temp_dir() from the parent process" (phpstan/phpstan-src@dd0ab39), #14093
- Fix incorrect type with spread of array with optional named keys (#4908), #14097
- Fix array_count_values key type for general string input (#4909), #13996, thanks @VincentLanglet!
- Fix
@phpstan-assertnot working correctly with union types (#4920), #14108, thanks @staabm! - Fix
list<mixed>becomesarray<int<0, max>, mixed>without array keys being modified (#4933), #13809, #1311, #13851, #14083, #14084 - Fix: Reassigning to
array<string, list<T>>out parameter does not see thelist<T>property during assignment (#5006), #14124, thanks @staabm! - Improve count on list with greater/smaller-than (#4507), #13747, thanks @staabm!
- Fix array + array inference (#4944), #13561, thanks @VincentLanglet!
- Fix BcMath\Number increment/decrement (#4957), thanks @mpesari!
- Fix: Method call phpstan error is reported on wrong line (#4967), #9820, thanks @staabm and @VincentLanglet!
- Fix error reported on the wrong line (#4991), #14150, thanks @VincentLanglet!
- Fix TypeError dead catch when assigning mixed to int in property (#4981), #9146, thanks @staabm!
- Filter less expression types (#4937), #13984, thanks @VincentLanglet!
- Fix false positive dead catch for ReflectionMethod::invoke/invokeArgs (#4985), #7719, #9267, thanks @staabm!
- Filter unsupported OpenSSL cipher methods on PHP 8.0-8.4 (#4982), #13692, thanks @VincentLanglet!
- Fix: Erroneous Offset might not exist (#4988), #12574, #10040, #11102, #11870, #6991, #7716, thanks @staabm!
- Use "Ignored error" instead of "Ignored error pattern" when rawMessage is used (#4990), thanks @janedbal!
- Fix isset() falsey branch not narrowing array type for dim fetches (#4983), #9908, #10544, #8724, #5128, #12401, thanks @VincentLanglet!
- More precise array_key_first/array_key_last inference (#4994), thanks @staabm!
- Specify conditional types for all falsey scalars (#4995), #6120, #10482, #13709, thanks @staabm!
- Add similar behavior for all Assign nodes (#4996), #12250, #4525, thanks @VincentLanglet!
- Fix: Using phpstan-import-type between classes makes alias unresolvable (#4997), #11463, thanks @staabm!
- Remove callable.nonNativeMethod (#5004), #13596, thanks @VincentLanglet!
- Fix: False Positive on Match Arm Comparison with Incremented Bounded Integer (#5003), #11310, thanks @VincentLanglet!
- Fix scope for MatchExpressionNode (phpstan/phpstan-src@7b850e4)
- Fix match regressions (phpstan/phpstan-src@87004e7, phpstan/phpstan-src@4628ff9)
- Fix conditional expression holder chain resolution regression (#5025), #14178
- Fix
get_classreturn type (#4456), #4890, thanks @VincentLanglet! - Unsetting optional offset might still give a list (#5029), #14177, thanks @VincentLanglet!
Performance 🏎️
- Faster NetteContainer (#4921), thanks @staabm!
- MutatingScope: prevent unnecessary work in removeTypeFromExpression() (#4922), thanks @staabm!
- Don't invalidate container cache on user-interactions in the shell (#4924), thanks @staabm!
- Prevent duplicate path normalization (#4931), thanks @staabm!
- DependencyResolver: Reduce duplicate work (#4923), thanks @staabm!
- speed up TrinaryLogic (#4833), thanks @kaja47!
- ClassNameCheck: Retrieve extensions just once (#4926, #5027), thanks @staabm!
- IsSuperTypeOfResult: cache YES/NO/MAYBE (#5011), thanks @staabm!
- Faster
IntersectionTypeMethodReflection->getVariants()(#5012), thanks @staabm! - ArgumentsNormalizer: remove duplicated work (#5010), thanks @staabm!
- Faster AcceptsResult, IsSuperTypeOfResult (#5013), thanks @staabm!
- TypeSpecifier: Prevent duplicate expression printing (#5018), thanks @staabm!
- Faster Ternary analysis (#5015), thanks @staabm!
Function signature fixes 🤖
- Add
@param-outfor getmxrr (#4943), #10704, thanks @VincentLanglet! - Add sodium_crypto_secretbox_keygen function stub (#4954), thanks @thePanz!
- Add sodium_xxxx_keygen function stubs (#4987), thanks @thePanz!
Internals 🔍
- Extract FileAnalyserCallback (#4872), thanks @staabm!
- Make sure invocations via blackfire use the same container (#4925), thanks @staabm!
- Add more foreach with by-ref $value tests (#4934), thanks @staabm!
- Allow to dumpType more than one thing (#4941), thanks @VincentLanglet!
- Cleanup ConstantArrayTypeBuilder (#4955), thanks @staabm!
- Fix typo (#4984), thanks @vrana!
- Fix test lint-comment (#4986), thanks @staabm!
- Fix isDummy implementation (#5002), thanks @VincentLanglet!
- Cover dynamic static calls in tests (#5009), thanks @staabm!
- Fix use of deprecated PHPParser LNumber, DNumber nodes (#5016), thanks @staabm!
- Simplify throw processing (#5017), thanks @staabm!
- Simplify MemoizingContainer (#5019), thanks @staabm!
- Assert ExprCacheHelper->import() will not mix up same expr-string based attributes (#5023), thanks @staabm!