Skip to content

Commit 857cf33

Browse files
Merge branch '5.2' into 5.x
* 5.2: Ignore indirect deprecation triggered by doctrine/orm Symfony Armenian Translations [Translation] Allow using dashes in locale when linting Xliff files use the right context for properties defined in traits
2 parents c54bfb7 + 00b4b76 commit 857cf33

File tree

12 files changed

+228
-25
lines changed

12 files changed

+228
-25
lines changed

.appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ init:
1212
- SET SYMFONY_DEPRECATIONS_HELPER=strict
1313
- SET ANSICON=121x90 (121x90)
1414
- SET SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE=1
15+
- SET SYMFONY_DEPRECATIONS_HELPER=max[indirect]=170
1516
- REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f
1617

1718
install:

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ before_install:
5454
export PHPUNIT_X="$PHPUNIT --exclude-group tty,benchmark,intl-data"
5555
export COMPOSER_UP='composer update --no-progress --ansi'
5656
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n' | sort)
57+
export SYMFONY_DEPRECATIONS_HELPER=max[indirect]=170
5758
5859
nanoseconds () {
5960
local cmd="date"

src/Symfony/Component/Form/Resources/translations/validators.hy.xlf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
<body>
55
<trans-unit id="28">
66
<source>This form should not contain extra fields.</source>
7-
<target>Այս ձևը չպետք է պարունակի լրացուցիչ տողեր.</target>
7+
<target>Այս ձևը չպետք է պարունակի լրացուցիչ տողեր։</target>
88
</trans-unit>
99
<trans-unit id="29">
1010
<source>The uploaded file was too large. Please try to upload a smaller file.</source>
11-
<target>Վերբեռնված ֆայլը չափազանց մեծ է: Խնդրվում է վերբեռնել ավելի փոքր չափսի ֆայլ.</target>
11+
<target>Վերբեռնված ֆայլը չափազանց մեծ է. Խնդրվում է վերբեռնել ավելի փոքր չափսի ֆայլ։</target>
1212
</trans-unit>
1313
<trans-unit id="30">
1414
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
15-
<target>CSRF արժեքը անթույլատրելի է: Փորձեք նորից ուղարկել ձևը.</target>
15+
<target>CSRF արժեքը անթույլատրելի է. Փորձեք նորից ուղարկել ձևը։</target>
1616
</trans-unit>
1717
</body>
1818
</file>

src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,17 @@ private function getDocBlockFromProperty(string $class, string $property): ?DocB
258258
}
259259

