JakubMisek Excatly, @phpstan-assert is respected, but @psalm-assert is not. I assume that is as bug? 😁
I was merely testing this using the webmozarts/assert package.
See how it annotates the methods:
/**
* @psalm-pure
*
* @psalm-template ExpectedType of object
*
* @psalm-param class-string<ExpectedType> $class
*
* @psalm-assert ExpectedType $value
*
* @param mixed $value
* @param string|object $class
* @param string $message
*
* @return void
*
* @throws InvalidArgumentException
*/
public static function isInstanceOf($value, $class, $message = '')
{
if (!($value instanceof $class)) {
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an instance of %2$s. Got: %s',
static::typeToString($value),
$class
));
}
}
The problem is that after calling Assert::isInstanceOf($obj, SomeClass::class) PHP DEVSENSE doesn't recognize $obj to be SomeClass afterwards, so autocompletion fails.