Skip to content

Commit 9846d78

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: [Validator] Add Catalan and Spanish translation for `WordCount` constraint" [DependencyInjection] Do not try to load default method name on interface [PropertyInfo] Fix nullable value returned from extractFromMutator on CollectionType
2 parents c2bafcd + c1469bf commit 9846d78

File tree

7 files changed

+25
-5
lines changed

7 files changed

+25
-5
lines changed

src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ public static function getDefault(ContainerBuilder $container, string $serviceId
133133
return null;
134134
}
135135

136+
if ($r->isInterface()) {
137+
return null;
138+
}
139+
136140
if (null !== $indexAttribute) {
137141
$service = $class !== $serviceId ? sprintf('service "%s"', $serviceId) : 'on the corresponding service';
138142
$message = [sprintf('Either method "%s::%s()" should ', $class, $defaultMethod), sprintf(' or tag "%s" on %s is missing attribute "%s".', $tagName, $service, $indexAttribute)];

src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,16 @@ public function testTheIndexedTagsByDefaultIndexMethod()
151151

152152
$container->register('service3', IntTagClass::class)->addTag('my_custom_tag');
153153

154+
$container->register('service4', HelloInterface::class)->addTag('my_custom_tag');
155+
154156
$priorityTaggedServiceTraitImplementation = new PriorityTaggedServiceTraitImplementation();
155157

156158
$tag = new TaggedIteratorArgument('my_custom_tag', 'foo', 'getFooBar');
157159
$expected = [
158160
'bar_tab_class_with_defaultmethod' => new TypedReference('service2', BarTagClass::class),
159161
'service1' => new TypedReference('service1', FooTagClass::class),
160162
'10' => new TypedReference('service3', IntTagClass::class),
163+
'service4' => new TypedReference('service4', HelloInterface::class),
161164
];
162165
$services = $priorityTaggedServiceTraitImplementation->test($tag, $container);
163166
$this->assertSame(array_keys($expected), array_keys($services));
@@ -247,3 +250,8 @@ class HelloNamedService extends \stdClass
247250
class HelloNamedService2
248251
{
249252
}
253+
254+
interface HelloInterface
255+
{
256+
public static function getFooBar(): string;
257+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ private function extractFromMutator(string $class, string $property): ?array
523523
$type = $this->extractFromReflectionType($reflectionType, $reflectionMethod->getDeclaringClass());
524524

525525
if (1 === \count($type) && \in_array($prefix, $this->arrayMutatorPrefixes, true)) {
526-
$type = [new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true, new LegacyType(LegacyType::BUILTIN_TYPE_INT), $type[0])];
526+
$type = [new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, $this->isNullableProperty($class, $property), null, true, new LegacyType(LegacyType::BUILTIN_TYPE_INT), $type[0])];
527527
}
528528

529529
return $type;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ public function testTypedPropertiesLegacy()
549549
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true, new LegacyType(LegacyType::BUILTIN_TYPE_INT), new LegacyType(LegacyType::BUILTIN_TYPE_STRING))], $this->extractor->getTypes(Php74Dummy::class, 'stringCollection'));
550550
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_INT, true)], $this->extractor->getTypes(Php74Dummy::class, 'nullableWithDefault'));
551551
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, false, null, true)], $this->extractor->getTypes(Php74Dummy::class, 'collection'));
552+
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_ARRAY, true, null, true, new LegacyType(LegacyType::BUILTIN_TYPE_INT), new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, Dummy::class))], $this->extractor->getTypes(Php74Dummy::class, 'nullableTypedCollection'));
552553
}
553554

554555
/**

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php74Dummy.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,18 @@ class Php74Dummy
2323
private ?int $nullableWithDefault = 1;
2424
public array $collection = [];
2525

26+
/** @var Dummy[]|null */
27+
public ?array $nullableTypedCollection = null;
28+
2629
public function addStringCollection(string $string): void
2730
{
2831
}
2932

3033
public function removeStringCollection(string $string): void
3134
{
3235
}
36+
37+
public function addNullableTypedCollection(Dummy $dummy): void
38+
{
39+
}
3340
}

src/Symfony/Component/Validator/Resources/translations/validators.ca.xlf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,11 @@
444444
</trans-unit>
445445
<trans-unit id="114">
446446
<source>This value is too short. It should contain at least one word.|This value is too short. It should contain at least {{ min }} words.</source>
447-
<target state="needs-translation">This value is too short. It should contain at least one word.|This value is too short. It should contain at least {{ min }} words.</target>
447+
<target>Aquest valor és massa curt. Ha de contenir almenys una paraula.|Aquest valor és massa curt. Ha de contenir almenys {{ min }} paraules.</target>
448448
</trans-unit>
449449
<trans-unit id="115">
450450
<source>This value is too long. It should contain one word.|This value is too long. It should contain {{ max }} words or less.</source>
451-
<target state="needs-translation">This value is too long. It should contain one word.|This value is too long. It should contain {{ max }} words or less.</target>
451+
<target>Aquest valor és massa llarg. Ha de contenir una paraula.|Aquest valor és massa llarg. Ha de contenir {{ max }} paraules o menys.</target>
452452
</trans-unit>
453453
</body>
454454
</file>

src/Symfony/Component/Validator/Resources/translations/validators.es.xlf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,11 @@
444444
</trans-unit>
445445
<trans-unit id="114">
446446
<source>This value is too short. It should contain at least one word.|This value is too short. It should contain at least {{ min }} words.</source>
447-
<target state="needs-translation">This value is too short. It should contain at least one word.|This value is too short. It should contain at least {{ min }} words.</target>
447+
<target>Este valor es demasiado corto. Debe contener al menos una palabra.|Este valor es demasiado corto. Debe contener al menos {{ min }} palabras.</target>
448448
</trans-unit>
449449
<trans-unit id="115">
450450
<source>This value is too long. It should contain one word.|This value is too long. It should contain {{ max }} words or less.</source>
451-
<target state="needs-translation">This value is too long. It should contain one word.|This value is too long. It should contain {{ max }} words or less.</target>
451+
<target>Este valor es demasiado largo. Debe contener una palabra.|Este valor es demasiado largo. Debe contener {{ max }} palabras o menos.</target>
452452
</trans-unit>
453453
</body>
454454
</file>

0 commit comments

Comments
 (0)