Skip to content

Looping through an array shape has wrong count #3339

@allejo

Description

@allejo

Bug report

Given I'm using an array shape like array{bool, bool, bool}, it expects a key of int<min, 2>, where I would think it should be int<min, 3> or make it inclusive?

Code snippet that reproduces the problem

https://phpstan.org/r/eaaf2943-60db-49fa-9336-a2dead66c788

<?php declare(strict_types = 1);

class HelloWorld
{
	/** @var array{bool, bool, bool} */
	private $tuple;
	
	public function main(): void
	{
		$this->tuple = [true, true, true];
		
		for ($i = 0; $i < 3; ++$i)
		{
		    $this->tuple[$i] = false;
		}
	}
}

Expected output

I would think PHPStan should accept this code as valid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions