Permalink
Browse files

Update more few places to use PHP 5.4 code

  • Loading branch information...
jrbasso committed Oct 7, 2012
1 parent a5739e5 commit 4876517af12bf687a8b883a167b42c61120a765c
View
@@ -264,7 +264,7 @@ public static function set($settings = array(), $value = null, $config = 'defaul
$settings = array($settings => $value);
}
$engine = self::engine($config);
$engine = static::engine($config);
if (!$engine) {
return false;
}
@@ -127,7 +127,7 @@ public function main() {
$this->_documentRoot
);
$port = ($this->_port == self::DEFAULT_PORT) ? '' : ':' . $this->_port;
$port = ($this->_port == static::DEFAULT_PORT) ? '' : ':' . $this->_port;
$this->out(__d('cake_console', 'built-in server is running in http://%s%s/', $this->_host, $port));
$ret = system($command);
}
@@ -349,7 +349,7 @@ public function startup(Controller $controller) {
*/
protected function _unauthorized(Controller $controller) {
if (!$this->unauthorizedRedirect) {
throw new ForbiddenException($this->authError);
throw new Error\ForbiddenException($this->authError);
}
$this->flash($this->authError);
View
@@ -536,7 +536,7 @@ public static function location($className) {
* @return void
*/
public static function init() {
register_shutdown_function(array(__CLASS__, 'shutdown'));
register_shutdown_function(array(get_called_class(), 'shutdown'));
}
/**
@@ -122,7 +122,7 @@ public static function check($var = null) {
if (empty($var)) {
return false;
}
return Hash::get(self::$_values, $var) !== null;
return Hash::get(static::$_values, $var) !== null;
}
/**
@@ -278,7 +278,7 @@ protected static function _error($errorNumber) {
if (!is_array(static::$error) || !array_key_exists($errorNumber, static::$error)) {
return false;
}
return self::$error[$errorNumber];
return static::$error[$errorNumber];
}
/**
@@ -764,7 +764,7 @@ public function parseAccept() {
* @return If a $language is provided, a boolean. Otherwise the array of accepted languages.
*/
public static function acceptLanguage($language = null) {
$raw = self::_parseAcceptWithQualifier(self::header('Accept-Language'));
$raw = static::_parseAcceptWithQualifier(static::header('Accept-Language'));
$accept = array();
foreach ($raw as $qualifier => $languages) {
foreach ($languages as &$lang) {
@@ -332,10 +332,6 @@ public function testExportVar() {
elementCacheSettings => array()
int => (int) 2
float => (float) 1.333
TEXT;
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$expected .= <<<TEXT
[protected] _passedVars => array(
(int) 0 => 'viewVars',
(int) 1 => 'autoLayout',
@@ -361,10 +357,6 @@ public function testExportVar() {
[protected] _stack => array()
[protected] _eventManager => object(Cake\Event\EventManager) {}
[protected] _eventManagerConfigured => false
TEXT;
}
$expected .= <<<TEXT
}
TEXT;
@@ -720,7 +720,7 @@ public static function apply(array $data, $path, $function) {
* - `numeric` Sort by numeric value.
* - `regular` Sort by numeric value.
* - `string` Sort by numeric value.
* - `natural` Sort by natural order. Requires PHP 5.4 or greater.
* - `natural` Sort by natural order.
*
* @param array $data An array of data to sort
* @param string $path A Set-compatible path to the array value
View
@@ -401,11 +401,11 @@ public static function niceShort($dateString = null, $timezone = null) {
__d('cake', 'Friday'),
__d('cake', 'Saturday')
);
if (self::wasWithinLast('7 days', $dateString, $timezone)) {
return sprintf('%s %s', $day[$d], self::_strftime(self::$niceShortFormat, $date));
if (static::wasWithinLast('7 days', $dateString, $timezone)) {
return sprintf('%s %s', $day[$d], static::_strftime(static::$niceShortFormat, $date));
}
if (self::isWithinNext('7 days', $dateString, $timezone)) {
return __d('cake', 'On %s %s', $day[$d], self::_strftime(self::$niceShortFormat, $date));
if (static::isWithinNext('7 days', $dateString, $timezone)) {
return __d('cake', 'On %s %s', $day[$d], static::_strftime(static::$niceShortFormat, $date));
}
$y = '';
@@ -978,9 +978,9 @@ public static function i18nFormat($date, $format = null, $default = false, $time
* Get list of timezone identifiers
*
* @param integer|string $filter A regex to filter identifer
* Or one of DateTimeZone class constants (PHP 5.3 and above)
* Or one of DateTimeZone class constants
* @param string $country A two-letter ISO 3166-1 compatible country code.
* This option is only used when $filter is set to DateTimeZone::PER_COUNTRY (available only in PHP 5.3 and above)
* This option is only used when $filter is set to DateTimeZone::PER_COUNTRY
* @param boolean $group If true (default value) groups the identifiers list by primary region
* @return array List of timezone identifiers
* @since 2.2
@@ -409,7 +409,7 @@ public static function decimal($check, $places = null, $regex = null) {
/**
* Validates for an email address.
*
* Only uses getmxrr() checking for deep validation if PHP 5.3.0+ is used, or
* Only uses getmxrr() checking for deep validation, or
* any PHP version on a non-windows distribution
*
* @param string $check Value to check

0 comments on commit 4876517

Please sign in to comment.