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 rawMessages key 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 ๐Ÿ›

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-out for getmxrr (#4943), #10704, thanks ...

Read more

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 ๐Ÿ”ง

Bugfixes ๐Ÿ›

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 ๐Ÿค–

Internals ๐Ÿ”

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 checkMissingOverrideMethodAttribute as 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 ๐Ÿ›

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 createMethod with includingAnnotations: true if @method does 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 ๐Ÿ”

2.1.37

Improvements ๐Ÿ”ง

Bugfixes ๐Ÿ›

Performance ๐ŸŽ๏ธ

Internals ๐Ÿ”

  • TrinaryLogic: detect logic errors (#4802), thanks @staabm!

2.1.36

Bugfixes ๐Ÿ›

Function signature fixes ๐Ÿค–

Internals ๐Ÿ”

2.1.35

Bugfixes ๐Ÿ›

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 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 ๐Ÿ›

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...

Read more

2.1.33

Improvements ๐Ÿ”ง

Bugfixes ๐Ÿ›

Function signature fixes ๐Ÿค–

Internals ๐Ÿ”

2.1.32

Improvements ๐Ÿ”ง

Bugfixes ๐Ÿ›

Function signature fixes ๐Ÿค–

  • Make BcMath\Number::$value numeric-string (#4505), thanks @schlndh!

Internals ๐Ÿ”

Read more