Skip to content

Pass by reference changes type to mixed with no way to avoid this in annotation #5785

@leongersen

Description

@leongersen

Bug report

I wasn't sure whether to report this as a bug or a feature request.

Code snippet that reproduces the problem

https://phpstan.org/r/32817f47-8e5a-4aa6-9d31-c2aa9493f656

/**
 * @template T
 * @param iterable<T> $iterable
 */
public static function act(iterable &$iterable): void { }

Expected output

When viewing this as a bug report: I expected both dumped types to be array<HelloWorld>

When viewing this as a feature request: I'd like to be able to annotate what the type of the argument will be after calling the method.

Did PHPStan help you today? Did it make you happy in any way?

I've created a couple of issues in a row; my intent is to help improve PHPStan where I can. I love working with the generics support, it allows for such amazing code improvements! If I can help solve these issues, please let me know!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions