Bug report
In here, i'm expecting return $to_box; in the inbox function to fail, as $to_box is known to be Box or Box<unknown> at this point, not Box<T>. as T has no constraints, and could itself be a Box.
This can cause actual problems down the line as shown with the following code, where phpstan incorrectly infers $box to be Box<Box<int>> where in reality, it is Box<int>.
Triggering an error at inbox will make the user rethink their design choice here, and won't allow for such bugs.
ref: vimeo/psalm#11492
Code snippet that reproduces the problem
https://phpstan.org/r/539c3023-65bf-46fa-a9d0-d09ce9cf1b17
Expected output
return $to_box; should trigger an invalid return statement error, as $to_box is Box<T>|Box, not Box<T>.
Did PHPStan help you today? Did it make you happy in any way?
No response
Bug report
In here, i'm expecting
return $to_box;in theinboxfunction to fail, as$to_boxis known to be Box orBox<unknown>at this point, notBox<T>. asThas no constraints, and could itself be aBox.This can cause actual problems down the line as shown with the following code, where phpstan incorrectly infers $box to be
Box<Box<int>>where in reality, it isBox<int>.Triggering an error at inbox will make the user rethink their design choice here, and won't allow for such bugs.
ref: vimeo/psalm#11492
Code snippet that reproduces the problem
https://phpstan.org/r/539c3023-65bf-46fa-a9d0-d09ce9cf1b17
Expected output
return $to_box;should trigger an invalid return statement error, as$to_boxisBox<T>|Box, notBox<T>.Did PHPStan help you today? Did it make you happy in any way?
No response