1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00
psalm/docs/running_psalm/issues/MixedAssignment.md
2020-03-19 12:32:49 -04:00

468 B
Raw Blame History

MixedAssignment

Emitted when assigning an unannotated variable to a value for which Psalm cannot infer a type more specific than mixed.

$a = $_GET['foo'];

How to fix

The above example can be fixed in a few ways by adding an assert call:

$a = $_GET['foo'];
assert(is_string($a));

or by adding an explicit cast:

$a = (string) $_GET['foo'];

or by adding a docblock

/** @var string */
$a = $_GET['foo'];