-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AutoImport] Handle AnnotationToAttributeRector + RenameClassRector t…
…hen enable auto import (#5213) * [AutoImport] Handle AnnotationToAttributeRector + RenameClassRector then enable auto import * [ci-review] Rector Rectify * use * clean unrelated printing change * Fix * Fqcn test fixture * more fixture --------- Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
c1657f0
commit 3c526c9
Showing
6 changed files
with
160 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
...ssues/AnnotationToAttributeRenameAutoImport/AnnotationToAttributeRenameAutoImportTest.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\Core\Tests\Issues\AnnotationToAttributeRenameAutoImport; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class AnnotationToAttributeRenameAutoImportTest 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'; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/Issues/AnnotationToAttributeRenameAutoImport/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,29 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\AnnotationToAttributeRenameAutoImport\Fixture; | ||
|
||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
|
||
/** | ||
* @IsGranted("TEST") | ||
*/ | ||
class IsGrantedController extends AbstractController | ||
{ | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\AnnotationToAttributeRenameAutoImport\Fixture; | ||
|
||
use Symfony\Component\Security\Http\Attribute\IsGranted; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
|
||
#[IsGranted('TEST')] | ||
class IsGrantedController extends AbstractController | ||
{ | ||
} | ||
|
||
?> |
28 changes: 28 additions & 0 deletions
28
tests/Issues/AnnotationToAttributeRenameAutoImport/Fixture/not_imported_yet.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\Core\Tests\Issues\AnnotationToAttributeRenameAutoImport\Fixture; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
|
||
/** | ||
* @\Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted("TEST") | ||
*/ | ||
class NotImportedYet extends AbstractController | ||
{ | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\AnnotationToAttributeRenameAutoImport\Fixture; | ||
|
||
use Symfony\Component\Security\Http\Attribute\IsGranted; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
|
||
#[IsGranted('TEST')] | ||
class NotImportedYet extends AbstractController | ||
{ | ||
} | ||
|
||
?> |
29 changes: 29 additions & 0 deletions
29
tests/Issues/AnnotationToAttributeRenameAutoImport/Fixture/not_imported_yet2.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,29 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\AnnotationToAttributeRenameAutoImport\Fixture; | ||
|
||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
|
||
/** | ||
* @\Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted("TEST") | ||
*/ | ||
class NotImportedYet2 extends AbstractController | ||
{ | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\AnnotationToAttributeRenameAutoImport\Fixture; | ||
|
||
use Symfony\Component\Security\Http\Attribute\IsGranted; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
|
||
#[IsGranted('TEST')] | ||
class NotImportedYet2 extends AbstractController | ||
{ | ||
} | ||
|
||
?> |
23 changes: 23 additions & 0 deletions
23
tests/Issues/AnnotationToAttributeRenameAutoImport/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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Renaming\Rector\Name\RenameClassRector; | ||
use Rector\Config\RectorConfig; | ||
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; | ||
use Rector\Php80\ValueObject\AnnotationToAttribute; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->importNames(); | ||
|
||
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [ | ||
new AnnotationToAttribute('Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted'), | ||
]); | ||
|
||
$rectorConfig->ruleWithConfiguration( | ||
RenameClassRector::class, | ||
[ | ||
'Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted' => 'Symfony\Component\Security\Http\Attribute\IsGranted', | ||
], | ||
); | ||
}; |