Skip to content

Loop boundary is wrongly detected when the initialization is not done "classically"  #3310

@lyrixx

Description

@lyrixx

Bug report

Hello,

It looks like the scope of loop variable to not clearly detected

Code snippet that reproduces the problem

https://phpstan.org/r/5cf62680-7651-4d08-bc82-69be0fe581aa

<?php 
declare(strict_types = 1);

function explain(int $bitField): void
{
	for ($i = 0; $i < 5; ++$i) {
	}
	for (; $i < 15; ++$i) {
	}
}

Expected output

no error :)


maybe related to

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions