Skip to content

Commit

Permalink
Rename attribute to GeneratedValue
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Feb 8, 2024
1 parent feb91a2 commit f603c11
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
#[\Attribute(\Attribute::TARGET_PROPERTY)]
#[NamedArgumentConstructor]
class Generated
class GeneratedValue
{
public function __construct(
protected bool $beforeInsert = false,
Expand Down
4 changes: 2 additions & 2 deletions src/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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;
}

0 comments on commit f603c11

Please sign in to comment.