-
Notifications
You must be signed in to change notification settings - Fork 663
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
Trait template type check fails for static methods #5753
Comments
I found these snippets: https://psalm.dev/r/917c4e806c<?php
/**
* @template T
*/
trait MyTrait {
/** @param T $arg */
abstract public function bar($arg): void;
/** @param T $arg */
abstract public static function baz($arg): void;
}
class Foo {
/**
* @use MyTrait<int>
*/
use MyTrait;
/** @param int $arg */
public function bar($arg): void {}
/** @param int $arg */
public static function baz($arg): void {}
}
https://psalm.dev/r/ed6e47c8e4<?php
/**
* @template T
*/
abstract class Foo {
/** @param T $arg */
abstract public function bar($arg): void;
/** @param T $arg */
abstract public static function baz($arg): void;
}
/** @extends Foo<int> */
class Bar extends Foo {
/** @param int $arg */
public function bar($arg): void {}
/** @param int $arg */
public static function baz($arg): void {}
}
|
Closed
Is this still an issue? |
I'm experiencing the same issue with interfaces: https://psalm.dev/r/5bdf9334de |
I found these snippets: https://psalm.dev/r/5bdf9334de<?php
/**
* @template T
*/
interface Foo
{
/** @param T $data */
public static function test($data) : void;
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/917c4e806c
False positive ImplementedParamTypeMismatch on
baz
, butbar
works fine.Probably has something to do with the way classes ignore templates for static methods, this doesn't seem to work at all. Of course the
T
param onFoo::baz
can't be resolved and would have to bemixed
sinceFoo
isn't instantiated, but it might make sense to allow this so children can extend with tighter template restrictions and haveBar::baz
take anint
.The text was updated successfully, but these errors were encountered: