packagist vimeo/psalm 3.8.4

latest releases: 5.x-dev, dev-master, dev-isTypeContainedByType_flags...
4 years ago

Features

Class constant wildcards

Psalm now supports wildcards when specifying class constants. Instead of writing
@psalm-param self::ERROR_ONE|self::ERROR_TWO,
you can now write self::ERROR_* and Psalm will resolve all matching constants:

class A {
    const ERROR_ONE = 'some error';
    const ERROR_TWO = 'another error';
    const WARNING_THREE = 'some warning';

    /**
     * @psalm-param self::ERROR_* $i
     */
    public static function foo(string $i) : void {}
}

A::foo(A::ERROR_ONE);
A::foo(A::ERROR_TWO);
A::foo(A::WARNING_THREE); // this is an issue

(#2739)

Other features

  • allow XML imports in Psalm config files - thanks @weirdan (#2635)
  • @scottarc got Psalm running on PHP 8 (#2660)
  • Support GitHub checks-compatible output with --output-format=github (#2678)
  • @pilif added a config flag that allows you to specify the version of PHP that Psalm expects (#2715)
  • added a new @psalm-readonly-allow-private-mutation annotation for public properties that you don't want to be editable outside the context of a class, but you do want to manipulate in private methods (#2729)

Bugfixes

  • Prevent crashes when combining hard-to-resolve constants (#2623)
  • Infer arrow function effects for array_filter (#2627)
  • Allow constant arrays to be interpreted as lists (#2624)
  • @ShiraNai7 re-fixed DOMXPath::query and added a generic version of DOMNamedNodeMap (#2703)
  • @alfredbez fixed RarArchive signatures
  • @l-x improved PDO::fetch return types
  • Allow non-empty-list in @psalm-assert annotation (#2636)
  • Explicit lists merged together are still lists (#2642)
  • Improve type inference of autoloaded constants (#2644)
  • Allow destructuring of a callable array (#2653)
  • Fix conditional class definition using traits (#2645)
  • Ensure template types are always defined as coming from docblocks (#2625)
  • Allow assertions on resource types (#2626)
  • Ensure that exceptions thrown inside catch blocks are warned about (#2658)
  • Language server catch more unanalyzed file exceptions to prevent crashes (#2633)
  • Fix some performance bottlenecks - thanks @bendavies (#2671)
  • Detect invalid array_push, array_unshfit on properties (#2661)
  • Allow .phpstorm.meta.php to be a directory – thanks @SignpostMarv (#2640)
  • Improve purity checks for a number of functions (#2679, #2631)
  • Prevent invalid pass-by-ref calls in pure functions (#2632)
  • Improve handling of null coalescing (#2677)
  • Always ++/-- operators in unknown function calls (#2685)
  • @orklah added list<...> notation to a number of stubbed functions (#2675, #2693)
  • Evaluate call_user_func more thoroughly (#726)
  • foreach should allow for value variable changes inside loop (#2688)
  • Use more accurate types for very large class constant arrays (#2690)
  • @pilif and @voku marked more functions as impure (#2699)
  • Understand break conditions in switches nested inside loops and vice-versa (#2700)
  • Prevent references to static properties in pure functions (#2696)
  • @pilif detected a state corruption bug (hanging by-reference var) when sorting baseline output (#2710)
  • array_merge should avoid possibly-false issues where appropriate (#2704)
  • Allow === checks on objects of unknown type (#2707)
  • Allow __toString to have a more specific type (#2712)
  • Treat an interface that defines __invoke as callable (#2713)
  • Allow @throws self (#2720)
  • Reduce likely false-negatives after calling isset on nested array keys (#2724)
  • strengthen templated resolution around is_a and explicit class-string checks (#2734, #2735)
  • @LeSuisse fixed params for ldap_bind
  • Fix a couple of bugs in --diff-methods mode
  • @BenMorel improved return types for PDOStatement::fetchColumn
  • Added better stubs for ext-ds classes, thanks to @enumag's work on PHPStan
  • Improve assertions on templated types (#2756)
  • Psalter don't remove string casts when removing variables, as they might implicitly call a __toString method (#2752)
  • @morozov added support for installation alongside PHPUnit 9

Don't miss a new psalm release

NewReleases is sending notifications on new releases.