bug #19751 Fixes the calendar in constructor to handle null (wakqasahmed)
This PR was merged into the 2.7 branch.
Discussion
----------
Fixes the calendar in constructor to handle null
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #19688
| License | MIT
| Doc PR | none
Fix the calendar exception to handle null, error was raised while exporting from akeneo
The Symfony\Component\Intl\DateFormatter\IntlDateFormatter::__construct() method's argument $calendar value NULL behavior is not implemented. Only the GREGORIAN calendar is supported. Please install the "intl" extension for full localization capabilities.
https://cloud.githubusercontent.com/assets/4486133/17287404/81f951cc-57e0-11e6-9f6f-e231bbf00bf4.png
Commits
-------
43f2672
Fixes the calendar in constructor to handle null
This commit is contained in:
commit
ac604cb100
@ -134,7 +134,7 @@ class IntlDateFormatter
|
|||||||
* @param int $timetype Type of time formatting, one of the format type constants
|
* @param int $timetype Type of time formatting, one of the format type constants
|
||||||
* @param mixed $timezone Timezone identifier
|
* @param mixed $timezone Timezone identifier
|
||||||
* @param int $calendar Calendar to use for formatting or parsing. The only currently
|
* @param int $calendar Calendar to use for formatting or parsing. The only currently
|
||||||
* supported value is IntlDateFormatter::GREGORIAN.
|
* supported value is IntlDateFormatter::GREGORIAN (or null using the default calendar, i.e. "GREGORIAN")
|
||||||
* @param string $pattern Optional pattern to use when formatting
|
* @param string $pattern Optional pattern to use when formatting
|
||||||
*
|
*
|
||||||
* @see http://www.php.net/manual/en/intldateformatter.create.php
|
* @see http://www.php.net/manual/en/intldateformatter.create.php
|
||||||
@ -149,7 +149,7 @@ class IntlDateFormatter
|
|||||||
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
|
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::GREGORIAN !== $calendar) {
|
if (self::GREGORIAN !== $calendar && null !== $calendar) {
|
||||||
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'calendar', $calendar, 'Only the GREGORIAN calendar is supported');
|
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'calendar', $calendar, 'Only the GREGORIAN calendar is supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,12 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
|
|||||||
$this->assertEquals('y-M-d', $formatter->getPattern());
|
$this->assertEquals('y-M-d', $formatter->getPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConstructorWithoutCalendar()
|
||||||
|
{
|
||||||
|
$formatter = new IntlDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, 'UTC', null, 'y-M-d');
|
||||||
|
$this->assertEquals('y-M-d', $formatter->getPattern());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
|
* @expectedException \Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user