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 /**
@@ -175,4 +173,19 @@ private function extractFromConstraints(array $constraints): void
175173 }
176174 }
177175 }
176+
177+ private function extractFromClassMetadata (MetadataInterface $ metadata ): void
178+ {
179+ if (!$ metadata instanceof ClassMetadata) {
180+ return ;
181+ }
182+
183+ foreach ($ metadata ->getConstrainedProperties () as $ property ) {
184+ $ memberMetadata = $ metadata ->getPropertyMetadata ($ property );
185+ foreach ($ memberMetadata as $ metadata ) {
186+ $ constraints = $ metadata ->getConstraints ();
187+ $ this ->extractFromConstraints ($ constraints );
188+ }
189+ }
190+ }
178191}
You can’t perform that action at this time.
0 commit comments