@@ -64,7 +64,11 @@ public function __invoke(): ArrayObject
6464 ->getMetadataFactory ()
6565 ->getMetadataFor ($ reflectionClass ->getName ());
6666
67- $ this ->buildMetadataForEntity ($ reflectionClass );
67+ // If an Entity attribute does not exist, skip this entity
68+ if (! $ this ->buildMetadataForEntity ($ reflectionClass )) {
69+ continue ;
70+ }
71+
6872 $ this ->buildMetadataForFields ($ entityClassMetadata , $ reflectionClass );
6973 $ this ->buildMetadataForAssociations ($ reflectionClass );
7074 }
@@ -82,9 +86,10 @@ public function __invoke(): ArrayObject
8286 * The buildmetadata* functions exist to simplify the buildMetadata
8387 * function.
8488 */
85- private function buildMetadataForEntity (ReflectionClass $ reflectionClass ): void
89+ private function buildMetadataForEntity (ReflectionClass $ reflectionClass ): bool
8690 {
87- $ entityInstance = null ;
91+ $ entityInstance = null ;
92+ $ entityAttributeFound = false ;
8893
8994 // Fetch attributes for the entity class filterd by Attribute\Entity
9095 foreach ($ reflectionClass ->getAttributes (Attribute \Entity::class) as $ attribute ) {
@@ -95,6 +100,8 @@ private function buildMetadataForEntity(ReflectionClass $reflectionClass): void
95100 continue ;
96101 }
97102
103+ $ entityAttributeFound = true ;
104+
98105 // Only one matching instance per group is allowed
99106 assert (
100107 ! $ entityInstance ,
@@ -116,6 +123,8 @@ private function buildMetadataForEntity(ReflectionClass $reflectionClass): void
116123 $ this ->getTypeName ($ reflectionClass ->getName ()),
117124 ];
118125 }
126+
127+ return $ entityAttributeFound ;
119128 }
120129
121130 /**
0 commit comments