[Locale] Adjust StubIntlDateFormatter to have new methods added in PHP 5.5

This commit is contained in:
Joseph Bielawski 2013-01-04 15:29:23 +01:00
parent b2ce983596
commit 73d9cef188

View File

@ -217,6 +217,24 @@ class StubIntlDateFormatter
return $formatted;
}
/**
* Formats an object
*
* @param object $object
* @param mixed $format
* @param string $locale
*
* @return string The formatted value
*
* @see http://www.php.net/manual/en/intldateformatter.formatobject.php
*
* @throws MethodNotImplementedException
*/
public function formatObject($object, $format = null, $locale = null)
{
throw new MethodNotImplementedException(__METHOD__);
}
/**
* Returns the formatter's calendar
*
@ -229,6 +247,20 @@ class StubIntlDateFormatter
return self::GREGORIAN;
}
/**
* Returns the formatter's calendar object
*
* @return object The calendar's object being used by the formatter
*
* @see http://www.php.net/manual/en/intldateformatter.getcalendarobject.php
*
* @throws MethodNotImplementedException
*/
public function getCalendarObject()
{
throw new MethodNotImplementedException(__METHOD__);
}
/**
* Returns the formatter's datetype
*
@ -327,17 +359,15 @@ class StubIntlDateFormatter
/**
* Returns the formatter's timezone
*
* @return \DateTimeZone The timezone identifier used by the formatter
* @return mixed The timezone used by the formatter
*
* @see http://www.php.net/manual/en/intldateformatter.gettimezone.php
*
* @throws MethodNotImplementedException
*/
public function getTimeZone()
{
if (!$this->unitializedTimeZoneId) {
return new \DateTimeZone($this->timeZoneId);
}
return new \DateTimeZone(date_default_timezone_get());
throw new MethodNotImplementedException(__METHOD__);
}
/**
@ -482,11 +512,16 @@ class StubIntlDateFormatter
public function setTimeZoneId($timeZoneId)
{
if (null === $timeZoneId) {
// TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will
// use ini's date.timezone when the time zone is not provided. As a not well tested workaround, uses UTC.
// See the first two items of the commit message for more information:
// https://github.com/php/php-src/commit/eb346ef0f419b90739aadfb6cc7b7436c5b521d9
$timeZoneId = getenv('TZ') ?: 'UTC';
// In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method
if (version_compare(\PHP_VERSION, '5.5.0alpha1', '>=')) {
$timeZoneId = date_default_timezone_get();
} else {
// TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will
// use ini's date.timezone when the time zone is not provided. As a not well tested workaround, uses UTC.
// See the first two items of the commit message for more information:
// https://github.com/php/php-src/commit/eb346ef0f419b90739aadfb6cc7b7436c5b521d9
$timeZoneId = getenv('TZ') ?: 'UTC';
}
$this->unitializedTimeZoneId = true;
}
@ -514,9 +549,18 @@ class StubIntlDateFormatter
return true;
}
public function setTimeZone($timeZoneId)
/**
* This method was added in PHP 5.5 as replacement for `setTimeZoneId()`
*
* @param mixed $timeZone
*
* @return Boolean true on success or false on failure
*
* @see http://www.php.net/manual/en/intldateformatter.settimezone.php
*/
public function setTimeZone($timeZone)
{
return $this->setTimeZoneId($timeZoneId);
return $this->setTimeZoneId($timeZone);
}
/**