Skip to content

Conversation

@samsonasik
Copy link
Member

@samsonasik samsonasik commented Jan 26, 2026

Given the following code:

    public function testThat($product)
    {
        foreach (self::TIME_UNITS as [$unit, $seconds]) {
            if ($product % $seconds === 0) {
                return [
                    'unit' => (string) $unit,
                    'value' => (int) ($product / $seconds),
                ];
            }
        }
    }

it got crash:

Time: 00:00.620, Memory: 76.50 MB

There was 1 error:

1) Rector\PHPUnit\Tests\CodeQuality\Rector\CallLike\DirectInstanceOverMockArgRector\DirectInstanceOverMockArgRectorTest::test with data set #3 ('/Users/samsonasik/www/rector-...hp.inc')
Rector\Exception\ShouldNotHappenException: Scope not available on "PhpParser\Node\ArrayItem" node. Fix scope refresh on changed nodes first

/Users/samsonasik/www/rector-phpunit/vendor/rector/rector-src/src/PHPStan/ScopeFetcher.php:26
/Users/samsonasik/www/rector-phpunit/rules/CodeQuality/Rector/CallLike/DirectInstanceOverMockArgRector.php:91

Ref rectorphp/rector#9620
see https://github.com/rectorphp/rector-phpunit/actions/runs/21367497756/job/61503133132#step:5:29

@samsonasik samsonasik changed the title [CodeQuality] Add failing fixture crash ArrayItem as Foreach_ value [CodeQuality] Add failing fixture crash ArrayItem as Foreach_ value on DirectInstanceOverMockArgRectorTest Jan 26, 2026
@samsonasik samsonasik changed the title [CodeQuality] Add failing fixture crash ArrayItem as Foreach_ value on DirectInstanceOverMockArgRectorTest [CodeQuality] Add failing fixture crash ArrayItem as Foreach_ value on DirectInstanceOverMockArgRector Jan 26, 2026
@samsonasik
Copy link
Member Author

The patch is in rector-src:

@samsonasik
Copy link
Member Author

I've pushed empty commit 1a08606 to trigger fetch latest rector-src patch here

@samsonasik
Copy link
Member Author

samsonasik commented Jan 26, 2026

All green now 🎉 @TomasVotruba let's merge ;)

@samsonasik samsonasik merged commit fcc50b9 into main Jan 26, 2026
7 checks passed
@samsonasik samsonasik deleted the add-failing-fixture-crash branch January 26, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants