Skip to content

AddClosureParamTypeForArrayReduceRector breaks with nullable values #9495

@Mika-

Description

@Mika-

Bug Report

Subject Details
Rector version 2.2.8

Rector tries to create a union type with 0, float|int for $carry but fails. This is triggered by a method returning float|null. Without nullability we get a proper type with float|int.

This could be a wider problem where narrover type is already covered, as I'm seeing similar issues with arrays trying to create a union type eg with array{null, null}, array{mixed, mixed}|TReturn.

Minimal PHP Code Causing Issue

https://getrector.com/demo/1837abc8-d65a-46f0-9fc4-fe7df5f697d5

Expected Behaviour

$carry typed with float|int. 0 + null results 0 and it's covered by int.

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