Skip to content

Union Types - is not contravariant with parameter #4179

@Carpenter0100

Description

@Carpenter0100

Bug report

PHPStan - PHP Static Analysis Tool 0.12.58

Hi,
first, thank you for phpstan!
I switched to union types and got following error:

Parameter #2 $pathConstraint (array|string|null) of method Pipeline::pipe() is not contravariant with parameter #2 $pathConstraint (array|null|string|null) of method PipelineInterface::pipe().

Here is the code snippet.
https://phpstan.org/r/f4b0f601-2de8-401e-9460-bbf2a254acc1

May I am missing something but isn´t it valid?

Expected output

No error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions