Skip to content

Commit 35ee027

Browse files
committed
Fixed Symfony 7.4 incompatibility
1 parent 0ee0f75 commit 35ee027

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
/**
@@ -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
}

0 commit comments

Comments
 (0)