-
-
Notifications
You must be signed in to change notification settings - Fork 741
Closed
rectorphp/rector-src
#6729Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | 2.0.9 |
<?php
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
$items = ['a', 'b', 'b', 'c'];
$reduces = \array_reduce($items, static function (Collection $carry, string $item) {
if (!$carry->contains($item)) {
$carry->add($item);
}
return $carry;
}, new ArrayCollection());https://getrector.com/demo/04651a65-55f1-4a8e-9b1c-f4244b8334d1
It does work when:
- I replace
Collection $carrywithArrayCollection $carry. (https://getrector.com/demo/b07901ef-afab-4605-acba-a2e261ec2db0) - Or add a return type to the callback:
static function ($carry, string $item): ArrayCollection, but It doesn't add the type to$carry: https://getrector.com/demo/2e18305a-a744-4063-99fc-48a11d165f21
Expected Behaviour
No error.
Reactions are currently unavailable