File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change 2626use PhpParser \Node ;
2727use PhpParser \NodeTraverser ;
2828use PhpParser \NodeVisitor ;
29+ use Symfony \Component \Validator \Mapping \ClassMetadata ;
2930use Symfony \Component \Validator \Mapping \Factory \MetadataFactoryInterface ;
31+ use Symfony \Component \Validator \Mapping \MetadataInterface ;
3032use Twig \Node \Node as TwigNode ;
3133
3234/**
@@ -89,12 +91,8 @@ public function enterNode(Node $node)
8991 return ;
9092 }
9193
92- $ this ->extractFromConstraints ($ metadata ->constraints );
93- foreach ($ metadata ->members as $ members ) {
94- foreach ($ members as $ member ) {
95- $ this ->extractFromConstraints ($ member ->constraints );
96- }
97- }
94+ $ this ->extractFromConstraints ($ metadata ->getConstraints ());
95+ $ this ->extractFromClassMetadata ($ metadata );
9896 }
9997
10098 /**
@@ -178,4 +176,19 @@ private function extractFromConstraints(array $constraints)
178176 }
179177 }
180178 }
179+
180+ private function extractFromClassMetadata (MetadataInterface $ metadata ): void
181+ {
182+ if (!$ metadata instanceof ClassMetadata) {
183+ return ;
184+ }
185+
186+ foreach ($ metadata ->getConstrainedProperties () as $ property ) {
187+ $ memberMetadata = $ metadata ->getPropertyMetadata ($ property );
188+ foreach ($ memberMetadata as $ metadata ) {
189+ $ constraints = $ metadata ->getConstraints ();
190+ $ this ->extractFromConstraints ($ constraints );
191+ }
192+ }
193+ }
181194}
You can’t perform that action at this time.
0 commit comments