Skip to content

Latest commit

 

History

History
54 lines (41 loc) · 2.15 KB

MIGRATION-2.0.md

File metadata and controls

54 lines (41 loc) · 2.15 KB

How to migrate from v0 to v1

Using rector

The followings rector line configs

  1. Install rector/rector if not already done (init file by launching vendor/bin/rector process) : see how to install
  2. 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);
  1. Launch vendor/bin/rector

Manually

  1. Replace namespace
- use Mapado\RestClientSdk\Mapping\Annotations as Rest;
+ use Mapado\RestClientSdk\Mapping\Attributes as Rest;
  1. Replace annotations by attributes

Example :

- /**
- * @Rest\Attribute(name="id", type="string")
- /
+ #[Rest\Attribute(name: 'id', type: 'string')]
  private $var;
  1. 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 {

  }