Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Rector\Core\Tests\Issues\Issue6840;

use Iterator;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;

/**
* @see https://github.com/rectorphp/rector/issues/6840
*/
final class ClassPropertyPromotionAndNewLineAfterStatementRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$this->doTestFileInfo($fileInfo);
}

/**
* @return Iterator<SmartFileInfo>
*/
public function provideData(): Iterator
{
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
}

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

namespace Rector\Core\Tests\Issues\Issue6840\Fixture;

class Fixture
{
protected string $imageId;
protected array $imageSize;

public function __construct($imageId)
{
$this->imageId = $imageId;
$this->imageSize = [];
}
}
?>
-----
<?php

namespace Rector\Core\Tests\Issues\Issue6840\Fixture;

class Fixture
{
private array $imageSize;

public function __construct(
private string $imageId
) {
$this->imageSize = [];
}
}
?>
14 changes: 14 additions & 0 deletions tests/Issues/Issue6840/config/configured_rule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;

return static function (ContainerConfigurator $containerConfigurator): void {

$services = $containerConfigurator->services();
$services->set(ClassPropertyAssignToConstructorPromotionRector::class);
$services->set(NewlineAfterStatementRector::class);
};