Merge branch '5.2' into 5.x

* 5.2:
  [HttpFoundation] Removed obsolete test.
  [HttpFoundation] Fix TypeError: Argument 1 passed to JsonResponse::setJson() must be of the type string, object given
  Fix: Indentation
  Fix: Remove unused sprintf() parameters
  [Security][Validator] Add missing Portuguese translations
  Add Croatian (hr) translations
  Add missing entries in gitattributes
This commit is contained in:
Alexander M. Turek 2020-12-07 23:41:29 +01:00
commit e9ab48f349
17 changed files with 274 additions and 16 deletions

View File

@ -14,6 +14,126 @@
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
<target>CSRF vrijednost nije ispravna. Pokušajte ponovo poslati obrazac.</target>
</trans-unit>
<trans-unit id="99">
<source>This value is not a valid HTML5 color.</source>
<target>Ova vrijednost nije ispravna HTML5 boja.</target>
</trans-unit>
<trans-unit id="100">
<source>Please enter a valid birthdate.</source>
<target>Molim upišite ispravan datum rođenja.</target>
</trans-unit>
<trans-unit id="101">
<source>The selected choice is invalid.</source>
<target>Odabrani izbor nije ispravan.</target>
</trans-unit>
<trans-unit id="102">
<source>The collection is invalid.</source>
<target>Kolekcija nije ispravna.</target>
</trans-unit>
<trans-unit id="103">
<source>Please select a valid color.</source>
<target>Molim odaberite ispravnu boju.</target>
</trans-unit>
<trans-unit id="104">
<source>Please select a valid country.</source>
<target>Molim odaberite ispravnu državu.</target>
</trans-unit>
<trans-unit id="105">
<source>Please select a valid currency.</source>
<target>Molim odaberite ispravnu valutu.</target>
</trans-unit>
<trans-unit id="106">
<source>Please choose a valid date interval.</source>
<target>Molim odaberite ispravni vremenski interval.</target>
</trans-unit>
<trans-unit id="107">
<source>Please enter a valid date and time.</source>
<target>Molim unesite ispravni datum i vrijeme.</target>
</trans-unit>
<trans-unit id="108">
<source>Please enter a valid date.</source>
<target>Molim odaberite ispravan datum.</target>
</trans-unit>
<trans-unit id="109">
<source>Please select a valid file.</source>
<target>Molim odaberite ispravnu datoteku.</target>
</trans-unit>
<trans-unit id="110">
<source>The hidden field is invalid.</source>
<target>Skriveno polje nije ispravno.</target>
</trans-unit>
<trans-unit id="111">
<source>Please enter an integer.</source>
<target>Molim unesite cijeli broj.</target>
</trans-unit>
<trans-unit id="112">
<source>Please select a valid language.</source>
<target>Molim odaberite ispravan jezik.</target>
</trans-unit>
<trans-unit id="113">
<source>Please select a valid locale.</source>
<target>Molim odaberite ispravnu lokalizaciju.</target>
</trans-unit>
<trans-unit id="114">
<source>Please enter a valid money amount.</source>
<target>Molim unesite ispravan iznos novca.</target>
</trans-unit>
<trans-unit id="115">
<source>Please enter a number.</source>
<target>Molim unesite broj.</target>
</trans-unit>
<trans-unit id="116">
<source>The password is invalid.</source>
<target>Ova lozinka nije ispravna.</target>
</trans-unit>
<trans-unit id="117">
<source>Please enter a percentage value.</source>
<target>Molim unesite vrijednost postotka.</target>
</trans-unit>
<trans-unit id="118">
<source>The values do not match.</source>
<target>Ove vrijednosti se ne poklapaju.</target>
</trans-unit>
<trans-unit id="119">
<source>Please enter a valid time.</source>
<target>Molim unesite ispravno vrijeme.</target>
</trans-unit>
<trans-unit id="120">
<source>Please select a valid timezone.</source>
<target>Molim odaberite ispravnu vremensku zonu.</target>
</trans-unit>
<trans-unit id="121">
<source>Please enter a valid URL.</source>
<target>Molim unesite ispravan URL.</target>
</trans-unit>
<trans-unit id="122">
<source>Please enter a valid search term.</source>
<target>Molim unesite ispravan pojam za pretraživanje.</target>
</trans-unit>
<trans-unit id="123">
<source>Please provide a valid phone number.</source>
<target>Molim navedite ispravan telefonski broj.</target>
</trans-unit>
<trans-unit id="124">
<source>The checkbox has an invalid value.</source>
<target>Polje za potvrdu sadrži neispravnu vrijednost.</target>
</trans-unit>
<trans-unit id="125">
<source>Please enter a valid email address.</source>
<target>Molim unesite valjanu adresu elektronske pošte.</target>
</trans-unit>
<trans-unit id="126">
<source>Please select a valid option.</source>
<target>Molim odaberite ispravnu opciju.</target>
</trans-unit>
<trans-unit id="127">
<source>Please select a valid range.</source>
<target>Molim odaberite ispravan raspon.</target>
</trans-unit>
<trans-unit id="128">
<source>Please enter a valid week.</source>
<target>Molim unesite ispravni tjedan.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -43,6 +43,10 @@ class JsonResponse extends Response
{
parent::__construct('', $status, $headers);
if ($json && !\is_string($data) && !is_numeric($data) && !\is_callable([$data, '__toString'])) {
throw new \TypeError(sprintf('"%s": If $json is set to true, argument $data must be a string or object implementing __toString(), "%s" given.', __METHOD__, get_debug_type($data)));
}
if (null === $data) {
$data = new \ArrayObject();
}
@ -81,13 +85,13 @@ class JsonResponse extends Response
* return JsonResponse::fromJsonString('{"key": "value"}')
* ->setSharedMaxAge(300);
*
* @param string|null $data The JSON response string
* @param int $status The response status code
* @param array $headers An array of response headers
* @param string $data The JSON response string
* @param int $status The response status code
* @param array $headers An array of response headers
*
* @return static
*/
public static function fromJsonString(string $data = null, int $status = 200, array $headers = [])
public static function fromJsonString(string $data, int $status = 200, array $headers = [])
{
return new static($data, $status, $headers, true);
}

View File

@ -267,6 +267,36 @@ class JsonResponseTest extends TestCase
$this->assertEquals('/**/ಠ_ಠ["foo"].bar[0]({"foo":"bar"});', $response->getContent());
}
public function testConstructorWithNullAsDataThrowsAnUnexpectedValueException()
{
$this->expectException(\TypeError::class);
$this->expectExceptionMessage('If $json is set to true, argument $data must be a string or object implementing __toString(), "null" given.');
new JsonResponse(null, 200, [], true);
}
public function testConstructorWithObjectWithToStringMethod()
{
$class = new class() {
public function __toString()
{
return '{}';
}
};
$response = new JsonResponse($class, 200, [], true);
$this->assertSame('{}', $response->getContent());
}
public function testConstructorWithObjectWithoutToStringMethodThrowsAnException()
{
$this->expectException(\TypeError::class);
$this->expectExceptionMessage('If $json is set to true, argument $data must be a string or object implementing __toString(), "stdClass" given.');
new JsonResponse(new \stdClass(), 200, [], true);
}
}
if (interface_exists('JsonSerializable', false)) {

View File

@ -1,3 +1,4 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore

View File

@ -1,3 +1,4 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore

View File

@ -68,7 +68,7 @@ final class DiscordTransport extends AbstractTransport
$content = $message->getSubject();
if (\strlen($content) > 2000) {
throw new LogicException(sprintf('The subject length of "%s" transport must be less than 2000 characters.', __CLASS__, ChatMessage::class, get_debug_type($message)));
throw new LogicException(sprintf('The subject length of "%s" transport must be less than 2000 characters.', __CLASS__));
}
$endpoint = sprintf('https://%s/api/webhooks/%s/%s', $this->getEndpoint(), $this->webhookId, $this->token);

View File

@ -1,3 +1,4 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore

View File

@ -1,3 +1,4 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore

View File

@ -97,17 +97,17 @@ final class LinkedInTransport extends AbstractTransport
{
return [
'specificContent' => [
'com.linkedin.ugc.ShareContent' => [
'shareCommentary' => [
'attributes' => [],
'text' => $message->getSubject(),
],
'shareMediaCategory' => 'NONE',
],
'com.linkedin.ugc.ShareContent' => [
'shareCommentary' => [
'attributes' => [],
'text' => $message->getSubject(),
],
'visibility' => [
'com.linkedin.ugc.MemberNetworkVisibility' => 'PUBLIC',
'shareMediaCategory' => 'NONE',
],
],
'visibility' => [
'com.linkedin.ugc.MemberNetworkVisibility' => 'PUBLIC',
],
'lifecycleState' => 'PUBLISHED',
'author' => sprintf('urn:li:person:%s', $this->accountId),
];

View File

@ -1,3 +1,4 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore

View File

@ -1,3 +1,4 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore

View File

@ -1,3 +1,4 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore

View File

@ -62,6 +62,14 @@
<source>Account is locked.</source>
<target>Račun je zaključan.</target>
</trans-unit>
<trans-unit id="17">
<source>Too many failed login attempts, please try again later.</source>
<target>Previše neuspjelih pokušaja prijave, molim pokušajte ponovo kasnije.</target>
</trans-unit>
<trans-unit id="18">
<source>Invalid or expired login link.</source>
<target>Link za prijavu je isteako ili je neispravan.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -62,6 +62,14 @@
<source>Account is locked.</source>
<target>A conta está trancada.</target>
</trans-unit>
<trans-unit id="17">
<source>Too many failed login attempts, please try again later.</source>
<target>Várias tentativas de login falhadas, por favor tente mais tarde.</target>
</trans-unit>
<trans-unit id="18">
<source>Invalid or expired login link.</source>
<target>Ligação de login inválida ou expirada.</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -1,3 +1,4 @@
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore

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>
<target>Ova lozinka je procurila u nekom od sigurnosnih propusta, te je potrebno koristiti drugu lozinku.</target>
</trans-unit>
<trans-unit id="94">
<source>This value should be between {{ min }} and {{ max }}.</source>
<target>Ova vrijednost treba biti između {{ min }} i {{ max }}.</target>
</trans-unit>
<trans-unit id="95">
<source>This value is not a valid hostname.</source>
<target>Ova vrijednost nije ispravno ime poslužitelja (engl. hostname).</target>
</trans-unit>
<trans-unit id="96">
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
<target>Broj elemenata u kolekciji treba biti djeljiv s {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="97">
<source>This value should satisfy at least one of the following constraints:</source>
<target>Ova vrijednost mora zadovoljiti jedan od sljedećih ograničenja:</target>
</trans-unit>
<trans-unit id="98">
<source>Each element of this collection should satisfy its own set of constraints.</source>
<target>Svaki element ove kolekcije mora zadovoljiti vlastiti skup ograničenja.</target>
</trans-unit>
<trans-unit id="99">
<source>This value is not a valid International Securities Identification Number (ISIN).</source>
<target>Ova vrijednost nije ispravan međunarodni identifikacijski broj vrijednosnih papira (ISIN).</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -330,6 +330,62 @@
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
<target>O Código de Identificação de Empresa (BIC) não está associado ao IBAN {{ iban }}.</target>
</trans-unit>
<trans-unit id="86">
<source>This value should be valid JSON.</source>
<target>Este valor deve ser um JSON válido.</target>
</trans-unit>
<trans-unit id="87">
<source>This collection should contain only unique elements.</source>
<target>Esta coleção deve conter só elementos únicos.</target>
</trans-unit>
<trans-unit id="88">
<source>This value should be positive.</source>
<target>Este valor deve ser estritamente positivo.</target>
</trans-unit>
<trans-unit id="89">
<source>This value should be either positive or zero.</source>
<target>Este valor deve ser superior ou igual a zero.</target>
</trans-unit>
<trans-unit id="90">
<source>This value should be negative.</source>
<target>Este valor deve ser estritamente negativo.</target>
</trans-unit>
<trans-unit id="91">
<source>This value should be either negative or zero.</source>
<target>Este valor deve ser inferior ou igual a zero.</target>
</trans-unit>
<trans-unit id="92">
<source>This value is not a valid timezone.</source>
<target>Este valor não é um fuso horário válido.</target>
</trans-unit>
<trans-unit id="93">
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
<target>Esta senha foi divulgada durante uma fuga de dados, não deve ser usada de novamente. Por favor usar uma senha outra.</target>
</trans-unit>
<trans-unit id="94">
<source>This value should be between {{ min }} and {{ max }}.</source>
<target>Este valor deve situar-se entre {{ min }} e {{ max }}.</target>
</trans-unit>
<trans-unit id="95">
<source>This value is not a valid hostname.</source>
<target>Este valor não é um nome de host válido.</target>
</trans-unit>
<trans-unit id="96">
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
<target>O número de elementos desta coleção deve ser um múltiplo de {{ compared_value }}.</target>
</trans-unit>
<trans-unit id="97">
<source>This value should satisfy at least one of the following constraints:</source>
<target>Este valor deve satisfazer pelo menos uma das seguintes restrições :</target>
</trans-unit>
<trans-unit id="98">
<source>Each element of this collection should satisfy its own set of constraints.</source>
<target>Cada elemento desta coleção deve satisfazer o seu próprio conjunto de restrições.</target>
</trans-unit>
<trans-unit id="99">
<source>This value is not a valid International Securities Identification Number (ISIN).</source>
<target>Este valor não é um Número Internacional de Identificação de Segurança (ISIN) válido.</target>
</trans-unit>
</body>
</file>
</xliff>