8000 [Validator] Renamed valueToString() to formatValue(); added missing f… · symfony/symfony@d6a783f · GitHub
[go: up one dir, main page]

Skip to content

Commit d6a783f

Browse files
committed
[Validator] Renamed valueToString() to formatValue(); added missing formatValue() calls
1 parent 71897d7 commit d6a783f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+105
-85
lines changed

src/Symfony/Component/Validator/ConstraintValidator.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function initialize(ExecutionContextInterface $context)
4040
*
4141
* @return string
4242
*/
43-
protected function valueToType($value)
43+
protected function formatTypeOf($value)
4444
{
4545
return is_object($value) ? get_class($value) : gettype($value);
4646
}
@@ -49,13 +49,13 @@ protected function valueToType($value)
4949
* Returns a string representation of the value.
5050
*
5151
* @param mixed $value
52-
* @param bool $formatDates
52+
* @param bool $prettyDateTime
5353
*
5454
* @return string
5555
*/
56-
protected function valueToString($value, $formatDates = false)
56+
protected function formatValue($value, $prettyDateTime = false)
5757
{
58-
if ($formatDates && $value instanceof \DateTime) {
58+
if ($prettyDateTime && $value instanceof \DateTime) {
5959
if (class_exists('IntlDateFormatter')) {
6060
$locale = \Locale::getDefault();
6161
$formatter = new \IntlDateFormatter($locale, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT);
@@ -101,14 +101,14 @@ protected function valueToString($value, $formatDates = false)
101101
* Returns a string representation of a list of values.
102102
*
103103
* @param array $values
104-
* @param bool $formatDates
104+
* @param bool $prettyDateTime
105105
*
106106
* @return string
107107
*/
108-
protected function valuesToString(array $values, $formatDates = false)
108+
protected function formatValues(array $values, $prettyDateTime = false)
109109
{
110110
foreach ($values as $key => $value) {
111-
$values[$key] = $this->valueToString($value, $formatDates);
111+
$values[$key] = $this->formatValue($value, $prettyDateTime);
112112
}
113113

114114
return implode(', ', $values);

src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public function validate($value, Constraint $constraint)
3232

3333
if (!$this->compareValues($value, $constraint->value)) {
3434
$this->context->addViolation($constraint->message, array(
35-
'{{ value }}' => $this->valueToString($value, true),
36-
'{{ compared_value }}' => $this->valueToString($constraint->value, true),
37-
'{{ compared_value_type }}' => $this->valueToType($constraint->value)
35+
'{{ value }}' => $this->formatValue($value, true),
36+
'{{ compared_value }}' => $this->formatValue($constraint->value, true),
37+
'{{ compared_value_type }}' => $this->formatTypeOf($constraint->value)
3838
));
3939
}
4040
}

src/Symfony/Component/Validator/Constraints/BlankValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function validate($value, Constraint $constraint)
2828
{
2929
if ('' !== $value && null !== $value) {
3030
$this->context->addViolation($constraint->message, array(
31-
'{{ value }}' => $this->valueToString($value)
31+
'{{ value }}' => $this->formatValue($value)
3232
));
3333
}
3434
}

src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function validate($value, Constraint $constraint)
109109

110110
if (!is_numeric($value)) {
111111
$this->context->addViolation($constraint->message, array(
112-
'{{ value }}' => $this->valueToString($value),
112+
'{{ value }}' => $this->formatValue($value),
113113
));
114114

115115
return;
@@ -127,7 +127,7 @@ public function validate($value, Constraint $constraint)
127127
}
128128

129129
$this->context->addViolation($constraint->message, array(
130-
'{{ value }}' => $value,
130+
'{{ value }}' => $this->formatValue($value),
131131
));
132132
}
133133
}

src/Symfony/Component/Validator/Constraints/ChoiceValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function validate($value, Constraint $constraint)
6060
foreach ($value as $_value) {
6161
if (!in_array($_value, $choices, $constraint->strict)) {
6262
$this->context->addViolation($constraint->multipleMessage, array(
63-
'{{ value }}' => $this->valueToString($_value),
63+
'{{ value }}' => $this->formatValue($_value),
6464
));
6565
}
6666
}
@@ -84,7 +84,7 @@ public function validate($value, Constraint $constraint)
8484
}
8585
} elseif (!in_array($value, $choices, $constraint->strict)) {
8686
$this->context->addViolation($constraint->message, array(
87-
'{{ value }}' => $this->valueToString($value)
87+
'{{ value }}' => $this->formatValue($value)
8888
));
8989
}
9090
}

src/Symfony/Component/Validator/Constraints/CollectionValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function validate($value, Constraint $constraint)
4848
}
4949
} elseif (!$fieldConstraint instanceof Optional && !$constraint->allowMissingFields) {
5050
$this->context->addViolationAt('['.$field.']', $constraint->missingFieldsMessage, array(
51-
'{{ field }}' => $field
51+
'{{ field }}' => $this->formatValue($field)
5252
), null);
5353
}
5454
}
@@ -57,7 +57,7 @@ public function validate($value, Constraint $constraint)
5757
foreach ($value as $field => $fieldValue) {
5858
if (!isset($constraint->fields[$field])) {
5959
$this->context->addViolationAt('['.$field.']', $constraint->extraFieldsMessage, array(
60-
'{{ field }}' => $field
60+
'{{ field }}' => $this->formatValue($field)
6161
), $fieldValue);
6262
}
6363
}

src/Symfony/Component/Validator/Constraints/CountryValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function validate($value, Constraint $constraint)
4343

4444
if (!isset($countries[$value])) {
4545
$this->context->addViolation($constraint->message, array(
46-
'{{ value }}' => $value,
46+
'{{ value }}' => $this->formatValue($value),
4747
));
4848
}
4949
}

src/Symfony/Component/Validator/Constraints/CurrencyValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function validate($value, Constraint $constraint)
4343

4444
if (!isset($currencies[$value])) {
4545
$this->context->addViolation($constraint->message, array(
46-
'{{ value }}' => $value,
46+
'{{ value }}' => $this->formatValue($value),
4747
));
4848
}
4949
}

src/Symfony/Component/Validator/Constraints/DateValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function validate($value, Constraint $constraint)
4141

4242
if (!preg_match(static::PATTERN, $value, $matches) || !checkdate($matches[2], $matches[3], $matches[1])) {
4343
$this->context->addViolation($constraint->message, array(
44-
'{{ value }}' => $value,
44+
'{{ value }}' => $this->formatValue($value),
4545
));
4646
}
4747
}

src/Symfony/Component/Validator/Constraints/EmailValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function validate($value, Constraint $constraint)
5151

5252
if (!$valid) {
5353
$this->context->addViolation($constraint->message, array(
54-
'{{ value }}' => $value,
54+
'{{ value }}' => $this->formatValue($value),
5555
));
5656
}
5757
}

0 commit comments

Comments
 (0)
0