-
Notifications
You must be signed in to change notification settings - Fork 650
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect ImplementedReturnTypeMismatch #3760
Comments
I found these snippets: https://psalm.dev/r/b4af700040<?php
/**
* @template Tk of array-key
* @template Tv
*/
interface Collection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return Collection<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): Collection;
}
/**
* @template Tk of array-key
* @template Tv
* @extends Collection<Tk, Tv>
*/
interface MutableCollection extends Collection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return MutableCollection<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): MutableCollection;
}
/**
* @template Tk of array-key
* @template Tv
* @extends Collection<Tk, Tv>
*/
interface Map extends Collection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return Map<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): Map;
}
/**
* @template Tk of array-key
* @template Tv
* @extends Map<Tk, Tv>
* @extends MutableCollection<Tk, Tv>
*/
interface MutableMap extends Map, MutableCollection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return MutableMap<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): MutableMap;
}
|
currently https://github.com/azjezz/psl has only this issue left before it hits 100% code coverage 馃槃 |
You just need to define the template |
I found these snippets: https://psalm.dev/r/38ae009d63<?php
/**
* @template Tk of array-key
* @template-covariant Tv
*/
interface Collection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return Collection<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): Collection;
}
/**
* @template Tk of array-key
* @template-covariant Tv
* @extends Collection<Tk, Tv>
*/
interface MutableCollection extends Collection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return MutableCollection<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): MutableCollection;
}
/**
* @template Tk of array-key
* @template-covariant Tv
* @extends Collection<Tk, Tv>
*/
interface Map extends Collection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return Map<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): Map;
}
/**
* @template Tk of array-key
* @template Tv
* @extends Map<Tk, Tv>
* @extends MutableCollection<Tk, Tv>
*/
interface MutableMap extends Map, MutableCollection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return MutableMap<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): MutableMap;
}
|
I think i don't understand what
interface A<Tk, Tv> {
public function zip<Tu>(Container<Tu> $container): A<Tk, (Tv, Tu)>;
}
interface B<Tk, Tv> extends A<Tk, Tv> {
public function zip<Tu>(Container<Tu> $container): B<Tk, (Tv, Tu)>;
public function filter((function(Tv): bool) $func): B<Tk, Tv>;
}
interface C<Tk, Tv> extends A<Tk, Tv> {
public function zip<Tu>(Container<Tu> $container): C<Tk, (Tv, Tu)>;
}
interface D<Tk, Tv> extends B<Tk, Tv>, C<Tk, Tv> {
public function zip<Tu>(Container<Tu> $container): D<Tk, (Tv, Tu)>;
public function filter((function(Tv): bool) $func): D<Tk, Tv>;
}
|
I found these snippets: https://psalm.dev/r/53aa1bd176<?php
/**
* @template Tk of array-key
* @template-covariant Tv
*/
interface Collection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return Collection<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): Collection;
}
/**
* @template Tk of array-key
* @template-covariant Tv
* @extends Collection<Tk, Tv>
*/
interface MutableCollection extends Collection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return MutableCollection<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): MutableCollection;
}
/**
* @template Tk of array-key
* @template-covariant Tv
* @extends Collection<Tk, Tv>
*/
interface Map extends Collection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return Map<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): Map;
/**
* @param (callable(Tv): bool) $func
*
* @return Map<Tk, Tv>
*/
public function filter(callable $func): Map;
}
/**
* @template Tk of array-key
* @template Tv
* @extends Map<Tk, Tv>
* @extends MutableCollection<Tk, Tv>
*/
interface MutableMap extends Map, MutableCollection {
/**
* @template Tu
* @param iterable<Tu> $iterable
* @return MutableMap<Tk, array{0: Tv, 1: Tu}>
*/
public function zip(iterable $iterable): MutableMap;
/**
* @param (callable(Tv): bool) $func
*
* @return MutableMap<Tk, Tv>
*/
public function filter(callable $func): MutableMap;
}
|
Yeah definitely buggy behaviour actually |
@azjezz happy for you to add this to |
I'll make sure to send a PR once 100% type coverage is achieved in PSL. Thank you for the fix. |
I have encountered this issue 3 times before, and every time it finds it's way back into psalm 馃
snippet: https://psalm.dev/r/b4af700040
related issues:
The text was updated successfully, but these errors were encountered: