Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Identify value range by max return #9586

@LucianoHanna

Description

@LucianoHanna

Feature request

Hi,

It would be nice if phpstan identify possible values for a variable, for example:


$a = rand(0,5);
$b = rand(0,5);
$c = rand(0,5);

$max = max($a, $b, $c);

$h = match($max) {
	$a => 0,
	$b => 1,
	$c => 2, 
};

$max value is $a, $b or $c, so match expression are handling all possible values.

https://phpstan.org/r/c6fff031-9d48-46fe-8af3-66f3d84dfed6

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

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions