Skip to content

AddClosureParamTypeForArrayReduceRector doesn't agree with doctrine collections. #9016

@mickverm

Description

@mickverm

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:

Expected Behaviour

No error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions