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

@psalm-require-extends does not consider generics #10900

Open
alex-dev opened this issue Apr 11, 2024 · 1 comment
Open

@psalm-require-extends does not consider generics #10900

alex-dev opened this issue Apr 11, 2024 · 1 comment

Comments

@alex-dev
Copy link

https://psalm.dev/r/346857a814

Copy link

I found these snippets:

https://psalm.dev/r/346857a814
<?php

/** @template T */
class A {
    /** @param T $a */
    public function __construct(protected readonly $a) {}
}

/**
 * @template T
 * @psalm-require-extends A<T>
 */
trait C {
	/** @return T */
    public function a() { return $this->a; }
}

/**
 * @template T
 * @extends A<T>
 */
class B extends A {
    /** @use C<T> */
	use C;
}

/** @psalm-trace $_a */
$_a = (new B('ssss'))->a();
Psalm output (using commit ef3b018):

INFO: Trace - 28:1 - $_a: mixed

ERROR: ExtensionRequirementViolation - 24:6 - C requires using class to extend A<T>, but B does not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant