Skip to content

Incorrect behavior of DataProviderArrayItemsNewLinedRector #9689

@mvhirsch

Description

@mvhirsch

Bug Report

Subject Details
Rector version v2.3.8
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/74dc9db5-9d81-42d6-9d0e-5a8bdcc1c6dc

<?php

use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

final class ImporterTest extends TestCase
{  
    #[Test]
    public function severalQueries(): void
    {
        $importer = self::createMock(Importer::class);
        $importer->expects($invokedCount)
            ->method('processFiles')
            ->willReturnCallback(function (array $parameters) use ($invokedCount): array {
                switch ($invokedCount->numberOfInvocations()) {
                    case 1:
                        self::assertSame(range(1, 250), $parameters);

                        return [233, [], []];
                    case 2:
                        self::assertSame(range(251, 500), $parameters);

                        return [15, [], []];

                    default:
                        throw new \OutOfBoundsException('Did not expect this to run thrice.');
                }
            });
    }
}

Responsible rules

  • DataProviderArrayItemsNewLinedRector

Expected Behavior

No changes, as I'm not building a dataprovider, but a test here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions