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

MismatchingDocblockReturnType with iterable|object #10917

Open
priyadi opened this issue Apr 20, 2024 · 1 comment
Open

MismatchingDocblockReturnType with iterable|object #10917

priyadi opened this issue Apr 20, 2024 · 1 comment

Comments

@priyadi
Copy link

priyadi commented Apr 20, 2024

I believe this should not result in a MismatchingDocblockReturnType

https://psalm.dev/r/e367d0726c

/**
 * @template T
 */
interface FooInterface {
    /**
     * @return T|iterable<T>|null
     */
    public function foo(): object|array|null;
}

Using T|array<T>|\Traversable<T>|null also gives the same result.

Copy link

I found these snippets:

https://psalm.dev/r/e367d0726c
<?php

/**
 * @template T
 */
interface FooInterface {
    /**
     * @return T|iterable<T>|null
     */
    public function foo(): object|array|null;
}
Psalm output (using commit 08afc45):

ERROR: MismatchingDocblockReturnType - 8:16 - Docblock has incorrect return type '(T:FooInterface as mixed)|(iterable<mixed, T:FooInterface as mixed>)|null', should be 'array<array-key, mixed>|null|object'

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