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 8f7b8aa

Browse filesBrowse files
committed
Merge branch '3.4' into 4.4
* 3.4: [Validator] Add missing vietnamese translations add German translation [Validator][ConstraintValidator] Update wrong PRETTY_DATE doc [DomCrawler][Form] Fix PHPDoc on get & offsetGet prevent method calls on null values Return int if scale = 0
2 parents 4ac38ef + 34c2e96 commit 8f7b8aa
Copy full SHA for 8f7b8aa

File tree

10 files changed

+71
-10
lines changed
Filter options

10 files changed

+71
-10
lines changed

‎src/Symfony/Component/DomCrawler/Form.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Form.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function remove($name)
279279
*
280280
* @param string $name The field name
281281
*
282-
* @return FormField The field instance
282+
* @return FormField|FormField[]|FormField[][] The value of the field
283283
*
284284
* @throws \InvalidArgumentException When field is not present in this form
285285
*/
@@ -323,7 +323,7 @@ public function offsetExists($name)
323323
*
324324
* @param string $name The field name
325325
*
326-
* @return FormField The associated Field instance
326+
* @return FormField|FormField[]|FormField[][] The value of the field
327327
*
328328
* @throws \InvalidArgumentException if the field does not exist
329329
*/

‎src/Symfony/Component/DomCrawler/FormFieldRegistry.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/FormFieldRegistry.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function remove(string $name)
6666
/**
6767
* Returns the value of the field based on the fully qualifed name and its children.
6868
*
69-
* @return mixed The value of the field
69+
* @return FormField|FormField[]|FormField[][] The value of the field
7070
*
7171
* @throws \InvalidArgumentException if the field does not exist
7272
*/

‎src/Symfony/Component/DomCrawler/Tests/FormTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Tests/FormTest.php
+32-1Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DomCrawler\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\DomCrawler\Field\TextareaFormField;
1516
use Symfony\Component\DomCrawler\Form;
1617
use Symfony\Component\DomCrawler\FormFieldRegistry;
1718

@@ -965,7 +966,7 @@ protected function createTestMultipleForm()
965966
return $dom;
966967
}
967968

968-
public function testgetPhpValuesWithEmptyTextarea()
969+
public function testGetPhpValuesWithEmptyTextarea()
969970
{
970971
$dom = new \DOMDocument();
971972
$dom->loadHTML('
@@ -980,4 +981,34 @@ public function testgetPhpValuesWithEmptyTextarea()
980981
$form = new Form($nodes->item(0), 'http://example.com');
981982
$this->assertEquals($form->getPhpValues(), ['example' => '']);
982983
}
984+
985+
public function testGetReturnTypes()
986+
{
987+
$dom = new \DOMDocument();
988+
$dom->loadHTML('
989+
<html>
990+
<form>
991+
<textarea name="foo[collection][0][bar]">item 0</textarea>
992+
</form>
993+
</html>'
994+
);
995+
996+
$nodes = $dom->getElementsByTagName('form');
997+
$form = new Form($nodes->item(0), 'http://example.com');
998+
999+
// FormField
1000+
$this->assertInstanceOf(TextareaFormField::class, $textareaFormField = $form->get('foo[collection][0][bar]'));
1001+
1002+
// Array of FormField
1003+
$this->assertSame([
1004+
'bar' => $textareaFormField,
1005+
], $form->get('foo[collection][0]'));
1006+
1007+
// Array of array of FormField
1008+
$this->assertSame([
1009+
[
1010+
'bar' => $textareaFormField,
1011+
],
1012+
], $form->get('foo[collection]'));
1013+
}
9831014
}

‎src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private function round($number)
279279
break;
280280
}
281281

282-
$number /= $roundingCoef;
282+
$number = 1 === $roundingCoef ? (int) $number : $number / $roundingCoef;
283283
}
284284

