functional icon indicating copy to clipboard operation
functional copied to clipboard

ArrayList::prependedAll infer ArrayList<T|mixed> instead ArrayList<T>

Open klimick opened this issue 3 years ago • 0 comments

/**
 * @param ArrayList<int> $numbers
 */
function test(ArrayList $numbers): void {}

/**
 * @return ArrayList<int>
 */
function getNumbers(): ArrayList
{
    return ArrayList::empty();
}

/**
ERROR: MixedArgumentTypeCoercion
    at /app/run.php:34:5
    Argument 1 of test expects Fp\Collections\ArrayList<int>, parent type Fp\Collections\ArrayList<int|mixed> provided (see https://psalm.dev/194)
    getNumbers()->prepended(getNumbers())
*/
test(
    getNumbers()->prependedAll(getNumbers())
);

klimick avatar Jun 15 '22 18:06 klimick