-
-
Notifications
You must be signed in to change notification settings - Fork 928
Description
Bug report
PHPStan doesn't correctly pick up an array mixed with a PromiseInterface<bool>
and a int
to PromiseInterface<bool|int>
. However, when you give it an array with either something wrapped into a PromiseInterface
or a scaler directly it works fine. Mixing those doesn't work as expected.
One of the errors we're seeing is Expected type React\Promise\PromiseInterface<array<bool|float>>, actual: React\Promise\PromiseInterface<array<bool>>
, more can be viewed here: https://github.com/reactphp/promise/pull/223/files#diff-a89942ba3e42bb9ac06fc0b54af222747ddae43390b0170ad1d680e140fd6f47R48 . The React\Promise\PromiseInterface<array<bool|float>>
PHPStan is erroring as wrong is the one we're expecting.
Code snippet that reproduces the problem
Tried to put this in https://phpstan.org/try several times and it sadly doesn't fit. The PR for this bug can be found here and the branch containing those changes here. It's not as easy as an /try
but after a git clone
, branch switch, composer install
, and then running vendor/bin/phpstan --configuration="phpstan.types.neon.dist"
should get you the same results as I'm seeing.
Expected output
No output, just green tests.
Did PHPStan help you today? Did it make you happy in any way?
Haven't come here until I was very certain this is a bug and not me misunderstanding her these things work in PHPStan. It is also only on specific functions dealing with an array of mixing PromiseInterface
and scalers. In that regard, PHPStan has already helped greatly in preparing to improve this.