You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code is valid for plain array_filter for the psalm. https://psalm.dev/r/31351f98b0
But if you try to do a similar thing with the collection psalm will tell it is not valid.
<?php
declare(strict_types=1);
require '../vendor/autoload.php';
use Doctrine\Common\Collections\ArrayCollection;
class Test {
public int $a = 1;
}
$array = [];
$array[] = random_int(0, 1) === 1 ? new Test : null;
$array = new ArrayCollection($array);
$array = $array->filter(static fn(?Test $t):bool => $t !== null);
$array = $array->map(static fn(Test $t) => $t->a);
foreach ($array as $t) {
echo $t;
}
The text was updated successfully, but these errors were encountered:
This code is valid for plain array_filter for the psalm.
https://psalm.dev/r/31351f98b0
But if you try to do a similar thing with the collection psalm will tell it is not valid.
The text was updated successfully, but these errors were encountered: