-
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
Could not infer a return type for array_reduce #5574
Labels
Comments
I found these snippets: https://psalm.dev/r/57243f56e5<?php
/**
* @template TKey as array-key
* @template TValue as mixed
*/
abstract class AbstractCollection
{
/**
* @readonly
* @var array<TKey, TValue>
*/
private array $items;
/**
* @param array<TKey, TValue> $items
*/
final public function __construct(array $items)
{
$this->items = $items;
}
/**
* @template TReturn
* @template TInitial
* @param callable(TInitial|TReturn|null,TValue):(TInitial|TReturn) $callback
* @param TInitial|null $initial
* @return TReturn|TInitial|null
*/
public function reduce(callable $callback, $initial = null)
{
return array_reduce($this->items, $callback, $initial);
}
}
|
There is |
It seems to be fixed: https://psalm.dev/r/755aef1954 |
I found these snippets: https://psalm.dev/r/755aef1954<?php
/**
* @template TKey as array-key
* @template TValue as mixed
*/
abstract class AbstractCollection
{
/**
* @readonly
* @var array<TKey, TValue>
*/
private array $items;
/**
* @param array<TKey, TValue> $items
*/
final public function __construct(array $items)
{
$this->items = $items;
}
/**
* @template TReturn
* @template TInitial
* @param callable(TInitial|TReturn|null,TValue):(TInitial|TReturn) $callback
* @param TInitial|null $initial
* @return TReturn|TInitial|null
*/
public function reduce(callable $callback, $initial = null)
{
return array_reduce($this->items, $callback, $initial);
}
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://psalm.dev/r/57243f56e5
Gives
Can it be fixed?
The text was updated successfully, but these errors were encountered: