Releases
2.1.34
Compare
Sorry, something went wrong.
No results found
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 gets mixed, because $scope sees 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]) sees 1 as the type, not mixed.
Solves 10 reported issues: #12234 , #11982 , #11386 , #11079 , #10612 , #9652 , #8936 , #12663 , #12735 , #13353
Improvements π§
Bugfixes π
Fix UnionType::getObjectClassReflections (#4541 ), #13777 , thanks @VincentLanglet !
count(non-empty-array, COUNT_RECURSIVE) is int<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 a non-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 )
No need to resolve late-resolvable types in getVariableType (phpstan/phpstan-src@3eea03b )
Less expression printing (#4723 ), thanks @staabm !
MutatingScope: Prevent duplicate work in getVariableType() (#4726 ), thanks @staabm !
NodeScopeResolver: duplicate only if we actually change the storage (#4729 ), thanks @staabm !
NodeScopeResolver: cheap checks first (#4728 ), thanks @staabm !
Decrease usage of TypeTraverser (phpstan/phpstan-src@93b9c34 )
TypeSpecifier: cheap checks first (#4731 ), thanks @staabm !
CallTo*Rule: cheap checks first (#4733 ), thanks @staabm !
Optimize keepVoidType (#4735 ) (#4735 ), thanks @staabm !
Prevent unnecessary work in Match_ analysis (#4739 ), thanks @staabm !
Implement Type->getEnumCaseObject() (#4740 ), thanks @staabm !
IntersectionType: remove unnecessary hashing (#4744 ), thanks @staabm !
Faster IntersectionType->getFiniteTypes() (#4746 ), thanks @staabm !
MemoizingReflectionProvider->hasClass() is case-insensitive (#4750 ), thanks @staabm !
FileTypeMapper: Prevent unnecessary file IO (#4756 ), thanks @staabm !
TypeSpecifier: Prevent unnecessary type specification (#4757 ), thanks @staabm !
Cache ClassReflections (#4761 ), thanks @staabm !
FileAnalyser: Move repetitive work out of hot loop (#4758 ), thanks @staabm !
UnionType: inline array_map() call (#4765 ), thanks @staabm !
TypeCombinator: Prevent unnecessary work (#4773 ), thanks @staabm !
TypeCombinator: merge 2 loops in intersect() (#4771 ), thanks @staabm !
MutatingScope: merge loops into one (#4774 ), thanks @staabm !
Optimize Scope::mergeWith (phpstan/phpstan-src@64e0cb4 )
Various TypeCombinator optimization ideas (phpstan/phpstan-src@3577b69 )
No need to call rememberConstructorExpressions for each enterClassMethod if rememberConstructorScope is kept (phpstan/phpstan-src@78d946d )
TypeCombinator optimization (phpstan/phpstan-src@8b0c083 )
Call StaticType::transformStaticType less often (phpstan/phpstan-src@d27df94 )
Optimize CallableType::equals() (phpstan/phpstan-src@1f1d382 )
Cache StaticType and ObjectType::getMethod() (phpstan/phpstan-src@270b546 )
TrinaryLogic: faster or() (#4778 ), thanks @staabm !
Faster ExpressionTypeHolder->equals() (#4777 ), thanks @staabm !
Debug-Rules: cheap checks first (#4764 ), thanks @staabm !
InitializerExprTypeResolver: move work out of loop (#4785 ), thanks @staabm !
TrinaryLogic: Prevent unnecessary work (#4784 ), thanks @staabm !
Function signature fixes π€
Internals π
Remove unused baseline-7.3.neon file (#4622 ), thanks @staabm !
Update PHPStan packages (#4621 , #4625 ), thanks @staabm !
Tests: Use Stubs instead of Mocks (#4626 ), thanks @staabm !
Allow PHPUnit 12 (#4624 ), thanks @staabm !
Fix mutation testing (#4631 ), thanks @staabm !
Prevent double normalization of FuncCall nodes (#4637 ), thanks @staabm !
Simplify MutatingScope->compareVariableTypeHolders() (#4641 ), thanks @staabm !
Ignore by identifier instead of plain error (#4652 ), thanks @staabm !
ResultCacheManager - do not invalidate cache when switching Blackfire extension on/off (phpstan/phpstan-src@97c30ca )
Simplify NodeScopeResolver->processImmediatelyCalledCallable() (#4698 ), thanks @staabm !
Fix PHPStorm inspection errors (#4700 ), thanks @staabm !
More precise Type->getCallableParametersAcceptors() return type (#4713 ) (#4713 ), thanks @staabm !
Added native return types (#4732 ), thanks @staabm !
Simplify PhpClassReflectionExtension (#4741 ), thanks @staabm !
Fix typo in test data (#4743 ), thanks @takaram !
EnumCaseObjectType enumCaseName is readonly (#4745 ), thanks @staabm !
Simplify ContainerDynamicReturnTypeExtension (#4755 ), thanks @staabm !
Split MutatingScope->resolveType() into smaller methods (#4759 ) (#4759 ), thanks @staabm !
Split MutatingScope->resolveType() into smaller methods - part 2 (#4760 ) (#4760 ), thanks @staabm !
MemoizingReflector: more precise types (#4762 ), thanks @staabm !
Simplify TypeCombinator->processArrayTypes() (#4769 ) (#4769 ), thanks @staabm !
Drop MutatingScope->rememberConstructorScope() (#4768 ), thanks @staabm !
IntersectionType: Extract describeType() method (#4776 ), thanks @staabm !
More precise types (#4772 ), thanks @staabm !
You canβt perform that action at this time.