mirror of
https://github.com/danog/psalm.git
synced 2024-12-13 17:57:37 +01:00
506 B
506 B
MixedAssignment
Emitted when assigning an unannotated variable to a value for which Psalm
cannot infer a type more specific than mixed
.
<?php
$a = $GLOBALS['foo'];
How to fix
The above example can be fixed in a few ways – by adding an assert
call:
<?php
$a = $GLOBALS['foo'];
assert(is_string($a));
or by adding an explicit cast:
<?php
$a = (string) $GLOBALS['foo'];
or by adding a docblock
<?php
/** @var string */
$a = $GLOBALS['foo'];