Last active
November 20, 2023 04:29
-
-
Save Exon0/d5b8a4e2f7bb6f07d3031a4a66f5ddd0 to your computer and use it in GitHub Desktop.
Annotations to attributes symfony 5.4
This file contains hidden or 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
Follow these steps to refactor annotations to attributes in a symfony 5.4+ project | |
### **Annotation to attribute steps:** ## | |
1) Install rector: | |
composer require rector/rector --dev | |
2) Create rector.php | |
vendor/bin/rector init | |
3) Add the following code to rector.php | |
``` | |
use Rector\Doctrine\Set\DoctrineSetList; | |
use Rector\Php74\Rector\Property\TypedPropertyRector; | |
use Rector\Set\ValueObject\SetList; | |
use Rector\Config\RectorConfig; | |
use Rector\Symfony\Set\SymfonySetList; | |
return static function (RectorConfig $rectorConfig): void { | |
// here we can define, what sets of rules will be applied | |
// tip: use "SetList" class to autocomplete sets | |
$rectorConfig->sets([ | |
SetList::CODE_QUALITY, | |
SensiolabsSetList::ANNOTATIONS_TO_ATTRIBUTES | |
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, | |
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES, | |
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION, | |
SymfonySetList::SYMFONY_CODE_QUALITY | |
]); | |
// register single rule | |
$rectorConfig->rule(TypedPropertyRector::class); | |
}; | |
4) remove the starting semicolon ( ; ) from your xampp/php/php.ini | |
;extension=php_intl.dll | |
5) run refactor | |
vendor/bin/rector process | |
Reference : https://github.com/rectorphp/rector |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment