Skip to content

Commit ff76409

Browse files
committed
merged branch ManuelAC/2.0 (PR symfony#2629)
Commits ------- 462580c [Form] Check for normal integers. refs 0427b12 970e2a2 [Form] Replace `an` with `is` Discussion ---------- [Form] DateTimeToArrayTransformer fix Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: - Todo: - 0427b12 throws an `TransformationFailedException` if you're using integers. In other words: `` array('year' => '2011', 'month' => '11', 'day' => '12') = valid `` `` array('year' => 2011, 'month' => 11, 'day' => 12) = invalid ``
2 parents bb5fb79 + 462580c commit ff76409

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,16 @@ public function reverseTransform($value)
142142
));
143143
}
144144

145-
if (isset($value['month']) && !ctype_digit($value['month'])) {
146-
throw new TransformationFailedException('This month an invalid');
145+
if (isset($value['month']) && !ctype_digit($value['month']) && !is_int($value['month'])) {
146+
throw new TransformationFailedException('This month is invalid');
147147
}
148148

149-
if (isset($value['day']) && !ctype_digit($value['day'])) {
150-
throw new TransformationFailedException('This day an invalid');
149+
if (isset($value['day']) && !ctype_digit($value['day']) && !is_int($value['day'])) {
150+
throw new TransformationFailedException('This day is invalid');
151151
}
152152

153-
if (isset($value['year']) && !ctype_digit($value['year'])) {
154-
throw new TransformationFailedException('This year an invalid');
153+
if (isset($value['year']) && !ctype_digit($value['year']) && !is_int($value['year'])) {
154+
throw new TransformationFailedException('This year is invalid');
155155
}
156156

157157
if (!empty($value['month']) && !empty($value['day']) && !empty($value['year']) && false === checkdate($value['month'], $value['day'], $value['year'])) {

0 commit comments

Comments
 (0)