Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
bootstrap="vendor/autoload.php"
colors="true"
displayDetailsOnTestsThatTriggerWarnings="true"
failOnWarning="true"
failOnNotice="true"
>
<testsuites>
<testsuite name="main">
Expand Down
2 changes: 1 addition & 1 deletion src/NodeFactory/ConsecutiveIfsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{
public function __construct(
private NodeNameResolver $nodeNameResolver,
private readonly NestedClosureAssertFactory $nestedClosureAssertFactory
private NestedClosureAssertFactory $nestedClosureAssertFactory
) {
}

Expand Down
28 changes: 28 additions & 0 deletions tests/Issues/AnnotationParsing/AnnotationParsingTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\PHPUnit\Tests\Issues\WrongAnnotation;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class AnnotationParsingTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
{
$this->doTestFile($filePath);
}

public static function provideData(): Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

public function provideConfigFilePath(): string
{
return __DIR__ . '/config/configured_rule.php';
}
}
57 changes: 57 additions & 0 deletions tests/Issues/AnnotationParsing/Fixture/some_test.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Rector\PHPUnit\Tests\Issues\AnnotationParsing\Fixture;

use PHPUnit\Framework\TestCase;

final class SomeTest extends TestCase
{
#[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')]
public function test(?bool $param1, string $param2, bool $param3)
{
$this->assertTrue($param1);
$this->assertSame('string', $param2);
$this->assertTrue($param3);
}

/**
* @return array<array{0: bool|null, 1: string, 2: bool}>
*/
public static function dataProvider(): array
{
return [
'data1' => [null, 'string', false],
'data2' => [false, 'string', false],
];
}
}

?>
-----
<?php

namespace Rector\PHPUnit\Tests\Issues\AnnotationParsing\Fixture;

use PHPUnit\Framework\TestCase;

final class SomeTest extends TestCase
{
#[\PHPUnit\Framework\Attributes\DataProvider('dataProvider')]
public function test(?bool $param1, string $param2, bool $param3)
{
$this->assertTrue($param1);
$this->assertSame('string', $param2);
$this->assertTrue($param3);
}

/**
* @return \Iterator<(int | string), array{(bool | null), string, bool}>
*/
public static function dataProvider(): \Iterator
{
yield 'data1' => [null, 'string', false];
yield 'data2' => [false, 'string', false];
}
}

?>
11 changes: 11 additions & 0 deletions tests/Issues/AnnotationParsing/config/configured_rule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([YieldDataProviderRector::class, RemoveUselessReturnTagRector::class]);
};