The followings rector line configs
- Install
rector/rector
if not already done (init file by launchingvendor/bin/rector process
) : see how to install - Edit your
rector.php
file by adding this :
$rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [
new \Rector\Php80\ValueObject\AnnotationToAttribute('Mapado\\RestClientSdk\\Mapping\\Annotations\\Id', 'Mapado\\RestClientSdk\\Mapping\\Attributes\\Id'),
new \Rector\Php80\ValueObject\AnnotationToAttribute('Mapado\\RestClientSdk\\Mapping\\Annotations\\Entity', 'Mapado\\RestClientSdk\\Mapping\\Attributes\\Entity'),
new \Rector\Php80\ValueObject\AnnotationToAttribute('Mapado\\RestClientSdk\\Mapping\\Annotations\\Attribute', 'Mapado\\RestClientSdk\\Mapping\\Attributes\\Attribute'),
new \Rector\Php80\ValueObject\AnnotationToAttribute('Mapado\\RestClientSdk\\Mapping\\Annotations\\ManyToOne', 'Mapado\\RestClientSdk\\Mapping\\Attributes\\ManyToOne'),
new \Rector\Php80\ValueObject\AnnotationToAttribute('Mapado\\RestClientSdk\\Mapping\\Annotations\\OneToMany', 'Mapado\\RestClientSdk\\Mapping\\Attributes\\OneToMany'),
]);
$rectorConfig->rule(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class);
$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);
- Launch
vendor/bin/rector
- Replace namespace
- use Mapado\RestClientSdk\Mapping\Annotations as Rest;
+ use Mapado\RestClientSdk\Mapping\Attributes as Rest;
- Replace annotations by attributes
Example :
- /**
- * @Rest\Attribute(name="id", type="string")
- /
+ #[Rest\Attribute(name: 'id', type: 'string')]
private $var;
- Replace repositories class name in
Entity
attribute by class constants
+ use Mapado\Component\TicketingModel\Model\Repository\ProductRepository;
- #[Rest\Entity(key: 'products', repository:' Mapado\Component\TicketingModel\Model\Repository\ProductRepository')]
+ #[Rest\Entity(key: 'users', repository: ProductRepository::class)]
class Product {
}