Releases ยท phpstan/phpstan
1.12.33
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 ๐ค
2.1.39
Bleeding edge ๐ช
- Require generics for Iterator, IteratorAggregate, Generator (#4209), thanks @Flyingmana!
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 ๐ง
- New rule for
filter_var(PHP 8.5+) (#4553), thanks @canvural! - Introduce
reportNonIntStringArrayKeyparameter (#4012), #7864, #7884, #12589, thanks @VincentLanglet! - Introduce
@phpstan-all-methods-(im)pure(#4422), thanks @VincentLanglet! - Introduce
__stringnotstringable(#4457) (#4457), #6560, thanks @VincentLanglet! - FileFinder - sort files before returning (phpstan/phpstan-src@c33cfea)
- Respect
sys_get_temp_dir()from the parent process (#4699), #13929, thanks @dktapps! - Add ArrayCombineFunctionThrowTypeExtension (#4414) (#4414), #13642, thanks @VincentLanglet!
- Do not degrade closures in array shapes (#4823), #14012, thanks @staabm!
- Do not degrade array-shapes in PHPDocs (#4864), thanks @staabm!
- Don't lose known offset-types in
array_replace()(#4826), thanks @staabm!
Bugfixes ๐
- Resolve bitwise-not on constant integer (#4437), thanks @VincentLanglet!
- Support int range in bitwise operations (#4435) (#4435), #7912, #9384, thanks @VincentLanglet!
- Add exceptional case for DateInterval::format return type inference (#4442), #13693, thanks @adamturcsan!
- Comparison with strtolower() etc. leads lower/upper-case-string (#4857) (#4857), #14047, thanks @staabm!
- Resolve template with value of BackedEnum (#4548), #12219, #13282, #13638, #13782, thanks @VincentLanglet!
- SplObjectStorage iterates over objects (#4789) (#4789), #13985, #14046, thanks @staabm!
- Remove extra
dba_fetchvariant in PHP 8.3 functionMap (phpstan/phpstan-src@55d0fd7) - Constant's
isDeprecated()depends onScope::getPhpVersion()(#4630), thanks @staabm! - Add default value for getAttribute call in ContinueBreakInLoopRule (#4552), #13790, thanks @canvural!
- Infer non-empty-array after array_key_first/last() (#4536) (#4536), #13546, thanks @staabm!
- Fix strtr inferences (#4466) (#4466), #13708, thanks @VincentLanglet!
- Fix ignore comment handling for multiple traits in a single file (#4804), #13945, thanks @takaram!
- Do not report do-while-false pseudo-loops that are interrupted by a break statement (#4551), thanks @claudepache!
- Defer invalidating expressions after all args are processed (phpstan/phpstan-src@2a92c7b)
- Defer by-ref closure scope modifications after all args are processed (#4865)
Performance ๐๏ธ
- NodeScopeResolver: faster produceArrayDimFetchAssignValueToWrite() (#4842), thanks @staabm!
- NodeScopeResolver: Prevent repetitive union of static types (#4841, #4843), thanks @staabm!
- Prevent repetitive calls to
ParametersAcceptorSelector::selectFromArgs()(#4855) (#4855), thanks @staabm! - MutatingScope: prevent unnecessary scope re-creation after openssl* calls (#4854) (#4854), thanks @staabm!
- Made closures php-src cachable (#4724), thanks @staabm!
- VoidToNullTraverser: Intersections cannot contain void (#4868), thanks @staabm!
- Prevent unnecessary type-traversal (#4868), thanks @staabm!
Function signature fixes ๐ค
- mb_str_pad has side effects (#4849), thanks @longwave!
- More precise
microtime()return type (#4347), thanks @takaram! - Change return type of apcu_inc and apcu_dec function (#4419), thanks @LordSimal!
- Add missing parameters to RedisCluster signatures (#4430), thanks @RobiNN1!
- Fix return type of pcntl_signal_get_handler (#4544), thanks @marc-mabe!
- More precise
hrtime()return type (#4353) (#4353), thanks @takaram! - Fix
get_defined_vars()return type (#4632) (#4632), #13881, thanks @VincentLanglet! - Narrow string type when
ctype_*functions return true (#4570), #13089, thanks @takaram! - Fix get_object_vars() return type (#4629), thanks @Triplkrypl!
- Restrict chr param for PHP 8.5+ (#4673), #13930, thanks @VincentLanglet!
Internals ๐
- Parallelize RunCommand in issue-bot (#4840)
- Add "consts" to typos dictionary (#4851)
- Rename GITHUB_TOKEN env var because it conflicts with
ghCLI tool (phpstan/phpstan-src@d56d189) - Regression test for #14041 (#4845), thanks @longwave!
- Refactor ComposerPhpVersionFactory (#4635), thanks @staabm!
- Refactor InitializerExprTypeResolver (#4861) (#4861), thanks @staabm!
- Added
make infectioncommand to run it locally (#4524) (#4524), thanks @staabm! - Add PHPDoc documentation to Type, Scope, and Reflection interfaces (#4866)
- PHPDoc tag
@api-do-not-implementinstead of list in BcUncoveredInterface (phpstan/phpstan-src@43d5026), #14054 - Use named arguments for unreadable calls (#4869)
2.1.38
This version brings another 5-10 % faster performance! ๐๏ธ
Improvements ๐ง
- Remove PHP version constraint from the
#[\Override]attribute rules (#4436), thanks @johnbillion! - OverridingPropertyRule - take
checkMissingOverrideMethodAttributeas default only on PHP 8.5+ (phpstan/phpstan-src@64e9776) - Support StaticMethodParameterClosureTypeExtension for New_ expressions (#4819), thanks @ruudk!
- Improve inference on FuncCall === FuncCall (#4513), #13749, thanks @staabm!
- Don't lose known offset-types in
array_merge()(#4554), thanks @staabm!
Bugfixes ๐
- Fixed escaped hash in regex extended mode (#4814), thanks @dg!
- Fix closure type inference bug related to FNSR (phpstan/phpstan-src@66f2738), #13993
Performance ๐๏ธ
- Rework phpDoc inheritance to resolve through reflection instead of re-walking the hierarchy (#4829), #10771
- TemplateTypeHelper: prevent unnecessary work (#4818), thanks @staabm!
- ConstantArrayType: prevent unnecessary work (#4811), thanks @staabm!
- ImpossibleCheckTypeHelper: Remove unnecessary late-resolving (#4816), thanks @staabm!
- Prevent duplicate logic execution for
createMethodwithincludingAnnotations: trueif@methoddoes not exist (phpstan/phpstan-src@d5da11e) - Find all constant/method types per class at once (#4737), thanks @staabm!
- Speed up CombinationHelper (#4825), thanks @kaja47!
- MutatingScope: Faster createConditionalExpressions (#4831), thanks @staabm!
- Re-use ExpressionTypeHolder (#4832), thanks @staabm!
- IntersectionType cannot be void (#4835), thanks @staabm!
- Cache IntersectionType results (#4836) (#4836), thanks @staabm!
- Prevent unnecessary work in MutatingScope->mergeVariableHolders() (#4837), thanks @staabm!
- Simplify lowercase-string handling (#4838) (#4838), thanks @staabm!
Function signature fixes ๐ค
Internals ๐
- Clarify
new PhpPropertyReflectioncall with named arguments (phpstan/phpstan-src@0f6f059) - Narrow type of reflection
get*Type()after callinghas*Type()(#4806), thanks @paulbalandan! - Add regression test (#4824), #11598, thanks @takaram!
- No need to have generics in class constant-related messages (#4829), #10771
2.1.37
Improvements ๐ง
- Show LoC/s performance metric with
-vvv --debug(phpstan/phpstan-src@47936f2) - Configurable memory cache thresholds for eviction (phpstan/phpstan-src@d9a1233)
Bugfixes ๐
- Fix closure type inference (phpstan/phpstan-src@bcdbfd8), #13993, #10612
- infinite loop in never returning function is allowed (#4516), #6458, #12813, thanks @canvural!
- fix: nested trait
@use, use original class file name to get trait data (#4813), thanks @calebdw!
Performance ๐๏ธ
- Do
gc_disable()inbin/phpstanfor speedup (phpstan/phpstan-src@8acd93b) - Prevent repetitive calls to getArgs() (#4799), thanks @staabm!
- ExpressionTypeHolder: Prevent unnecessary work (#4800), thanks @staabm!
- ExpressionTypeHolder: re-use objects more often (#4801), thanks @staabm!
- PhpDocBlock - only ask immediate interfaces for PHPDocs to inherit (phpstan/phpstan-src@1104170)
- PhpDocBlock - only ask immediate traits (phpstan/phpstan-src@4d9f2b1)
- PhpDocBlock - skip abstract trait methods without PHPDoc (phpstan/phpstan-src@47aa39d)
- NodeDependencies: prevent unnecessary FileHelper::normalizePath() calls (#4809), thanks @staabm!
- FileCacheStorage: Don't use sprintf() on maybe huge strings (#4808), thanks @staabm!
- ConstantStringType: prevent unnecessary work (#4810), thanks @staabm!
- CallPrivateMethodThroughStaticRule: cheap checks first (#4812), thanks @staabm!
Internals ๐
2.1.36
Bugfixes ๐
- Fix FNSR false positive about "expr.resultUnused" (phpstan/phpstan-src@ca7ab77)
- Fix named argument parameter matching in getFunctionCallStackWithParameters (#4791), thanks @janedbal!
- Do not deep-clone nodes (phpstan/phpstan-src@9a31328), #13992
- Add getScopeType and getScopeNativeType again (phpstan/phpstan-src@02869f6), #13983
- See discussion #13983 (comment)
- Skip polyfills in
vendorwhen on a higher PHP version (phpstan/phpstan-src@f06c4a2)
Function signature fixes ๐ค
Internals ๐
- Test that expr inside
isset()can be changed with fixable rule (phpstan/phpstan-src@53a03d5), #13983 - Added regression test (#4796), #13694, thanks @staabm!
2.1.35
Bugfixes ๐
- Fix ArrayCountValuesDynamicReturnTypeExtension (#4618), thanks @VincentLanglet!
- Make processStmtNodesInternal synchronous despite Fibers & Deep-clone synthetic nodes before processing (#4793), #13980, #13983, #13987, #13982, #13978, #13989
Internals ๐
- RuleTestCase - sort actual and expected errors before comparing (#4790)
- Revert "Keep errors ordering even when nodeCallback executed out of order" (#4790)
- narrowMethodScopeFromConstructor parameter no longer needed because RuleTestCase sorts the errors (#4790)
- Prevent unnecessary work around parametersAcceptor->getParameters() call-sites (#4792), thanks @staabm!
2.1.34
Major new features ๐
- Optimized performance ๐๏ธ
- Caching of reflection objects and resolved PHPDocs
- Many raw performance optimization tweaks in analyser code (thanks @staabm!)
- Projects typically see 25 % to 40 % faster analysis times. Please test this release and report back, we're looking forward to your numbers as well!
- Utilization of Fibers for more precise analysis (PHP 8.1+)
- Code like
doFoo($a = 1, $a)will see better type inference for 2nd call argument. - When a rule hooked onto MethodCall AST node asks for
$scope->getType($node->args[1]), without Fibers it getsmixed, because$scopesees the state before the method call. - Fibers allow PHPStan to "pause" the execution of the rule until the precise type of
$node->args[1]is available in the analyser. - When the 2nd argument is processed, the execution of the rule is resumed and
$scope->getType($node->args[1])sees1as the type, notmixed. - Solves 10 reported issues: #12234, #11982, #11386, #11079, #10612, #9652, #8936, #12663, #12735, #13353
- Code like
Improvements ๐ง
- Add ArrayCountValuesDynamicReturnTypeExtension (#4615), #13816, thanks @mad-briller!
Bugfixes ๐
- Fix
UnionType::getObjectClassReflections(#4541), #13777, thanks @VincentLanglet! count(non-empty-array, COUNT_RECURSIVE)isint<1, max>(#4515), thanks @staabm!- Fix bitwise operators on mixed (#4423), #8094, thanks @VincentLanglet!
- Immediate unwrap AlwaysRememberedExpr after used on NodeScopeResolver (#4651), thanks @samsonasik!
- Improve return type of
range()function to always yield anon-empty-list(#4688), thanks @FeBe95! - Fix ArgumentsNormalizer - do not overwrite already passed args (phpstan/phpstan-src@7bdd172)
- Prevent crash when analysing curl_setopt (#4722), thanks @schlndh!
- Fix the handling of sealed concrete classes (#4567), #13734, thanks @stof!
- Improve and sync Accessory types
accepts()methods (#4766), #13964, thanks @staabm!
Performance ๐๏ธ
- Prevent unnecessary scope merging (#4640), thanks @staabm!
- Prevent reading & json-decoding composer.json multiple times (#4645), thanks @staabm!
- Cache neon file reads (#4646), thanks @staabm!
- Optimize keepVoidType (phpstan/phpstan-src@ff39220)
- TypeCombinator - assume that inner types in UnionType are already normalized (phpstan/phpstan-src@e8f9992)
- Remember resolved types after pushInFunctionCall (#4648), thanks @staabm!
- Remember function return type extensions (#4644) (#4644), thanks @staabm!
- Use sha256 which is cpu optimized in PHP 8.4+ (#4656), thanks @staabm!
- Cache ast-parsing in RegexGroupParser (#4655), thanks @staabm!
- Microoptimize TypeCombinator (#4657), thanks @staabm!
- TypeCombinator: Remove unnecessary md5 encoding (#4658), thanks @staabm!
- Prevent duplicate super-global-variable detection (#4662) (#4662), thanks @staabm!
- Prevent Scalar expressions to be specified (#4663), thanks @staabm!
- Print more precise elapsed time (#4664), thanks @staabm!
- TypeCombinator: remove unnecessary loop (#4665), thanks @staabm!
- TypeCombinator: Reduce number of intersect() calls (#4668), thanks @staabm!
- TypeCombinator: Simplify ConstantStringType handling (#4666) (#4666), thanks @staabm!
- TypeCombinator: Prevent unnecessary work (#4667) (#4667), thanks @staabm!
- Prevent unnecessary work when resolving Expr\BinaryOp\Coalesce (#4661), thanks @staabm!
- VerbosityLevel: early return type traversal (#4670) (#4670), thanks @staabm!
- ParametersAcceptorSelector: early return type traversal (#4669) (#4669), thanks @staabm!
- UnresolvableTypeHelper: early return type traversal (#4671), thanks @staabm!
- LazyInternalScopeFactory: Prevent expensive repeated getService() calls (#4672), thanks @staabm!
- Use more efficient spl_object_id() over spl_object_hash() (#4674), thanks @staabm!
- Remove
TypeCombinator::union()calls that are not necessary (phpstan/phpstan-src@12f2b23) - Remove
TypeCombinator::intersect()calls that are not necessary (phpstan/phpstan-src@f1f97c3) - Prevent repetative method calls on ParametersAcceptor (#4686), thanks @staabm!
- Prevent unnecessary node-key calculation (#4691), thanks @staabm!
- Prevent maybe unnecessary work in MutatingScope::filterBySpecifiedTypes() (#4690), thanks @staabm!
- Prevent unnecessary work in BetterReflectionProvider (#4687), thanks @staabm!
- Simplify MutatingScope->invalidateMethodsOnExpression() (#4692), thanks @staabm!
- Speedup analysis of arrays containing closures (#4684), thanks @staabm!
- TypeNodeResolver: Reduce number of intersect() calls (#4694), thanks @staabm!
- TypeCombinator: prevent unnecessary work (#4695), thanks @staabm!
- ConstantStringType: Prevent creation of unnecessary constant-object types (#4696), thanks @staabm!
- Remove NodeFinder from MutatingScope->restoreThis() (#4697), thanks @staabm!
- MemoizingContainer - memoize getService (phpstan/phpstan-src@68815ac)
- Use static callback for TypeTraverser::map() (#4701), thanks @staabm!
- Prevent unnecessary work while Ternary analysis (#4704), thanks @staabm!
- Prevent unnecessary work in NodeScopeResolver->processAssignVar() (#4705), thanks @staabm!
- Prevent unnecessary work in While/Do analysis (#4706), thanks @staabm!
- Prevent unnecessary work in TypeSpecifier->createForExpr() (#4707), thanks @staabm!
- NodeScopeResolver: Move condition out of loop (#4708), thanks @staabm!
- NodeScopeResolver: determine callCallbackImmediately only for callables (#4709) (#4709), thanks @staabm!
- NodeScopeResolver: cheap checks first (#4710) (#4710), thanks @staabm!
- NodeScopeResolver: Move assignByReference logic out of generic path (#4711), thanks @staabm!
- Process called methods looking for initialized properties only when called from constructor (phpstan/phpstan-src@c993754)
- Cheap checks first (#4715), thanks @staabm!
- Store only variables as expression types with maybe certainty (#4719)
- Prevent unnecessary work in MutatingScope->mergeVariableHolders() (#4720), thanks @staabm!
- Prevent unnecessary work in
NodeScopeResolver::processAssignVar()(#4716), thanks @staabm! - Minor optimization (phpstan/phpstan-src@21d86f0...
2.1.33
Improvements ๐ง
- Cache files in OptimizedDirectorySourceLocatorFactory (#4577), #13852, thanks @staabm!
- Add more numeric-string inferences after string concat (#4447), thanks @VincentLanglet!
- Improve EnumSanityRule (#4543), #13768, thanks @VincentLanglet!
- Too wide bool return type is not reported in trivial methods (#4444), #13482, thanks @staabm!
Bugfixes ๐
- De-duplicate phpstan.php errors (#4560) (#4560), #13813, thanks @staabm!
- Fix default level message (phpstan/phpstan-src@9ab9647)
- [PHP 8.5]
ini_get("max_memory_limit")is a string (#4574), thanks @staabm! - Revert changes to ArrayMapArgVisitor which switch the order of named arguments (phpstan/phpstan-src@f562834)
- Fix "Array does not have offset" in
curl_setopt_array()(#4590), #13862, thanks @staabm! - OversizedArray is not truthy (#4556), #13797, thanks @VincentLanglet!
- Do not instantiate Accessory without string type (#4550), #13784, thanks @VincentLanglet!
- Narrow CURLOPT_SHARE accepting type (#4611), thanks @staabm!
Function signature fixes ๐ค
- Fix return-type for DOMNode::C14N (#4608), thanks @tvdijen!
- Fix DOMNode::C14N bad definition (#4361), #8096, thanks @VincentLanglet!
- Fix time not being considered an impure function. (#4609), #13874, thanks @mad-briller!
Internals ๐
- Simplify ClassReflection constructor (phpstan/phpstan-src@821ff76)
- Introduce ClassReflectionFactory (phpstan/phpstan-src@35470a0)
- Prevent global side-effect in Bug13813IntegrationTest (#4566), thanks @staabm!
- Parameter narrowMethodScopeFromConstructor in DI (phpstan/phpstan-src@05b80ef)
- Reduce ContainerFactory::postInitializeContainer() calls (#4572), thanks @staabm!
- TypeSpecifier as an interface (phpstan/phpstan-src@fc6a2b1)
- Change where TypeSpecifier is set into TypeSpecifierAwareExtension (phpstan/phpstan-src@36cf9a1)
- Enable FileCacheStorage for OptimizedDirectorySourceLocatorFactory in tests (#4576), thanks @staabm!
- Upload baseline on downgraded code (phpstan/phpstan-src@057c79f)
- More precise return type for gatherAssertTypes (#4614), thanks @staabm!
- AnalyserIntegrationTest uses
narrowMethodScopeFromConstructor: true(phpstan/phpstan-src@dc9bf7f)
2.1.32
Improvements ๐ง
- [PHP 8.5] Pipe operator support (phpstan/phpstan-src@e9df52e)
- [PHP 8.5] Report deprecated casts (phpstan/phpstan-src@d0a77d1)
- [PHP 8.5] Report deprecated backtick operator (phpstan/phpstan-src@9405233)
- [PHP 8.5] Added PHP_BUILD_DATE type (#4468), thanks @staabm!
- [PHP 8.5] Global constants support attributes (phpstan/phpstan-src@6958f86)
- [PHP 8.5] Add support for FILTER_THROW_ON_FAILURE for filter_var (#4495), thanks @canvural!
- [PHP 8.5] Add
array_firstandarray_lastreturn type extensions (#4499) (#4499), thanks @canvural! - [PHP 8.5] Support for deprecated traits (phpstan/phpstan-src@f0675a7)
- [PHP 8.5] Support for
#[Override]on properties (phpstan/phpstan-src@8b85e62) - [PHP 8.5] clone with support (phpstan/phpstan-src@5a9471a)
- [PHP 8.5] Support for
Closure::getCurrent()(phpstan/phpstan-src@e3ac5ee) - [PHP 8.5] Support for casts in constant (initializer) expressions (phpstan/phpstan-src@df5ede5)
- [PHP 8.5] Support for first class callables in constant expressions (initializers) (phpstan/phpstan-src@f436abf)
- [PHP 8.5] Support for static Closures in constant expressions (initializers) (phpstan/phpstan-src@ab704f4)
- [PHP 8.5] Support for asymmetric visibility in static properties (phpstan/phpstan-src@8b2b97f)
- NodeCallbackInvoker interface to invoke all PHPStan rules on a synthetic AST node (#4429)
- The interface NodeCallbackInvoker can be typehinted in 2nd parameter of
Rule::processNode() - See full explanation
- CompositeRule can be used to test rules using NodeCallbackInvoker (#4438), thanks @staabm!
- The interface NodeCallbackInvoker can be typehinted in 2nd parameter of
- InvalidIncDecOperationRule - make aware of deprecation of
--(PHP 8.3) and++(PHP 8.5) on non-numeric strings (phpstan/phpstan-src@0ff7e44) - InvalidIncDecOperationRule - make aware of more deprecations (phpstan/phpstan-src@3d6bbe4)
- InvalidPromotedPropertiesRule - report
finalin promoted property on PHP < 8.5 (phpstan/phpstan-src@e5de6b8) - The
(void)cast is supported only on PHP 8.5 and later. (phpstan/phpstan-src@53b87e0) - Rules about
#[NoDiscard]report errors only on PHP 8.5+, errors are non-ignorable (phpstan/phpstan-src@d00b769) - Rules about
#[NoDiscard]report when call is in(void)cast but should not (phpstan/phpstan-src@099b87a) - Understand always-overwritten arrays in foreach (#4534), #2273, #13730
- Support writing to array in foreach with value-by-ref (#4537)
- Report unknown parameter for implicit variadic methods (#4481) (#4481), #13719, thanks @VincentLanglet!
- IgnoreErrorExtension is a valid conditional tag (#4488), thanks @staabm!
- Reduce file-parsing in ResultCacheManager (#4491), thanks @staabm!
- Faster AutowiredAttributeServicesExtension->processParameters() (#4489) (#4489), thanks @staabm!
- Detect duplicated args passed to a variadic parameter (#4498), #13710, thanks @takaram!
- Add support for statement in conditional tags (#4512), thanks @VincentLanglet!
- Include identifier in
gitlaberror format (#4421), thanks @spawnia! - PropertyInClassRule - move supportsPropertyHooks check to bottom to have more errors reported (phpstan/phpstan-src@6ccdba2)
- TooWideMethodThrowTypeRule - new opt-in option for reporting too-wide implicit (inherited)
@throws(phpstan/phpstan-src@b6a2e0f), #13696, #13671
Bugfixes ๐
- Fixed infinite recursion with late-resolvable types (phpstan/phpstan-src@7f3ad70), #13685
- Infer
non-empty-list/arrayafterarray_key_exists($i, $arr)(#4440) (#4440), thanks @staabm! !array_key_exists()should implyarrayfor PHP8+ (#4417), #6209, #13301, thanks @staabm!- Invalidate native expression types after clearstatcache call (#4448) (#4448), #11484, thanks @VincentLanglet!
- Use the same scalar limit for sprintf and concat (#4454), #13378, thanks @VincentLanglet!
- Handle impure/throw point of inherited constructors of anonymous classes (#4455), #13698, thanks @takaram!
- Adjust a bunch of places for first-class callables and nullsafe operators (phpstan/phpstan-src@e437c5a)
- Fix sprintf() types and placeholders (#4463), thanks @staabm!
- Fix return type inference from immediately invoked closure (phpstan/phpstan-src@3702305)
- Fix crashes in ParametersAcceptorSelector (#4467), #13714, thanks @staabm!
- Fix null coalesce false positive for multi-dimensional array in loop (#4475), thanks @schlndh!
- Fix type of clone expression (phpstan/phpstan-src@020adb5)
- Ensure that JetBrains terminal sees correct relative path (#4479), #13697, thanks @caufang!
- Fix for losing
array_key_existsinference when adding a false condition (#4473) (#4473), #11276, thanks @staabm! - Fix filter var on uncertainty flags (#4418), #11485, thanks @VincentLanglet!
- TestCaseSourceLocatorFactory - skip polyfills based on PHP version (phpstan/phpstan-src@f63b423)
- Fix
composerAutoloaderProjectPathsarray so that the items always refer to dir with composer.json in it (#4522), phpstan/phpstan-doctrine#646 - Add support for union of constant integer for filter_var (#4519), thanks @VincentLanglet!
- Child class of parent class that uses a trait with a constant can redeclare the constant with a different value (phpstan/phpstan-src@9f415ae), #13119
Function signature fixes ๐ค
Internals ๐
- SimultaneousTypeTraverserTest for improved UnionType implementation (phpstan/phpstan-src@0bddac1)
- Fix
BenevolentUnionType::traverseSimultaneously()(phpstan/phpstan-src@856a9f1) - Improve
IntersectionType::traverseSimultaneously()for arrays (phpstan/phpstan-src@0693e5a) - Changelog generator: Use better API to associate commit with a merged PR (phpstan/phpstan-src@e153fa4)
- Use GraphQL to find autoclosed issues when a PR is merged (phpstan/phpstan-src@2f69398)
- GenerateFactory - allow setting the result type in attribute, override create method return type (#4429)
- Narrow errors array type to list (#4445), thanks @staabm!
- No memory_limit for tests as PHPUnit recommends (#4449)
- Compute allowedArrayType only once (#4453), thanks @VincentLanglet!
- Narrow types (#4465), thanks @staabm!
- Revert "MemoryCacheStorage - var_export the data to reproduce certain issues" (ht...