Skip to content

Commit 721bd83

Browse files
authored
Merge pull request #578 from schmittjoh/1.x
Merge back 1.x into master
2 parents b117e81 + 42655d8 commit 721bd83

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

DependencyInjection/JMSTranslationExtension.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function load(array $configs, ContainerBuilder $container)
4141
$container->setParameter('jms_translation.locales', $config['locales']);
4242

4343
foreach ($config['dumper'] as $option => $value) {
44-
$container->setParameter("jms_translation.dumper.${option}", $value);
44+
$container->setParameter('jms_translation.dumper.' . $option, $value);
4545
}
4646

4747
$requests = [];

Tests/Twig/RemovingNodeVisitorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public function testRemovalWithSimpleTemplate(): void
3030

3131
$templateSuffix = $isSF5 ? '_sf5' : '';
3232

33-
$expected = $this->parse("simple_template_compiled${templateSuffix}.html.twig");
34-
$actual = $this->parse("simple_template${templateSuffix}.html.twig");
33+
$expected = $this->parse('simple_template_compiled' . $templateSuffix . '.html.twig');
34+
$actual = $this->parse('simple_template' . $templateSuffix . '.html.twig');
3535

3636
$this->assertEquals($expected, $actual);
3737
}

Translation/Extractor/File/ValidationExtractor.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private function extractFromConstraints(array $constraints)
168168
foreach ($constraints as $constraint) {
169169
$ref = new \ReflectionClass($constraint);
170170
$defaultValues = $ref->getDefaultProperties();
171-
171+
$defaultParameters = null !== $ref->getConstructor() ? $ref->getConstructor()->getParameters() : [];
172172
$properties = $ref->getProperties();
173173

174174
foreach ($properties as $property) {
@@ -177,9 +177,18 @@ private function extractFromConstraints(array $constraints)
177177
// If the property ends with 'Message'
178178
if (strtolower(substr($propName, -1 * strlen('Message'))) === 'message') {
179179
// If it is different from the default value
180-
if ($defaultValues[$propName] !== $constraint->{$propName}) {
180+
if (array_key_exists($propName, $defaultValues) && $defaultValues[$propName] !== $constraint->{$propName}) {
181181
$message = new Message($constraint->{$propName}, 'validators');
182182
$this->catalogue->add($message);
183+
} elseif (method_exists($property, 'isPromoted') && $property->isPromoted()) {
184+
foreach ($defaultParameters as $defaultParameter) {
185+
if ($defaultParameter->getName() === $propName && $defaultParameter->isDefaultValueAvailable() && $defaultParameter->getDefaultValue() !== $constraint->{$propName}) {
186+
$message = new Message($constraint->{$propName}, 'validators');
187+
$this->catalogue->add($message);
188+
189+
break;
190+
}
191+
}
183192
}
184193
}
185194
}

0 commit comments

Comments
 (0)