Skip to content

Type of variable assigned in a parameter list is not preserved in following parameters #12735

@pauci

Description

@pauci

Bug report

When value is assigned to a variable within a parameter of a method call, it's type is not applied in context of remaining parameters.

$this->foo(
    $now = new DateTimeImmutable(),
    $now, // phpstan wrongly assumes the type is mixed here
);

There is a similar issue with assignment in arrays #12207

Code snippet that reproduces the problem

https://phpstan.org/r/59b9367b-8f29-4008-8536-91dca00362df

Expected output

There should be no issue detected.

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

PHPStan helps me every day, thank you so much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions