Skip to content

Commit 4d87609

Browse files
Merge branch '2.7' into 2.8
* 2.7: (22 commits) Tests and fix for issue in array model data in EntityType field with multiple=true [Form] Fixed PercentToLocalizedStringTransformer to accept both comma and dot as decimal separator, if possible removed useless PHPDoc [Form] Fix FormInterface::submit() annotation PdoSessionHandler: fix advisory lock for pgsql when session.sid_bits_per_character > 4 HttpCache does not consider ESI resources in HEAD requests Fix translation for "This field was not expected" [Routing] Enhance Route(Collection) docblocks Added improvement for accuracy in MoneyToLocalizedStringTransformer. Removed unused private property Use correct verb form in the pull request template Use PHP_MAXPATHLEN in Filesystem. Added null as explicit return type (?TokenInterface) [FrameworkBundle] Fix Routing\DelegatingLoader Render all line breaks according to the exception message [Form] Fix phpdoc [DI] remove confusing code [Form] Fixed GroupSequence with "constraints" option [Validator] Clarify UUID validator behavior [Filesystem] Fixed makePathRelative ...
2 parents 65d44bf + bb910fc commit 4d87609

28 files changed

+217
-73
lines changed

CallbackTransformer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ class CallbackTransformer implements DataTransformerInterface
3131
private $reverseTransform;
3232

3333
/**
34-
* Constructor.
35-
*
3634
* @param callable $transform The forward transform callback
3735
* @param callable $reverseTransform The reverse transform callback
3836
*

Extension/Core/DataTransformer/BaseDateTimeTransformer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface
3030
protected $outputTimezone;
3131

3232
/**
33-
* Constructor.
34-
*
3533
* @param string $inputTimezone The name of the input timezone
3634
* @param string $outputTimezone The name of the output timezone
3735
*

Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class ChoiceToBooleanArrayTransformer implements DataTransformerInterface
3030
private $placeholderPresent;
3131

3232
/**
33-
* Constructor.
34-
*
3533
* @param ChoiceListInterface $choiceList
3634
* @param bool $placeholderPresent
3735
*/

Extension/Core/DataTransformer/ChoiceToValueTransformer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class ChoiceToValueTransformer implements DataTransformerInterface
2323
private $choiceList;
2424

2525
/**
26-
* Constructor.
27-
*
2826
* @param ChoiceListInterface $choiceList
2927
*/
3028
public function __construct(ChoiceListInterface $choiceList)

Extension/Core/DataTransformer/ChoicesToValuesTransformer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class ChoicesToValuesTransformer implements DataTransformerInterface
2323
private $choiceList;
2424

2525
/**
26-
* Constructor.
27-
*
2826
* @param ChoiceListInterface $choiceList
2927
*/
3028
public function __construct(ChoiceListInterface $choiceList)

Extension/Core/DataTransformer/DateTimeToArrayTransformer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer
2727
private $fields;
2828

2929
/**
30-
* Constructor.
31-
*
3230
* @param string $inputTimezone The input timezone
3331
* @param string $outputTimezone The output timezone
3432
* @param array $fields The date fields

Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
2828
private $calendar;
2929

3030
/**
31-
* Constructor.
32-
*
3331
* @see BaseDateTimeTransformer::formats for available format options
3432
*
3533
* @param string $inputTimezone The name of the input timezone

Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ public function __construct($scale = 2, $grouping = true, $roundingMode = self::
5454
*/
5555
public function transform($value)
5656
{
57-
if (null !== $value) {
57+
if (null !== $value && 1 !== $this->divisor) {
5858
if (!is_numeric($value)) {
5959
throw new TransformationFailedException('Expected a numeric.');
6060
}
61-
62-
$value /= $this->divisor;
61+
$value = (string) ($value / $this->divisor);
6362
}
6463

6564
return parent::transform($value);
@@ -78,9 +77,8 @@ public function transform($value)
7877
public function reverseTransform($value)
7978
{
8079
$value = parent::reverseTransform($value);
81-
82-
if (null !== $value) {
83-
$value *= $this->divisor;
80+
if (null !== $value && 1 !== $this->divisor) {
81+
$value = (float) (string) ($value * $this->divisor);
8482
}
8583

8684
return $value;

Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface
3636
private $scale;
3737

3838
/**
39-
* Constructor.
40-
*
4139
* @see self::$types for a list of supported types
4240
*
4341
* @param int $scale The scale
@@ -119,6 +117,18 @@ public function reverseTransform($value)
119117
}
120118

121119
$formatter = $this->getNumberFormatter();
120+
$groupSep = $formatter->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
121+
$decSep = $formatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
122+
$grouping = $formatter->getAttribute(\NumberFormatter::GROUPING_USED);
123+
124+
if ('.' !== $decSep && (!$grouping || '.' !== $groupSep)) {
125+
$value = str_replace('.', $decSep, $value);
126+
}
127+
128+
if (',' !== $decSep && (!$grouping || ',' !== $groupSep)) {
129+
$value = str_replace(',', $decSep, $value);
130+
}
131+
122132
// replace normal spaces so that the formatter can read them
123133
$value = $formatter->parse(str_replace(' ', "\xc2\xa0", $value));
124134

Extension/Core/EventListener/FixCheckboxInputListener.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class FixCheckboxInputListener implements EventSubscriberInterface
3333
private $choiceList;
3434

3535
/**
36-
* Constructor.
37-
*
3836
* @param ChoiceListInterface $choiceList
3937
*/
4038
public function __construct(ChoiceListInterface $choiceList)

0 commit comments

Comments
 (0)