psalm icon indicating copy to clipboard operation
psalm copied to clipboard

@psalm-assert cannot be used with imported and aliased types.

Open rzvc opened this issue 1 year ago • 1 comments

Same symptoms as #8263.

https://psalm.dev/r/4da30212ca

rzvc avatar Feb 12 '24 06:02 rzvc

I found these snippets:

https://psalm.dev/r/4da30212ca
<?php

/**
* @psalm-type Foo = 'a'|'b'
*/
class Dummy
{
}

/**
* @psalm-import-type Foo from Dummy as Bar
*/
class Dummy2
{
}

/**
* @psalm-assert Bar $param
*/
function test(mixed $param) : bool
{
    echo (string)$param;
    return true;
}

function caller(string $value) : void
{
    if (test($value))
        error_log('something');
}
Psalm output (using commit cb0e6a1):

ERROR: TypeDoesNotContainType - 28:9 - Cannot resolve types for $value - string does not contain type-alias(Dummy::Foo)

psalm-github-bot[bot] avatar Feb 12 '24 06:02 psalm-github-bot[bot]