-
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
Expects T:fn-a as object, object provided #5279
Labels
Comments
I found these snippets: https://psalm.dev/r/b70f1af09b<?php
interface Serializer
{
/**
* @param mixed $data
*/
public function serialize($data): string;
/**
* @return mixed
*
* @psalm-template T
* @psalm-param class-string<T> $type
* @psalm-return T
*/
public function deserialize(string $data, string $type);
}
/**
* @template T of object
* @psalm-param T $serializable
* @psalm-param callable(T, T): void $cmp
*/
function a(Serializer $serializer, $serializable, callable $cmp) : void
{
$serialized = $serializer->serialize($serializable);
$deserialized = $serializer->deserialize($serialized, get_class($serializable));
$cmp($serializable, $deserialized);
}
|
Simplified: https://psalm.dev/r/93c8173378 |
I found these snippets: https://psalm.dev/r/93c8173378<?php
/**
* @template T of object
* @psalm-param T $obj
* @return T
*/
function a(string $str, object $obj) {
$class = get_class($obj);
return deserialize_object($str, $class);
}
/**
* @psalm-template T
* @psalm-param class-string<T> $type
* @psalm-return T
* @psalm-suppress InvalidReturnType
*/
function deserialize_object(string $data, string $type) {}
|
This was referenced Mar 15, 2021
This was referenced Mar 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/b70f1af09b
callback expects an object and I passed an object. It is not very clear what is the issue in the code / psalm bug?
The text was updated successfully, but these errors were encountered: