@@ -97,7 +97,7 @@ public function initEmbedding(Embeddable $emb, \ReflectionClass $class): EntityS
9797
9898 public function initFields (EntitySchema $ entity , \ReflectionClass $ class , string $ columnPrefix = '' ): void
9999 {
100- foreach ($ this -> getActualProperties ( $ class ) as $ property ) {
100+ foreach ($ class -> getProperties ( ) as $ property ) {
101101 try {
102102 $ column = $ this ->reader ->firstPropertyMetadata ($ property , Column::class);
103103 } catch (\Exception $ e ) {
@@ -114,13 +114,14 @@ public function initFields(EntitySchema $entity, \ReflectionClass $class, string
114114
115115 $ field = $ this ->initField ($ property ->getName (), $ column , $ class , $ columnPrefix );
116116 $ field ->setEntityClass ($ property ->getDeclaringClass ()->getName ());
117+ $ field ->setObsolete ($ this ->isObsolete ($ property ));
117118 $ entity ->getFields ()->set ($ property ->getName (), $ field );
118119 }
119120 }
120121
121122 public function initRelations (EntitySchema $ entity , \ReflectionClass $ class ): void
122123 {
123- foreach ($ this -> getActualProperties ( $ class ) as $ property ) {
124+ foreach ($ class -> getProperties ( ) as $ property ) {
124125 $ metadata = $ this ->getPropertyMetadata ($ property , RelationAnnotation \RelationInterface::class);
125126
126127 foreach ($ metadata as $ meta ) {
@@ -173,6 +174,7 @@ public function initRelations(EntitySchema $entity, \ReflectionClass $class): vo
173174 $ relation ->getOptions ()->set ($ option , $ value );
174175 }
175176
177+ $ relation ->setObsolete ($ this ->isObsolete ($ property ));
176178 // need relation definition
177179 $ entity ->getRelations ()->set ($ property ->getName (), $ relation );
178180 }
@@ -415,22 +417,8 @@ private function isOnInsertGeneratedField(Field $field): bool
415417 };
416418 }
417419
418- /**
419- * @return \Generator<\ReflectionProperty>
420- */
421- private function getActualProperties (\ReflectionClass $ class ): \Generator
420+ private function isObsolete (\ReflectionProperty $ property ): bool
422421 {
423- foreach ($ class ->getProperties () as $ property ) {
424- // Obsolete property must not be included in the scheme.
425- $ metadata = $ this ->getPropertyMetadata ($ property , Obsolete::class);
426- if (!\is_array ($ metadata )) {
427- $ metadata = \iterator_to_array ($ metadata );
428- }
429- if ($ metadata !== []) {
430- continue ;
431- }
432-
433- yield $ property ;
434- }
422+ return $ this ->reader ->firstPropertyMetadata ($ property , Obsolete::class) !== null ;
435423 }
436424}
0 commit comments