Skip to content
Closed
Show file tree
Hide file tree
Changes from 10 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 phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ parameters:
- '#Register "Rector\\Php81\\Rector\\ClassMethod\\NewInInitializerRector" service to "php81\.php" config set#'

- '#Register "Rector\\Php80\\Rector\\NotIdentical\\MbStrContainsRector" service to "php80\.php" config set#'

- '#Register "Rector\\Php85\\Rector\\Class_\\FinalPropertyPromotionRector" service to "php85\.php" config set#'

# closure detailed
- '#Method Rector\\Config\\RectorConfig\:\:singleton\(\) has parameter \$concrete with no signature specified for Closure#'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector;

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

final class FinalPropertyPromotionRectorTest 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';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Fixture;

use Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Source\ParentClass;

class ChildExtendsParent extends ParentClass
{
public function __construct(
/** @final */
public string $idd
){}
}
?>
-----
<?php

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Fixture;

use Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Source\ParentClass;

class ChildExtendsParent extends ParentClass
{
public function __construct(
final public string $idd
){}
}
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Fixture;

class FinalPropertyPromotion
{
public function __construct(
/** @final */
public string $id
){}
}

?>
-----
<?php

declare(strict_types=1);

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Fixture;

class FinalPropertyPromotion
{
public function __construct(
final public string $id
){}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Fixture;

class FinalPropertyPromotion
{
public function __construct(
/** @final */
public readonly string $id
){}
}

?>
-----
<?php

declare(strict_types=1);

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Fixture;

class FinalPropertyPromotion
{
public function __construct(
final public readonly string $id
){}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Fixture;

class FinalPropertyPromotion
{
public function __construct(
final public string $id
){}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Fixture;

$obj = new class {
public function __construct(
/** @final */
public string $id
){}
};
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Fixture;

use Rector\Tests\Php82\Rector\Class_\FinalPropertyPromotionRector\Source\FinalParent;

class ChildExtendsFinalParent extends FinalParent
Comment thread
samsonasik marked this conversation as resolved.
Outdated
{
public function __construct(
/** @final */
public string $id
){}
}
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Fixture;

final class FinalPropertyPromotion
{
public function __construct(
/** @final */
public string $id
){}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Source;

final class FinalParent
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Rector\Tests\Php85\Rector\Class_\FinalPropertyPromotionRector\Source;

class ParentClass
{
}
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\Php85\Rector\Class_\FinalPropertyPromotionRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(FinalPropertyPromotionRector::class);

};
Loading
Loading