diff --git a/src/Annotation/Generated.php b/src/Annotation/GeneratedValue.php similarity index 97% rename from src/Annotation/Generated.php rename to src/Annotation/GeneratedValue.php index c27bc013..8c108a1f 100644 --- a/src/Annotation/Generated.php +++ b/src/Annotation/GeneratedValue.php @@ -14,7 +14,7 @@ */ #[\Attribute(\Attribute::TARGET_PROPERTY)] #[NamedArgumentConstructor] -class Generated +class GeneratedValue { public function __construct( protected bool $beforeInsert = false, diff --git a/src/Configurator.php b/src/Configurator.php index ea30c586..e5b06ebe 100644 --- a/src/Configurator.php +++ b/src/Configurator.php @@ -8,7 +8,7 @@ use Cycle\Annotated\Annotation\Embeddable; use Cycle\Annotated\Annotation\Entity; use Cycle\Annotated\Annotation\ForeignKey; -use Cycle\Annotated\Annotation\Generated; +use Cycle\Annotated\Annotation\GeneratedValue; use Cycle\Annotated\Annotation\Relation as RelationAnnotation; use Cycle\Annotated\Exception\AnnotationException; use Cycle\Annotated\Exception\AnnotationRequiredArgumentsException; @@ -306,7 +306,7 @@ public function initGeneratedFields(EntitySchema $entity, \ReflectionClass $clas { foreach ($class->getProperties() as $property) { try { - $generated = $this->reader->firstPropertyMetadata($property, Generated::class); + $generated = $this->reader->firstPropertyMetadata($property, GeneratedValue::class); if ($generated !== null) { $entity->getFields()->get($property->getName())->setGenerated($generated->getFlags()); } diff --git a/tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php b/tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php index 07585654..27e5d985 100644 --- a/tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php +++ b/tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php @@ -6,7 +6,7 @@ use Cycle\Annotated\Annotation\Column; use Cycle\Annotated\Annotation\Entity; -use Cycle\Annotated\Annotation\Generated; +use Cycle\Annotated\Annotation\GeneratedValue; /** * @Entity(role="withGeneratedFields", table="with_generated_fields") @@ -22,31 +22,31 @@ class WithGeneratedFields /** * @Column(type="datetime", name="created_at") - * @Generated(beforeInsert=true) + * @GeneratedValue(beforeInsert=true) */ #[ Column(type: 'datetime', name: 'created_at'), - Generated(beforeInsert: true) + GeneratedValue(beforeInsert: true) ] public \DateTimeImmutable $createdAt; /** * @Column(type="datetime", name="created_at_generated_by_database") - * @Generated(onInsert=true) + * @GeneratedValue(onInsert=true) */ #[ Column(type: 'datetime', name: 'created_at_generated_by_database'), - Generated(onInsert: true) + GeneratedValue(onInsert: true) ] public \DateTimeImmutable $createdAtGeneratedByDatabase; /** * @Column(type="datetime", name="created_at") - * @Generated(beforeInsert=true, beforeUpdate=true) + * @GeneratedValue(beforeInsert=true, beforeUpdate=true) */ #[ Column(type: 'datetime', name: 'updated_at'), - Generated(beforeInsert: true, beforeUpdate: true) + GeneratedValue(beforeInsert: true, beforeUpdate: true) ] public \DateTimeImmutable $updatedAt; }