Skip to content

Commit

Permalink
Merge pull request #578 from schmittjoh/1.x
Browse files Browse the repository at this point in the history
Merge back 1.x into master
  • Loading branch information
goetas authored Mar 29, 2023
2 parents b117e81 + 42655d8 commit 721bd83
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DependencyInjection/JMSTranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function load(array $configs, ContainerBuilder $container)
$container->setParameter('jms_translation.locales', $config['locales']);

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

$requests = [];
Expand Down
4 changes: 2 additions & 2 deletions Tests/Twig/RemovingNodeVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function testRemovalWithSimpleTemplate(): void

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

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

$this->assertEquals($expected, $actual);
}
Expand Down
13 changes: 11 additions & 2 deletions Translation/Extractor/File/ValidationExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private function extractFromConstraints(array $constraints)
foreach ($constraints as $constraint) {
$ref = new \ReflectionClass($constraint);
$defaultValues = $ref->getDefaultProperties();

$defaultParameters = null !== $ref->getConstructor() ? $ref->getConstructor()->getParameters() : [];
$properties = $ref->getProperties();

foreach ($properties as $property) {
Expand All @@ -177,9 +177,18 @@ private function extractFromConstraints(array $constraints)
// If the property ends with 'Message'
if (strtolower(substr($propName, -1 * strlen('Message'))) === 'message') {
// If it is different from the default value
if ($defaultValues[$propName] !== $constraint->{$propName}) {
if (array_key_exists($propName, $defaultValues) && $defaultValues[$propName] !== $constraint->{$propName}) {
$message = new Message($constraint->{$propName}, 'validators');
$this->catalogue->add($message);
} elseif (method_exists($property, 'isPromoted') && $property->isPromoted()) {
foreach ($defaultParameters as $defaultParameter) {
if ($defaultParameter->getName() === $propName && $defaultParameter->isDefaultValueAvailable() && $defaultParameter->getDefaultValue() !== $constraint->{$propName}) {
$message = new Message($constraint->{$propName}, 'validators');
$this->catalogue->add($message);

break;
}
}
}
}
}
Expand Down

0 comments on commit 721bd83

Please sign in to comment.