Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 494 Bytes

MixedAssignment.md

File metadata and controls

38 lines (25 loc) · 494 Bytes

MixedAssignment

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

<?php

$a = $_GET['foo'];

How to fix

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

<?php

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

or by adding an explicit cast:

<?php

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

or by adding a docblock

<?php

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