readonly class Identifier extends Regexp
{
/**
* @param array<int,int>|array<int,string> $possibleValues
*/
public function __construct(array $possibleValues = [])
{
$regexp = implode('|', $possibleValues);
parent::__construct('' !== $regexp ? $regexp : null);
}
}
Everything works fine when i create an Identifierwith an array that contains a float, phpstan detects an error. But it does not detect any error when i create an Identifier with an array of int and string mixed like
$test = new Identifier([1,2,"test"];
Is there a way to tells phpStan that $possibleValues can be an array of int, an array of string but not a mix of int and string ?
array<int, int|string>. I tried with aList<int>|List<string>and some type aliases, but they all did the same thing, too.