260260
try {
261-
return $this->docBlockFactory->create($reflectionProperty, $this->createFromReflector($reflectionProperty->getDeclaringClass()));
261+
$reflector = $reflectionProperty->getDeclaringClass();
262+
263+
foreach ($reflector->getTraits() as $trait) {
264+
if ($trait->hasProperty($property)) {
265+
$reflector = $trait;
266+
267+
break;
268+
}
269+
}
270+
271+
return $this->docBlockFactory->create($reflectionProperty, $this->createFromReflector($reflector));
262272
} catch (\InvalidArgumentException $e) {
263273
return null;
264274
} catch (\RuntimeException $e) {

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
use phpDocumentor\Reflection\Types\Collection;
1717
use PHPUnit\Framework\TestCase;
1818
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
19+
use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy;
20+
use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\DummyUsedInTrait;
21+
use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\DummyUsingTrait;
1922
use Symfony\Component\PropertyInfo\Type;
2023

2124
/**
@@ -322,6 +325,23 @@ public function testDocBlockFallback($property, $types)
322325
$this->assertEquals($types, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\DockBlockFallback', $property));
323326
}
324327

328+
/**
329+
* @dataProvider propertiesDefinedByTraitsProvider
330+
*/
331+
public function testPropertiesDefinedByTraits(string $property, Type $type)
332+
{
333+
$this->assertEquals([$type], $this->extractor->getTypes(DummyUsingTrait::class, $property));
334+
}
335+
336+
public function propertiesDefinedByTraitsProvider(): array
337+
{
338+
return [
339+
['propertyInTraitPrimitiveType', new Type(Type::BUILTIN_TYPE_STRING)],
340+
['propertyInTraitObjectSameNamespace', new Type(Type::BUILTIN_TYPE_OBJECT, false, DummyUsedInTrait::class)],
341+
['propertyInTraitObjectDifferentNamespace', new Type(Type::BUILTIN_TYPE_OBJECT, false, Dummy::class)],
342+
];
343+
}
344+
325345
protected function isPhpDocumentorV5()
326346
{
327347
if (class_exists(InvalidTag::class)) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage;
13+
14+
use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy;
15+
16+
trait DummyTrait
17+
{
18+
/**
19+
* @var string
20+
*/
21+
private $propertyInTraitPrimitiveType;
22+
23+
/**
24+
* @var DummyUsedInTrait
25+
*/
26+
private $propertyInTraitObjectSameNamespace;
27+
28+
/**
29+
* @var Dummy
30+
*/
31+
private $propertyInTraitObjectDifferentNamespace;
32+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage;
13+
14+
class DummyUsedInTrait
15+
{
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage;
13+
14+
class DummyUsingTrait
15+
{
16+
use DummyTrait;
17+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0"?>
2+
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
3+
<file source-language="en" datatype="plaintext" original="file.ext">
4+
<body>
5+
<trans-unit id="1">
6+
<source>An authentication exception occurred.</source>
7+
<target>Նույնականացման սխալ։</target>
8+
</trans-unit>
9+
<trans-unit id="2">
10+
<source>Authentication credentials could not be found.</source>
11+
<target>Նույնականացման տվյալները չեն գտնվել։</target>
12+
</trans-unit>
13+
<trans-unit id="3">
14+
<source>Authentication request could not be processed due to a system problem.</source>
15+
<target>Համակարգային սխալ՝ նույնականացման հացրման պրոցեսինգի ժամանակ։</target>
16+
</trans-unit>
17+
<trans-unit id="4">
18+
<source>Invalid credentials.</source>
19+
<target>Սխալ մուտքային տվյալներ</target>
20+
</trans-unit>
21+
<trans-unit id="5">
22+
<source>Cookie has already been used by someone else.</source>
23+
<target>Cookie-ն արդեն օգտագործվում է ուրիշի կողմից։</target>
24+
</trans-unit>
25+
<trans-unit id="6">
26+
<source>Not privileged to request the resource.</source>
27+
<target>Ռեսուրսի հարցման համար չկա թույլատվություն։</target>
28+
</trans-unit>
29+
<trans-unit id="7">
30+
<source>Invalid CSRF token.</source>
31+
<target>Անվավեր CSRF թոքեն։</target>
32+
</trans-unit>
33+
<trans-unit id="9">
34+
<source>No authentication provider found to support the authentication token.</source>
35+
<target>Նույնականացման ոչ մի մատակարար չի գտնվել, որ աջակցի նույնականացման թոքենը։</target>
36+
</trans-unit>
37+
<trans-unit id="10">
38+
<source>No session available, it either timed out or cookies are not enabled.</source>
39+
<target>No session available, it either timed out or cookies are not enabled.</target>
40+
</trans-unit>
41+
<trans-unit id="11">
42+
<source>No token could be found.</source>
43+
<target>Թոքենը չի գտնվել։</target>
44+
</trans-unit>
45+
<trans-unit id="12">
46+
<source>Username could not be found.</source>
47+
<target>Օգտանունը չի գտնվել։</target>
48+
</trans-unit>
49+
<trans-unit id="13">
50+
<source>Account has expired.</source>
51+
<target>Հաշիվը ժամկետանց է։</target>
52+
</trans-unit>
53+
<trans-unit id="14">
54+
<source>Credentials have expired.</source>
55+
<target>Մուտքային տվյալները ժամկետանց են։</target>
56+
</trans-unit>
57+
<trans-unit id="15">
58+
<source>Account is disabled.</source>
59+
<target>Հաշիվը դեկատիվացված է։</target>
60+
</trans-unit>
61+
<trans-unit id="16">
62+
<source>Account is locked.</source>
63+
<target>Հաշիվն արգելափակված է։</target>
64+
</trans-unit>
65+
<trans-unit id="17">
66+
<source>Too many failed login attempts, please try again later.</source>
67+
<target>Չափից շատ մուտքի փորձեր, խնդրում ենք փորձել մի փոքր ուշ</target>
68+
</trans-unit>
69+
<trans-unit id="18">
70+
<source>Invalid or expired login link.</source>
71+
<target>Անվավեր կամ ժամկետանց մուտքի հղում։</target>
72+
</trans-unit>
73+
</body>
74+
</file>
75+
</xliff>

src/Symfony/Component/Translation/Command/XliffLintCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ private function validate(string $content, string $file = null): array
123123
$document->loadXML($content);
124124

125125
if (null !== $targetLanguage = $this->getTargetLanguageFromFile($document)) {
126-
$normalizedLocale = preg_quote(str_replace('-', '_', $targetLanguage), '/');
126+
$normalizedLocalePattern = sprintf('(%s|%s)', preg_quote($targetLanguage, '/'), preg_quote(str_replace('-', '_', $targetLanguage), '/'));
127127
// strict file names require translation files to be named '____.locale.xlf'
128128
// otherwise, both '____.locale.xlf' and 'locale.____.xlf' are allowed
129129
// also, the regexp matching must be case-insensitive, as defined for 'target-language' values
130130
// http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#target-language
131-
$expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.(?i:%s)\.(?:xlf|xliff)/', $normalizedLocale) : sprintf('/^(?:.*\.(?i:%s)|(?i:%s)\..*)\.(?:xlf|xliff)/', $normalizedLocale, $normalizedLocale);
131+
$expectedFilenamePattern = $this->requireStrictFileNames ? sprintf('/^.*\.(?i:%s)\.(?:xlf|xliff)/', $normalizedLocalePattern) : sprintf('/^(?:.*\.(?i:%s)|(?i:%s)\..*)\.(?:xlf|xliff)/', $normalizedLocalePattern, $normalizedLocalePattern);
132132

133133
if (0 === preg_match($expectedFilenamePattern, basename($file))) {
134134
$errors[] = [

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy