Skip to content

Commit 7ae5197

Browse files
committed
Fixed Symfony 7.4 incompatibility
1 parent 2a51f8a commit 7ae5197

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

Translation/Extractor/File/ValidationExtractor.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
use PhpParser\Node;
2727
use PhpParser\NodeTraverser;
2828
use PhpParser\NodeVisitor;
29+
use Symfony\Component\Validator\Mapping\ClassMetadata;
2930
use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
31+
use Symfony\Component\Validator\Mapping\MetadataInterface;
3032
use 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
}

0 commit comments

Comments
 (0)