It seems like $location can also be of type boolean; however, parameter $string of mb_substr() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
The expression return $location could return the type boolean|null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.