github vimeo/psalm 3.11.6
Improve diff behaviour & bugfixes

latest releases: 5.24.0, 5.23.1, 5.23.0...
3 years ago

Improved --diff behaviour

@bendavies pointed out an issue (#3367) in Psalm's behaviour when running --diff, where the caching would only take effect the third time you ran Psalm, not the second. This is now fixed.

Pathological-case switch statement speedups

switch statements with 100 case statements in a row like

switch ($i) {
  case 0:
  case 1:
  ...
  case 99:
    return;
}

Used to have polynomial complexity, but now they're evaluated in linear time.

sealAllMethods config

by default, if Psalm sees

/**
 * @method getString():string
 */
class Foo {
  public function __call(string $name, array $args) {}
}

(new Foo)->bar(); // UndefinedMagicMethod

it emits a UndefinedMagicMethod for the call to Foo::bar().

But if no @method annotation is given, nor a @psalm-seal-methods annotation, then the call is allowed:

class Foo {
  public function __call(string $name, array $args) {}
}

(new Foo)->bar(); // no issue

@olleharstedt added a new config option, sealAllMethods, that tells Psalm that this is always bad.

@mixin bugfixes

  • @mr-feek fixed a bug in a @mixin annotation used with a final class (#3470)
  • fix a crash when encountering a weird @mixin annotation (#3537)
  • allow magic method call on @mixin (#3534)
  • added back support for static @mixin calls (#3552)

Bugfixes

  • @still-dreaming-1 added better type inference for __TRAIT__ and __FILE__ (#3464)

  • allow wildcard references to builtin class constants (#3484)

  • @orklah added a better return type for DateInterval::$days (#3493)

  • @orklah added checks for duplicate @return/@param annotations (#3487)

  • @0x450x6c added wildcard support for class constants inside generics (#3489)

  • @orklah prevented division by explicit zero in bcdiv (#3494)

  • @staabm fixed the type of mysqli_warning::$sqlstate (#3497)

  • prevent crash on malformed @throws annotation (#3506)

  • prevent incorrect mixed type with Amp when a @psalm-yield annotation is provided (#3418)

  • @LeSuisse fixed signatures of stream_filter_append/prepend (#3514)

  • prevent crash when a callable string is empty (#3519)

  • fix a regression with the memoizeMethodCallResults option (#3522)

  • expand @psalm-type aliases recursively (#3532)

  • Language Server: @joehoyle added support for globally-defined functions (#3477)

  • @andrei-petre fixed some config location resolution issues when setting baselines (#3521)

  • @gharlan added PharData::offsetGet/offsetExists to callmap (#3557)

  • @enumag improved ext-ds stubs (#3559)

  • fix a crash when reconciling strings to template params (#3510)

  • @tvdijen improved the return type for preg_grep (#3565)

  • support complicated case expressions after switch (true) (#3563)

  • make callable():void is valid for callable():?bool (#3571)

  • always analyse cast expressions even when used in unknown context (#3577)

  • @weirdan marked session_decode as impure (#3572)

  • @andrei-petre added a check to prevent users extending final classes (#3037)

  • @ostrolucky marked fgetcsv impure (#3582)

  • prevent impure use of count (#3551)

  • @Daeroni fixed the property type of tidyNode::$child (#3599)

  • @jaikdean fixed some Redis:: signatures (#3597)

Don't miss a new psalm release

NewReleases is sending notifications on new releases.