-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d64b9f
commit c799fed
Showing
4 changed files
with
54 additions
and
8 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
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 |
---|---|---|
@@ -1,6 +1,54 @@ | ||
## How to migrate from v0 to v1 | ||
|
||
### Attributes | ||
### Using rector | ||
|
||
- Search and replace all occurences of `Mapado\RestClientSdk\Mapping\Annotations` to `Mapado\RestClientSdk\Mapping\Attributes` | ||
- Replace annotations by attributes using a tool like [rector/rector](https://github.com/rectorphp/rector) or manually | ||
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](https://getrector.com/documentation) | ||
2. Edit your `rector.php` file by adding this : | ||
```php | ||
$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); | ||
``` | ||
3. Launch `vendor/bin/rector` | ||
|
||
### Manually | ||
|
||
1. Replace namespace | ||
```diff | ||
- use Mapado\RestClientSdk\Mapping\Annotations as Rest; | ||
+ use Mapado\RestClientSdk\Mapping\Attributes as Rest; | ||
``` | ||
|
||
2. Replace annotations by attributes | ||
|
||
Example : | ||
```diff | ||
- /** | ||
- * @Rest\Attribute(name="id", type="string") | ||
- / | ||
+ #[Rest\Attribute(name: 'id', type: 'string')] | ||
private $var; | ||
``` | ||
|
||
3. Replace repositories class name in `Entity` attribute by class constants | ||
|
||
```diff | ||
+ 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 { | ||
|
||
} | ||
``` |
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