@@ -63,7 +63,11 @@ public function getMetadata(): Metadata
6363 ->getMetadataFactory ()
6464 ->getMetadataFor ($ reflectionClass ->getName ());
6565
66- $ this ->buildMetadataForEntity ($ reflectionClass );
66+ // If an Entity attribute does not exist, skip this entity
67+ if (! $ this ->buildMetadataForEntity ($ reflectionClass )) {
68+ continue ;
69+ }
70+
6771 $ this ->buildMetadataForFields ($ entityClassMetadata , $ reflectionClass );
6872 $ this ->buildMetadataForAssociations ($ reflectionClass );
6973 }
@@ -81,9 +85,10 @@ public function getMetadata(): Metadata
8185 * The buildmetadata* functions exist to simplify the buildMetadata
8286 * function.
8387 */
84- private function buildMetadataForEntity (ReflectionClass $ reflectionClass ): void
88+ private function buildMetadataForEntity (ReflectionClass $ reflectionClass ): bool
8589 {
86- $ entityInstance = null ;
90+ $ entityInstance = null ;
91+ $ entityAttributeFound = false ;
8792
8893 // Fetch attributes for the entity class filterd by Attribute\Entity
8994 foreach ($ reflectionClass ->getAttributes (Attribute \Entity::class) as $ attribute ) {
@@ -94,6 +99,8 @@ private function buildMetadataForEntity(ReflectionClass $reflectionClass): void
9499 continue ;
95100 }
96101
102+ $ entityAttributeFound = true ;
103+
97104 // Only one matching instance per group is allowed
98105 assert (
99106 ! $ entityInstance ,
@@ -115,6 +122,8 @@ private function buildMetadataForEntity(ReflectionClass $reflectionClass): void
115122 $ this ->getTypeName ($ reflectionClass ->getName ()),
116123 ];
117124 }
125+
126+ return $ entityAttributeFound ;
118127 }
119128
120129 /**
0 commit comments