-
Notifications
You must be signed in to change notification settings - Fork 664
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
ArgumentTypeCoercion for static in 3.11.0 #3127
Labels
Comments
I found these snippets: https://psalm.dev/r/cc4ea0abe5<?php
/**
* @psalm-immutable
*/
abstract class Id
{
protected string $id;
final protected function __construct(string $id)
{
$this->id = $id;
}
/**
* @param static $id
*/
final public function equals(self $id): bool
{
return $this->id === $id->id;
}
}
/**
* @template T of Id
*/
final class Ids
{
/**
* @psalm-var list<T>
*/
private array $ids;
/**
* @psalm-param list<T> $ids
*/
private function __construct(array $ids)
{
$this->ids = $ids;
}
/**
* @psalm-param T $id
*/
public function contains(Id $id): bool
{
foreach ($this->ids as $oneId) {
if ($oneId->equals($id)) {
return true;
}
}
return false;
}
}
|
Why do you think it's correct? |
@weirdan , as I said, if I have |
Okay, maybe I am overthinking this and it's just a bug :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/cc4ea0abe5
I think this is the correct behavior of Psalm, just want to make sure I understand the edge case.
If I have
abstract class AbstractId extends Id
and thenIds<AbstractId>
, theIds<AbstractId>::contains
method will not work correctly, right?The text was updated successfully, but these errors were encountered: