Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a set to convert mongodb annotations to attributes #239

Merged
merged 1 commit into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions config/sets/doctrine-mongodb-annotations-to-attributes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationToAttribute;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(NestedAnnotationToAttributeRector::class, [
new NestedAnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\Indexes', [
new AnnotationPropertyToAttributeClass('Doctrine\ODM\MongoDB\Mapping\Annotations\Index'),
new AnnotationPropertyToAttributeClass('Doctrine\ODM\MongoDB\Mapping\Annotations\UniqueIndex'),
], true),
]);
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\File\ChunkSize'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\File\Filename'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\File\Length'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\File\Metadata'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\File\UploadDate'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\AlsoLoad'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\ChangeTrackingPolicy'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\DefaultDiscriminatorValue'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\DiscriminatorField'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\DiscriminatorMap'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\DiscriminatorValue'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\Document'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\EmbeddedDocument'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\EmbedMany'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\EmbedOne'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\Field'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\File'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\HasLifecycleCallbacks'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\Id'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\Index'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\InheritanceType'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\Lock'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\MappedSuperclass'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\PostLoad'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\PostPersist'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\PostRemove'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\PostUpdate'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\PreFlush'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\PreLoad'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\PrePersist'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\PreRemove'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\PreUpdate'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\QueryResultDocument'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\ReadPreference'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\ReferenceMany'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\ReferenceOne'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\ShardKey'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\UniqueIndex'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\Validation'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\Version'),
new AnnotationToAttribute('Doctrine\ODM\MongoDB\Mapping\Annotations\View'),
]);
};
5 changes: 5 additions & 0 deletions src/Set/DoctrineSetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,9 @@ final class DoctrineSetList implements SetListInterface
* @var string
*/
public const GEDMO_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/doctrine-gedmo-annotations-to-attributes.php';

/**
* @var string
*/
public const MONGODB__ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../config/sets/doctrine-mongodb-annotations-to-attributes.php';
}
Loading