-
Notifications
You must be signed in to change notification settings - Fork 653
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
require-extends implications on the interface #10538
Comments
I found these snippets: https://psalm.dev/r/8aefff36a3<?php
namespace Bug10302InterfaceExtends;
use function PHPStan\Testing\assertType;
/**
* @psalm-require-extends SomeClass
*/
interface SampleInterface
{
}
class SomeClass {
public int $x;
protected string $y;
private array $z = [];
public function doFoo():int
{
return 1;
}
}
function test(SampleInterface $test): void
{
$test->x;
$test->y;
$test->z;
$test->doFoo();
}
function testExtendedInterface(AnotherInterface $test): void
{
$test->x;
$test->y;
$test->z;
$test->doFoo();
}
interface AnotherInterface extends SampleInterface
{
}
class SomeSubClass extends SomeClass {}
class ValidClass extends SomeClass implements SampleInterface {}
class ValidSubClass extends SomeSubClass implements SampleInterface {}
class InvalidClass implements SampleInterface {}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
recently I worked on adding psalm-require-extends semantics into phpstan.
in phpstan we allowed to access public properties and public methods on the interface type as an implication of using
psalm-require-extends
. It seems this is something missing in psalmthis issue is meant to discuss whether we could achieve feature parity in this regard.
see https://psalm.dev/r/8aefff36a3 vs https://phpstan.org/r/707a92dc-d8e7-4749-9eb4-06f796e5e432
you might be interessted more test-cases which have been added in the following PRs:
The text was updated successfully, but these errors were encountered: