packagist vimeo/psalm 3.8.0
Improve type inference

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

Improved type inference

I had a look at Psalm's type inference as part of addressing #2426.

Type inference in non-statically-typed languages is a bit of a beast, and a lot of Psalm‘s development time is devoted to ensuring that Psalm’s type inference is as good as it can possibly be.

This release should hopefully improve the accuracy a notch, with fewer false positives – and fewer false negatives too.

Other improvements

  • @erunion improved the --help page (#2417)
  • @TysonAndre added a full stack trace when Psalm runs into an error (#2418)
  • Psalm now bails out of very long conditionals (#1943)
  • Psalm now supports outputting reports in JUnit format, with help from @m50 (#2485)
  • Psalm supports @phpstan-var, @phpstan-param etc. annotations (#2488)
  • Psalm now supports a class-string-map<T as Foo, T> type which can be used for an array where the keys are class strings and the values are instances of those keys (#1969)

Bugfixes

  • allow use of covariant params in templated array return value (#2411)
  • fix an issue with class constant resolution (#2413)
  • ignore passed-by-reference variables when removing unused code (#2423)
  • improve handling of get_class() calls outside assertions (#2438)
  • improve callmap for stream_bucket_new and ssh2* functions – thanks @pilif and @Daeroni ! (#2434, #2447)
  • fix templating of property types inside those functions where the templates are applicable (#2436)
  • properly template the result of calling someMethod on a string of type class-string<T> when someMethod returns static (#2439)
  • make sure uasort is templated properly (#2440)
  • narrow template types after is_* checks (#2432)
  • fix templated static<T> values on already-templated classes (#2445)
  • don’t suggest templated values when adding phpdoc types (#2443, #2437)
  • find circular references in class constants (#2453)
  • allow extending templated classes with nested parameterised types (#2454)
  • ignore UnusedFunctionCall issues if the function has custom assertions (#2456)
  • allow @psalm-type types to be used above return (#2457)
  • memoize immutable calls (#2457)
  • null coalesce shouldn't hide undefined var issues (#2464)
  • allow inferred templated null in param default (#2431)
  • fix inheritance of templated params without rewritten __construct (#2470)
  • array_map now remembers array emptiness when passed callable strings (#2472)
  • allow array_map to work with callables that return static (#2473)
  • allow covariance for iterable (#2475)
  • still analyse arguments even when function doesn’t exist (#2479)
  • add better inference for array_map(null, $array1, $array2) (#2468)
  • allow isset tests on known list offsets (#2408)
  • add support for spaces in @psalm-assert-if-true types (#2484)
  • add better behaviour when multiple interfaces define a method signature (#2483)
  • trait issues are now reported where it makes most sense for the given project (#2491)
  • allow overridding renamed trait methods in subclasses (#2490)
  • don’t crash when a plugin-provided function doesn’t exist (#2493)
  • use correct flag when checking for unused variables (#2506)
  • add better return types for array_fill_keys - thanks @vudaltsov! (#2512)
  • preserve params when subtracting Traversable from iterable (#2509)
  • improve hexdec returned value (#2352)
  • remove erroneous messages from Phar installation - thanks @bdsl! (#2514)

Don't miss a new psalm release

NewReleases is sending notifications on new releases.