285285
return $number;

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public function testReverseTransformWithRounding($scale, $input, $output, $round
370370
{
371371
$transformer = new NumberToLocalizedStringTransformer($scale, null, $roundingMode);
372372

373-
$this->assertEquals($output, $transformer->reverseTransform($input));
373+
$this->assertSame($output, $transformer->reverseTransform($input));
374374
}
375375

376376
public function testReverseTransformDoesNotRoundIfNoScale()

‎src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/XmlEncoder.php
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Serializer\Encoder;
1313

14+
use Symfony\Component\Serializer\Exception\BadMethodCallException;
1415
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
1516
use Symfony\Component\Serializer\SerializerAwareInterface;
1617
use Symfony\Component\Serializer\SerializerAwareTrait;
@@ -413,7 +414,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName =
413414
$removeEmptyTags = $this->context[self::REMOVE_EMPTY_TAGS] ?? $this->defaultContext[self::REMOVE_EMPTY_TAGS] ?? false;
414415
$encoderIgnoredNodeTypes = $this->context[self::ENCODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::ENCODER_IGNORED_NODE_TYPES];
415416

416-
if (\is_array($data) || ($data instanceof \Traversable && !$this->serializer->supportsNormalization($data, $this->format))) {
417+
if (\is_array($data) || ($data instanceof \Traversable && (null === $this->serializer || !$this->serializer->supportsNormalization($data, $this->format)))) {
417418
foreach ($data as $key => $data) {
418419
//Ah this is the magic @ attribute types.
419420
if (0 === strpos($key, '@') && $this->isElementNameValid($attributeName = substr($key, 1))) {
@@ -452,6 +453,10 @@ private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName =
452453
}
453454

454455
if (\is_object($data)) {
456+
if (null === $this->serializer) {
457+
throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used with object data.', __METHOD__));
458+
}
459+
455460
$data = $this->serializer->normalize($data, $this->format, $this->context);
456461
if (null !== $data && !is_scalar($data)) {
457462
return $this->buildXml($parentNode, $data, $xmlRootNodeName);
@@ -514,6 +519,10 @@ private function selectNodeType(\DOMNode $node, $val): bool
514519
} elseif ($val instanceof \Traversable) {
515520
$this->buildXml($node, $val);
516521
} elseif (\is_object($val)) {
522+
if (null === $this->serializer) {
523+
throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used with object data.', __METHOD__));
524+
}
525+
517526
return $this->selectNodeType($node, $this->serializer->normalize($val, $this->format, $this->context));
518527
} elseif (is_numeric($val)) {
519528
return $this->appendText($node, (string) $val);

‎src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/ArrayDenormalizer.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function denormalize($data, $type, $format = null, array $context = [])
6868
*/
6969
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool
7070
{
71+
if (null === $this->serializer) {
72+
throw new BadMethodCallException(sprintf('The serializer needs to be set to allow %s() to be used.', __METHOD__));
73+
}
74+
7175
return '[]' === substr($type, -2)
7276
&& $this->serializer->supportsDenormalization($data, substr($type, 0, -2), $format, $context);
7377
}

‎src/Symfony/Component/Validator/ConstraintValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/ConstraintValidator.php
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
abstract class ConstraintValidator implements ConstraintValidatorInterface
2222
{
2323
/**
24-
* Whether to format {@link \DateTime} objects as RFC-3339 dates
25-
* ("Y-m-d H:i:s").
24+
* Whether to format {@link \DateTime} objects, either with the {@link \IntlDateFormatter}
25+
* (if it is available) or as RFC-3339 dates ("Y-m-d H:i:s").
2626
*/
2727
const PRETTY_DATE = 1;
2828

@@ -69,7 +69,8 @@ protected function formatTypeOf($value)
6969
* in double quotes ("). Objects, arrays and resources are formatted as
7070
* "object", "array" and "resource". If the $format bitmask contains
7171
* the PRETTY_DATE bit, then {@link \DateTime} objects will be formatted
72-
* as RFC-3339 dates ("Y-m-d H:i:s").
72+
* with the {@link \IntlDateFormatter}. If it is not available, they will be
73+
* formatted as RFC-3339 dates ("Y-m-d H:i:s").
7374
*
7475
* Be careful when passing message parameters to a constraint violation
7576
* that (may) contain objects, arrays or resources. These parameters

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.de.xlf
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@
370370
<source>This value is not a valid hostname.</source>
371371
<target>Dieser Wert ist kein gültiger Hostname.</target>
372372
</trans-unit>
373+
<trans-unit id="96">
374+
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375+
<target>Die Anzahl an Elementen in dieser Sammlung sollte ein Vielfaches von {{ compared_value }} sein.</target>
376+
</trans-unit>
373377
</body>
374378
</file>
375379
</xliff>

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Resources/translations/validators.vi.xlf
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,18 @@
362362
<source>This password has been leaked in a data breach, it must not be used. Please use another password.</source>
363363
<target>Mật khẩu này đã bị rò rỉ dữ liệu, không được sử dụng nữa. Xin vui lòng sử dụng mật khẩu khác.</target>
364364
</trans-unit>
365+
<trans-unit id="94">
366+
<source>This value should be between {{ min }} and {{ max }}.</source>
367+
<target>Giá trị này nên thuộc giữa {{ min }} và {{ max }}.</target>
368+
</trans-unit>
369+
<trans-unit id="95">
370+
<source>This value is not a valid hostname.</source>
371+
<target>Giá trị này không phải là tên máy chủ hợp lệ.</target>
372+
</trans-unit>
373+
<trans-unit id="96">
374+
<source>The number of elements in this collection should be a multiple of {{ compared_value }}.</source>
375+
<target>Số lượng các phần tử trong bộ sưu tập này nên là bội số của {{compared_value}}.</target>
376+
</trans-unit>
365377
</body>
366378
</file>
367379
</xliff>

0 commit comments

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