-
-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Transform] Do not create a new node if the existing node is already …
…the correct one on AttributeKeyToClassConstFetchRector (#5328) * Write testcase to show existing attributes are replaced by new nodes * Do not replace existing constant nodes if they are already the correct ones --------- Co-authored-by: SerethiX <[email protected]>
- Loading branch information
Showing
7 changed files
with
89 additions
and
14 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
15 changes: 15 additions & 0 deletions
15
...ibute/AttributeKeyToClassConstFetchRector/Fixture/not_replacing_existing_constant.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,15 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector\Fixture; | ||
|
||
use Doctrine\ORM\Mapping\Column; | ||
use Rector\Tests\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector\Source\Constant; | ||
use Rector\Tests\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector\Source\TestAttribute; | ||
|
||
class SomeClass | ||
{ | ||
#[TestAttribute(type: Constant::VALUE)] | ||
public string $name; | ||
} | ||
|
||
?> |
15 changes: 15 additions & 0 deletions
15
...ansform/Rector/Attribute/AttributeKeyToClassConstFetchRector/Fixture/skip_already.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,15 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector\Fixture; | ||
|
||
use Doctrine\ORM\Mapping\Column; | ||
|
||
use Doctrine\DBAL\Types\Types; | ||
|
||
class SkipAlready | ||
{ | ||
#[Column(type: Types::STRING)] | ||
public $name; | ||
} | ||
|
||
?> |
10 changes: 10 additions & 0 deletions
10
...-tests/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector/Source/Constant.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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector\Source; | ||
|
||
class Constant | ||
{ | ||
public const VALUE = 'value'; | ||
} |
16 changes: 16 additions & 0 deletions
16
...s/Transform/Rector/Attribute/AttributeKeyToClassConstFetchRector/Source/TestAttribute.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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector\Source; | ||
|
||
use Attribute; | ||
|
||
#[Attribute(Attribute::TARGET_PROPERTY)] | ||
class TestAttribute | ||
{ | ||
public function __construct( | ||
public readonly string $type, | ||
) { | ||
} | ||
} |
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
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