-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DowngradePhp80] Downgrade same line attribute on non-removed attribu…
…te on DowngradeAttributeToAnnotationRector (#251) * [DowngradePhp80] Downgrade same line attribute on non-removed attribute on DowngradeAttributeToAnnotationRector * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <[email protected]>
- Loading branch information
1 parent
ecd33d6
commit 4201862
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...s/DowngradeAttributeSameLineWithPromotion/DowngradeAttributeSameLineWithPromotionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Issues\DowngradeAttributeSameLineWithPromotion; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class DowngradeAttributeSameLineWithPromotionTest 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'; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/Issues/DowngradeAttributeSameLineWithPromotion/Fixture/fixture.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\DowngradeAttributeSameLineWithPromotion\Fixture; | ||
|
||
#[\Attribute]final class WithSameLine | ||
{ | ||
public function __construct(public string $a) | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Issues\DowngradeAttributeSameLineWithPromotion\Fixture; | ||
|
||
#[\Attribute] | ||
final class WithSameLine | ||
{ | ||
public string $a; | ||
public function __construct(string $a) | ||
{ | ||
$this->a = $a; | ||
} | ||
} | ||
|
||
?> |
11 changes: 11 additions & 0 deletions
11
tests/Issues/DowngradeAttributeSameLineWithPromotion/config/configured_rule.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector; | ||
use Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rules([DowngradeAttributeToAnnotationRector::class, DowngradePropertyPromotionRector::class]); | ||
}; |