Skip to content

IntlDateFormatter Notice when passing null as second or third parameter #29705

Closed
@flack

Description

@flack

Symfony version(s) affected: v3.4.20 (but the code looks the same in master)

Description

According to the PHP documentation, the $datetype and $timetype parameter can be null:

http://php.net/manual/en/intldateformatter.create.php

So this is a valid call:

$formatter = new IntlDateFormatter('en', null, null)

however, this produces the following notice:

Undefined index: 
vendor/symfony/intl/DateFormatter/IntlDateFormatter.php:606
vendor/symfony/intl/DateFormatter/IntlDateFormatter.php:498
vendor/symfony/intl/DateFormatter/IntlDateFormatter.php:148

How to reproduce

See above

Possible Solution

I'm not sure, but a naive fix would be to do something like this:

if (self::NONE !== $this->datetype && null !== $this->datetype) {

in https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php#L604 (and similarly below)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions