Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dbeb261

Browse filesBrowse files
committed
Merge branch '5.4' into 6.4
* 5.4: detect wrong e-mail validation modes read form values using the chain data accessor [Validator] Review Bulgarian (bg) translation Reviewed italian translation Fix french translation call substr() with integer offsets review: FR translation Update spanish and catalan translations Updated id=113 Arabic translation. #53771 Updated validator Lithuanian translations review: translation RU [PropertyInfo] Fix PHPStan properties type in trait [Validator] review validators.lv.xlf Review translation
2 parents 7c2f5a7 + 868eb11 commit dbeb261
Copy full SHA for dbeb261

File tree

Expand file treeCollapse file tree

22 files changed

+158
-56
lines changed
Filter options
Expand file treeCollapse file tree

22 files changed

+158
-56
lines changed

‎src/Symfony/Component/Form/Extension/Core/DataAccessor/PropertyPathAccessor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataAccessor/PropertyPathAccessor.php
+23-2Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
namespace Symfony\Component\Form\Extension\Core\DataAccessor;
1313

1414
use Symfony\Component\Form\DataAccessorInterface;
15+
use Symfony\Component\Form\DataMapperInterface;
1516
use Symfony\Component\Form\Exception\AccessException;
17+
use Symfony\Component\Form\Extension\Core\DataMapper\DataMapper;
1618
use Symfony\Component\Form\FormInterface;
1719
use Symfony\Component\PropertyAccess\Exception\AccessException as PropertyAccessException;
1820
use Symfony\Component\PropertyAccess\Exception\NoSuchIndexException;
@@ -51,15 +53,25 @@ public function setValue(object|array &$data, mixed $value, FormInterface $form)
5153
throw new AccessException('Unable to write the given value as no property path is defined.');
5254
}
5355

56+
$getValue = function () use ($data, $form, $propertyPath) {
57+
$dataMapper = $this->getDataMapper($form);
58+
59+
if ($dataMapper instanceof DataMapper && null !== $dataAccessor = $dataMapper->getDataAccessor()) {
60+
return $dataAccessor->getValue($data, $form);
61+
}
62+
63+
return $this->getPropertyValue($data, $propertyPath);
64+
};
65+
5466
// If the field is of type DateTimeInterface and the data is the same skip the update to
5567
// keep the original object hash
56-
if ($value instanceof \DateTimeInterface && $value == $this->getPropertyValue($data, $propertyPath)) {
68+
if ($value instanceof \DateTimeInterface && $value == $getValue()) {
5769
return;
5870
}
5971

6072
// If the data is identical to the value in $data, we are
6173
// dealing with a reference
62-
if (!\is_object($data) || !$form->getConfig()->getByReference() || $value !== $this->getPropertyValue($data, $propertyPath)) {
74+
if (!\is_object($data) || !$form->getConfig()->getByReference() || $value !== $getValue()) {
6375
$this->propertyAccessor->setValue($data, $propertyPath, $value);
6476
}
6577
}
@@ -93,4 +105,13 @@ private function getPropertyValue(object|array $data, PropertyPathInterface $pro
93105
return null;
94106
}
95107
}
108+
109+
private function getDataMapper(FormInterface $form): ?DataMapperInterface
110+
{
111+
do {
112+
$dataMapper = $form->getConfig()->getDataMapper();
113+
} while (null === $dataMapper && null !== $form = $form->getParent());
114+
115+
return $dataMapper;
116+
}
96117
}

‎src/Symfony/Component/Form/Extension/Core/DataMapper/DataMapper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataMapper/DataMapper.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ public function mapFormsToData(\Traversable $forms, mixed &$data): void
7474
}
7575
}
7676
}
77+
78+
/**
79+
* @internal
80+
*/
81+
public function getDataAccessor(): DataAccessorInterface
82+
{
83+
return $this->dataAccessor;
84+
}
7785
}

‎src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/DataMapperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataMapper/DataMapperTest.php
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Symfony\Component\Form\Extension\Core\DataAccessor\PropertyPathAccessor;
1717
use Symfony\Component\Form\Extension\Core\DataMapper\DataMapper;
1818
use Symfony\Component\Form\Extension\Core\Type\DateType;
19+
use Symfony\Component\Form\Extension\Core\Type\FormType;
20+
use Symfony\Component\Form\Extension\Core\Type\TextType;
1921
use Symfony\Component\Form\Form;
2022
use Symfony\Component\Form\FormConfigBuilder;
2123
use Symfony\Component\Form\FormFactoryBuilder;
@@ -403,6 +405,25 @@ public function testMapFormsToDataMapsDateTimeInstanceToArrayIfNotSetBefore()
403405

404406
$this->assertEquals(['date' => new \DateTime('2022-08-04', new \DateTimeZone('UTC'))], $form->getData());
405407
}
408+
409+
public function testMapFormToDataWithOnlyGetterConfigured()
410+
{
411+
$person = new DummyPerson('foo');
412+
$form = (new FormFactoryBuilder())
413+
->getFormFactory()
414+
->createBuilder(FormType::class, $person)
415+
->add('name', TextType::class, [
416+
'getter' => function (DummyPerson $person) {
417+
return $person->myName();
418+
},
419+
])
420+
->getForm();
421+
$form->submit([
422+
'name' => 'bar',
423+
]);
424+
425+
$this->assertSame('bar', $person->myName());
426+
}
406427
}
407428

408429
class SubmittedForm extends Form
@@ -439,4 +460,9 @@ public function rename($name): void
439460
{
440461
$this->name = $name;
441462
}
463+
464+
public function setName($name): void
465+
{
466+
$this->name = $name;
467+
}
442468
}

‎src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ private function getDocBlockFromProperty(string $class, string $property): ?arra
232232
return null;
233233
}
234234

235+
$reflector = $reflectionProperty->getDeclaringClass();
236+
237+
foreach ($reflector->getTraits() as $trait) {
238+
if ($trait->hasProperty($property)) {
239+
return $this->getDocBlockFromProperty($trait->getName(), $property);
240+
}
241+
}
242+
235243
// Type can be inside property docblock as `@var`
236244
$rawDocNode = $reflectionProperty->getDocComment();
237245
$phpDocNode = $rawDocNode ? $this->getPhpDocNode($rawDocNode) : null;

‎src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\PropertyInfo\Tests\Fixtures\Php80Dummy;
2222
use Symfony\Component\PropertyInfo\Tests\Fixtures\Php80PromotedDummy;
2323
use Symfony\Component\PropertyInfo\Tests\Fixtures\RootDummy\RootDummyItem;
24+
use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\AnotherNamespace\DummyInAnotherNamespace;
2425
use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\DummyUsedInTrait;
2526
use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\DummyUsingTrait;
2627
use Symfony\Component\PropertyInfo\Type;
@@ -306,6 +307,7 @@ public static function propertiesDefinedByTraitsProvider(): array
306307
['propertyInTraitPrimitiveType', new Type(Type::BUILTIN_TYPE_STRING)],
307308
['propertyInTraitObjectSameNamespace', new Type(Type::BUILTIN_TYPE_OBJECT, false, DummyUsedInTrait::class)],
308309
['propertyInTraitObjectDifferentNamespace', new Type(Type::BUILTIN_TYPE_OBJECT, false, Dummy::class)],
310+
['dummyInAnotherNamespace', new Type(Type::BUILTIN_TYPE_OBJECT, false, DummyInAnotherNamespace::class)],
309311
];
310312
}
311313

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\AnotherNamespace;
4+
5+
class DummyInAnotherNamespace
6+
{
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\AnotherNamespace;
4+
5+
trait DummyTraitInAnotherNamespace
6+
{
7+
/**
8+
* @var DummyInAnotherNamespace
9+
*/
10+
public $dummyInAnotherNamespace;
11+
}

‎src/Symfony/Component/PropertyInfo/Tests/Fixtures/TraitUsage/DummyUsingTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Fixtures/TraitUsage/DummyUsingTrait.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
namespace Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage;
1313

14+
use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\AnotherNamespace\DummyTraitInAnotherNamespace;
15+
1416
class DummyUsingTrait
1517
{
1618
use DummyTrait;
19+
use DummyTraitInAnotherNamespace;
1720
}

‎src/Symfony/Component/Validator/Constraints/Email.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Email.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function __construct(
6868
throw new InvalidArgumentException('The "mode" parameter value is not valid.');
6969
}
7070

71+
if (null !== $mode && !\in_array($mode, self::$validationModes, true)) {
72+
throw new InvalidArgumentException('The "mode" parameter value is not valid.');
73+
}
74+
7175
parent::__construct($options, $groups, $payload);
7276

7377
$this->message = $message ?? $this->message;

‎src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.ar.xlf
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@
440440
</trans-unit>
441441
<trans-unit id="113">
442442
<source>This URL is missing a top-level domain.</source>
443-
<target state="needs-review-translation">هذا الرابط يفتقر إلى نطاق أعلى مستوى.</target>
443+
<target>هذا الرابط يفتقر إلى نطاق المستوى الأعلى.</target>
444444
</trans-unit>
445445
</body>
446446
</file>

‎src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.bg.xlf
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</trans-unit>
6969
<trans-unit id="17">
7070
<source>The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}.</source>
71-
<target>Mime типа на файла е невалиден ({{ type }}). Разрешени mime типове са {{ types }}.</target>
71+
<target>Mime типът на файла е невалиден ({{ type }}). Разрешени mime типове са {{ types }}.</target>
7272
</trans-unit>
7373
<trans-unit id="18">
7474
<source>This value should be {{ limit }} or less.</source>
@@ -136,7 +136,7 @@
136136
</trans-unit>
137137
<trans-unit id="37" resname="This is not a valid IP address.">
138138
<source>This value is not a valid IP address.</source>
139-
<target state="needs-review-translation">Тази стойност не е валиден IP адрес.</target>
139+
<target>Стойността не е валиден IP адрес.</target>
140140
</trans-unit>
141141
<trans-unit id="38">
142142
<source>This value is not a valid language.</source>
@@ -156,7 +156,7 @@
156156
</trans-unit>
157157
<trans-unit id="42">
158158
<source>The size of the image could not be detected.</source>
159-
<target>Размера на изображението не може да бъде определен.</target>
159+
<target>Размерът на изображението не може да бъде определен.</target>
160160
</trans-unit>
161161
<trans-unit id="43">
162162
<source>The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px.</source>
@@ -192,7 +192,7 @@
192192
</trans-unit>
193193
<trans-unit id="51" resname="No temporary folder was configured in php.ini.">
194194
<source>No temporary folder was configured in php.ini, or the configured folder does not exist.</source>
195-
<target state="needs-review-translation">В php.ini не е конфигурирана временна директория, или конфигурираната директория не съществува.</target>
195+
<target>В php.ini не е конфигурирана временна директория или конфигурираната директория не съществува.</target>
196196
</trans-unit>
197197
<trans-unit id="52">
198198
<source>Cannot write temporary file to disk.</source>
@@ -224,7 +224,7 @@
224224
</trans-unit>
225225
<trans-unit id="59" resname="This is not a valid International Bank Account Number (IBAN).">
226226
<source>This value is not a valid International Bank Account Number (IBAN).</source>
227-
<target state="needs-review-translation">Тази стойност не е валиден международен банков сметка номер (IBAN).</target>
227+
<target>Стойността не е валиден Международен номер на банкова сметка (IBAN).</target>
228228
</trans-unit>
229229
<trans-unit id="60">
230230
<source>This value is not a valid ISBN-10.</source>
@@ -312,23 +312,23 @@
312312
</trans-unit>
313313
<trans-unit id="81" resname="This is not a valid Business Identifier Code (BIC).">
314314
<source>This value is not a valid Business Identifier Code (BIC).</source>
315-
<target state="needs-review-translation">Тази стойност не е валиден код за идентификация на бизнеса (BIC).</target>
315+
<target>Стойността не е валиден Бизнес идентификационен код (BIC).</target>
316316
</trans-unit>
317317
<trans-unit id="82">
318318
<source>Error</source>
319319
<target>Грешка</target>
320320
</trans-unit>
321321
<trans-unit id="83" resname="This is not a valid UUID.">
322322
<source>This value is not a valid UUID.</source>
323-
<target state="needs-review-translation">Тази стойност не е валиден UUID.</target>
323+
<target>Стойността не е валиден UUID.</target>
324324
</trans-unit>
325325
<trans-unit id="84">
326326
<source>This value should be a multiple of {{ compared_value }}.</source>
327327
<target>Стойността трябва да бъде кратно число на {{ compared_value }}.</target>
328328
</trans-unit>
329329
<trans-unit id="85">
330330
<source>This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.</source>
331-
<target>Бизнес идентификационния код (BIC) не е свързан с IBAN {{ iban }}.</target>
331+
<target>Бизнес идентификационният код (BIC) не е свързан с IBAN {{ iban }}.</target>
332332
</trans-unit>
333333
<trans-unit id="86">
334334
<source>This value should be valid JSON.</source>
@@ -360,7 +360,7 @@
360360
</trans-unit>
361361
<trans-unit id="93">
362362
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
363-
<target>Тази парола е компрометирана, не трябва да бъде използвана. Моля използвайте друга парола.</target>
363+
<target>Тази парола е компрометирана, не може да бъде използвана. Моля използвайте друга парола.</target>
364364
</trans-unit>
365365
<trans-unit id="94">
366366
<source>This value should be between {{ min }} and {{ max }}.</source>
@@ -436,11 +436,11 @@
436436
</trans-unit>
437437
<trans-unit id="112">
438438
<source>This value is not a valid MAC address.</source>
439-
<target state="needs-review-translation">Тази стойност не е валиден MAC адрес.</target>
439+
<target>Стойността не е валиден MAC адрес.</target>
440440
</trans-unit>
441441
<trans-unit id="113">
442442
<source>This URL is missing a top-level domain.</source>
443-
<target state="needs-review-translation">На този URL липсва домейн от най-високо ниво.</target>
443+
<target>На този URL липсва домейн от най-високо ниво.</target>
444444
</trans-unit>
445445
</body>
446446
</file>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.