minor #31278 [Form] Fix author tag + exception messages (ro0NL)
This PR was squashed before being merged into the 3.4 branch (closes #31278).
Discussion
----------
[Form] Fix author tag + exception messages
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
spotted in #31195 😅
Commits
-------
796f2fff9b
[Form] Fix author tag + exception messages
This commit is contained in:
commit
f033ea4ab8
@ -17,7 +17,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
|
|||||||
/**
|
/**
|
||||||
* Transforms between a timezone identifier string and a DateTimeZone object.
|
* Transforms between a timezone identifier string and a DateTimeZone object.
|
||||||
*
|
*
|
||||||
* @author Roland Franssen <franssen.roland@gmai.com>
|
* @author Roland Franssen <franssen.roland@gmail.com>
|
||||||
*/
|
*/
|
||||||
class DateTimeZoneToStringTransformer implements DataTransformerInterface
|
class DateTimeZoneToStringTransformer implements DataTransformerInterface
|
||||||
{
|
{
|
||||||
@ -39,14 +39,14 @@ class DateTimeZoneToStringTransformer implements DataTransformerInterface
|
|||||||
|
|
||||||
if ($this->multiple) {
|
if ($this->multiple) {
|
||||||
if (!\is_array($dateTimeZone)) {
|
if (!\is_array($dateTimeZone)) {
|
||||||
throw new TransformationFailedException('Expected an array.');
|
throw new TransformationFailedException('Expected an array of \DateTimeZone objects.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_map([new self(), 'transform'], $dateTimeZone);
|
return array_map([new self(), 'transform'], $dateTimeZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$dateTimeZone instanceof \DateTimeZone) {
|
if (!$dateTimeZone instanceof \DateTimeZone) {
|
||||||
throw new TransformationFailedException('Expected a \DateTimeZone.');
|
throw new TransformationFailedException('Expected a \DateTimeZone object.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dateTimeZone->getName();
|
return $dateTimeZone->getName();
|
||||||
@ -63,14 +63,14 @@ class DateTimeZoneToStringTransformer implements DataTransformerInterface
|
|||||||
|
|
||||||
if ($this->multiple) {
|
if ($this->multiple) {
|
||||||
if (!\is_array($value)) {
|
if (!\is_array($value)) {
|
||||||
throw new TransformationFailedException('Expected an array.');
|
throw new TransformationFailedException('Expected an array of timezone identifier strings.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_map([new self(), 'reverseTransform'], $value);
|
return array_map([new self(), 'reverseTransform'], $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\is_string($value)) {
|
if (!\is_string($value)) {
|
||||||
throw new TransformationFailedException('Expected a string.');
|
throw new TransformationFailedException('Expected a timezone identifier string.');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user