diff --git a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
index 46fdd9e7b7..9e927ecdf0 100644
--- a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
+++ b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
@@ -49,11 +49,19 @@ class TranslationExtension extends AbstractExtension
}
/**
- * @deprecated since Symfony 4.2
+ * @return TranslatorInterface|null
*/
public function getTranslator()
{
- @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
+ if (null === $this->translator) {
+ if (!interface_exists(TranslatorInterface::class)) {
+ throw new \LogicException(sprintf('You cannot use the "%s" if the Translation Contracts are not available. Try running "composer require symfony/translation".', __CLASS__));
+ }
+
+ $this->translator = new class() implements TranslatorInterface {
+ use TranslatorTrait;
+ };
+ }
return $this->translator;
}
@@ -108,13 +116,8 @@ class TranslationExtension extends AbstractExtension
if (null !== $count) {
$arguments['%count%'] = $count;
}
- if (null === $this->translator) {
- $this->translator = new class() implements TranslatorInterface {
- use TranslatorTrait;
- };
- }
- return $this->translator->trans($message, $arguments, $domain, $locale);
+ return $this->getTranslator()->trans($message, $arguments, $domain, $locale);
}
/**
@@ -122,17 +125,13 @@ class TranslationExtension extends AbstractExtension
*/
public function transchoice($message, $count, array $arguments = [], $domain = null, $locale = null)
{
- if (null === $this->translator) {
- $this->translator = new class() implements TranslatorInterface {
- use TranslatorTrait;
- };
+ $translator = $this->getTranslator();
+
+ if ($translator instanceof TranslatorInterface) {
+ return $translator->trans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale);
}
- if ($this->translator instanceof TranslatorInterface) {
- return $this->translator->trans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale);
- }
-
- return $this->translator->transChoice($message, $count, array_merge(['%count%' => $count], $arguments), $domain, $locale);
+ return $translator->transChoice($message, $count, array_merge(['%count%' => $count], $arguments), $domain, $locale);
}
/**
diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php
index 224fbc5a34..fa88fd0d05 100644
--- a/src/Symfony/Component/Filesystem/Filesystem.php
+++ b/src/Symfony/Component/Filesystem/Filesystem.php
@@ -751,7 +751,6 @@ class Filesystem
return $result;
} catch (\Throwable $e) {
- } catch (\Exception $e) {
}
\restore_error_handler();
diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php
index 5b3a9cbf2e..e653286121 100644
--- a/src/Symfony/Component/HttpKernel/Kernel.php
+++ b/src/Symfony/Component/HttpKernel/Kernel.php
@@ -494,7 +494,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
$fresh = true;
}
} catch (\Throwable $e) {
- } catch (\Exception $e) {
} finally {
error_reporting($errorLevel);
}
@@ -563,7 +562,6 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
try {
$oldContainer = include $cache->getPath();
} catch (\Throwable $e) {
- } catch (\Exception $e) {
} finally {
error_reporting($errorLevel);
}
diff --git a/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php
index 3c3ea1aa17..3a5c4f0c4b 100644
--- a/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php
+++ b/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php
@@ -48,8 +48,8 @@ abstract class BasePasswordEncoder implements PasswordEncoderInterface
/**
* Merges a password and a salt.
*
- * @param string $password The password to be used
- * @param string $salt The salt to be used
+ * @param string $password The password to be used
+ * @param string|null $salt The salt to be used
*
* @return string a merged password and salt
*
diff --git a/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php b/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php
index e0573051eb..03cdaca44a 100644
--- a/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php
+++ b/src/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php
@@ -23,8 +23,8 @@ interface PasswordEncoderInterface
/**
* Encodes the raw password.
*
- * @param string $raw The password to encode
- * @param string $salt The salt
+ * @param string $raw The password to encode
+ * @param string|null $salt The salt
*
* @return string The encoded password
*
@@ -36,9 +36,9 @@ interface PasswordEncoderInterface
/**
* Checks a raw password against an encoded password.
*
- * @param string $encoded An encoded password
- * @param string $raw A raw password
- * @param string $salt The salt
+ * @param string $encoded An encoded password
+ * @param string $raw A raw password
+ * @param string|null $salt The salt
*
* @return bool true if the password is valid, false otherwise
*
diff --git a/src/Symfony/Component/Translation/Command/XliffLintCommand.php b/src/Symfony/Component/Translation/Command/XliffLintCommand.php
index 9bea4d9499..3c2cc9efde 100644
--- a/src/Symfony/Component/Translation/Command/XliffLintCommand.php
+++ b/src/Symfony/Component/Translation/Command/XliffLintCommand.php
@@ -124,7 +124,9 @@ EOF
$normalizedLocale = preg_quote(str_replace('-', '_', $targetLanguage), '/');
// strict file names require translation files to be named '____.locale.xlf'
// otherwise, both '____.locale.xlf' and 'locale.____.xlf' are allowed
- $expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.%s\.xlf/', $normalizedLocale) : sprintf('/^(.*\.%s\.xlf|%s\..*\.xlf)/', $normalizedLocale, $normalizedLocale);
+ // also, the regexp matching must be case-insensitive, as defined for 'target-language' values
+ // http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#target-language
+ $expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.(?i:%s)\.xlf/', $normalizedLocale) : sprintf('/^(.*\.(?i:%s)\.xlf|(?i:%s)\..*\.xlf)/', $normalizedLocale, $normalizedLocale);
if (0 === preg_match($expectedFilenamePattern, basename($file))) {
$errors[] = [
diff --git a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php
index d99b493ac6..35dfc0e344 100644
--- a/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php
+++ b/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php
@@ -36,12 +36,9 @@ class TranslationDataCollector extends DataCollector implements LateDataCollecto
{
$messages = $this->sanitizeCollectedMessages($this->translator->getCollectedMessages());
- $this->data = $this->computeCount($messages);
+ $this->data += $this->computeCount($messages);
$this->data['messages'] = $messages;
- $this->data['locale'] = $this->translator->getLocale();
- $this->data['fallback_locales'] = $this->translator->getFallbackLocales();
-
$this->data = $this->cloneVar($this->data);
}
@@ -50,6 +47,8 @@ class TranslationDataCollector extends DataCollector implements LateDataCollecto
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
+ $this->data['locale'] = $this->translator->getLocale();
+ $this->data['fallback_locales'] = $this->translator->getFallbackLocales();
}
/**
diff --git a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php
index 516d98af53..df2e2f0951 100644
--- a/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php
+++ b/src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php
@@ -94,6 +94,17 @@ class XliffLintCommandTest extends TestCase
$this->assertContains('There is a mismatch between the language included in the file name ("messages.en.xlf") and the "es" value used in the "target-language" attribute of the file.', trim($tester->getDisplay()));
}
+ public function testLintTargetLanguageIsCaseInsensitive()
+ {
+ $tester = $this->createCommandTester();
+ $filename = $this->createFile('note', 'zh-cn', 'messages.zh_CN.xlf');
+
+ $tester->execute(['filename' => $filename], ['decorated' => false]);
+
+ $this->assertEquals(0, $tester->getStatusCode());
+ $this->assertContains('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay()));
+ }
+
/**
* @expectedException \RuntimeException
*/
diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf
index 60f02435f5..ccc0c0135a 100644
--- a/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf
+++ b/src/Symfony/Component/Validator/Resources/translations/validators.hr.xlf
@@ -334,6 +334,34 @@
Ova vrijednost treba biti validan JSON.
+
+
+ Ova kolekcija treba sadržavati samo unikatne elemente.
+
+
+
+ Ova vrijednost treba biti pozitivna.
+
+
+
+ Ova vrijednost treba biti pozitivna ili jednaka nuli.
+
+
+
+ Ova vrijednost treba biti negativna.
+
+
+
+ Ova vrijednost treba biti negativna ili jednaka nuli.
+
+
+
+ Ova vrijednost nije validna vremenska zona.
+
+
+
+ Ova lozinka je procurila u nekom od sigurnosnih propusta, te je potrebno koristiti drugu lozinku.
+