diff --git a/composer.json b/composer.json index 85e415c..50c31c4 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "require-dev": { "phpunit/phpunit": "^9.5", "spiral/tokenizer": "^2.8", - "vimeo/psalm": "^5.12", + "vimeo/psalm": "^5.12 || ^6.10", "symfony/console": "^6.0 || ^7.0", "spiral/code-style": "^2.2" }, diff --git a/src/Compiler.php b/src/Compiler.php index 648b0d0..49d017c 100644 --- a/src/Compiler.php +++ b/src/Compiler.php @@ -157,6 +157,9 @@ private function renderColumns(Entity $entity): array $fieldGroups = []; // Collect and group fields by column name foreach ($entity->getFields() as $name => $field) { + if ($field->getAttributes()->get('obsolete')) { + continue; + } $fieldGroups[$field->getColumn()][$name] = $field; } foreach ($fieldGroups as $fields) { @@ -182,6 +185,9 @@ private function renderColumns(Entity $entity): array $schema = []; foreach ($entity->getFields() as $name => $field) { + if ($field->getAttributes()->get('obsolete')) { + continue; + } $schema[$name] = $field->getColumn(); } @@ -204,7 +210,7 @@ private function renderTypecast(Entity $entity): array { $schema = []; foreach ($entity->getFields() as $name => $field) { - if ($field->hasTypecast()) { + if ($field->hasTypecast() && !$field->getAttributes()->get('obsolete')) { $schema[$name] = $field->getTypecast(); } } diff --git a/src/Definition/Field.php b/src/Definition/Field.php index 75d34cf..a284250 100644 --- a/src/Definition/Field.php +++ b/src/Definition/Field.php @@ -173,6 +173,16 @@ public function setEntityClass(?string $entityClass): self return $this; } + public function isObsolete(): bool + { + return $this->obsolete; + } + + public function setObsolete(bool $obsolete): void + { + $this->obsolete = $obsolete; + } + public function __clone() { $this->options = clone $this->options; diff --git a/src/Generator/GenerateRelations.php b/src/Generator/GenerateRelations.php index 52bbc8a..3bd2e8c 100644 --- a/src/Generator/GenerateRelations.php +++ b/src/Generator/GenerateRelations.php @@ -43,6 +43,7 @@ final class GenerateRelations implements GeneratorInterface 'indexCreate' => RelationSchema::INDEX_CREATE, 'morphKeyLength' => RelationSchema::MORPH_KEY_LENGTH, 'embeddedPrefix' => RelationSchema::EMBEDDED_PREFIX, + 'obsolete' => Relation::OBSOLETE, // deprecated 'though' => Relation::THROUGH_ENTITY, @@ -110,6 +111,10 @@ protected function register(Registry $registry, Entity $entity): void \assert($role !== null); foreach ($entity->getRelations() as $name => $r) { + if ($r->getOptions()->get('obsolete') === true) { + continue; + } + $schema = $this->initRelation($r->getType())->withContext( $name, $role,