-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php80] Handle FQCN @\ usage on AnnotationToAttributeRector (#5240)
* [Php80] Handle FQCN @\ usage on AnnotationToAttributeRector * [ci-review] Rector Rectify * update fixture * update config * fix fixture * fixed * fixture * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
520829e
commit 51695ae
Showing
4 changed files
with
100 additions
and
3 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
48 changes: 48 additions & 0 deletions
48
tests/Issues/FqcnAnnotationToAttribute/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,48 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\FqcnAnnotationToAttribute\Fixture; | ||
|
||
/** | ||
* @\Doctrine\ORM\Mapping\Entity() | ||
* @\Doctrine\ORM\Mapping\Table("user", indexes={ | ||
* @\Doctrine\ORM\Mapping\Index(name="name_index", columns={"name"}), | ||
* @\Doctrine\ORM\Mapping\Index(name="surname_index", columns={"surname"}), | ||
* }) | ||
* @\Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity("azureB2cUuid") | ||
* @\Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity("uuid") | ||
* @\Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity("email") | ||
*/ | ||
class Entity | ||
{ | ||
/** | ||
* @\Symfony\Component\Validator\Constraints\NotBlank() | ||
* @\Symfony\Component\Validator\Constraints\Email(mode="strict") | ||
* @\Doctrine\ORM\Mapping\Column(type="string", unique=true) | ||
* @\Symfony\Component\Serializer\Annotation\Groups({"import", "export-user", "export-claim"}) | ||
*/ | ||
protected string $email = ""; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\FqcnAnnotationToAttribute\Fixture; | ||
|
||
#[\Doctrine\ORM\Mapping\Entity] | ||
#[\Doctrine\ORM\Mapping\Index(name: 'name_index', columns: ['name'])] | ||
#[\Doctrine\ORM\Mapping\Index(name: 'surname_index', columns: ['surname'])] | ||
#[\Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity('azureB2cUuid')] | ||
#[\Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity('uuid')] | ||
#[\Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity('email')] | ||
#[\Doctrine\ORM\Mapping\Table('user')] | ||
class Entity | ||
{ | ||
#[\Symfony\Component\Validator\Constraints\NotBlank] | ||
#[\Symfony\Component\Validator\Constraints\Email(mode: 'strict')] | ||
#[\Doctrine\ORM\Mapping\Column(type: 'string', unique: true)] | ||
#[\Symfony\Component\Serializer\Annotation\Groups(['import', 'export-user', 'export-claim'])] | ||
protected string $email = ""; | ||
} | ||
|
||
?> |
28 changes: 28 additions & 0 deletions
28
tests/Issues/FqcnAnnotationToAttribute/FqcnAnnotationToAttributeTest.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\FqcnAnnotationToAttribute; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class FqcnAnnotationToAttributeTest 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'; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/Issues/FqcnAnnotationToAttribute/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,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Symfony\Set\SymfonySetList; | ||
use Rector\Doctrine\Set\DoctrineSetList; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->sets([ | ||
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES, | ||
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, | ||
]); | ||
}; |