-
Notifications
You must be signed in to change notification settings - Fork 661
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
Incorrect comparison of inherited "static" types #11139
Comments
I found these snippets: https://psalm.dev/r/e205e7be5f<?php
declare(strict_types=1);
interface AI
{
/**
* @return $this
*/
public function test(): static;
}
class A implements AI
{
#[Override]
public function test(): static
{
return $this;
}
}
class B extends A
{
#[Override]
public function test(): static
{
return parent::test();
}
}
https://psalm.dev/r/0535cc284a<?php
declare(strict_types=1);
interface AI
{
/**
* @return $this
*/
public function test(): static;
}
class A implements AI
{
/**
* @return $this
*/
#[Override]
public function test(): static
{
return $this;
}
}
class B extends A
{
/**
* @return $this
*/
#[Override]
public function test(): static
{
return parent::test();
}
}
|
https://psalm.dev/r/51e9ac4bb6 Here is another case |
I found these snippets: https://psalm.dev/r/51e9ac4bb6<?php
declare(strict_types=1);
interface I
{
/**
* return $this
*/
public function test(): static;
}
trait T1
{
#[Override]
public function test(): static
{
return $this;
}
}
trait T2
{
use T1;
abstract public function test(): static;
}
class A
{
use T1;
use T2;
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/e205e7be5f
https://psalm.dev/r/0535cc284a
I expect that these 2 examples should pass the test equally correctly, since the types should inherit from the interface, but for some reason this does not happen.
The text was updated successfully, but these errors were encountered: