Merge branch '5.2' into 5.x

* 5.2:
  [Validator] Fix return types
  Add translation for Belarusian
  fix parsing calls of methods named "method"
  [Security] Remove unnecessary inherited doc annotation
  deal with indented heredoc/nowdoc tokens
  Adding templates for Belarusian
This commit is contained in:
Fabien Potencier 2021-03-04 16:41:30 +01:00
commit 33791925af
11 changed files with 238 additions and 8 deletions

View File

@ -541,7 +541,7 @@ class YamlFileLoader extends FileLoader
throw new InvalidArgumentException(sprintf('Invalid method call for service "%s", did you forgot a leading dash before "%s: ..." in "%s"?', $id, $k, $file)); throw new InvalidArgumentException(sprintf('Invalid method call for service "%s", did you forgot a leading dash before "%s: ..." in "%s"?', $id, $k, $file));
} }
if (isset($call['method'])) { if (isset($call['method']) && \is_string($call['method'])) {
$method = $call['method']; $method = $call['method'];
$args = $call['arguments'] ?? []; $args = $call['arguments'] ?? [];
$returnsClone = $call['returns_clone'] ?? false; $returnsClone = $call['returns_clone'] ?? false;

View File

@ -3,3 +3,5 @@ services:
calls: calls:
- foo: [1, 2, 3] - foo: [1, 2, 3]
- bar: !returns_clone [1, 2, 3] - bar: !returns_clone [1, 2, 3]
- method:
- url

View File

@ -958,6 +958,7 @@ class YamlFileLoaderTest extends TestCase
$expected = [ $expected = [
['foo', [1, 2, 3]], ['foo', [1, 2, 3]],
['bar', [1, 2, 3], true], ['bar', [1, 2, 3], true],
['method', ['url']],
]; ];
$this->assertSame($expected, $container->getDefinition('foo')->getMethodCalls()); $this->assertSame($expected, $container->getDefinition('foo')->getMethodCalls());

View File

@ -14,6 +14,126 @@
<source>The CSRF token is invalid. Please try to resubmit the form.</source> <source>The CSRF token is invalid. Please try to resubmit the form.</source>
<target>CSRF-токен не сапраўдны. Калі ласка, паспрабуйце яшчэ раз адправіць форму.</target> <target>CSRF-токен не сапраўдны. Калі ласка, паспрабуйце яшчэ раз адправіць форму.</target>
</trans-unit> </trans-unit>
<trans-unit id="99">
<source>This value is not a valid HTML5 color.</source>
<target>Значэнне не з'яўляецца карэктным HTML5 колерам.</target>
</trans-unit>
<trans-unit id="100">
<source>Please enter a valid birthdate.</source>
<target>Калі ласка, увядзіце карэктную дату нараджэння.</target>
</trans-unit>
<trans-unit id="101">
<source>The selected choice is invalid.</source>
<target>Выбраны варыянт некарэктны.</target>
</trans-unit>
<trans-unit id="102">
<source>The collection is invalid.</source>
<target>Калекцыя некарэктна.</target>
</trans-unit>
<trans-unit id="103">
<source>Please select a valid color.</source>
<target>Калі ласка, выберыце карэктны колер.</target>
</trans-unit>
<trans-unit id="104">
<source>Please select a valid country.</source>
<target>Калі ласка, выберыце карэктную краіну.</target>
</trans-unit>
<trans-unit id="105">
<source>Please select a valid currency.</source>
<target>Калі ласка, выберыце карэктную валюту.</target>
</trans-unit>
<trans-unit id="106">
<source>Please choose a valid date interval.</source>
<target>Калі ласка, выберыце карэктны інтэрвал дат.</target>
</trans-unit>
<trans-unit id="107">
<source>Please enter a valid date and time.</source>
<target>Калі ласка, увядзіце карэктныя дату і час.</target>
</trans-unit>
<trans-unit id="108">
<source>Please enter a valid date.</source>
<target>Калі ласка, увядзіце карэктную дату.</target>
</trans-unit>
<trans-unit id="109">
<source>Please select a valid file.</source>
<target>Калі ласка, выберыце карэктны файл.</target>
</trans-unit>
<trans-unit id="110">
<source>The hidden field is invalid.</source>
<target>Значэнне схаванага поля некарэктна.</target>
</trans-unit>
<trans-unit id="111">
<source>Please enter an integer.</source>
<target>Калі ласка, увядзіце цэлы лік.</target>
</trans-unit>
<trans-unit id="112">
<source>Please select a valid language.</source>
<target>Калі ласка, выберыце карэктную мову.</target>
</trans-unit>
<trans-unit id="113">
<source>Please select a valid locale.</source>
<target>Калі ласка, выберыце карэктную лакаль.</target>
</trans-unit>
<trans-unit id="114">
<source>Please enter a valid money amount.</source>
<target>Калі ласка, увядзіце карэктную колькасць грошай.</target>
</trans-unit>
<trans-unit id="115">
<source>Please enter a number.</source>
<target>Калі ласка, увядзіце нумар.</target>
</trans-unit>
<trans-unit id="116">
<source>The password is invalid.</source>
<target>Няправільны пароль.</target>
</trans-unit>
<trans-unit id="117">
<source>Please enter a percentage value.</source>
<target>Калі ласка, увядзіце працэнтнае значэнне.</target>
</trans-unit>
<trans-unit id="118">
<source>The values do not match.</source>
<target>Значэнні не супадаюць.</target>
</trans-unit>
<trans-unit id="119">
<source>Please enter a valid time.</source>
<target>Калі ласка, увядзіце карэктны час.</target>
</trans-unit>
<trans-unit id="120">
<source>Please select a valid timezone.</source>
<target>Калі ласка, выберыце карэктны гадзінны пояс.</target>
</trans-unit>
<trans-unit id="121">
<source>Please enter a valid URL.</source>
<target>Калі ласка, увядзіце карэктны URL.</target>
</trans-unit>
<trans-unit id="122">
<source>Please enter a valid search term.</source>
<target>Калі ласка, увядзіце карэктны пошукавы запыт.</target>
</trans-unit>
<trans-unit id="123">
<source>Please provide a valid phone number.</source>
<target>Калі ласка, увядзіце карэктны нумар тэлефона.</target>
</trans-unit>
<trans-unit id="124">
<source>The checkbox has an invalid value.</source>
<target>Флажок мае некарэктнае значэнне.</target>
</trans-unit>
<trans-unit id="125">
<source>Please enter a valid email address.</source>
<target>Калі ласка, увядзіце карэктны адрас электроннай пошты.</target>
</trans-unit>
<trans-unit id="126">
<source>Please select a valid option.</source>
<target>Калі ласка, выберыце карэктны варыянт.</target>
</trans-unit>
<trans-unit id="127">
<source>Please select a valid range.</source>
<target>Калі ласка, выберыце карэктны дыяпазон.</target>
</trans-unit>
<trans-unit id="128">
<source>Please enter a valid week.</source>
<target>Калі ласка, увядзіце карэктны тыдзень.</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -62,6 +62,14 @@
<source>Account is locked.</source> <source>Account is locked.</source>
<target>Акаўнт заблакіраван.</target> <target>Акаўнт заблакіраван.</target>
</trans-unit> </trans-unit>
<trans-unit id="17">
<source>Too many failed login attempts, please try again later.</source>
<target>Зашмат няўдалых спроб уваходу, калі ласка, паспрабуйце пазней.</target>
</trans-unit>
<trans-unit id="18">
<source>Invalid or expired login link.</source>
<target>Спасылка для ўваходу несапраўдная або пратэрмінаваная.</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -83,7 +83,14 @@ final class User implements UserInterface, EquatableInterface
} }
/** /**
* {@inheritdoc} * Checks whether the user's account has expired.
*
* Internally, if this method returns false, the authentication system
* will throw an AccountExpiredException and prevent login.
*
* @return bool true if the user's account is non expired, false otherwise
*
* @see AccountExpiredException
*/ */
public function isAccountNonExpired(): bool public function isAccountNonExpired(): bool
{ {
@ -91,7 +98,14 @@ final class User implements UserInterface, EquatableInterface
} }
/** /**
* {@inheritdoc} * Checks whether the user is locked.
*
* Internally, if this method returns false, the authentication system
* will throw a LockedException and prevent login.
*
* @return bool true if the user is not locked, false otherwise
*
* @see LockedException
*/ */
public function isAccountNonLocked(): bool public function isAccountNonLocked(): bool
{ {
@ -99,7 +113,14 @@ final class User implements UserInterface, EquatableInterface
} }
/** /**
* {@inheritdoc} * Checks whether the user's credentials (password) has expired.
*
* Internally, if this method returns false, the authentication system
* will throw a CredentialsExpiredException and prevent login.
*
* @return bool true if the user's credentials are non expired, false otherwise
*
* @see CredentialsExpiredException
*/ */
public function isCredentialsNonExpired(): bool public function isCredentialsNonExpired(): bool
{ {
@ -107,7 +128,14 @@ final class User implements UserInterface, EquatableInterface
} }
/** /**
* {@inheritdoc} * Checks whether the user is enabled.
*
* Internally, if this method returns false, the authentication system
* will throw a DisabledException and prevent login.
*
* @return bool true if the user is enabled, false otherwise
*
* @see DisabledException
*/ */
public function isEnabled(): bool public function isEnabled(): bool
{ {

View File

@ -236,6 +236,19 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
} }
break; break;
case \T_END_HEREDOC: case \T_END_HEREDOC:
if ($indentation = strspn($t[1], ' ')) {
$docPartWithLineBreaks = $docPart;
$docPart = '';
foreach (preg_split('~(\r\n|\n|\r)~', $docPartWithLineBreaks, -1, \PREG_SPLIT_DELIM_CAPTURE) as $str) {
if (\in_array($str, ["\r\n", "\n", "\r"], true)) {
$docPart .= $str;
} else {
$docPart .= substr($str, $indentation);
}
}
}
$message .= PhpStringTokenParser::parseDocString($docToken, $docPart); $message .= PhpStringTokenParser::parseDocString($docToken, $docPart);
$docToken = ''; $docToken = '';
$docPart = ''; $docPart = '';

View File

@ -130,6 +130,27 @@ EOF;
$this->assertEquals(['sources' => [$filename.':37']], $catalogue->getMetadata('other-domain-test-no-params-short-array', 'not_messages')); $this->assertEquals(['sources' => [$filename.':37']], $catalogue->getMetadata('other-domain-test-no-params-short-array', 'not_messages'));
} }
/**
* @requires PHP 7.3
*/
public function testExtractionFromIndentedHeredocNowdoc()
{
$catalogue = new MessageCatalogue('en');
$extractor = new PhpExtractor();
$extractor->setPrefix('prefix');
$extractor->extract(__DIR__.'/../fixtures/extractor-7.3/translation.html.php', $catalogue);
$expectedCatalogue = [
'messages' => [
"heredoc\nindented\n further" => "prefixheredoc\nindented\n further",
"nowdoc\nindented\n further" => "prefixnowdoc\nindented\n further",
],
];
$this->assertEquals($expectedCatalogue, $catalogue->all());
}
public function resourcesProvider() public function resourcesProvider()
{ {
$directory = __DIR__.'/../fixtures/extractor/'; $directory = __DIR__.'/../fixtures/extractor/';

View File

@ -0,0 +1,13 @@
This template is used for translation message extraction tests
<?php echo $view['translator']->trans(<<<EOF
heredoc
indented
further
EOF
); ?>
<?php echo $view['translator']->trans(<<<'EOF'
nowdoc
indented
further
EOF
); ?>

View File

@ -25,7 +25,7 @@ use Symfony\Component\Validator\Exception\MissingOptionsException;
* *
* Constraint instances are immutable and serializable. * Constraint instances are immutable and serializable.
* *
* @property array $groups The groups that the constraint belongs to * @property string[] $groups The groups that the constraint belongs to
* *
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
*/ */
@ -263,7 +263,7 @@ abstract class Constraint
* *
* Override this method if you want to define required options. * Override this method if you want to define required options.
* *
* @return array * @return string[]
* *
* @see __construct() * @see __construct()
*/ */
@ -293,7 +293,7 @@ abstract class Constraint
* This method should return one or more of the constants * This method should return one or more of the constants
* Constraint::CLASS_CONSTRAINT and Constraint::PROPERTY_CONSTRAINT. * Constraint::CLASS_CONSTRAINT and Constraint::PROPERTY_CONSTRAINT.
* *
* @return string|array One or more constant values * @return string|string[] One or more constant values
*/ */
public function getTargets() public function getTargets()
{ {

View File

@ -362,6 +362,30 @@
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source> <source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
<target>Гэты пароль быў выкрадзены ў выніку ўзлому дадзеных, таму яго нельга выкарыстоўваць. Калі ласка, выкарыстоўвайце іншы пароль.</target> <target>Гэты пароль быў выкрадзены ў выніку ўзлому дадзеных, таму яго нельга выкарыстоўваць. Калі ласка, выкарыстоўвайце іншы пароль.</target>
</trans-unit> </trans-unit>
<trans-unit id="94">
<source>This value should be between {{ min }} and {{ max }}.</source>
<target>Значэнне павінна быць паміж {{min}} і {{max}}.</target>
</trans-unit>
<trans-unit id="95">
<source>This value is not a valid hostname.</source>
<target>Значэнне не з'яўляецца карэктным імем хаста.</target>
</trans-unit>
<trans-unit id="96">
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
<target>Колькасць элементаў у гэтай калекцыі павінна быць кратным {{compared_value}}.</target>
</trans-unit>
<trans-unit id="97">
<source>This value should satisfy at least one of the following constraints:</source>
<target>Значэнне павінна задавальняць як мінімум аднаму з наступных абмежаванняў:</target>
</trans-unit>
<trans-unit id="98">
<source>Each element of this collection should satisfy its own set of constraints.</source>
<target>Кожны элемент гэтай калекцыі павінен задавальняць свайму ўласнаму набору абмежаванняў.</target>
</trans-unit>
<trans-unit id="99">
<source>This value is not a valid International Securities Identification Number (ISIN).</source>
<target>Значэнне не з'яўляецца карэктным міжнародным ідэнтыфікацыйным нумарам каштоўных папер (ISIN).</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>