10000 [Form] Remove stalled PHP bug mentions · symfony/symfony@e688419 · GitHub
[go: up one dir, main page]

Skip to content

Commit e688419

Browse files
[Form] Remove stalled PHP bug mentions
1 parent f654df3 commit e688419

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Extension\Core\DataTransformer;
1313

14+
use Symfony\Component\Form\Exception\InvalidArgumentException;
1415
use Symfony\Component\Form\Exception\TransformationFailedException;
1516
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1617

@@ -60,6 +61,10 @@ public function __construct(
6061
throw new UnexpectedTypeException($timeFormat, implode('", "', self::$formats));
6162
}
6263

64+
if (\is_int($calendar) && !\in_array($calendar, [\IntlDateFormatter::GREGORIAN, \IntlDateFormatter::TRADITIONAL], true)) {
65+
throw new InvalidArgumentException('The "calendar" option should be either an \IntlDateFormatter constant or an \IntlCalendar instance.');
66+
}
67+
6368
$this->dateFormat = $dateFormat;
6469
$this->timeFormat = $timeFormat;
6570
}
@@ -157,8 +162,6 @@ public function reverseTransform(mixed $value): ?\DateTime
157162
* Returns a preconfigured IntlDateFormatter instance.
158163
*
159164
* @param bool $ignoreTimezone Use UTC regardless of the configured timezone
160-
*
161-
* @throws TransformationFailedException in case the date formatter cannot be constructed
162165
*/
163166
protected function getIntlDateFormatter(bool $ignoreTimezone = false): \IntlDateFormatter
164167
{
@@ -170,12 +173,6 @@ protected function getIntlDateFormatter(bool $ignoreTimezone = false): \IntlDate
170173
$pattern = $this->pattern;
171174

172175
$intlDateFormatter = new \IntlDateFormatter(\Locale::getDefault(), $dateFormat, $timeFormat, $timezone, $calendar, $pattern ?? '');
173-
174-
// new \intlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/66323
175-
if (!$intlDateFormatter) {
176-
throw new TransformationFailedException(intl_get_error_message(), intl_get_error_code());
177-
}
178-
179176
$intlDateFormatter->setLenient(false);
180177

181178
return $intlDateFormatter;

src/Symfony/Component/Form/Extension/Core/Type/DateType.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
120120
\Locale::getDefault(),
121121
$dateFormat,
122122
$timeFormat,
123-
// see https://bugs.php.net/66323
124-
class_exists(\IntlTimeZone::class, false) ? \IntlTimeZone::createDefault() : null,
123+
null,
125124
$calendar,
126125
$pattern
127126
);
128127

129-
// new \IntlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/66323
130-
if (!$formatter) {
131-
throw new InvalidOptionsException(intl_get_error_message(), intl_get_error_code());
132-
}
133-
134128
$formatter->setLenient(false);
135129

136130
if ('choice' === $options['widget']) {

src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer;
1313

14+
use Symfony\Component\Form\Exception\InvalidArgumentException;
1415
use Symfony\Component\Form\Exception\TransformationFailedException;
1516
use Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer;
1617
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer;
@@ -446,6 +447,14 @@ public function testDefaultCalendarIsGregorian()
446447
);
447448
}
448449

450+
public function testInvalidCalendar()
451+
{
452+
$this->expectException(InvalidArgumentException::class);
453+
$this->expectExceptionMessage('The "calendar" option should be either an \IntlDateFormatter constant or an \IntlCalendar instance.');
454+
455+
new DateTimeToLocalizedStringTransformer(calendar: 123456);
456+
}
457+
449458
protected function createDateTimeTransformer(?string $inputTimezone = null, ?string $outputTimezone = null): BaseDateTimeTransformer
450459
{
451460
return new DateTimeToLocalizedStringTransformer($inputTimezone, $outputTimezone);

0 commit comments

Comments
 (0)
0