Find more bugs
Features
Better analysis of when dealing with unknown types
Prior to this release, Psalm wouldn't see any problems with the following:
class A {}
function foo($bar) : void {
if (rand(0, 1)) {
$bar = new A();
}
$bar->bat();
}That's because $bar would always be treated as mixed. mixed is a special type that basically says "we don't know anything", but if we look at the code above it's clear that it might fail.
I changed Psalm's type system so that mixed no longer subsumes any other possible type, and now the above reports a PossiblyUndefinedMethod issue.
New compact output
@erunion resolved #967, which asked for a more concise output format.
Use --output-format=compact to see the new format.
class_alias support
It used not to be supported. Now it is (as long as the class_alias calls are in your bootstrap file). Fixes #1102.
@method improvements
As per #999, @method annotations can now override parent method return/param types.
@psalm-misspelled-annotation warnings
If you use an annotation beginning with @psalm- that's not recognised, Psalm will now warn you (#490).
@internal warnings
Psalm will now emit issues if you're using code marked @internal in a different namespace (#689).
Bugfixes
- Improved handling of long switch statements (#1103)
- Add support for
referencedFunctioninUndefinedFunctionconfig issue suppression blocks (#1108) - Fixed automatic inference of
assert*-named function for complicated logic (#1095) - Emit
PossiblyUndefinedArrayOffsetin more places (#1107) - Many method trait method aliases can now map to the same method (#1104)
- Allow function docblocks with
...$some_varto imply variadic input (#945) - Allow
@throwsannotation to capture subclasses of the given Exception class (#1115) - Improve handling of callables with generic-param intersection return types (#1119)
Changes
- Psalm will now emit a
TypeDoesNotContainTypeissue when comparingget_class($foo)to a string. Use class constants instead!