Here is very simplified example:
function getList<Tx>():Vector<Tx> {
$values = ['1','2','3','4','5'];
$list = Vector{};
foreach ($values as $value) {
$list->add((Tx) $value);
}
return $list;
}
For instance I know that $values are numeric, derrived from database fetching results or whatever, but stored as strings. So I want to cast them as int through
Vector<int> $myList = $this->getList<int>();
but
Object casts are unsupported. Try 'if ($var instanceof Tx)' or 'invariant($var instanceof Tx, ...)'. (Naming[2055])
So should I use two functions for different types in this case like getListInt():Vector<int>
and getListString():Vector<string>
or I do miss something?