Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeDoesNotContainType caused by implemented interface and extended class mix #3917

Closed
ntzm opened this issue Jul 31, 2020 · 1 comment
Closed
Labels

Comments

@ntzm
Copy link
Contributor

ntzm commented Jul 31, 2020

https://psalm.dev/r/a4aded111f

It is perfectly possible for the statement get_class($this) === get_class($other) to return true or false

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/a4aded111f
<?php

interface Id
{
    public function is(Id $other): bool;
    
    public function asString(): string;
}

abstract class UuidId
{
 	final public function is(Id $other): bool
    {
        return get_class($this) === get_class($other) && $this->asString() === $other->asString();
    }
    
    final public function asString(): string
    {
        return '';
    }
}

interface EventId extends Id
{
}

final class UuidEventId extends UuidId implements EventId
{   
}
Psalm output (using commit afd8874):

ERROR: TypeDoesNotContainType - 14:16 - class-string<Id> cannot be identical to class-string<UuidId>

@weirdan weirdan added the bug label Jul 31, 2020
@muglug muglug closed this as completed in cb24377 Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants