diff --git a/DependencyInjection/JMSTranslationExtension.php b/DependencyInjection/JMSTranslationExtension.php index f28b399c..4321cdca 100644 --- a/DependencyInjection/JMSTranslationExtension.php +++ b/DependencyInjection/JMSTranslationExtension.php @@ -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 = []; diff --git a/Tests/Twig/RemovingNodeVisitorTest.php b/Tests/Twig/RemovingNodeVisitorTest.php index e2da3374..f44b3eb3 100644 --- a/Tests/Twig/RemovingNodeVisitorTest.php +++ b/Tests/Twig/RemovingNodeVisitorTest.php @@ -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); } diff --git a/Translation/Extractor/File/ValidationExtractor.php b/Translation/Extractor/File/ValidationExtractor.php index 7316c7e4..9b1a1530 100644 --- a/Translation/Extractor/File/ValidationExtractor.php +++ b/Translation/Extractor/File/ValidationExtractor.php @@ -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) { @@ -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; + } + } } } }