Skip to content

Commit 2e68801

Browse files
committed
[Form] Add argument type checking in BaseDateTimeTransformer
1 parent dac798c commit 2e68801

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,19 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface
3232
*
3333
* @param string $inputTimezone The name of the input timezone
3434
* @param string $outputTimezone The name of the output timezone
35+
*
36+
* @throws UnexpectedTypeException if a timezone is not a string
3537
*/
3638
public function __construct($inputTimezone = null, $outputTimezone = null)
3739
{
40+
if (!is_string($inputTimezone) && null !== $inputTimezone) {
41+
throw new UnexpectedTypeException($inputTimezone, 'string');
42+
}
43+
44+
if (!is_string($outputTimezone) && null !== $outputTimezone) {
45+
throw new UnexpectedTypeException($outputTimezone, 'string');
46+
}
47+
3848
$this->inputTimezone = $inputTimezone ?: date_default_timezone_get();
3949
$this->outputTimezone = $outputTimezone ?: date_default_timezone_get();
4050
}

0 commit comments

Comments
 (0)