phpstan icon indicating copy to clipboard operation
phpstan copied to clipboard

Union Types - is not contravariant with parameter

Open simo-markus-noerenberg opened this issue 6 years ago • 3 comments

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.

simo-markus-noerenberg avatar Dec 03 '20 13:12 simo-markus-noerenberg

Hi, thank you very much, this is definitely a bug, I'll look into it very soon.

Also, thank you for the sponsorship! :)

ondrejmirtes avatar Dec 03 '20 13:12 ondrejmirtes

Fixed: https://github.com/phpstan/phpstan-src/pull/400

ondrejmirtes avatar Dec 07 '20 13:12 ondrejmirtes

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar May 04 '21 00:05 github-actions[bot]