Replacing self with static due to PHP5.3+. Following #7040.

This commit is contained in:
Mark Scherer 2015-07-21 10:22:53 +02:00
parent 27e40f084d
commit 52e79987a2
53 changed files with 998 additions and 998 deletions

View file

@ -125,33 +125,33 @@ class Cache {
} }
$current = array(); $current = array();
if (isset(self::$_config[$name])) { if (isset(static::$_config[$name])) {
$current = self::$_config[$name]; $current = static::$_config[$name];
} }
if (!empty($settings)) { if (!empty($settings)) {
self::$_config[$name] = $settings + $current; static::$_config[$name] = $settings + $current;
} }
if (empty(self::$_config[$name]['engine'])) { if (empty(static::$_config[$name]['engine'])) {
return false; return false;
} }
if (!empty(self::$_config[$name]['groups'])) { if (!empty(static::$_config[$name]['groups'])) {
foreach (self::$_config[$name]['groups'] as $group) { foreach (static::$_config[$name]['groups'] as $group) {
self::$_groups[$group][] = $name; static::$_groups[$group][] = $name;
sort(self::$_groups[$group]); sort(static::$_groups[$group]);
self::$_groups[$group] = array_unique(self::$_groups[$group]); static::$_groups[$group] = array_unique(static::$_groups[$group]);
} }
} }
$engine = self::$_config[$name]['engine']; $engine = static::$_config[$name]['engine'];
if (!isset(self::$_engines[$name])) { if (!isset(static::$_engines[$name])) {
self::_buildEngine($name); static::_buildEngine($name);
$settings = self::$_config[$name] = self::settings($name); $settings = static::$_config[$name] = static::settings($name);
} elseif ($settings = self::set(self::$_config[$name], null, $name)) { } elseif ($settings = static::set(static::$_config[$name], null, $name)) {
self::$_config[$name] = $settings; static::$_config[$name] = $settings;
} }
return compact('engine', 'settings'); return compact('engine', 'settings');
} }
@ -164,7 +164,7 @@ class Cache {
* @throws CacheException * @throws CacheException
*/ */
protected static function _buildEngine($name) { protected static function _buildEngine($name) {
$config = self::$_config[$name]; $config = static::$_config[$name];
list($plugin, $class) = pluginSplit($config['engine'], true); list($plugin, $class) = pluginSplit($config['engine'], true);
$cacheClass = $class . 'Engine'; $cacheClass = $class . 'Engine';
@ -176,8 +176,8 @@ class Cache {
if (!is_subclass_of($cacheClass, 'CacheEngine')) { if (!is_subclass_of($cacheClass, 'CacheEngine')) {
throw new CacheException(__d('cake_dev', 'Cache engines must use %s as a base class.', 'CacheEngine')); throw new CacheException(__d('cake_dev', 'Cache engines must use %s as a base class.', 'CacheEngine'));
} }
self::$_engines[$name] = new $cacheClass(); static::$_engines[$name] = new $cacheClass();
if (!self::$_engines[$name]->init($config)) { if (!static::$_engines[$name]->init($config)) {
$msg = __d( $msg = __d(
'cake_dev', 'cake_dev',
'Cache engine "%s" is not properly configured. Ensure required extensions are installed, and credentials/permissions are correct', 'Cache engine "%s" is not properly configured. Ensure required extensions are installed, and credentials/permissions are correct',
@ -185,8 +185,8 @@ class Cache {
); );
throw new CacheException($msg); throw new CacheException($msg);
} }
if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) { if (static::$_engines[$name]->settings['probability'] && time() % static::$_engines[$name]->settings['probability'] === 0) {
self::$_engines[$name]->gc(); static::$_engines[$name]->gc();
} }
return true; return true;
} }
@ -197,7 +197,7 @@ class Cache {
* @return array Array of configured Cache config names. * @return array Array of configured Cache config names.
*/ */
public static function configured() { public static function configured() {
return array_keys(self::$_config); return array_keys(static::$_config);
} }
/** /**
@ -209,10 +209,10 @@ class Cache {
* @return bool success of the removal, returns false when the config does not exist. * @return bool success of the removal, returns false when the config does not exist.
*/ */
public static function drop($name) { public static function drop($name) {
if (!isset(self::$_config[$name])) { if (!isset(static::$_config[$name])) {
return false; return false;
} }
unset(self::$_config[$name], self::$_engines[$name]); unset(static::$_config[$name], static::$_engines[$name]);
return true; return true;
} }
@ -243,29 +243,29 @@ class Cache {
if (is_array($settings) && $value !== null) { if (is_array($settings) && $value !== null) {
$config = $value; $config = $value;
} }
if (!isset(self::$_config[$config]) || !isset(self::$_engines[$config])) { if (!isset(static::$_config[$config]) || !isset(static::$_engines[$config])) {
return false; return false;
} }
if (!empty($settings)) { if (!empty($settings)) {
self::$_reset = true; static::$_reset = true;
} }
if (self::$_reset === true) { if (static::$_reset === true) {
if (empty($settings)) { if (empty($settings)) {
self::$_reset = false; static::$_reset = false;
$settings = self::$_config[$config]; $settings = static::$_config[$config];
} else { } else {
if (is_string($settings) && $value !== null) { if (is_string($settings) && $value !== null) {
$settings = array($settings => $value); $settings = array($settings => $value);
} }
$settings += self::$_config[$config]; $settings += static::$_config[$config];
if (isset($settings['duration']) && !is_numeric($settings['duration'])) { if (isset($settings['duration']) && !is_numeric($settings['duration'])) {
$settings['duration'] = strtotime($settings['duration']) - time(); $settings['duration'] = strtotime($settings['duration']) - time();
} }
} }
self::$_engines[$config]->settings = $settings; static::$_engines[$config]->settings = $settings;
} }
return self::settings($config); return static::settings($config);
} }
/** /**
@ -278,7 +278,7 @@ class Cache {
* @return void * @return void
*/ */
public static function gc($config = 'default', $expires = null) { public static function gc($config = 'default', $expires = null) {
self::$_engines[$config]->gc($expires); static::$_engines[$config]->gc($expires);
} }
/** /**
@ -300,29 +300,29 @@ class Cache {
* @return bool True if the data was successfully cached, false on failure * @return bool True if the data was successfully cached, false on failure
*/ */
public static function write($key, $value, $config = 'default') { public static function write($key, $value, $config = 'default') {
$settings = self::settings($config); $settings = static::settings($config);
if (empty($settings)) { if (empty($settings)) {
return false; return false;
} }
if (!self::isInitialized($config)) { if (!static::isInitialized($config)) {
return false; return false;
} }
$key = self::$_engines[$config]->key($key); $key = static::$_engines[$config]->key($key);
if (!$key || is_resource($value)) { if (!$key || is_resource($value)) {
return false; return false;
} }
$success = self::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']); $success = static::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']);
self::set(null, $config); static::set(null, $config);
if ($success === false && $value !== '') { if ($success === false && $value !== '') {
trigger_error( trigger_error(
__d('cake_dev', __d('cake_dev',
"%s cache was unable to write '%s' to %s cache", "%s cache was unable to write '%s' to %s cache",
$config, $config,
$key, $key,
self::$_engines[$config]->settings['engine'] static::$_engines[$config]->settings['engine']
), ),
E_USER_WARNING E_USER_WARNING
); );
@ -348,19 +348,19 @@ class Cache {
* @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
*/ */
public static function read($key, $config = 'default') { public static function read($key, $config = 'default') {
$settings = self::settings($config); $settings = static::settings($config);
if (empty($settings)) { if (empty($settings)) {
return false; return false;
} }
if (!self::isInitialized($config)) { if (!static::isInitialized($config)) {
return false; return false;
} }
$key = self::$_engines[$config]->key($key); $key = static::$_engines[$config]->key($key);
if (!$key) { if (!$key) {
return false; return false;
} }
return self::$_engines[$config]->read($settings['prefix'] . $key); return static::$_engines[$config]->read($settings['prefix'] . $key);
} }
/** /**
@ -373,21 +373,21 @@ class Cache {
* or if there was an error fetching it. * or if there was an error fetching it.
*/ */
public static function increment($key, $offset = 1, $config = 'default') { public static function increment($key, $offset = 1, $config = 'default') {
$settings = self::settings($config); $settings = static::settings($config);
if (empty($settings)) { if (empty($settings)) {
return false; return false;
} }
if (!self::isInitialized($config)) { if (!static::isInitialized($config)) {
return false; return false;
} }
$key = self::$_engines[$config]->key($key); $key = static::$_engines[$config]->key($key);
if (!$key || !is_int($offset) || $offset < 0) { if (!$key || !is_int($offset) || $offset < 0) {
return false; return false;
} }
$success = self::$_engines[$config]->increment($settings['prefix'] . $key, $offset); $success = static::$_engines[$config]->increment($settings['prefix'] . $key, $offset);
self::set(null, $config); static::set(null, $config);
return $success; return $success;
} }
@ -401,21 +401,21 @@ class Cache {
* or if there was an error fetching it * or if there was an error fetching it
*/ */
public static function decrement($key, $offset = 1, $config = 'default') { public static function decrement($key, $offset = 1, $config = 'default') {
$settings = self::settings($config); $settings = static::settings($config);
if (empty($settings)) { if (empty($settings)) {
return false; return false;
} }
if (!self::isInitialized($config)) { if (!static::isInitialized($config)) {
return false; return false;
} }
$key = self::$_engines[$config]->key($key); $key = static::$_engines[$config]->key($key);
if (!$key || !is_int($offset) || $offset < 0) { if (!$key || !is_int($offset) || $offset < 0) {
return false; return false;
} }
$success = self::$_engines[$config]->decrement($settings['prefix'] . $key, $offset); $success = static::$_engines[$config]->decrement($settings['prefix'] . $key, $offset);
self::set(null, $config); static::set(null, $config);
return $success; return $success;
} }
@ -437,21 +437,21 @@ class Cache {
* @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed * @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
*/ */
public static function delete($key, $config = 'default') { public static function delete($key, $config = 'default') {
$settings = self::settings($config); $settings = static::settings($config);
if (empty($settings)) { if (empty($settings)) {
return false; return false;
} }
if (!self::isInitialized($config)) { if (!static::isInitialized($config)) {
return false; return false;
} }
$key = self::$_engines[$config]->key($key); $key = static::$_engines[$config]->key($key);
if (!$key) { if (!$key) {
return false; return false;
} }
$success = self::$_engines[$config]->delete($settings['prefix'] . $key); $success = static::$_engines[$config]->delete($settings['prefix'] . $key);
self::set(null, $config); static::set(null, $config);
return $success; return $success;
} }
@ -463,11 +463,11 @@ class Cache {
* @return bool True if the cache was successfully cleared, false otherwise * @return bool True if the cache was successfully cleared, false otherwise
*/ */
public static function clear($check = false, $config = 'default') { public static function clear($check = false, $config = 'default') {
if (!self::isInitialized($config)) { if (!static::isInitialized($config)) {
return false; return false;
} }
$success = self::$_engines[$config]->clear($check); $success = static::$_engines[$config]->clear($check);
self::set(null, $config); static::set(null, $config);
return $success; return $success;
} }
@ -479,11 +479,11 @@ class Cache {
* @return bool True if the cache group was successfully cleared, false otherwise * @return bool True if the cache group was successfully cleared, false otherwise
*/ */
public static function clearGroup($group, $config = 'default') { public static function clearGroup($group, $config = 'default') {
if (!self::isInitialized($config)) { if (!static::isInitialized($config)) {
return false; return false;
} }
$success = self::$_engines[$config]->clearGroup($group); $success = static::$_engines[$config]->clearGroup($group);
self::set(null, $config); static::set(null, $config);
return $success; return $success;
} }
@ -497,7 +497,7 @@ class Cache {
if (Configure::read('Cache.disable')) { if (Configure::read('Cache.disable')) {
return false; return false;
} }
return isset(self::$_engines[$config]); return isset(static::$_engines[$config]);
} }
/** /**
@ -508,8 +508,8 @@ class Cache {
* @see Cache::config() * @see Cache::config()
*/ */
public static function settings($name = 'default') { public static function settings($name = 'default') {
if (!empty(self::$_engines[$name])) { if (!empty(static::$_engines[$name])) {
return self::$_engines[$name]->settings(); return static::$_engines[$name]->settings();
} }
return array(); return array();
} }
@ -535,10 +535,10 @@ class Cache {
*/ */
public static function groupConfigs($group = null) { public static function groupConfigs($group = null) {
if ($group === null) { if ($group === null) {
return self::$_groups; return static::$_groups;
} }
if (isset(self::$_groups[$group])) { if (isset(static::$_groups[$group])) {
return array($group => self::$_groups[$group]); return array($group => static::$_groups[$group]);
} }
throw new CacheException(__d('cake_dev', 'Invalid cache group %s', $group)); throw new CacheException(__d('cake_dev', 'Invalid cache group %s', $group));
} }
@ -569,12 +569,12 @@ class Cache {
* @return mixed The results of the callable or unserialized results. * @return mixed The results of the callable or unserialized results.
*/ */
public static function remember($key, $callable, $config = 'default') { public static function remember($key, $callable, $config = 'default') {
$existing = self::read($key, $config); $existing = static::read($key, $config);
if ($existing !== false) { if ($existing !== false) {
return $existing; return $existing;
} }
$results = call_user_func($callable); $results = call_user_func($callable);
self::write($key, $results, $config); static::write($key, $results, $config);
return $results; return $results;
} }

View file

@ -65,8 +65,8 @@ class ServerShell extends AppShell {
* @return void * @return void
*/ */
public function initialize() { public function initialize() {
$this->_host = self::DEFAULT_HOST; $this->_host = static::DEFAULT_HOST;
$this->_port = self::DEFAULT_PORT; $this->_port = static::DEFAULT_PORT;
$this->_documentRoot = WWW_ROOT; $this->_documentRoot = WWW_ROOT;
} }
@ -135,7 +135,7 @@ class ServerShell extends AppShell {
escapeshellarg($this->_documentRoot . '/index.php') escapeshellarg($this->_documentRoot . '/index.php')
); );
$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)); $this->out(__d('cake_console', 'built-in server is running in http://%s%s/', $this->_host, $port));
system($command); system($command);
} }

View file

@ -40,10 +40,10 @@ class ConsoleErrorHandler {
* @return ConsoleOutput * @return ConsoleOutput
*/ */
public static function getStderr() { public static function getStderr() {
if (empty(self::$stderr)) { if (empty(static::$stderr)) {
self::$stderr = new ConsoleOutput('php://stderr'); static::$stderr = new ConsoleOutput('php://stderr');
} }
return self::$stderr; return static::$stderr;
} }
/** /**
@ -53,7 +53,7 @@ class ConsoleErrorHandler {
* @return void * @return void
*/ */
public function handleException(Exception $exception) { public function handleException(Exception $exception) {
$stderr = self::getStderr(); $stderr = static::getStderr();
$stderr->write(__d('cake_console', "<error>Error:</error> %s\n%s", $stderr->write(__d('cake_console', "<error>Error:</error> %s\n%s",
$exception->getMessage(), $exception->getMessage(),
$exception->getTraceAsString() $exception->getTraceAsString()
@ -78,7 +78,7 @@ class ConsoleErrorHandler {
if (error_reporting() === 0) { if (error_reporting() === 0) {
return; return;
} }
$stderr = self::getStderr(); $stderr = static::getStderr();
list($name, $log) = ErrorHandler::mapErrorCode($code); list($name, $log) = ErrorHandler::mapErrorCode($code);
$message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line); $message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line);
$stderr->write(__d('cake_console', "<error>%s Error:</error> %s\n", $name, $message)); $stderr->write(__d('cake_console', "<error>%s Error:</error> %s\n", $name, $message));

View file

@ -165,7 +165,7 @@ class ConsoleOutput {
$stream === 'php://output' || $stream === 'php://output' ||
(function_exists('posix_isatty') && !posix_isatty($this->_output)) (function_exists('posix_isatty') && !posix_isatty($this->_output))
) { ) {
$this->_outputAs = self::PLAIN; $this->_outputAs = static::PLAIN;
} }
} }
@ -179,9 +179,9 @@ class ConsoleOutput {
*/ */
public function write($message, $newlines = 1) { public function write($message, $newlines = 1) {
if (is_array($message)) { if (is_array($message)) {
$message = implode(self::LF, $message); $message = implode(static::LF, $message);
} }
return $this->_write($this->styleText($message . str_repeat(self::LF, $newlines))); return $this->_write($this->styleText($message . str_repeat(static::LF, $newlines)));
} }
/** /**
@ -191,11 +191,11 @@ class ConsoleOutput {
* @return string String with color codes added. * @return string String with color codes added.
*/ */
public function styleText($text) { public function styleText($text) {
if ($this->_outputAs == self::RAW) { if ($this->_outputAs == static::RAW) {
return $text; return $text;
} }
if ($this->_outputAs == self::PLAIN) { if ($this->_outputAs == static::PLAIN) {
$tags = implode('|', array_keys(self::$_styles)); $tags = implode('|', array_keys(static::$_styles));
return preg_replace('#</?(?:' . $tags . ')>#', '', $text); return preg_replace('#</?(?:' . $tags . ')>#', '', $text);
} }
return preg_replace_callback( return preg_replace_callback(
@ -216,16 +216,16 @@ class ConsoleOutput {
} }
$styleInfo = array(); $styleInfo = array();
if (!empty($style['text']) && isset(self::$_foregroundColors[$style['text']])) { if (!empty($style['text']) && isset(static::$_foregroundColors[$style['text']])) {
$styleInfo[] = self::$_foregroundColors[$style['text']]; $styleInfo[] = static::$_foregroundColors[$style['text']];
} }
if (!empty($style['background']) && isset(self::$_backgroundColors[$style['background']])) { if (!empty($style['background']) && isset(static::$_backgroundColors[$style['background']])) {
$styleInfo[] = self::$_backgroundColors[$style['background']]; $styleInfo[] = static::$_backgroundColors[$style['background']];
} }
unset($style['text'], $style['background']); unset($style['text'], $style['background']);
foreach ($style as $option => $value) { foreach ($style as $option => $value) {
if ($value) { if ($value) {
$styleInfo[] = self::$_options[$option]; $styleInfo[] = static::$_options[$option];
} }
} }
return "\033[" . implode($styleInfo, ';') . 'm' . $matches['text'] . "\033[0m"; return "\033[" . implode($styleInfo, ';') . 'm' . $matches['text'] . "\033[0m";
@ -268,16 +268,16 @@ class ConsoleOutput {
*/ */
public function styles($style = null, $definition = null) { public function styles($style = null, $definition = null) {
if ($style === null && $definition === null) { if ($style === null && $definition === null) {
return self::$_styles; return static::$_styles;
} }
if (is_string($style) && $definition === null) { if (is_string($style) && $definition === null) {
return isset(self::$_styles[$style]) ? self::$_styles[$style] : null; return isset(static::$_styles[$style]) ? static::$_styles[$style] : null;
} }
if ($definition === false) { if ($definition === false) {
unset(self::$_styles[$style]); unset(static::$_styles[$style]);
return true; return true;
} }
self::$_styles[$style] = $definition; static::$_styles[$style] = $definition;
return true; return true;
} }

View file

@ -68,7 +68,7 @@ class PhpAcl extends Object implements AclInterface {
*/ */
public function __construct() { public function __construct() {
$this->options = array( $this->options = array(
'policy' => self::DENY, 'policy' => static::DENY,
'config' => APP . 'Config' . DS . 'acl.php', 'config' => APP . 'Config' . DS . 'acl.php',
); );
} }
@ -252,7 +252,7 @@ class PhpAco {
} }
foreach ($root as $node => $elements) { foreach ($root as $node => $elements) {
$pattern = '/^' . str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node) . '$/'; $pattern = '/^' . str_replace(array_keys(static::$modifiers), array_values(static::$modifiers), $node) . '$/';
if ($node == $aco[$level] || preg_match($pattern, $aco[$level])) { if ($node == $aco[$level] || preg_match($pattern, $aco[$level])) {
// merge allow/denies with $path of current level // merge allow/denies with $path of current level
@ -494,7 +494,7 @@ class PhpAro {
return $this->aliases[$mapped]; return $this->aliases[$mapped];
} }
} }
return self::DEFAULT_ROLE; return static::DEFAULT_ROLE;
} }
/** /**

View file

@ -610,7 +610,7 @@ class AuthComponent extends Component {
} }
if ($user) { if ($user) {
$this->Session->renew(); $this->Session->renew();
$this->Session->write(self::$sessionKey, $user); $this->Session->write(static::$sessionKey, $user);
$event = new CakeEvent('Auth.afterIdentify', $this, array('user' => $user)); $event = new CakeEvent('Auth.afterIdentify', $this, array('user' => $user));
$this->_Collection->getController()->getEventManager()->dispatch($event); $this->_Collection->getController()->getEventManager()->dispatch($event);
} }
@ -639,7 +639,7 @@ class AuthComponent extends Component {
foreach ($this->_authenticateObjects as $auth) { foreach ($this->_authenticateObjects as $auth) {
$auth->logout($user); $auth->logout($user);
} }
$this->Session->delete(self::$sessionKey); $this->Session->delete(static::$sessionKey);
$this->Session->delete('Auth.redirect'); $this->Session->delete('Auth.redirect');
$this->Session->renew(); $this->Session->renew();
return Router::normalize($this->logoutRedirect); return Router::normalize($this->logoutRedirect);
@ -657,10 +657,10 @@ class AuthComponent extends Component {
* @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user * @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user
*/ */
public static function user($key = null) { public static function user($key = null) {
if (!empty(self::$_user)) { if (!empty(static::$_user)) {
$user = self::$_user; $user = static::$_user;
} elseif (self::$sessionKey && CakeSession::check(self::$sessionKey)) { } elseif (static::$sessionKey && CakeSession::check(static::$sessionKey)) {
$user = CakeSession::read(self::$sessionKey); $user = CakeSession::read(static::$sessionKey);
} else { } else {
return null; return null;
} }
@ -689,7 +689,7 @@ class AuthComponent extends Component {
foreach ($this->_authenticateObjects as $auth) { foreach ($this->_authenticateObjects as $auth) {
$result = $auth->getUser($this->request); $result = $auth->getUser($this->request);
if (!empty($result) && is_array($result)) { if (!empty($result) && is_array($result)) {
self::$_user = $result; static::$_user = $result;
return true; return true;
} }
} }

View file

@ -218,14 +218,14 @@ class App {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::path * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::path
*/ */
public static function path($type, $plugin = null) { public static function path($type, $plugin = null) {
if (!empty(self::$legacy[$type])) { if (!empty(static::$legacy[$type])) {
$type = self::$legacy[$type]; $type = static::$legacy[$type];
} }
if (!empty($plugin)) { if (!empty($plugin)) {
$path = array(); $path = array();
$pluginPath = CakePlugin::path($plugin); $pluginPath = CakePlugin::path($plugin);
$packageFormat = self::_packageFormat(); $packageFormat = static::_packageFormat();
if (!empty($packageFormat[$type])) { if (!empty($packageFormat[$type])) {
foreach ($packageFormat[$type] as $f) { foreach ($packageFormat[$type] as $f) {
$path[] = sprintf($f, $pluginPath); $path[] = sprintf($f, $pluginPath);
@ -234,10 +234,10 @@ class App {
return $path; return $path;
} }
if (!isset(self::$_packages[$type])) { if (!isset(static::$_packages[$type])) {
return array(); return array();
} }
return self::$_packages[$type]; return static::$_packages[$type];
} }
/** /**
@ -249,7 +249,7 @@ class App {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::paths * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::paths
*/ */
public static function paths() { public static function paths() {
return self::$_packages; return static::$_packages;
} }
/** /**
@ -279,8 +279,8 @@ class App {
//Provides Backwards compatibility for old-style package names //Provides Backwards compatibility for old-style package names
$legacyPaths = array(); $legacyPaths = array();
foreach ($paths as $type => $path) { foreach ($paths as $type => $path) {
if (!empty(self::$legacy[$type])) { if (!empty(static::$legacy[$type])) {
$type = self::$legacy[$type]; $type = static::$legacy[$type];
} }
$legacyPaths[$type] = $path; $legacyPaths[$type] = $path;
} }
@ -288,17 +288,17 @@ class App {
if ($mode === App::RESET) { if ($mode === App::RESET) {
foreach ($paths as $type => $new) { foreach ($paths as $type => $new) {
self::$_packages[$type] = (array)$new; static::$_packages[$type] = (array)$new;
self::objects($type, null, false); static::objects($type, null, false);
} }
return; return;
} }
if (empty($paths)) { if (empty($paths)) {
self::$_packageFormat = null; static::$_packageFormat = null;
} }
$packageFormat = self::_packageFormat(); $packageFormat = static::_packageFormat();
if ($mode === App::REGISTER) { if ($mode === App::REGISTER) {
foreach ($paths as $package => $formats) { foreach ($paths as $package => $formats) {
@ -309,7 +309,7 @@ class App {
$packageFormat[$package] = array_values(array_unique($formats)); $packageFormat[$package] = array_values(array_unique($formats));
} }
} }
self::$_packageFormat = $packageFormat; static::$_packageFormat = $packageFormat;
} }
$defaults = array(); $defaults = array();
@ -320,7 +320,7 @@ class App {
} }
if (empty($paths)) { if (empty($paths)) {
self::$_packages = $defaults; static::$_packages = $defaults;
return; return;
} }
@ -329,8 +329,8 @@ class App {
} }
foreach ($defaults as $type => $default) { foreach ($defaults as $type => $default) {
if (!empty(self::$_packages[$type])) { if (!empty(static::$_packages[$type])) {
$path = self::$_packages[$type]; $path = static::$_packages[$type];
} else { } else {
$path = $default; $path = $default;
} }
@ -347,7 +347,7 @@ class App {
$path = array_values(array_unique($path)); $path = array_values(array_unique($path));
} }
self::$_packages[$type] = $path; static::$_packages[$type] = $path;
} }
} }
@ -380,12 +380,12 @@ class App {
*/ */
public static function themePath($theme) { public static function themePath($theme) {
$themeDir = 'Themed' . DS . Inflector::camelize($theme); $themeDir = 'Themed' . DS . Inflector::camelize($theme);
foreach (self::$_packages['View'] as $path) { foreach (static::$_packages['View'] as $path) {
if (is_dir($path . $themeDir)) { if (is_dir($path . $themeDir)) {
return $path . $themeDir . DS; return $path . $themeDir . DS;
} }
} }
return self::$_packages['View'][0] . $themeDir . DS; return static::$_packages['View'][0] . $themeDir . DS;
} }
/** /**
@ -427,8 +427,8 @@ class App {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::objects * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::objects
*/ */
public static function objects($type, $path = null, $cache = true) { public static function objects($type, $path = null, $cache = true) {
if (empty(self::$_objects) && $cache === true) { if (empty(static::$_objects) && $cache === true) {
self::$_objects = (array)Cache::read('object_map', '_cake_core_'); static::$_objects = (array)Cache::read('object_map', '_cake_core_');
} }
$extension = '/\.php$/'; $extension = '/\.php$/';
@ -446,8 +446,8 @@ class App {
list($plugin, $type) = pluginSplit($type); list($plugin, $type) = pluginSplit($type);
if (isset(self::$legacy[$type . 's'])) { if (isset(static::$legacy[$type . 's'])) {
$type = self::$legacy[$type . 's']; $type = static::$legacy[$type . 's'];
} }
if ($type === 'file' && !$path) { if ($type === 'file' && !$path) {
@ -459,11 +459,11 @@ class App {
$cacheLocation = empty($plugin) ? 'app' : $plugin; $cacheLocation = empty($plugin) ? 'app' : $plugin;
if ($cache !== true || !isset(self::$_objects[$cacheLocation][$name])) { if ($cache !== true || !isset(static::$_objects[$cacheLocation][$name])) {
$objects = array(); $objects = array();
if (empty($path)) { if (empty($path)) {
$path = self::path($type, $plugin); $path = static::path($type, $plugin);
} }
foreach ((array)$path as $dir) { foreach ((array)$path as $dir) {
@ -494,13 +494,13 @@ class App {
return $objects; return $objects;
} }
self::$_objects[$cacheLocation][$name] = $objects; static::$_objects[$cacheLocation][$name] = $objects;
if ($cache) { if ($cache) {
self::$_objectCacheChange = true; static::$_objectCacheChange = true;
} }
} }
return self::$_objects[$cacheLocation][$name]; return static::$_objects[$cacheLocation][$name];
} }
/** /**
@ -519,7 +519,7 @@ class App {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::uses * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::uses
*/ */
public static function uses($className, $location) { public static function uses($className, $location) {
self::$_classMap[$className] = $location; static::$_classMap[$className] = $location;
} }
/** /**
@ -532,24 +532,24 @@ class App {
* @return bool * @return bool
*/ */
public static function load($className) { public static function load($className) {
if (!isset(self::$_classMap[$className])) { if (!isset(static::$_classMap[$className])) {
return false; return false;
} }
if (strpos($className, '..') !== false) { if (strpos($className, '..') !== false) {
return false; return false;
} }
$parts = explode('.', self::$_classMap[$className], 2); $parts = explode('.', static::$_classMap[$className], 2);
list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts)); list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts));
$file = self::_mapped($className, $plugin); $file = static::_mapped($className, $plugin);
if ($file) { if ($file) {
return include $file; return include $file;
} }
$paths = self::path($package, $plugin); $paths = static::path($package, $plugin);
if (empty($plugin)) { if (empty($plugin)) {
$appLibs = empty(self::$_packages['Lib']) ? APPLIBS : current(self::$_packages['Lib']); $appLibs = empty(static::$_packages['Lib']) ? APPLIBS : current(static::$_packages['Lib']);
$paths[] = $appLibs . $package . DS; $paths[] = $appLibs . $package . DS;
$paths[] = APP . $package . DS; $paths[] = APP . $package . DS;
$paths[] = CAKE . $package . DS; $paths[] = CAKE . $package . DS;
@ -563,7 +563,7 @@ class App {
foreach ($paths as $path) { foreach ($paths as $path) {
$file = $path . $normalizedClassName . '.php'; $file = $path . $normalizedClassName . '.php';
if (file_exists($file)) { if (file_exists($file)) {
self::_map($file, $className, $plugin); static::_map($file, $className, $plugin);
return include $file; return include $file;
} }
} }
@ -579,8 +579,8 @@ class App {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::location * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::location
*/ */
public static function location($className) { public static function location($className) {
if (!empty(self::$_classMap[$className])) { if (!empty(static::$_classMap[$className])) {
return self::$_classMap[$className]; return static::$_classMap[$className];
} }
return null; return null;
} }
@ -629,8 +629,8 @@ class App {
$originalType = strtolower($type); $originalType = strtolower($type);
$specialPackage = in_array($originalType, array('file', 'vendor')); $specialPackage = in_array($originalType, array('file', 'vendor'));
if (!$specialPackage && isset(self::$legacy[$originalType . 's'])) { if (!$specialPackage && isset(static::$legacy[$originalType . 's'])) {
$type = self::$legacy[$originalType . 's']; $type = static::$legacy[$originalType . 's'];
} }
list($plugin, $name) = pluginSplit($name); list($plugin, $name) = pluginSplit($name);
if (!empty($plugin)) { if (!empty($plugin)) {
@ -640,15 +640,15 @@ class App {
} }
if (!$specialPackage) { if (!$specialPackage) {
return self::_loadClass($name, $plugin, $type, $originalType, $parent); return static::_loadClass($name, $plugin, $type, $originalType, $parent);
} }
if ($originalType === 'file' && !empty($file)) { if ($originalType === 'file' && !empty($file)) {
return self::_loadFile($name, $plugin, $search, $file, $return); return static::_loadFile($name, $plugin, $search, $file, $return);
} }
if ($originalType === 'vendor') { if ($originalType === 'vendor') {
return self::_loadVendor($name, $plugin, $file, $ext); return static::_loadVendor($name, $plugin, $file, $ext);
} }
return false; return false;
@ -668,12 +668,12 @@ class App {
protected static function _loadClass($name, $plugin, $type, $originalType, $parent) { protected static function _loadClass($name, $plugin, $type, $originalType, $parent) {
if ($type === 'Console/Command' && $name === 'Shell') { if ($type === 'Console/Command' && $name === 'Shell') {
$type = 'Console'; $type = 'Console';
} elseif (isset(self::$types[$originalType]['suffix'])) { } elseif (isset(static::$types[$originalType]['suffix'])) {
$suffix = self::$types[$originalType]['suffix']; $suffix = static::$types[$originalType]['suffix'];
$name .= ($suffix === $name) ? '' : $suffix; $name .= ($suffix === $name) ? '' : $suffix;
} }
if ($parent && isset(self::$types[$originalType]['extends'])) { if ($parent && isset(static::$types[$originalType]['extends'])) {
$extends = self::$types[$originalType]['extends']; $extends = static::$types[$originalType]['extends'];
$extendType = $type; $extendType = $type;
if (strpos($extends, '/') !== false) { if (strpos($extends, '/') !== false) {
$parts = explode('/', $extends); $parts = explode('/', $extends);
@ -704,7 +704,7 @@ class App {
* @return mixed if $return contents of the file after php parses it, boolean indicating success otherwise * @return mixed if $return contents of the file after php parses it, boolean indicating success otherwise
*/ */
protected static function _loadFile($name, $plugin, $search, $file, $return) { protected static function _loadFile($name, $plugin, $search, $file, $return) {
$mapped = self::_mapped($name, $plugin); $mapped = static::_mapped($name, $plugin);
if ($mapped) { if ($mapped) {
$file = $mapped; $file = $mapped;
} elseif (!empty($search)) { } elseif (!empty($search)) {
@ -721,7 +721,7 @@ class App {
} }
} }
if (!empty($file) && file_exists($file)) { if (!empty($file) && file_exists($file)) {
self::_map($file, $name, $plugin); static::_map($file, $name, $plugin);
$returnValue = include $file; $returnValue = include $file;
if ($return) { if ($return) {
return $returnValue; return $returnValue;
@ -741,7 +741,7 @@ class App {
* @return bool true if the file was loaded successfully, false otherwise * @return bool true if the file was loaded successfully, false otherwise
*/ */
protected static function _loadVendor($name, $plugin, $file, $ext) { protected static function _loadVendor($name, $plugin, $file, $ext) {
if ($mapped = self::_mapped($name, $plugin)) { if ($mapped = static::_mapped($name, $plugin)) {
return (bool)include_once $mapped; return (bool)include_once $mapped;
} }
$fileTries = array(); $fileTries = array();
@ -759,7 +759,7 @@ class App {
foreach ($fileTries as $file) { foreach ($fileTries as $file) {
foreach ($paths as $path) { foreach ($paths as $path) {
if (file_exists($path . $file)) { if (file_exists($path . $file)) {
self::_map($path . $file, $name, $plugin); static::_map($path . $file, $name, $plugin);
return (bool)include $path . $file; return (bool)include $path . $file;
} }
} }
@ -773,7 +773,7 @@ class App {
* @return void * @return void
*/ */
public static function init() { public static function init() {
self::$_map += (array)Cache::read('file_map', '_cake_core_'); static::$_map += (array)Cache::read('file_map', '_cake_core_');
register_shutdown_function(array('App', 'shutdown')); register_shutdown_function(array('App', 'shutdown'));
} }
@ -790,14 +790,14 @@ class App {
if ($plugin) { if ($plugin) {
$key = 'plugin.' . $name; $key = 'plugin.' . $name;
} }
if ($plugin && empty(self::$_map[$name])) { if ($plugin && empty(static::$_map[$name])) {
self::$_map[$key] = $file; static::$_map[$key] = $file;
} }
if (!$plugin && empty(self::$_map['plugin.' . $name])) { if (!$plugin && empty(static::$_map['plugin.' . $name])) {
self::$_map[$key] = $file; static::$_map[$key] = $file;
} }
if (!self::$bootstrapping) { if (!static::$bootstrapping) {
self::$_cacheChange = true; static::$_cacheChange = true;
} }
} }
@ -813,7 +813,7 @@ class App {
if ($plugin) { if ($plugin) {
$key = 'plugin.' . $name; $key = 'plugin.' . $name;
} }
return isset(self::$_map[$key]) ? self::$_map[$key] : false; return isset(static::$_map[$key]) ? static::$_map[$key] : false;
} }
/** /**
@ -822,8 +822,8 @@ class App {
* @return array templates for each customizable package path * @return array templates for each customizable package path
*/ */
protected static function _packageFormat() { protected static function _packageFormat() {
if (empty(self::$_packageFormat)) { if (empty(static::$_packageFormat)) {
self::$_packageFormat = array( static::$_packageFormat = array(
'Model' => array( 'Model' => array(
'%s' . 'Model' . DS '%s' . 'Model' . DS
), ),
@ -885,7 +885,7 @@ class App {
); );
} }
return self::$_packageFormat; return static::$_packageFormat;
} }
/** /**
@ -897,13 +897,13 @@ class App {
* @return void * @return void
*/ */
public static function shutdown() { public static function shutdown() {
if (self::$_cacheChange) { if (static::$_cacheChange) {
Cache::write('file_map', array_filter(self::$_map), '_cake_core_'); Cache::write('file_map', array_filter(static::$_map), '_cake_core_');
} }
if (self::$_objectCacheChange) { if (static::$_objectCacheChange) {
Cache::write('object_map', self::$_objects, '_cake_core_'); Cache::write('object_map', static::$_objects, '_cake_core_');
} }
self::_checkFatalError(); static::_checkFatalError();
} }
/** /**

View file

@ -91,7 +91,7 @@ class CakePlugin {
if (is_array($plugin)) { if (is_array($plugin)) {
foreach ($plugin as $name => $conf) { foreach ($plugin as $name => $conf) {
list($name, $conf) = (is_numeric($name)) ? array($conf, $config) : array($name, $conf); list($name, $conf) = (is_numeric($name)) ? array($conf, $config) : array($name, $conf);
self::load($name, $conf); static::load($name, $conf);
} }
return; return;
} }
@ -99,26 +99,26 @@ class CakePlugin {
if (empty($config['path'])) { if (empty($config['path'])) {
foreach (App::path('plugins') as $path) { foreach (App::path('plugins') as $path) {
if (is_dir($path . $plugin)) { if (is_dir($path . $plugin)) {
self::$_plugins[$plugin] = $config + array('path' => $path . $plugin . DS); static::$_plugins[$plugin] = $config + array('path' => $path . $plugin . DS);
break; break;
} }
//Backwards compatibility to make easier to migrate to 2.0 //Backwards compatibility to make easier to migrate to 2.0
$underscored = Inflector::underscore($plugin); $underscored = Inflector::underscore($plugin);
if (is_dir($path . $underscored)) { if (is_dir($path . $underscored)) {
self::$_plugins[$plugin] = $config + array('path' => $path . $underscored . DS); static::$_plugins[$plugin] = $config + array('path' => $path . $underscored . DS);
break; break;
} }
} }
} else { } else {
self::$_plugins[$plugin] = $config; static::$_plugins[$plugin] = $config;
} }
if (empty(self::$_plugins[$plugin]['path'])) { if (empty(static::$_plugins[$plugin]['path'])) {
throw new MissingPluginException(array('plugin' => $plugin)); throw new MissingPluginException(array('plugin' => $plugin));
} }
if (!empty(self::$_plugins[$plugin]['bootstrap'])) { if (!empty(static::$_plugins[$plugin]['bootstrap'])) {
self::bootstrap($plugin); static::bootstrap($plugin);
} }
} }
@ -160,7 +160,7 @@ class CakePlugin {
if (isset($options[0])) { if (isset($options[0])) {
$opts += $options[0]; $opts += $options[0];
} }
self::load($p, $opts); static::load($p, $opts);
} }
} }
@ -172,10 +172,10 @@ class CakePlugin {
* @throws MissingPluginException if the folder for plugin was not found or plugin has not been loaded * @throws MissingPluginException if the folder for plugin was not found or plugin has not been loaded
*/ */
public static function path($plugin) { public static function path($plugin) {
if (empty(self::$_plugins[$plugin])) { if (empty(static::$_plugins[$plugin])) {
throw new MissingPluginException(array('plugin' => $plugin)); throw new MissingPluginException(array('plugin' => $plugin));
} }
return self::$_plugins[$plugin]['path']; return static::$_plugins[$plugin]['path'];
} }
/** /**
@ -186,7 +186,7 @@ class CakePlugin {
* @see CakePlugin::load() for examples of bootstrap configuration * @see CakePlugin::load() for examples of bootstrap configuration
*/ */
public static function bootstrap($plugin) { public static function bootstrap($plugin) {
$config = self::$_plugins[$plugin]; $config = static::$_plugins[$plugin];
if ($config['bootstrap'] === false) { if ($config['bootstrap'] === false) {
return false; return false;
} }
@ -194,9 +194,9 @@ class CakePlugin {
return call_user_func_array($config['bootstrap'], array($plugin, $config)); return call_user_func_array($config['bootstrap'], array($plugin, $config));
} }
$path = self::path($plugin); $path = static::path($plugin);
if ($config['bootstrap'] === true) { if ($config['bootstrap'] === true) {
return self::_includeFile( return static::_includeFile(
$path . 'Config' . DS . 'bootstrap.php', $path . 'Config' . DS . 'bootstrap.php',
$config['ignoreMissing'] $config['ignoreMissing']
); );
@ -204,7 +204,7 @@ class CakePlugin {
$bootstrap = (array)$config['bootstrap']; $bootstrap = (array)$config['bootstrap'];
foreach ($bootstrap as $file) { foreach ($bootstrap as $file) {
self::_includeFile( static::_includeFile(
$path . 'Config' . DS . $file . '.php', $path . 'Config' . DS . $file . '.php',
$config['ignoreMissing'] $config['ignoreMissing']
); );
@ -222,17 +222,17 @@ class CakePlugin {
*/ */
public static function routes($plugin = null) { public static function routes($plugin = null) {
if ($plugin === null) { if ($plugin === null) {
foreach (self::loaded() as $p) { foreach (static::loaded() as $p) {
self::routes($p); static::routes($p);
} }
return true; return true;
} }
$config = self::$_plugins[$plugin]; $config = static::$_plugins[$plugin];
if ($config['routes'] === false) { if ($config['routes'] === false) {
return false; return false;
} }
return (bool)self::_includeFile( return (bool)static::_includeFile(
self::path($plugin) . 'Config' . DS . 'routes.php', static::path($plugin) . 'Config' . DS . 'routes.php',
$config['ignoreMissing'] $config['ignoreMissing']
); );
} }
@ -247,9 +247,9 @@ class CakePlugin {
*/ */
public static function loaded($plugin = null) { public static function loaded($plugin = null) {
if ($plugin) { if ($plugin) {
return isset(self::$_plugins[$plugin]); return isset(static::$_plugins[$plugin]);
} }
$return = array_keys(self::$_plugins); $return = array_keys(static::$_plugins);
sort($return); sort($return);
return $return; return $return;
} }
@ -262,9 +262,9 @@ class CakePlugin {
*/ */
public static function unload($plugin = null) { public static function unload($plugin = null) {
if ($plugin === null) { if ($plugin === null) {
self::$_plugins = array(); static::$_plugins = array();
} else { } else {
unset(self::$_plugins[$plugin]); unset(static::$_plugins[$plugin]);
} }
} }

View file

@ -67,7 +67,7 @@ class Configure {
*/ */
public static function bootstrap($boot = true) { public static function bootstrap($boot = true) {
if ($boot) { if ($boot) {
self::_appDefaults(); static::_appDefaults();
if (!include APP . 'Config' . DS . 'core.php') { if (!include APP . 'Config' . DS . 'core.php') {
trigger_error(__d('cake_dev', trigger_error(__d('cake_dev',
@ -87,7 +87,7 @@ class Configure {
'handler' => 'ErrorHandler::handleError', 'handler' => 'ErrorHandler::handleError',
'level' => E_ALL & ~E_DEPRECATED, 'level' => E_ALL & ~E_DEPRECATED,
); );
self::_setErrorHandlers($error, $exception); static::_setErrorHandlers($error, $exception);
if (!include APP . 'Config' . DS . 'bootstrap.php') { if (!include APP . 'Config' . DS . 'bootstrap.php') {
trigger_error(__d('cake_dev', trigger_error(__d('cake_dev',
@ -98,13 +98,13 @@ class Configure {
} }
restore_error_handler(); restore_error_handler();
self::_setErrorHandlers( static::_setErrorHandlers(
self::$_values['Error'], static::$_values['Error'],
self::$_values['Exception'] static::$_values['Exception']
); );
// Preload Debugger + CakeText in case of E_STRICT errors when loading files. // Preload Debugger + CakeText in case of E_STRICT errors when loading files.
if (self::$_values['debug'] > 0) { if (static::$_values['debug'] > 0) {
class_exists('Debugger'); class_exists('Debugger');
class_exists('CakeText'); class_exists('CakeText');
} }
@ -117,7 +117,7 @@ class Configure {
* @return void * @return void
*/ */
protected static function _appDefaults() { protected static function _appDefaults() {
self::write('App', (array)self::read('App') + array( static::write('App', (array)static::read('App') + array(
'base' => false, 'base' => false,
'baseUrl' => false, 'baseUrl' => false,
'dir' => APP_DIR, 'dir' => APP_DIR,
@ -156,11 +156,11 @@ class Configure {
} }
foreach ($config as $name => $value) { foreach ($config as $name => $value) {
self::$_values = Hash::insert(self::$_values, $name, $value); static::$_values = Hash::insert(static::$_values, $name, $value);
} }
if (isset($config['debug']) && function_exists('ini_set')) { if (isset($config['debug']) && function_exists('ini_set')) {
if (self::$_values['debug']) { if (static::$_values['debug']) {
ini_set('display_errors', 1); ini_set('display_errors', 1);
} else { } else {
ini_set('display_errors', 0); ini_set('display_errors', 0);
@ -185,9 +185,9 @@ class Configure {
*/ */
public static function read($var = null) { public static function read($var = null) {
if ($var === null) { if ($var === null) {
return self::$_values; return static::$_values;
} }
return Hash::get(self::$_values, $var); return Hash::get(static::$_values, $var);
} }
/** /**
@ -201,16 +201,16 @@ class Configure {
*/ */
public static function consume($var) { public static function consume($var) {
$simple = strpos($var, '.') === false; $simple = strpos($var, '.') === false;
if ($simple && !isset(self::$_values[$var])) { if ($simple && !isset(static::$_values[$var])) {
return null; return null;
} }
if ($simple) { if ($simple) {
$value = self::$_values[$var]; $value = static::$_values[$var];
unset(self::$_values[$var]); unset(static::$_values[$var]);
return $value; return $value;
} }
$value = Hash::get(self::$_values, $var); $value = Hash::get(static::$_values, $var);
self::$_values = Hash::remove(self::$_values, $var); static::$_values = Hash::remove(static::$_values, $var);
return $value; return $value;
} }
@ -224,7 +224,7 @@ class Configure {
if (empty($var)) { if (empty($var)) {
return false; return false;
} }
return Hash::get(self::$_values, $var) !== null; return Hash::get(static::$_values, $var) !== null;
} }
/** /**
@ -241,7 +241,7 @@ class Configure {
* @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::delete * @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::delete
*/ */
public static function delete($var) { public static function delete($var) {
self::$_values = Hash::remove(self::$_values, $var); static::$_values = Hash::remove(static::$_values, $var);
} }
/** /**
@ -259,7 +259,7 @@ class Configure {
* @return void * @return void
*/ */
public static function config($name, ConfigReaderInterface $reader) { public static function config($name, ConfigReaderInterface $reader) {
self::$_readers[$name] = $reader; static::$_readers[$name] = $reader;
} }
/** /**
@ -270,9 +270,9 @@ class Configure {
*/ */
public static function configured($name = null) { public static function configured($name = null) {
if ($name) { if ($name) {
return isset(self::$_readers[$name]); return isset(static::$_readers[$name]);
} }
return array_keys(self::$_readers); return array_keys(static::$_readers);
} }
/** /**
@ -283,10 +283,10 @@ class Configure {
* @return bool Success * @return bool Success
*/ */
public static function drop($name) { public static function drop($name) {
if (!isset(self::$_readers[$name])) { if (!isset(static::$_readers[$name])) {
return false; return false;
} }
unset(self::$_readers[$name]); unset(static::$_readers[$name]);
return true; return true;
} }
@ -316,7 +316,7 @@ class Configure {
* @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::load * @link http://book.cakephp.org/2.0/en/development/configuration.html#Configure::load
*/ */
public static function load($key, $config = 'default', $merge = true) { public static function load($key, $config = 'default', $merge = true) {
$reader = self::_getReader($config); $reader = static::_getReader($config);
if (!$reader) { if (!$reader) {
return false; return false;
} }
@ -325,13 +325,13 @@ class Configure {
if ($merge) { if ($merge) {
$keys = array_keys($values); $keys = array_keys($values);
foreach ($keys as $key) { foreach ($keys as $key) {
if (($c = self::read($key)) && is_array($values[$key]) && is_array($c)) { if (($c = static::read($key)) && is_array($values[$key]) && is_array($c)) {
$values[$key] = Hash::merge($c, $values[$key]); $values[$key] = Hash::merge($c, $values[$key]);
} }
} }
} }
return self::write($values); return static::write($values);
} }
/** /**
@ -360,14 +360,14 @@ class Configure {
* @throws ConfigureException if the adapter does not implement a `dump` method. * @throws ConfigureException if the adapter does not implement a `dump` method.
*/ */
public static function dump($key, $config = 'default', $keys = array()) { public static function dump($key, $config = 'default', $keys = array()) {
$reader = self::_getReader($config); $reader = static::_getReader($config);
if (!$reader) { if (!$reader) {
throw new ConfigureException(__d('cake_dev', 'There is no "%s" adapter.', $config)); throw new ConfigureException(__d('cake_dev', 'There is no "%s" adapter.', $config));
} }
if (!method_exists($reader, 'dump')) { if (!method_exists($reader, 'dump')) {
throw new ConfigureException(__d('cake_dev', 'The "%s" adapter, does not have a %s method.', $config, 'dump()')); throw new ConfigureException(__d('cake_dev', 'The "%s" adapter, does not have a %s method.', $config, 'dump()'));
} }
$values = self::$_values; $values = static::$_values;
if (!empty($keys) && is_array($keys)) { if (!empty($keys) && is_array($keys)) {
$values = array_intersect_key($values, array_flip($keys)); $values = array_intersect_key($values, array_flip($keys));
} }
@ -382,14 +382,14 @@ class Configure {
* @return mixed Reader instance or false * @return mixed Reader instance or false
*/ */
protected static function _getReader($config) { protected static function _getReader($config) {
if (!isset(self::$_readers[$config])) { if (!isset(static::$_readers[$config])) {
if ($config !== 'default') { if ($config !== 'default') {
return false; return false;
} }
App::uses('PhpReader', 'Configure'); App::uses('PhpReader', 'Configure');
self::config($config, new PhpReader()); static::config($config, new PhpReader());
} }
return self::$_readers[$config]; return static::$_readers[$config];
} }
/** /**
@ -400,11 +400,11 @@ class Configure {
* @return string Current version of CakePHP * @return string Current version of CakePHP
*/ */
public static function version() { public static function version() {
if (!isset(self::$_values['Cake']['version'])) { if (!isset(static::$_values['Cake']['version'])) {
require CAKE . 'Config' . DS . 'config.php'; require CAKE . 'Config' . DS . 'config.php';
self::write($config); static::write($config);
} }
return self::$_values['Cake']['version']; return static::$_values['Cake']['version'];
} }
/** /**
@ -419,7 +419,7 @@ class Configure {
*/ */
public static function store($name, $cacheConfig = 'default', $data = null) { public static function store($name, $cacheConfig = 'default', $data = null) {
if ($data === null) { if ($data === null) {
$data = self::$_values; $data = static::$_values;
} }
return Cache::write($name, $data, $cacheConfig); return Cache::write($name, $data, $cacheConfig);
} }
@ -435,7 +435,7 @@ class Configure {
public static function restore($name, $cacheConfig = 'default') { public static function restore($name, $cacheConfig = 'default') {
$values = Cache::read($name, $cacheConfig); $values = Cache::read($name, $cacheConfig);
if ($values) { if ($values) {
return self::write($values); return static::write($values);
} }
return false; return false;
} }
@ -446,7 +446,7 @@ class Configure {
* @return bool Success. * @return bool Success.
*/ */
public static function clear() { public static function clear() {
self::$_values = array(); static::$_values = array();
return true; return true;
} }

View file

@ -115,7 +115,7 @@ class ErrorHandler {
*/ */
public static function handleException(Exception $exception) { public static function handleException(Exception $exception) {
$config = Configure::read('Exception'); $config = Configure::read('Exception');
self::_log($exception, $config); static::_log($exception, $config);
$renderer = isset($config['renderer']) ? $config['renderer'] : 'ExceptionRenderer'; $renderer = isset($config['renderer']) ? $config['renderer'] : 'ExceptionRenderer';
if ($renderer !== 'ExceptionRenderer') { if ($renderer !== 'ExceptionRenderer') {
@ -134,7 +134,7 @@ class ErrorHandler {
$e->getTraceAsString() $e->getTraceAsString()
); );
self::$_bailExceptionRendering = true; static::$_bailExceptionRendering = true;
trigger_error($message, E_USER_ERROR); trigger_error($message, E_USER_ERROR);
} }
} }
@ -185,7 +185,7 @@ class ErrorHandler {
} }
} }
} }
return CakeLog::write(LOG_ERR, self::_getMessage($exception)); return CakeLog::write(LOG_ERR, static::_getMessage($exception));
} }
/** /**
@ -208,9 +208,9 @@ class ErrorHandler {
return false; return false;
} }
$errorConfig = Configure::read('Error'); $errorConfig = Configure::read('Error');
list($error, $log) = self::mapErrorCode($code); list($error, $log) = static::mapErrorCode($code);
if ($log === LOG_ERR) { if ($log === LOG_ERR) {
return self::handleFatalError($code, $description, $file, $line); return static::handleFatalError($code, $description, $file, $line);
} }
$debug = Configure::read('debug'); $debug = Configure::read('debug');
@ -266,8 +266,8 @@ class ErrorHandler {
$exception = new InternalErrorException(); $exception = new InternalErrorException();
} }
if (self::$_bailExceptionRendering) { if (static::$_bailExceptionRendering) {
self::$_bailExceptionRendering = false; static::$_bailExceptionRendering = false;
throw $exception; throw $exception;
} }

View file

@ -67,14 +67,14 @@ class CakeEventManager {
*/ */
public static function instance($manager = null) { public static function instance($manager = null) {
if ($manager instanceof CakeEventManager) { if ($manager instanceof CakeEventManager) {
self::$_generalManager = $manager; static::$_generalManager = $manager;
} }
if (empty(self::$_generalManager)) { if (empty(static::$_generalManager)) {
self::$_generalManager = new CakeEventManager(); static::$_generalManager = new CakeEventManager();
} }
self::$_generalManager->_isGlobal = true; static::$_generalManager->_isGlobal = true;
return self::$_generalManager; return static::$_generalManager;
} }
/** /**
@ -105,7 +105,7 @@ class CakeEventManager {
$this->_attachSubscriber($callable); $this->_attachSubscriber($callable);
return; return;
} }
$options = $options + array('priority' => self::$defaultPriority, 'passParams' => false); $options = $options + array('priority' => static::$defaultPriority, 'passParams' => false);
$this->_listeners[$eventKey][$options['priority']][] = array( $this->_listeners[$eventKey][$options['priority']][] = array(
'callable' => $callable, 'callable' => $callable,
'passParams' => $options['passParams'], 'passParams' => $options['passParams'],
@ -265,7 +265,7 @@ class CakeEventManager {
$localListeners = $this->prioritisedListeners($eventKey); $localListeners = $this->prioritisedListeners($eventKey);
$localListeners = empty($localListeners) ? array() : $localListeners; $localListeners = empty($localListeners) ? array() : $localListeners;
} }
$globalListeners = self::instance()->prioritisedListeners($eventKey); $globalListeners = static::instance()->prioritisedListeners($eventKey);
$globalListeners = empty($globalListeners) ? array() : $globalListeners; $globalListeners = empty($globalListeners) ? array() : $globalListeners;
$priorities = array_merge(array_keys($globalListeners), array_keys($localListeners)); $priorities = array_merge(array_keys($globalListeners), array_keys($localListeners));

View file

@ -223,7 +223,7 @@ class I18n {
} }
if ($domain === null) { if ($domain === null) {
$domain = self::$defaultDomain; $domain = static::$defaultDomain;
} }
if ($domain === '') { if ($domain === '') {
throw new CakeException(__d('cake_dev', 'You cannot use "" as a domain.')); throw new CakeException(__d('cake_dev', 'You cannot use "" as a domain.'));
@ -399,7 +399,7 @@ class I18n {
foreach ($this->l10n->languagePath as $lang) { foreach ($this->l10n->languagePath as $lang) {
$localeDef = $directory . $lang . DS . $this->category; $localeDef = $directory . $lang . DS . $this->category;
if (is_file($localeDef)) { if (is_file($localeDef)) {
$definitions = self::loadLocaleDefinition($localeDef); $definitions = static::loadLocaleDefinition($localeDef);
if ($definitions !== false) { if ($definitions !== false) {
$this->_domains[$domain][$this->_lang][$this->category] = $definitions; $this->_domains[$domain][$this->_lang][$this->category] = $definitions;
$this->_noLocale = false; $this->_noLocale = false;
@ -412,10 +412,10 @@ class I18n {
$translations = false; $translations = false;
if (is_file($app . '.mo')) { if (is_file($app . '.mo')) {
$translations = self::loadMo($app . '.mo'); $translations = static::loadMo($app . '.mo');
} }
if ($translations === false && is_file($app . '.po')) { if ($translations === false && is_file($app . '.po')) {
$translations = self::loadPo($app . '.po'); $translations = static::loadPo($app . '.po');
} }
if ($translations !== false) { if ($translations !== false) {
@ -430,10 +430,10 @@ class I18n {
$translations = false; $translations = false;
if (is_file($file . '.mo')) { if (is_file($file . '.mo')) {
$translations = self::loadMo($file . '.mo'); $translations = static::loadMo($file . '.mo');
} }
if ($translations === false && is_file($file . '.po')) { if ($translations === false && is_file($file . '.po')) {
$translations = self::loadPo($file . '.po'); $translations = static::loadPo($file . '.po');
} }
if ($translations !== false) { if ($translations !== false) {

View file

@ -550,7 +550,7 @@ class Multibyte {
$matched = true; $matched = true;
} else { } else {
$matched = false; $matched = false;
$keys = self::_find($char, 'upper'); $keys = static::_find($char, 'upper');
if (!empty($keys)) { if (!empty($keys)) {
foreach ($keys as $key => $value) { foreach ($keys as $key => $value) {
@ -596,7 +596,7 @@ class Multibyte {
} else { } else {
$matched = false; $matched = false;
$keys = self::_find($char); $keys = static::_find($char);
$keyCount = count($keys); $keyCount = count($keys);
if (!empty($keys)) { if (!empty($keys)) {
@ -815,7 +815,7 @@ class Multibyte {
} else { } else {
$return = false; $return = false;
} }
self::$_codeRange[$decimal] = $return; static::$_codeRange[$decimal] = $return;
return $return; return $return;
} }
@ -828,8 +828,8 @@ class Multibyte {
*/ */
protected static function _find($char, $type = 'lower') { protected static function _find($char, $type = 'lower') {
$found = array(); $found = array();
if (!isset(self::$_codeRange[$char])) { if (!isset(static::$_codeRange[$char])) {
$range = self::_codepoint($char); $range = static::_codepoint($char);
if ($range === false) { if ($range === false) {
return array(); return array();
} }
@ -838,21 +838,21 @@ class Multibyte {
Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS)); Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS));
} }
Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_'); Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_');
self::$_caseFold[$range] = Configure::read($range); static::$_caseFold[$range] = Configure::read($range);
Configure::delete($range); Configure::delete($range);
} }
if (!self::$_codeRange[$char]) { if (!static::$_codeRange[$char]) {
return array(); return array();
} }
self::$_table = self::$_codeRange[$char]; static::$_table = static::$_codeRange[$char];
$count = count(self::$_caseFold[self::$_table]); $count = count(static::$_caseFold[static::$_table]);
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
if ($type === 'lower' && self::$_caseFold[self::$_table][$i][$type][0] === $char) { if ($type === 'lower' && static::$_caseFold[static::$_table][$i][$type][0] === $char) {
$found[] = self::$_caseFold[self::$_table][$i]; $found[] = static::$_caseFold[static::$_table][$i];
} elseif ($type === 'upper' && self::$_caseFold[self::$_table][$i][$type] === $char) { } elseif ($type === 'upper' && static::$_caseFold[static::$_table][$i][$type] === $char) {
$found[] = self::$_caseFold[self::$_table][$i]; $found[] = static::$_caseFold[static::$_table][$i];
} }
} }
return $found; return $found;

View file

@ -118,8 +118,8 @@ class CakeLog {
* @return void * @return void
*/ */
protected static function _init() { protected static function _init() {
self::$_levels = self::defaultLevels(); static::$_levels = static::defaultLevels();
self::$_Collection = new LogEngineCollection(); static::$_Collection = new LogEngineCollection();
} }
/** /**
@ -193,10 +193,10 @@ class CakeLog {
if (empty($config['engine'])) { if (empty($config['engine'])) {
throw new CakeLogException(__d('cake_dev', 'Missing logger class name')); throw new CakeLogException(__d('cake_dev', 'Missing logger class name'));
} }
if (empty(self::$_Collection)) { if (empty(static::$_Collection)) {
self::_init(); static::_init();
} }
self::$_Collection->load($key, $config); static::$_Collection->load($key, $config);
return true; return true;
} }
@ -206,10 +206,10 @@ class CakeLog {
* @return array Array of configured log streams. * @return array Array of configured log streams.
*/ */
public static function configured() { public static function configured() {
if (empty(self::$_Collection)) { if (empty(static::$_Collection)) {
self::_init(); static::_init();
} }
return self::$_Collection->loaded(); return static::$_Collection->loaded();
} }
/** /**
@ -259,20 +259,20 @@ class CakeLog {
* @return array Active log levels * @return array Active log levels
*/ */
public static function levels($levels = array(), $append = true) { public static function levels($levels = array(), $append = true) {
if (empty(self::$_Collection)) { if (empty(static::$_Collection)) {
self::_init(); static::_init();
} }
if (empty($levels)) { if (empty($levels)) {
return self::$_levels; return static::$_levels;
} }
$levels = array_values($levels); $levels = array_values($levels);
if ($append) { if ($append) {
self::$_levels = array_merge(self::$_levels, $levels); static::$_levels = array_merge(static::$_levels, $levels);
} else { } else {
self::$_levels = $levels; static::$_levels = $levels;
} }
self::$_levelMap = array_flip(self::$_levels); static::$_levelMap = array_flip(static::$_levels);
return self::$_levels; return static::$_levels;
} }
/** /**
@ -281,9 +281,9 @@ class CakeLog {
* @return array Default log levels * @return array Default log levels
*/ */
public static function defaultLevels() { public static function defaultLevels() {
self::$_levelMap = self::$_defaultLevels; static::$_levelMap = static::$_defaultLevels;
self::$_levels = array_flip(self::$_levelMap); static::$_levels = array_flip(static::$_levelMap);
return self::$_levels; return static::$_levels;
} }
/** /**
@ -294,10 +294,10 @@ class CakeLog {
* @return void * @return void
*/ */
public static function drop($streamName) { public static function drop($streamName) {
if (empty(self::$_Collection)) { if (empty(static::$_Collection)) {
self::_init(); static::_init();
} }
self::$_Collection->unload($streamName); static::$_Collection->unload($streamName);
} }
/** /**
@ -308,13 +308,13 @@ class CakeLog {
* @throws CakeLogException * @throws CakeLogException
*/ */
public static function enabled($streamName) { public static function enabled($streamName) {
if (empty(self::$_Collection)) { if (empty(static::$_Collection)) {
self::_init(); static::_init();
} }
if (!isset(self::$_Collection->{$streamName})) { if (!isset(static::$_Collection->{$streamName})) {
throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName)); throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName));
} }
return self::$_Collection->enabled($streamName); return static::$_Collection->enabled($streamName);
} }
/** /**
@ -326,13 +326,13 @@ class CakeLog {
* @throws CakeLogException * @throws CakeLogException
*/ */
public static function enable($streamName) { public static function enable($streamName) {
if (empty(self::$_Collection)) { if (empty(static::$_Collection)) {
self::_init(); static::_init();
} }
if (!isset(self::$_Collection->{$streamName})) { if (!isset(static::$_Collection->{$streamName})) {
throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName)); throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName));
} }
self::$_Collection->enable($streamName); static::$_Collection->enable($streamName);
} }
/** /**
@ -345,13 +345,13 @@ class CakeLog {
* @throws CakeLogException * @throws CakeLogException
*/ */
public static function disable($streamName) { public static function disable($streamName) {
if (empty(self::$_Collection)) { if (empty(static::$_Collection)) {
self::_init(); static::_init();
} }
if (!isset(self::$_Collection->{$streamName})) { if (!isset(static::$_Collection->{$streamName})) {
throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName)); throw new CakeLogException(__d('cake_dev', 'Stream %s not found', $streamName));
} }
self::$_Collection->disable($streamName); static::$_Collection->disable($streamName);
} }
/** /**
@ -362,11 +362,11 @@ class CakeLog {
* @see BaseLog * @see BaseLog
*/ */
public static function stream($streamName) { public static function stream($streamName) {
if (empty(self::$_Collection)) { if (empty(static::$_Collection)) {
self::_init(); static::_init();
} }
if (!empty(self::$_Collection->{$streamName})) { if (!empty(static::$_Collection->{$streamName})) {
return self::$_Collection->{$streamName}; return static::$_Collection->{$streamName};
} }
return false; return false;
} }
@ -403,19 +403,19 @@ class CakeLog {
* @link http://book.cakephp.org/2.0/en/core-libraries/logging.html#writing-to-logs * @link http://book.cakephp.org/2.0/en/core-libraries/logging.html#writing-to-logs
*/ */
public static function write($type, $message, $scope = array()) { public static function write($type, $message, $scope = array()) {
if (empty(self::$_Collection)) { if (empty(static::$_Collection)) {
self::_init(); static::_init();
} }
if (is_int($type) && isset(self::$_levels[$type])) { if (is_int($type) && isset(static::$_levels[$type])) {
$type = self::$_levels[$type]; $type = static::$_levels[$type];
} }
if (is_string($type) && empty($scope) && !in_array($type, self::$_levels)) { if (is_string($type) && empty($scope) && !in_array($type, static::$_levels)) {
$scope = $type; $scope = $type;
} }
$logged = false; $logged = false;
foreach (self::$_Collection->enabled() as $streamName) { foreach (static::$_Collection->enabled() as $streamName) {
$logger = self::$_Collection->{$streamName}; $logger = static::$_Collection->{$streamName};
$types = $scopes = $config = array(); $types = $scopes = $config = array();
if (method_exists($logger, 'config')) { if (method_exists($logger, 'config')) {
$config = $logger->config(); $config = $logger->config();
@ -455,7 +455,7 @@ class CakeLog {
* @return bool Success * @return bool Success
*/ */
public static function emergency($message, $scope = array()) { public static function emergency($message, $scope = array()) {
return self::write(self::$_levelMap['emergency'], $message, $scope); return static::write(static::$_levelMap['emergency'], $message, $scope);
} }
/** /**
@ -467,7 +467,7 @@ class CakeLog {
* @return bool Success * @return bool Success
*/ */
public static function alert($message, $scope = array()) { public static function alert($message, $scope = array()) {
return self::write(self::$_levelMap['alert'], $message, $scope); return static::write(static::$_levelMap['alert'], $message, $scope);
} }
/** /**
@ -479,7 +479,7 @@ class CakeLog {
* @return bool Success * @return bool Success
*/ */
public static function critical($message, $scope = array()) { public static function critical($message, $scope = array()) {
return self::write(self::$_levelMap['critical'], $message, $scope); return static::write(static::$_levelMap['critical'], $message, $scope);
} }
/** /**
@ -491,7 +491,7 @@ class CakeLog {
* @return bool Success * @return bool Success
*/ */
public static function error($message, $scope = array()) { public static function error($message, $scope = array()) {
return self::write(self::$_levelMap['error'], $message, $scope); return static::write(static::$_levelMap['error'], $message, $scope);
} }
/** /**
@ -503,7 +503,7 @@ class CakeLog {
* @return bool Success * @return bool Success
*/ */
public static function warning($message, $scope = array()) { public static function warning($message, $scope = array()) {
return self::write(self::$_levelMap['warning'], $message, $scope); return static::write(static::$_levelMap['warning'], $message, $scope);
} }
/** /**
@ -515,7 +515,7 @@ class CakeLog {
* @return bool Success * @return bool Success
*/ */
public static function notice($message, $scope = array()) { public static function notice($message, $scope = array()) {
return self::write(self::$_levelMap['notice'], $message, $scope); return static::write(static::$_levelMap['notice'], $message, $scope);
} }
/** /**
@ -527,7 +527,7 @@ class CakeLog {
* @return bool Success * @return bool Success
*/ */
public static function debug($message, $scope = array()) { public static function debug($message, $scope = array()) {
return self::write(self::$_levelMap['debug'], $message, $scope); return static::write(static::$_levelMap['debug'], $message, $scope);
} }
/** /**
@ -539,7 +539,7 @@ class CakeLog {
* @return bool Success * @return bool Success
*/ */
public static function info($message, $scope = array()) { public static function info($message, $scope = array()) {
return self::write(self::$_levelMap['info'], $message, $scope); return static::write(static::$_levelMap['info'], $message, $scope);
} }
} }

View file

@ -66,9 +66,9 @@ class ConnectionManager {
protected static function _init() { protected static function _init() {
include_once APP . 'Config' . DS . 'database.php'; include_once APP . 'Config' . DS . 'database.php';
if (class_exists('DATABASE_CONFIG')) { if (class_exists('DATABASE_CONFIG')) {
self::$config = new DATABASE_CONFIG(); static::$config = new DATABASE_CONFIG();
} }
self::$_init = true; static::$_init = true;
} }
/** /**
@ -79,20 +79,20 @@ class ConnectionManager {
* @throws MissingDatasourceException * @throws MissingDatasourceException
*/ */
public static function getDataSource($name) { public static function getDataSource($name) {
if (empty(self::$_init)) { if (empty(static::$_init)) {
self::_init(); static::_init();
} }
if (!empty(self::$_dataSources[$name])) { if (!empty(static::$_dataSources[$name])) {
return self::$_dataSources[$name]; return static::$_dataSources[$name];
} }
if (empty(self::$_connectionsEnum[$name])) { if (empty(static::$_connectionsEnum[$name])) {
self::_getConnectionObject($name); static::_getConnectionObject($name);
} }
self::loadDataSource($name); static::loadDataSource($name);
$conn = self::$_connectionsEnum[$name]; $conn = static::$_connectionsEnum[$name];
$class = $conn['classname']; $class = $conn['classname'];
if (strpos(App::location($class), 'Datasource') === false) { if (strpos(App::location($class), 'Datasource') === false) {
@ -102,10 +102,10 @@ class ConnectionManager {
'message' => 'Datasource is not found in Model/Datasource package.' 'message' => 'Datasource is not found in Model/Datasource package.'
)); ));
} }
self::$_dataSources[$name] = new $class(self::$config->{$name}); static::$_dataSources[$name] = new $class(static::$config->{$name});
self::$_dataSources[$name]->configKeyName = $name; static::$_dataSources[$name]->configKeyName = $name;
return self::$_dataSources[$name]; return static::$_dataSources[$name];
} }
/** /**
@ -116,10 +116,10 @@ class ConnectionManager {
* @return array List of available connections * @return array List of available connections
*/ */
public static function sourceList() { public static function sourceList() {
if (empty(self::$_init)) { if (empty(static::$_init)) {
self::_init(); static::_init();
} }
return array_keys(self::$_dataSources); return array_keys(static::$_dataSources);
} }
/** /**
@ -130,10 +130,10 @@ class ConnectionManager {
* in the ConnectionManager. * in the ConnectionManager.
*/ */
public static function getSourceName($source) { public static function getSourceName($source) {
if (empty(self::$_init)) { if (empty(static::$_init)) {
self::_init(); static::_init();
} }
foreach (self::$_dataSources as $name => $ds) { foreach (static::$_dataSources as $name => $ds) {
if ($ds === $source) { if ($ds === $source) {
return $name; return $name;
} }
@ -151,14 +151,14 @@ class ConnectionManager {
* @throws MissingDatasourceException * @throws MissingDatasourceException
*/ */
public static function loadDataSource($connName) { public static function loadDataSource($connName) {
if (empty(self::$_init)) { if (empty(static::$_init)) {
self::_init(); static::_init();
} }
if (is_array($connName)) { if (is_array($connName)) {
$conn = $connName; $conn = $connName;
} else { } else {
$conn = self::$_connectionsEnum[$connName]; $conn = static::$_connectionsEnum[$connName];
} }
if (class_exists($conn['classname'], false)) { if (class_exists($conn['classname'], false)) {
@ -190,10 +190,10 @@ class ConnectionManager {
* (as defined in Connections), and the value is an array with keys 'filename' and 'classname'. * (as defined in Connections), and the value is an array with keys 'filename' and 'classname'.
*/ */
public static function enumConnectionObjects() { public static function enumConnectionObjects() {
if (empty(self::$_init)) { if (empty(static::$_init)) {
self::_init(); static::_init();
} }
return (array)self::$config; return (array)static::$config;
} }
/** /**
@ -204,16 +204,16 @@ class ConnectionManager {
* @return DataSource|null A reference to the DataSource object, or null if creation failed * @return DataSource|null A reference to the DataSource object, or null if creation failed
*/ */
public static function create($name = '', $config = array()) { public static function create($name = '', $config = array()) {
if (empty(self::$_init)) { if (empty(static::$_init)) {
self::_init(); static::_init();
} }
if (empty($name) || empty($config) || array_key_exists($name, self::$_connectionsEnum)) { if (empty($name) || empty($config) || array_key_exists($name, static::$_connectionsEnum)) {
return null; return null;
} }
self::$config->{$name} = $config; static::$config->{$name} = $config;
self::$_connectionsEnum[$name] = self::_connectionData($config); static::$_connectionsEnum[$name] = static::_connectionData($config);
$return = self::getDataSource($name); $return = static::getDataSource($name);
return $return; return $return;
} }
@ -224,14 +224,14 @@ class ConnectionManager {
* @return bool success if connection was removed, false if it does not exist * @return bool success if connection was removed, false if it does not exist
*/ */
public static function drop($name) { public static function drop($name) {
if (empty(self::$_init)) { if (empty(static::$_init)) {
self::_init(); static::_init();
} }
if (!isset(self::$config->{$name})) { if (!isset(static::$config->{$name})) {
return false; return false;
} }
unset(self::$_connectionsEnum[$name], self::$_dataSources[$name], self::$config->{$name}); unset(static::$_connectionsEnum[$name], static::$_dataSources[$name], static::$config->{$name});
return true; return true;
} }
@ -243,8 +243,8 @@ class ConnectionManager {
* @throws MissingDatasourceConfigException * @throws MissingDatasourceConfigException
*/ */
protected static function _getConnectionObject($name) { protected static function _getConnectionObject($name) {
if (!empty(self::$config->{$name})) { if (!empty(static::$config->{$name})) {
self::$_connectionsEnum[$name] = self::_connectionData(self::$config->{$name}); static::$_connectionsEnum[$name] = static::_connectionData(static::$config->{$name});
} else { } else {
throw new MissingDatasourceConfigException(array('config' => $name)); throw new MissingDatasourceConfigException(array('config' => $name));
} }

View file

@ -141,20 +141,20 @@ class CakeSession {
* @return void * @return void
*/ */
public static function init($base = null) { public static function init($base = null) {
self::$time = time(); static::$time = time();
if (env('HTTP_USER_AGENT')) { if (env('HTTP_USER_AGENT')) {
self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt')); static::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt'));
} }
self::_setPath($base); static::_setPath($base);
self::_setHost(env('HTTP_HOST')); static::_setHost(env('HTTP_HOST'));
if (!self::$_initialized) { if (!static::$_initialized) {
register_shutdown_function('session_write_close'); register_shutdown_function('session_write_close');
} }
self::$_initialized = true; static::$_initialized = true;
} }
/** /**
@ -165,7 +165,7 @@ class CakeSession {
*/ */
protected static function _setPath($base = null) { protected static function _setPath($base = null) {
if (empty($base)) { if (empty($base)) {
self::$path = '/'; static::$path = '/';
return; return;
} }
if (strpos($base, 'index.php') !== false) { if (strpos($base, 'index.php') !== false) {
@ -174,7 +174,7 @@ class CakeSession {
if (strpos($base, '?') !== false) { if (strpos($base, '?') !== false) {
$base = str_replace('?', '', $base); $base = str_replace('?', '', $base);
} }
self::$path = $base; static::$path = $base;
} }
/** /**
@ -184,9 +184,9 @@ class CakeSession {
* @return void * @return void
*/ */
protected static function _setHost($host) { protected static function _setHost($host) {
self::$host = $host; static::$host = $host;
if (strpos(self::$host, ':') !== false) { if (strpos(static::$host, ':') !== false) {
self::$host = substr(self::$host, 0, strpos(self::$host, ':')); static::$host = substr(static::$host, 0, strpos(static::$host, ':'));
} }
} }
@ -196,20 +196,20 @@ class CakeSession {
* @return bool True if session was started * @return bool True if session was started
*/ */
public static function start() { public static function start() {
if (self::started()) { if (static::started()) {
return true; return true;
} }
$id = self::id(); $id = static::id();
self::_startSession(); static::_startSession();
if (!$id && self::started()) { if (!$id && static::started()) {
self::_checkValid(); static::_checkValid();
} }
self::$error = false; static::$error = false;
self::$valid = true; static::$valid = true;
return self::started(); return static::started();
} }
/** /**
@ -228,7 +228,7 @@ class CakeSession {
* @return bool True if variable is there * @return bool True if variable is there
*/ */
public static function check($name) { public static function check($name) {
if (empty($name) || !self::_hasSession() || !self::start()) { if (empty($name) || !static::_hasSession() || !static::start()) {
return false; return false;
} }
@ -251,13 +251,13 @@ class CakeSession {
*/ */
public static function id($id = null) { public static function id($id = null) {
if ($id) { if ($id) {
self::$id = $id; static::$id = $id;
session_id(self::$id); session_id(static::$id);
} }
if (self::started()) { if (static::started()) {
return session_id(); return session_id();
} }
return self::$id; return static::$id;
} }
/** /**
@ -267,9 +267,9 @@ class CakeSession {
* @return bool Success * @return bool Success
*/ */
public static function delete($name) { public static function delete($name) {
if (self::check($name)) { if (static::check($name)) {
self::_overwrite($_SESSION, Hash::remove($_SESSION, $name)); static::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
return !self::check($name); return !static::check($name);
} }
return false; return false;
} }
@ -301,10 +301,10 @@ class CakeSession {
* @return string Error as string * @return string Error as string
*/ */
protected static function _error($errorNumber) { protected static function _error($errorNumber) {
if (!is_array(self::$error) || !array_key_exists($errorNumber, self::$error)) { if (!is_array(static::$error) || !array_key_exists($errorNumber, static::$error)) {
return false; return false;
} }
return self::$error[$errorNumber]; return static::$error[$errorNumber];
} }
/** /**
@ -313,8 +313,8 @@ class CakeSession {
* @return mixed Error description as a string, or false. * @return mixed Error description as a string, or false.
*/ */
public static function error() { public static function error() {
if (self::$lastError) { if (static::$lastError) {
return self::_error(self::$lastError); return static::_error(static::$lastError);
} }
return false; return false;
} }
@ -325,32 +325,32 @@ class CakeSession {
* @return bool Success * @return bool Success
*/ */
public static function valid() { public static function valid() {
if (self::start() && self::read('Config')) { if (static::start() && static::read('Config')) {
if (self::_validAgentAndTime() && self::$error === false) { if (static::_validAgentAndTime() && static::$error === false) {
self::$valid = true; static::$valid = true;
} else { } else {
self::$valid = false; static::$valid = false;
self::_setError(1, 'Session Highjacking Attempted !!!'); static::_setError(1, 'Session Highjacking Attempted !!!');
} }
} }
return self::$valid; return static::$valid;
} }
/** /**
* Tests that the user agent is valid and that the session hasn't 'timed out'. * Tests that the user agent is valid and that the session hasn't 'timed out'.
* Since timeouts are implemented in CakeSession it checks the current self::$time * Since timeouts are implemented in CakeSession it checks the current static::$time
* against the time the session is set to expire. The User agent is only checked * against the time the session is set to expire. The User agent is only checked
* if Session.checkAgent == true. * if Session.checkAgent == true.
* *
* @return bool * @return bool
*/ */
protected static function _validAgentAndTime() { protected static function _validAgentAndTime() {
$config = self::read('Config'); $config = static::read('Config');
$validAgent = ( $validAgent = (
Configure::read('Session.checkAgent') === false || Configure::read('Session.checkAgent') === false ||
isset($config['userAgent']) && self::$_userAgent === $config['userAgent'] isset($config['userAgent']) && static::$_userAgent === $config['userAgent']
); );
return ($validAgent && self::$time <= $config['time']); return ($validAgent && static::$time <= $config['time']);
} }
/** /**
@ -361,12 +361,12 @@ class CakeSession {
*/ */
public static function userAgent($userAgent = null) { public static function userAgent($userAgent = null) {
if ($userAgent) { if ($userAgent) {
self::$_userAgent = $userAgent; static::$_userAgent = $userAgent;
} }
if (empty(self::$_userAgent)) { if (empty(static::$_userAgent)) {
CakeSession::init(self::$path); CakeSession::init(static::$path);
} }
return self::$_userAgent; return static::$_userAgent;
} }
/** /**
@ -380,11 +380,11 @@ class CakeSession {
if (empty($name) && $name !== null) { if (empty($name) && $name !== null) {
return null; return null;
} }
if (!self::_hasSession() || !self::start()) { if (!static::_hasSession() || !static::start()) {
return null; return null;
} }
if ($name === null) { if ($name === null) {
return self::_returnSessionVars(); return static::_returnSessionVars();
} }
$result = Hash::get($_SESSION, $name); $result = Hash::get($_SESSION, $name);
@ -403,7 +403,7 @@ class CakeSession {
if (!empty($_SESSION)) { if (!empty($_SESSION)) {
return $_SESSION; return $_SESSION;
} }
self::_setError(2, 'No Session vars set'); static::_setError(2, 'No Session vars set');
return false; return false;
} }
@ -415,7 +415,7 @@ class CakeSession {
* @return bool True if the write was successful, false if the write failed * @return bool True if the write was successful, false if the write failed
*/ */
public static function write($name, $value = null) { public static function write($name, $value = null) {
if (empty($name) || !self::start()) { if (empty($name) || !static::start()) {
return false; return false;
} }
@ -424,7 +424,7 @@ class CakeSession {
$write = array($name => $value); $write = array($name => $value);
} }
foreach ($write as $key => $val) { foreach ($write as $key => $val) {
self::_overwrite($_SESSION, Hash::insert($_SESSION, $key, $val)); static::_overwrite($_SESSION, Hash::insert($_SESSION, $key, $val));
if (Hash::get($_SESSION, $key) !== $val) { if (Hash::get($_SESSION, $key) !== $val) {
return false; return false;
} }
@ -443,9 +443,9 @@ class CakeSession {
if (empty($name)) { if (empty($name)) {
return null; return null;
} }
$value = self::read($name); $value = static::read($name);
if ($value !== null) { if ($value !== null) {
self::_overwrite($_SESSION, Hash::remove($_SESSION, $name)); static::_overwrite($_SESSION, Hash::remove($_SESSION, $name));
} }
return $value; return $value;
} }
@ -456,17 +456,17 @@ class CakeSession {
* @return void * @return void
*/ */
public static function destroy() { public static function destroy() {
if (!self::started()) { if (!static::started()) {
self::_startSession(); static::_startSession();
} }
if (self::started()) { if (static::started()) {
session_destroy(); session_destroy();
} }
$_SESSION = null; $_SESSION = null;
self::$id = null; static::$id = null;
self::$_cookieName = null; static::$_cookieName = null;
} }
/** /**
@ -484,8 +484,8 @@ class CakeSession {
} }
$_SESSION = null; $_SESSION = null;
self::$id = null; static::$id = null;
self::renew(); static::renew();
} }
/** /**
@ -500,7 +500,7 @@ class CakeSession {
$sessionConfig = Configure::read('Session'); $sessionConfig = Configure::read('Session');
if (isset($sessionConfig['defaults'])) { if (isset($sessionConfig['defaults'])) {
$defaults = self::_defaultConfig($sessionConfig['defaults']); $defaults = static::_defaultConfig($sessionConfig['defaults']);
if ($defaults) { if ($defaults) {
$sessionConfig = Hash::merge($defaults, $sessionConfig); $sessionConfig = Hash::merge($defaults, $sessionConfig);
} }
@ -518,7 +518,7 @@ class CakeSession {
if (!isset($sessionConfig['ini']['session.name'])) { if (!isset($sessionConfig['ini']['session.name'])) {
$sessionConfig['ini']['session.name'] = $sessionConfig['cookie']; $sessionConfig['ini']['session.name'] = $sessionConfig['cookie'];
} }
self::$_cookieName = $sessionConfig['ini']['session.name']; static::$_cookieName = $sessionConfig['ini']['session.name'];
if (!empty($sessionConfig['handler'])) { if (!empty($sessionConfig['handler'])) {
$sessionConfig['ini']['session.save_handler'] = 'user'; $sessionConfig['ini']['session.save_handler'] = 'user';
@ -548,7 +548,7 @@ class CakeSession {
call_user_func_array('session_set_save_handler', $sessionConfig['handler']); call_user_func_array('session_set_save_handler', $sessionConfig['handler']);
} }
if (!empty($sessionConfig['handler']['engine'])) { if (!empty($sessionConfig['handler']['engine'])) {
$handler = self::_getHandler($sessionConfig['handler']['engine']); $handler = static::_getHandler($sessionConfig['handler']['engine']);
session_set_save_handler( session_set_save_handler(
array($handler, 'open'), array($handler, 'open'),
array($handler, 'close'), array($handler, 'close'),
@ -559,7 +559,7 @@ class CakeSession {
); );
} }
Configure::write('Session', $sessionConfig); Configure::write('Session', $sessionConfig);
self::$sessionTime = self::$time + ($sessionConfig['timeout'] * 60); static::$sessionTime = static::$time + ($sessionConfig['timeout'] * 60);
} }
/** /**
@ -568,14 +568,14 @@ class CakeSession {
* @return string * @return string
*/ */
protected static function _cookieName() { protected static function _cookieName() {
if (self::$_cookieName !== null) { if (static::$_cookieName !== null) {
return self::$_cookieName; return static::$_cookieName;
} }
self::init(); static::init();
self::_configureSession(); static::_configureSession();
return self::$_cookieName = session_name(); return static::$_cookieName = session_name();
} }
/** /**
@ -584,7 +584,7 @@ class CakeSession {
* @return bool * @return bool
*/ */
protected static function _hasSession() { protected static function _hasSession() {
return self::started() || isset($_COOKIE[self::_cookieName()]); return static::started() || isset($_COOKIE[static::_cookieName()]);
} }
/** /**
@ -620,7 +620,7 @@ class CakeSession {
'timeout' => 240, 'timeout' => 240,
'ini' => array( 'ini' => array(
'session.use_trans_sid' => 0, 'session.use_trans_sid' => 0,
'session.cookie_path' => self::$path 'session.cookie_path' => static::$path
) )
), ),
'cake' => array( 'cake' => array(
@ -631,7 +631,7 @@ class CakeSession {
'url_rewriter.tags' => '', 'url_rewriter.tags' => '',
'session.serialize_handler' => 'php', 'session.serialize_handler' => 'php',
'session.use_cookies' => 1, 'session.use_cookies' => 1,
'session.cookie_path' => self::$path, 'session.cookie_path' => static::$path,
'session.save_path' => TMP . 'sessions', 'session.save_path' => TMP . 'sessions',
'session.save_handler' => 'files' 'session.save_handler' => 'files'
) )
@ -643,7 +643,7 @@ class CakeSession {
'session.use_trans_sid' => 0, 'session.use_trans_sid' => 0,
'url_rewriter.tags' => '', 'url_rewriter.tags' => '',
'session.use_cookies' => 1, 'session.use_cookies' => 1,
'session.cookie_path' => self::$path, 'session.cookie_path' => static::$path,
'session.save_handler' => 'user', 'session.save_handler' => 'user',
), ),
'handler' => array( 'handler' => array(
@ -658,7 +658,7 @@ class CakeSession {
'session.use_trans_sid' => 0, 'session.use_trans_sid' => 0,
'url_rewriter.tags' => '', 'url_rewriter.tags' => '',
'session.use_cookies' => 1, 'session.use_cookies' => 1,
'session.cookie_path' => self::$path, 'session.cookie_path' => static::$path,
'session.save_handler' => 'user', 'session.save_handler' => 'user',
'session.serialize_handler' => 'php', 'session.serialize_handler' => 'php',
), ),
@ -680,9 +680,9 @@ class CakeSession {
* @return bool Success * @return bool Success
*/ */
protected static function _startSession() { protected static function _startSession() {
self::init(); static::init();
session_write_close(); session_write_close();
self::_configureSession(); static::_configureSession();
if (headers_sent()) { if (headers_sent()) {
if (empty($_SESSION)) { if (empty($_SESSION)) {
@ -702,31 +702,31 @@ class CakeSession {
* @return void * @return void
*/ */
protected static function _checkValid() { protected static function _checkValid() {
$config = self::read('Config'); $config = static::read('Config');
if ($config) { if ($config) {
$sessionConfig = Configure::read('Session'); $sessionConfig = Configure::read('Session');
if (self::valid()) { if (static::valid()) {
self::write('Config.time', self::$sessionTime); static::write('Config.time', static::$sessionTime);
if (isset($sessionConfig['autoRegenerate']) && $sessionConfig['autoRegenerate'] === true) { if (isset($sessionConfig['autoRegenerate']) && $sessionConfig['autoRegenerate'] === true) {
$check = $config['countdown']; $check = $config['countdown'];
$check -= 1; $check -= 1;
self::write('Config.countdown', $check); static::write('Config.countdown', $check);
if ($check < 1) { if ($check < 1) {
self::renew(); static::renew();
self::write('Config.countdown', self::$requestCountdown); static::write('Config.countdown', static::$requestCountdown);
} }
} }
} else { } else {
$_SESSION = array(); $_SESSION = array();
self::destroy(); static::destroy();
self::_setError(1, 'Session Highjacking Attempted !!!'); static::_setError(1, 'Session Highjacking Attempted !!!');
self::_startSession(); static::_startSession();
self::_writeConfig(); static::_writeConfig();
} }
} else { } else {
self::_writeConfig(); static::_writeConfig();
} }
} }
@ -736,9 +736,9 @@ class CakeSession {
* @return void * @return void
*/ */
protected static function _writeConfig() { protected static function _writeConfig() {
self::write('Config.userAgent', self::$_userAgent); static::write('Config.userAgent', static::$_userAgent);
self::write('Config.time', self::$sessionTime); static::write('Config.time', static::$sessionTime);
self::write('Config.countdown', self::$requestCountdown); static::write('Config.countdown', static::$requestCountdown);
} }
/** /**
@ -751,7 +751,7 @@ class CakeSession {
return; return;
} }
if (isset($_COOKIE[session_name()])) { if (isset($_COOKIE[session_name()])) {
setcookie(Configure::read('Session.cookie'), '', time() - 42000, self::$path); setcookie(Configure::read('Session.cookie'), '', time() - 42000, static::$path);
} }
session_regenerate_id(true); session_regenerate_id(true);
} }
@ -764,11 +764,11 @@ class CakeSession {
* @return void * @return void
*/ */
protected static function _setError($errorNumber, $errorMessage) { protected static function _setError($errorNumber, $errorMessage) {
if (self::$error === false) { if (static::$error === false) {
self::$error = array(); static::$error = array();
} }
self::$error[$errorNumber] = $errorMessage; static::$error[$errorNumber] = $errorMessage;
self::$lastError = $errorNumber; static::$lastError = $errorNumber;
} }
} }

View file

@ -544,7 +544,7 @@ class Sqlserver extends DboSource {
$page = (int)($limitOffset[1] / $limitOffset[2]); $page = (int)($limitOffset[1] / $limitOffset[2]);
$offset = (int)($limitOffset[2] * $page); $offset = (int)($limitOffset[2] * $page);
$rowCounter = self::ROW_COUNTER; $rowCounter = static::ROW_COUNTER;
$sql = "SELECT {$limit} * FROM ( $sql = "SELECT {$limit} * FROM (
SELECT {$fields}, ROW_NUMBER() OVER ({$order}) AS {$rowCounter} SELECT {$fields}, ROW_NUMBER() OVER ({$order}) AS {$rowCounter}
FROM {$table} {$alias} {$joins} {$conditions} {$group} FROM {$table} {$alias} {$joins} {$conditions} {$group}
@ -634,7 +634,7 @@ class Sqlserver extends DboSource {
$resultRow = array(); $resultRow = array();
foreach ($this->map as $col => $meta) { foreach ($this->map as $col => $meta) {
list($table, $column, $type) = $meta; list($table, $column, $type) = $meta;
if ($table === 0 && $column === self::ROW_COUNTER) { if ($table === 0 && $column === static::ROW_COUNTER) {
continue; continue;
} }
$resultRow[$table][$column] = $row[$col]; $resultRow[$table][$column] = $row[$col];

View file

@ -759,7 +759,7 @@ class DboSource extends DataSource {
*/ */
public function flushMethodCache() { public function flushMethodCache() {
$this->_methodCacheChange = true; $this->_methodCacheChange = true;
self::$methodCache = array(); static::$methodCache = array();
} }
/** /**
@ -778,14 +778,14 @@ class DboSource extends DataSource {
if ($this->cacheMethods === false) { if ($this->cacheMethods === false) {
return $value; return $value;
} }
if (!$this->_methodCacheChange && empty(self::$methodCache)) { if (!$this->_methodCacheChange && empty(static::$methodCache)) {
self::$methodCache = (array)Cache::read('method_cache', '_cake_core_'); static::$methodCache = (array)Cache::read('method_cache', '_cake_core_');
} }
if ($value === null) { if ($value === null) {
return (isset(self::$methodCache[$method][$key])) ? self::$methodCache[$method][$key] : null; return (isset(static::$methodCache[$method][$key])) ? static::$methodCache[$method][$key] : null;
} }
$this->_methodCacheChange = true; $this->_methodCacheChange = true;
return self::$methodCache[$method][$key] = $value; return static::$methodCache[$method][$key] = $value;
} }
/** /**
@ -3571,7 +3571,7 @@ class DboSource extends DataSource {
*/ */
public function __destruct() { public function __destruct() {
if ($this->_methodCacheChange) { if ($this->_methodCacheChange) {
Cache::write('method_cache', self::$methodCache, '_cake_core_'); Cache::write('method_cache', static::$methodCache, '_cake_core_');
} }
parent::__destruct(); parent::__destruct();
} }

View file

@ -853,7 +853,7 @@ class CakeRequest implements ArrayAccess {
* @return mixed If a $language is provided, a boolean. Otherwise the array of accepted languages. * @return mixed If a $language is provided, a boolean. Otherwise the array of accepted languages.
*/ */
public static function acceptLanguage($language = null) { public static function acceptLanguage($language = null) {
$raw = self::_parseAcceptWithQualifier(self::header('Accept-Language')); $raw = static::_parseAcceptWithQualifier(static::header('Accept-Language'));
$accept = array(); $accept = array();
foreach ($raw as $languages) { foreach ($raw as $languages) {
foreach ($languages as &$lang) { foreach ($languages as &$lang) {

View file

@ -781,7 +781,7 @@ class CakeEmail {
$headers += $this->_headers; $headers += $this->_headers;
if (!isset($headers['X-Mailer'])) { if (!isset($headers['X-Mailer'])) {
$headers['X-Mailer'] = self::EMAIL_CLIENT; $headers['X-Mailer'] = static::EMAIL_CLIENT;
} }
if (!isset($headers['Date'])) { if (!isset($headers['Date'])) {
$headers['Date'] = date(DATE_RFC2822); $headers['Date'] = date(DATE_RFC2822);
@ -1113,9 +1113,9 @@ class CakeEmail {
*/ */
public function message($type = null) { public function message($type = null) {
switch ($type) { switch ($type) {
case self::MESSAGE_HTML: case static::MESSAGE_HTML:
return $this->_htmlMessage; return $this->_htmlMessage;
case self::MESSAGE_TEXT: case static::MESSAGE_TEXT:
return $this->_textMessage; return $this->_textMessage;
} }
return $this->_message; return $this->_message;
@ -1315,7 +1315,7 @@ class CakeEmail {
$this->headerCharset = null; $this->headerCharset = null;
$this->_attachments = array(); $this->_attachments = array();
$this->_config = array(); $this->_config = array();
$this->_emailPattern = self::EMAIL_PATTERN; $this->_emailPattern = static::EMAIL_PATTERN;
return $this; return $this;
} }

View file

@ -33,7 +33,7 @@ class BasicAuthentication {
*/ */
public static function authentication(HttpSocket $http, &$authInfo) { public static function authentication(HttpSocket $http, &$authInfo) {
if (isset($authInfo['user'], $authInfo['pass'])) { if (isset($authInfo['user'], $authInfo['pass'])) {
$http->request['header']['Authorization'] = self::_generateHeader($authInfo['user'], $authInfo['pass']); $http->request['header']['Authorization'] = static::_generateHeader($authInfo['user'], $authInfo['pass']);
} }
} }
@ -47,7 +47,7 @@ class BasicAuthentication {
*/ */
public static function proxyAuthentication(HttpSocket $http, &$proxyInfo) { public static function proxyAuthentication(HttpSocket $http, &$proxyInfo) {
if (isset($proxyInfo['user'], $proxyInfo['pass'])) { if (isset($proxyInfo['user'], $proxyInfo['pass'])) {
$http->request['header']['Proxy-Authorization'] = self::_generateHeader($proxyInfo['user'], $proxyInfo['pass']); $http->request['header']['Proxy-Authorization'] = static::_generateHeader($proxyInfo['user'], $proxyInfo['pass']);
} }
} }

View file

@ -33,10 +33,10 @@ class DigestAuthentication {
*/ */
public static function authentication(HttpSocket $http, &$authInfo) { public static function authentication(HttpSocket $http, &$authInfo) {
if (isset($authInfo['user'], $authInfo['pass'])) { if (isset($authInfo['user'], $authInfo['pass'])) {
if (!isset($authInfo['realm']) && !self::_getServerInformation($http, $authInfo)) { if (!isset($authInfo['realm']) && !static::_getServerInformation($http, $authInfo)) {
return; return;
} }
$http->request['header']['Authorization'] = self::_generateHeader($http, $authInfo); $http->request['header']['Authorization'] = static::_generateHeader($http, $authInfo);
} }
} }

View file

@ -213,10 +213,10 @@ class Router {
*/ */
public static function defaultRouteClass($routeClass = null) { public static function defaultRouteClass($routeClass = null) {
if ($routeClass === null) { if ($routeClass === null) {
return self::$_routeClass; return static::$_routeClass;
} }
self::$_routeClass = self::_validateRouteClass($routeClass); static::$_routeClass = static::_validateRouteClass($routeClass);
} }
/** /**
@ -243,7 +243,7 @@ class Router {
protected static function _setPrefixes() { protected static function _setPrefixes() {
$routing = Configure::read('Routing'); $routing = Configure::read('Routing');
if (!empty($routing['prefixes'])) { if (!empty($routing['prefixes'])) {
self::$_prefixes = array_merge(self::$_prefixes, (array)$routing['prefixes']); static::$_prefixes = array_merge(static::$_prefixes, (array)$routing['prefixes']);
} }
} }
@ -254,7 +254,7 @@ class Router {
* @see Router::$_namedExpressions * @see Router::$_namedExpressions
*/ */
public static function getNamedExpressions() { public static function getNamedExpressions() {
return self::$_namedExpressions; return static::$_namedExpressions;
} }
/** /**
@ -266,9 +266,9 @@ class Router {
*/ */
public static function resourceMap($resourceMap = null) { public static function resourceMap($resourceMap = null) {
if ($resourceMap === null) { if ($resourceMap === null) {
return self::$_resourceMap; return static::$_resourceMap;
} }
self::$_resourceMap = $resourceMap; static::$_resourceMap = $resourceMap;
} }
/** /**
@ -342,9 +342,9 @@ class Router {
* @throws RouterException * @throws RouterException
*/ */
public static function connect($route, $defaults = array(), $options = array()) { public static function connect($route, $defaults = array(), $options = array()) {
self::$initialized = true; static::$initialized = true;
foreach (self::$_prefixes as $prefix) { foreach (static::$_prefixes as $prefix) {
if (isset($defaults[$prefix])) { if (isset($defaults[$prefix])) {
if ($defaults[$prefix]) { if ($defaults[$prefix]) {
$defaults['prefix'] = $prefix; $defaults['prefix'] = $prefix;
@ -354,28 +354,28 @@ class Router {
break; break;
} }
} }
if (isset($defaults['prefix']) && !in_array($defaults['prefix'], self::$_prefixes)) { if (isset($defaults['prefix']) && !in_array($defaults['prefix'], static::$_prefixes)) {
self::$_prefixes[] = $defaults['prefix']; static::$_prefixes[] = $defaults['prefix'];
} }
$defaults += array('plugin' => null); $defaults += array('plugin' => null);
if (empty($options['action'])) { if (empty($options['action'])) {
$defaults += array('action' => 'index'); $defaults += array('action' => 'index');
} }
$routeClass = self::$_routeClass; $routeClass = static::$_routeClass;
if (isset($options['routeClass'])) { if (isset($options['routeClass'])) {
if (strpos($options['routeClass'], '.') === false) { if (strpos($options['routeClass'], '.') === false) {
$routeClass = $options['routeClass']; $routeClass = $options['routeClass'];
} else { } else {
list(, $routeClass) = pluginSplit($options['routeClass'], true); list(, $routeClass) = pluginSplit($options['routeClass'], true);
} }
$routeClass = self::_validateRouteClass($routeClass); $routeClass = static::_validateRouteClass($routeClass);
unset($options['routeClass']); unset($options['routeClass']);
} }
if ($routeClass === 'RedirectRoute' && isset($defaults['redirect'])) { if ($routeClass === 'RedirectRoute' && isset($defaults['redirect'])) {
$defaults = $defaults['redirect']; $defaults = $defaults['redirect'];
} }
self::$routes[] = new $routeClass($route, $defaults, $options); static::$routes[] = new $routeClass($route, $defaults, $options);
return self::$routes; return static::$routes;
} }
/** /**
@ -416,7 +416,7 @@ class Router {
if (is_string($url)) { if (is_string($url)) {
$url = array('redirect' => $url); $url = array('redirect' => $url);
} }
return self::connect($route, $url, $options); return static::connect($route, $url, $options);
} }
/** /**
@ -473,7 +473,7 @@ class Router {
*/ */
public static function connectNamed($named, $options = array()) { public static function connectNamed($named, $options = array()) {
if (isset($options['separator'])) { if (isset($options['separator'])) {
self::$_namedConfig['separator'] = $options['separator']; static::$_namedConfig['separator'] = $options['separator'];
unset($options['separator']); unset($options['separator']);
} }
@ -484,23 +484,23 @@ class Router {
$options += array('default' => false, 'reset' => false, 'greedy' => true); $options += array('default' => false, 'reset' => false, 'greedy' => true);
} }
if ($options['reset'] || self::$_namedConfig['rules'] === false) { if ($options['reset'] || static::$_namedConfig['rules'] === false) {
self::$_namedConfig['rules'] = array(); static::$_namedConfig['rules'] = array();
} }
if ($options['default']) { if ($options['default']) {
$named = array_merge($named, self::$_namedConfig['default']); $named = array_merge($named, static::$_namedConfig['default']);
} }
foreach ($named as $key => $val) { foreach ($named as $key => $val) {
if (is_numeric($key)) { if (is_numeric($key)) {
self::$_namedConfig['rules'][$val] = true; static::$_namedConfig['rules'][$val] = true;
} else { } else {
self::$_namedConfig['rules'][$key] = $val; static::$_namedConfig['rules'][$key] = $val;
} }
} }
self::$_namedConfig['greedyNamed'] = $options['greedy']; static::$_namedConfig['greedyNamed'] = $options['greedy'];
return self::$_namedConfig; return static::$_namedConfig;
} }
/** /**
@ -510,7 +510,7 @@ class Router {
* @see Router::$_namedConfig * @see Router::$_namedConfig
*/ */
public static function namedConfig() { public static function namedConfig() {
return self::$_namedConfig; return static::$_namedConfig;
} }
/** /**
@ -533,7 +533,7 @@ class Router {
$options += array( $options += array(
'connectOptions' => array(), 'connectOptions' => array(),
'prefix' => '/', 'prefix' => '/',
'id' => self::ID . '|' . self::UUID 'id' => static::ID . '|' . static::UUID
); );
$prefix = $options['prefix']; $prefix = $options['prefix'];
@ -554,7 +554,7 @@ class Router {
$prefix = '/' . $plugin . '/'; $prefix = '/' . $plugin . '/';
} }
foreach (self::$_resourceMap as $params) { foreach (static::$_resourceMap as $params) {
$url = $prefix . $urlName . (($params['id']) ? '/:id' : ''); $url = $prefix . $urlName . (($params['id']) ? '/:id' : '');
Router::connect($url, Router::connect($url,
@ -570,9 +570,9 @@ class Router {
) )
); );
} }
self::$_resourceMapped[] = $urlName; static::$_resourceMapped[] = $urlName;
} }
return self::$_resourceMapped; return static::$_resourceMapped;
} }
/** /**
@ -581,7 +581,7 @@ class Router {
* @return array A list of prefixes used in connected routes * @return array A list of prefixes used in connected routes
*/ */
public static function prefixes() { public static function prefixes() {
return self::$_prefixes; return static::$_prefixes;
} }
/** /**
@ -591,8 +591,8 @@ class Router {
* @return array Parsed elements from URL * @return array Parsed elements from URL
*/ */
public static function parse($url) { public static function parse($url) {
if (!self::$initialized) { if (!static::$initialized) {
self::_loadRoutes(); static::_loadRoutes();
} }
$ext = null; $ext = null;
@ -606,11 +606,11 @@ class Router {
parse_str($queryParameters, $queryParameters); parse_str($queryParameters, $queryParameters);
} }
extract(self::_parseExtension($url)); extract(static::_parseExtension($url));
foreach (self::$routes as $route) { foreach (static::$routes as $route) {
if (($r = $route->parse($url)) !== false) { if (($r = $route->parse($url)) !== false) {
self::$_currentRoute[] = $route; static::$_currentRoute[] = $route;
$out = $r; $out = $r;
break; break;
} }
@ -638,14 +638,14 @@ class Router {
protected static function _parseExtension($url) { protected static function _parseExtension($url) {
$ext = null; $ext = null;
if (self::$_parseExtensions) { if (static::$_parseExtensions) {
if (preg_match('/\.[0-9a-zA-Z]*$/', $url, $match) === 1) { if (preg_match('/\.[0-9a-zA-Z]*$/', $url, $match) === 1) {
$match = substr($match[0], 1); $match = substr($match[0], 1);
if (empty(self::$_validExtensions)) { if (empty(static::$_validExtensions)) {
$url = substr($url, 0, strpos($url, '.' . $match)); $url = substr($url, 0, strpos($url, '.' . $match));
$ext = $match; $ext = $match;
} else { } else {
foreach (self::$_validExtensions as $name) { foreach (static::$_validExtensions as $name) {
if (strcasecmp($name, $match) === 0) { if (strcasecmp($name, $match) === 0) {
$url = substr($url, 0, strpos($url, '.' . $name)); $url = substr($url, 0, strpos($url, '.' . $name));
$ext = $match; $ext = $match;
@ -674,13 +674,13 @@ class Router {
*/ */
public static function setRequestInfo($request) { public static function setRequestInfo($request) {
if ($request instanceof CakeRequest) { if ($request instanceof CakeRequest) {
self::$_requests[] = $request; static::$_requests[] = $request;
} else { } else {
$requestObj = new CakeRequest(); $requestObj = new CakeRequest();
$request += array(array(), array()); $request += array(array(), array());
$request[0] += array('controller' => false, 'action' => false, 'plugin' => null); $request[0] += array('controller' => false, 'action' => false, 'plugin' => null);
$requestObj->addParams($request[0])->addPaths($request[1]); $requestObj->addParams($request[0])->addPaths($request[1]);
self::$_requests[] = $requestObj; static::$_requests[] = $requestObj;
} }
} }
@ -692,7 +692,7 @@ class Router {
* @see Object::requestAction() * @see Object::requestAction()
*/ */
public static function popRequest() { public static function popRequest() {
return array_pop(self::$_requests); return array_pop(static::$_requests);
} }
/** /**
@ -703,10 +703,10 @@ class Router {
*/ */
public static function getRequest($current = false) { public static function getRequest($current = false) {
if ($current) { if ($current) {
$i = count(self::$_requests) - 1; $i = count(static::$_requests) - 1;
return isset(self::$_requests[$i]) ? self::$_requests[$i] : null; return isset(static::$_requests[$i]) ? static::$_requests[$i] : null;
} }
return isset(self::$_requests[0]) ? self::$_requests[0] : null; return isset(static::$_requests[0]) ? static::$_requests[0] : null;
} }
/** /**
@ -716,11 +716,11 @@ class Router {
* @return array Parameter information * @return array Parameter information
*/ */
public static function getParams($current = false) { public static function getParams($current = false) {
if ($current && self::$_requests) { if ($current && static::$_requests) {
return self::$_requests[count(self::$_requests) - 1]->params; return static::$_requests[count(static::$_requests) - 1]->params;
} }
if (isset(self::$_requests[0])) { if (isset(static::$_requests[0])) {
return self::$_requests[0]->params; return static::$_requests[0]->params;
} }
return array(); return array();
} }
@ -748,12 +748,12 @@ class Router {
*/ */
public static function getPaths($current = false) { public static function getPaths($current = false) {
if ($current) { if ($current) {
return self::$_requests[count(self::$_requests) - 1]; return static::$_requests[count(static::$_requests) - 1];
} }
if (!isset(self::$_requests[0])) { if (!isset(static::$_requests[0])) {
return array('base' => null); return array('base' => null);
} }
return array('base' => self::$_requests[0]->base); return array('base' => static::$_requests[0]->base);
} }
/** /**
@ -763,17 +763,17 @@ class Router {
* @return void * @return void
*/ */
public static function reload() { public static function reload() {
if (empty(self::$_initialState)) { if (empty(static::$_initialState)) {
self::$_initialState = get_class_vars('Router'); static::$_initialState = get_class_vars('Router');
self::_setPrefixes(); static::_setPrefixes();
return; return;
} }
foreach (self::$_initialState as $key => $val) { foreach (static::$_initialState as $key => $val) {
if ($key !== '_initialState') { if ($key !== '_initialState') {
self::${$key} = $val; static::${$key} = $val;
} }
} }
self::_setPrefixes(); static::_setPrefixes();
} }
/** /**
@ -785,14 +785,14 @@ class Router {
*/ */
public static function promote($which = null) { public static function promote($which = null) {
if ($which === null) { if ($which === null) {
$which = count(self::$routes) - 1; $which = count(static::$routes) - 1;
} }
if (!isset(self::$routes[$which])) { if (!isset(static::$routes[$which])) {
return false; return false;
} }
$route =& self::$routes[$which]; $route =& static::$routes[$which];
unset(self::$routes[$which]); unset(static::$routes[$which]);
array_unshift(self::$routes, $route); array_unshift(static::$routes, $route);
return true; return true;
} }
@ -826,8 +826,8 @@ class Router {
* @return string Full translated URL with base path. * @return string Full translated URL with base path.
*/ */
public static function url($url = null, $full = false) { public static function url($url = null, $full = false) {
if (!self::$initialized) { if (!static::$initialized) {
self::_loadRoutes(); static::_loadRoutes();
} }
$params = array('plugin' => null, 'controller' => null, 'action' => 'index'); $params = array('plugin' => null, 'controller' => null, 'action' => 'index');
@ -839,8 +839,8 @@ class Router {
} }
$path = array('base' => null); $path = array('base' => null);
if (!empty(self::$_requests)) { if (!empty(static::$_requests)) {
$request = self::$_requests[count(self::$_requests) - 1]; $request = static::$_requests[count(static::$_requests) - 1];
$params = $request->params; $params = $request->params;
$path = array('base' => $request->base, 'here' => $request->here); $path = array('base' => $request->base, 'here' => $request->here);
} }
@ -854,7 +854,7 @@ class Router {
if (empty($url)) { if (empty($url)) {
$output = isset($path['here']) ? $path['here'] : '/'; $output = isset($path['here']) ? $path['here'] : '/';
if ($full) { if ($full) {
$output = self::fullBaseUrl() . $output; $output = static::fullBaseUrl() . $output;
} }
return $output; return $output;
} elseif (is_array($url)) { } elseif (is_array($url)) {
@ -886,8 +886,8 @@ class Router {
} }
} }
$prefixExists = (array_intersect_key($url, array_flip(self::$_prefixes))); $prefixExists = (array_intersect_key($url, array_flip(static::$_prefixes)));
foreach (self::$_prefixes as $prefix) { foreach (static::$_prefixes as $prefix) {
if (!empty($params[$prefix]) && !$prefixExists) { if (!empty($params[$prefix]) && !$prefixExists) {
$url[$prefix] = true; $url[$prefix] = true;
} elseif (isset($url[$prefix]) && !$url[$prefix]) { } elseif (isset($url[$prefix]) && !$url[$prefix]) {
@ -902,7 +902,7 @@ class Router {
$match = false; $match = false;
foreach (self::$routes as $route) { foreach (static::$routes as $route) {
$originalUrl = $url; $originalUrl = $url;
$url = $route->persistParams($url, $params); $url = $route->persistParams($url, $params);
@ -914,7 +914,7 @@ class Router {
$url = $originalUrl; $url = $originalUrl;
} }
if ($match === false) { if ($match === false) {
$output = self::_handleNoRoute($url); $output = static::_handleNoRoute($url);
} }
} else { } else {
if (preg_match('/^([a-z][a-z0-9.+\-]+:|:?\/\/|[#?])/i', $url)) { if (preg_match('/^([a-z][a-z0-9.+\-]+:|:?\/\/|[#?])/i', $url)) {
@ -923,7 +923,7 @@ class Router {
if (substr($url, 0, 1) === '/') { if (substr($url, 0, 1) === '/') {
$output = substr($url, 1); $output = substr($url, 1);
} else { } else {
foreach (self::$_prefixes as $prefix) { foreach (static::$_prefixes as $prefix) {
if (isset($params[$prefix])) { if (isset($params[$prefix])) {
$output .= $prefix . '/'; $output .= $prefix . '/';
break; break;
@ -940,13 +940,13 @@ class Router {
$output = str_replace('//', '/', $base . '/' . $output); $output = str_replace('//', '/', $base . '/' . $output);
if ($full) { if ($full) {
$output = self::fullBaseUrl() . $output; $output = static::fullBaseUrl() . $output;
} }
if (!empty($extension)) { if (!empty($extension)) {
$output = rtrim($output, '/'); $output = rtrim($output, '/');
} }
} }
return $output . $extension . self::queryString($q, array(), $escape) . $frag; return $output . $extension . static::queryString($q, array(), $escape) . $frag;
} }
/** /**
@ -966,13 +966,13 @@ class Router {
*/ */
public static function fullBaseUrl($base = null) { public static function fullBaseUrl($base = null) {
if ($base !== null) { if ($base !== null) {
self::$_fullBaseUrl = $base; static::$_fullBaseUrl = $base;
Configure::write('App.fullBaseUrl', $base); Configure::write('App.fullBaseUrl', $base);
} }
if (empty(self::$_fullBaseUrl)) { if (empty(static::$_fullBaseUrl)) {
self::$_fullBaseUrl = Configure::read('App.fullBaseUrl'); static::$_fullBaseUrl = Configure::read('App.fullBaseUrl');
} }
return self::$_fullBaseUrl; return static::$_fullBaseUrl;
} }
/** /**
@ -987,7 +987,7 @@ class Router {
$named = $args = array(); $named = $args = array();
$skip = array_merge( $skip = array_merge(
array('bare', 'action', 'controller', 'plugin', 'prefix'), array('bare', 'action', 'controller', 'plugin', 'prefix'),
self::$_prefixes static::$_prefixes
); );
$keys = array_values(array_diff(array_keys($url), $skip)); $keys = array_values(array_diff(array_keys($url), $skip));
@ -1002,7 +1002,7 @@ class Router {
} }
list($args, $named) = array(Hash::filter($args), Hash::filter($named)); list($args, $named) = array(Hash::filter($args), Hash::filter($named));
foreach (self::$_prefixes as $prefix) { foreach (static::$_prefixes as $prefix) {
$prefixed = $prefix . '_'; $prefixed = $prefix . '_';
if (!empty($url[$prefix]) && strpos($url['action'], $prefixed) === 0) { if (!empty($url[$prefix]) && strpos($url['action'], $prefixed) === 0) {
$url['action'] = substr($url['action'], strlen($prefixed) * -1); $url['action'] = substr($url['action'], strlen($prefixed) * -1);
@ -1020,7 +1020,7 @@ class Router {
array_unshift($urlOut, $url['plugin']); array_unshift($urlOut, $url['plugin']);
} }
foreach (self::$_prefixes as $prefix) { foreach (static::$_prefixes as $prefix) {
if (isset($url[$prefix])) { if (isset($url[$prefix])) {
array_unshift($urlOut, $prefix); array_unshift($urlOut, $prefix);
break; break;
@ -1037,10 +1037,10 @@ class Router {
if (is_array($value)) { if (is_array($value)) {
$flattend = Hash::flatten($value, '%5D%5B'); $flattend = Hash::flatten($value, '%5D%5B');
foreach ($flattend as $namedKey => $namedValue) { foreach ($flattend as $namedKey => $namedValue) {
$output .= '/' . $name . "%5B{$namedKey}%5D" . self::$_namedConfig['separator'] . rawurlencode($namedValue); $output .= '/' . $name . "%5B{$namedKey}%5D" . static::$_namedConfig['separator'] . rawurlencode($namedValue);
} }
} else { } else {
$output .= '/' . $name . self::$_namedConfig['separator'] . rawurlencode($value); $output .= '/' . $name . static::$_namedConfig['separator'] . rawurlencode($value);
} }
} }
} }
@ -1163,7 +1163,7 @@ class Router {
* @return CakeRoute Matching route object. * @return CakeRoute Matching route object.
*/ */
public static function requestRoute() { public static function requestRoute() {
return self::$_currentRoute[0]; return static::$_currentRoute[0];
} }
/** /**
@ -1172,8 +1172,8 @@ class Router {
* @return CakeRoute Matching route object. * @return CakeRoute Matching route object.
*/ */
public static function currentRoute() { public static function currentRoute() {
$count = count(self::$_currentRoute) - 1; $count = count(static::$_currentRoute) - 1;
return ($count >= 0) ? self::$_currentRoute[$count] : false; return ($count >= 0) ? static::$_currentRoute[$count] : false;
} }
/** /**
@ -1215,9 +1215,9 @@ class Router {
* @see RequestHandler::startup() * @see RequestHandler::startup()
*/ */
public static function parseExtensions() { public static function parseExtensions() {
self::$_parseExtensions = true; static::$_parseExtensions = true;
if (func_num_args() > 0) { if (func_num_args() > 0) {
self::setExtensions(func_get_args(), false); static::setExtensions(func_get_args(), false);
} }
} }
@ -1230,11 +1230,11 @@ class Router {
* @return array Array of extensions Router is configured to parse. * @return array Array of extensions Router is configured to parse.
*/ */
public static function extensions() { public static function extensions() {
if (!self::$initialized) { if (!static::$initialized) {
self::_loadRoutes(); static::_loadRoutes();
} }
return self::$_validExtensions; return static::$_validExtensions;
} }
/** /**
@ -1248,12 +1248,12 @@ class Router {
*/ */
public static function setExtensions($extensions, $merge = true) { public static function setExtensions($extensions, $merge = true) {
if (!is_array($extensions)) { if (!is_array($extensions)) {
return self::$_validExtensions; return static::$_validExtensions;
} }
if (!$merge) { if (!$merge) {
return self::$_validExtensions = $extensions; return static::$_validExtensions = $extensions;
} }
return self::$_validExtensions = array_merge(self::$_validExtensions, $extensions); return static::$_validExtensions = array_merge(static::$_validExtensions, $extensions);
} }
/** /**
@ -1262,7 +1262,7 @@ class Router {
* @return void * @return void
*/ */
protected static function _loadRoutes() { protected static function _loadRoutes() {
self::$initialized = true; static::$initialized = true;
include APP . 'Config' . DS . 'routes.php'; include APP . 'Config' . DS . 'routes.php';
} }

View file

@ -200,7 +200,7 @@ class BlowfishAuthenticateTest extends CakeTestCase {
'username' => 'gwoo', 'username' => 'gwoo',
'created' => '2007-03-17 01:16:23' 'created' => '2007-03-17 01:16:23'
); );
$this->assertEquals(self::date(), $result['updated']); $this->assertEquals(static::date(), $result['updated']);
unset($result['updated']); unset($result['updated']);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
CakePlugin::unload(); CakePlugin::unload();

View file

@ -288,7 +288,7 @@ class FormAuthenticateTest extends CakeTestCase {
'username' => 'gwoo', 'username' => 'gwoo',
'created' => '2007-03-17 01:16:23' 'created' => '2007-03-17 01:16:23'
); );
$this->assertEquals(self::date(), $result['updated']); $this->assertEquals(static::date(), $result['updated']);
unset($result['updated']); unset($result['updated']);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
CakePlugin::unload(); CakePlugin::unload();

View file

@ -125,7 +125,7 @@ class TestAuthComponent extends AuthComponent {
} }
public static function clearUser() { public static function clearUser() {
self::$_user = array(); static::$_user = array();
} }
} }

View file

@ -77,7 +77,7 @@ class DebugCompTransport extends AbstractTransport {
$last .= sprintf("%s\n\n%s", 'Message:', $message); $last .= sprintf("%s\n\n%s", 'Message:', $message);
$last .= '</pre>'; $last .= '</pre>';
self::$lastEmail = $last; static::$lastEmail = $last;
return true; return true;
} }
@ -149,7 +149,7 @@ class EmailComponentTest extends CakeTestCase {
$this->Controller->Components->init($this->Controller); $this->Controller->Components->init($this->Controller);
$this->Controller->EmailTest->initialize($this->Controller, array()); $this->Controller->EmailTest->initialize($this->Controller, array());
self::$sentDate = date(DATE_RFC2822); static::$sentDate = date(DATE_RFC2822);
App::build(array( App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
@ -170,7 +170,7 @@ class EmailComponentTest extends CakeTestCase {
$this->Controller->EmailTest->delivery = 'DebugComp'; $this->Controller->EmailTest->delivery = 'DebugComp';
$this->Controller->EmailTest->messageId = false; $this->Controller->EmailTest->messageId = false;
$date = self::$sentDate; $date = static::$sentDate;
$message = <<<MSGBLOC $message = <<<MSGBLOC
<pre>To: postmaster@example.com <pre>To: postmaster@example.com
From: noreply@example.com From: noreply@example.com
@ -217,7 +217,7 @@ MSGBLOC;
$this->Controller->EmailTest->delivery = 'DebugComp'; $this->Controller->EmailTest->delivery = 'DebugComp';
$this->Controller->EmailTest->messageId = false; $this->Controller->EmailTest->messageId = false;
$date = self::$sentDate; $date = static::$sentDate;
$header = <<<HEADBLOC $header = <<<HEADBLOC
To: postmaster@example.com To: postmaster@example.com
From: noreply@example.com From: noreply@example.com
@ -363,7 +363,7 @@ HTMLBLOC;
$this->assertRegExp('/From: noreply@example.com\n/', $result); $this->assertRegExp('/From: noreply@example.com\n/', $result);
$this->assertRegExp('/Cc: cc@example.com\n/', $result); $this->assertRegExp('/Cc: cc@example.com\n/', $result);
$this->assertRegExp('/Bcc: bcc@example.com\n/', $result); $this->assertRegExp('/Bcc: bcc@example.com\n/', $result);
$this->assertRegExp('/Date: ' . preg_quote(self::$sentDate) . '\n/', $result); $this->assertRegExp('/Date: ' . preg_quote(static::$sentDate) . '\n/', $result);
$this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result);
$this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
$this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result); $this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result);
@ -392,7 +392,7 @@ HTMLBLOC;
$this->assertRegExp('/Subject: Cake Debug Test\n/', $result); $this->assertRegExp('/Subject: Cake Debug Test\n/', $result);
$this->assertRegExp('/Reply-To: noreply@example.com\n/', $result); $this->assertRegExp('/Reply-To: noreply@example.com\n/', $result);
$this->assertRegExp('/From: noreply@example.com\n/', $result); $this->assertRegExp('/From: noreply@example.com\n/', $result);
$this->assertRegExp('/Date: ' . preg_quote(self::$sentDate) . '\n/', $result); $this->assertRegExp('/Date: ' . preg_quote(static::$sentDate) . '\n/', $result);
$this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertRegExp('/X-Mailer: CakePHP Email Component\n/', $result);
$this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result); $this->assertRegExp('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
$this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result); $this->assertRegExp('/Content-Transfer-Encoding: 8bitMessage:\n/', $result);
@ -563,7 +563,7 @@ HTMLBLOC;
$this->Controller->EmailTest->to = 'postmaster@example.com'; $this->Controller->EmailTest->to = 'postmaster@example.com';
$this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->subject = 'Cake Debug Test';
$this->Controller->EmailTest->date = self::$sentDate = 'Today!'; $this->Controller->EmailTest->date = static::$sentDate = 'Today!';
$this->Controller->EmailTest->template = null; $this->Controller->EmailTest->template = null;
$this->Controller->EmailTest->delivery = 'DebugComp'; $this->Controller->EmailTest->delivery = 'DebugComp';

View file

@ -91,7 +91,7 @@ class SessionComponentTest extends CakeTestCase {
* @return void * @return void
*/ */
public static function setupBeforeClass() { public static function setupBeforeClass() {
self::$_sessionBackup = Configure::read('Session'); static::$_sessionBackup = Configure::read('Session');
Configure::write('Session', array( Configure::write('Session', array(
'defaults' => 'php', 'defaults' => 'php',
'timeout' => 100, 'timeout' => 100,
@ -105,7 +105,7 @@ class SessionComponentTest extends CakeTestCase {
* @return void * @return void
*/ */
public static function teardownAfterClass() { public static function teardownAfterClass() {
Configure::write('Session', self::$_sessionBackup); Configure::write('Session', static::$_sessionBackup);
} }
/** /**

View file

@ -35,7 +35,7 @@ class TestConsoleLog extends ConsoleLog {
class TestCakeLog extends CakeLog { class TestCakeLog extends CakeLog {
public static function replace($key, &$engine) { public static function replace($key, &$engine) {
self::$_Collection->{$key} = $engine; static::$_Collection->{$key} = $engine;
} }
} }

View file

@ -28,11 +28,11 @@ App::uses('CacheSession', 'Model/Datasource/Session');
class TestCakeSession extends CakeSession { class TestCakeSession extends CakeSession {
public static function setUserAgent($value) { public static function setUserAgent($value) {
self::$_userAgent = $value; static::$_userAgent = $value;
} }
public static function setHost($host) { public static function setHost($host) {
self::_setHost($host); static::_setHost($host);
} }
} }
@ -86,7 +86,7 @@ class CakeSessionTest extends CakeTestCase {
*/ */
public static function setupBeforeClass() { public static function setupBeforeClass() {
// Make sure garbage colector will be called // Make sure garbage colector will be called
self::$_gcDivisor = ini_get('session.gc_divisor'); static::$_gcDivisor = ini_get('session.gc_divisor');
ini_set('session.gc_divisor', '1'); ini_set('session.gc_divisor', '1');
} }
@ -97,7 +97,7 @@ class CakeSessionTest extends CakeTestCase {
*/ */
public static function teardownAfterClass() { public static function teardownAfterClass() {
// Revert to the default setting // Revert to the default setting
ini_set('session.gc_divisor', self::$_gcDivisor); ini_set('session.gc_divisor', static::$_gcDivisor);
} }
/** /**

View file

@ -39,7 +39,7 @@ class CacheSessionTest extends CakeTestCase {
'engine' => 'File', 'engine' => 'File',
'prefix' => 'session_test_' 'prefix' => 'session_test_'
)); ));
self::$_sessionBackup = Configure::read('Session'); static::$_sessionBackup = Configure::read('Session');
Configure::write('Session.handler.config', 'session_test'); Configure::write('Session.handler.config', 'session_test');
} }
@ -53,7 +53,7 @@ class CacheSessionTest extends CakeTestCase {
Cache::clear(false, 'session_test'); Cache::clear(false, 'session_test');
Cache::drop('session_test'); Cache::drop('session_test');
Configure::write('Session', self::$_sessionBackup); Configure::write('Session', static::$_sessionBackup);
} }
/** /**

View file

@ -54,7 +54,7 @@ class DatabaseSessionTest extends CakeTestCase {
* @return void * @return void
*/ */
public static function setupBeforeClass() { public static function setupBeforeClass() {
self::$_sessionBackup = Configure::read('Session'); static::$_sessionBackup = Configure::read('Session');
Configure::write('Session.handler', array( Configure::write('Session.handler', array(
'model' => 'SessionTestModel', 'model' => 'SessionTestModel',
)); ));
@ -67,7 +67,7 @@ class DatabaseSessionTest extends CakeTestCase {
* @return void * @return void
*/ */
public static function teardownAfterClass() { public static function teardownAfterClass() {
Configure::write('Session', self::$_sessionBackup); Configure::write('Session', static::$_sessionBackup);
} }
/** /**

View file

@ -1994,7 +1994,7 @@ class ModelIntegrationTest extends BaseModelTest {
'afterFind' => 'Successfully added by AfterFind' 'afterFind' => 'Successfully added by AfterFind'
) )
)); ));
$this->assertEquals(self::date(), $result['Something']['updated']); $this->assertEquals(static::date(), $result['Something']['updated']);
unset($result['Something']['updated']); unset($result['Something']['updated']);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }

View file

@ -2102,7 +2102,7 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Second Article Body', 'body' => 'Second Article Body',
'published' => 'Y', 'published' => 'Y',
'created' => '2007-03-18 10:41:23', 'created' => '2007-03-18 10:41:23',
'updated' => self::date() 'updated' => static::date()
), ),
'Tag' => array( 'Tag' => array(
array( array(
@ -3042,23 +3042,23 @@ class ModelWriteTest extends BaseModelTest {
'JoinA' => array( 'JoinA' => array(
'id' => '1', 'id' => '1',
'name' => 'New name for Join A 1', 'name' => 'New name for Join A 1',
'updated' => self::date() 'updated' => static::date()
), ),
'JoinB' => array( 'JoinB' => array(
array( array(
'id' => 1, 'id' => 1,
'join_b_id' => 2, 'join_b_id' => 2,
'other' => 'New data for Join A 1 Join B 2', 'other' => 'New data for Join A 1 Join B 2',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
)), )),
'JoinC' => array( 'JoinC' => array(
array( array(
'id' => 1, 'id' => 1,
'join_c_id' => 2, 'join_c_id' => 2,
'other' => 'New data for Join A 1 Join C 2', 'other' => 'New data for Join A 1 Join C 2',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
))); )));
$TestModel->set($data); $TestModel->set($data);
@ -3071,7 +3071,7 @@ class ModelWriteTest extends BaseModelTest {
'name' => 'New name for Join A 1', 'name' => 'New name for Join A 1',
'body' => 'Join A 1 Body', 'body' => 'Join A 1 Body',
'created' => '2008-01-03 10:54:23', 'created' => '2008-01-03 10:54:23',
'updated' => self::date() 'updated' => static::date()
), ),
'JoinB' => array( 'JoinB' => array(
0 => array( 0 => array(
@ -3084,8 +3084,8 @@ class ModelWriteTest extends BaseModelTest {
'join_a_id' => 1, 'join_a_id' => 1,
'join_b_id' => 2, 'join_b_id' => 2,
'other' => 'New data for Join A 1 Join B 2', 'other' => 'New data for Join A 1 Join B 2',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
))), ))),
'JoinC' => array( 'JoinC' => array(
0 => array( 0 => array(
@ -3098,8 +3098,8 @@ class ModelWriteTest extends BaseModelTest {
'join_a_id' => 1, 'join_a_id' => 1,
'join_c_id' => 2, 'join_c_id' => 2,
'other' => 'New data for Join A 1 Join C 2', 'other' => 'New data for Join A 1 Join C 2',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
)))); ))));
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -3143,10 +3143,10 @@ class ModelWriteTest extends BaseModelTest {
'password' => '5f4dcc3b5aa765d61d8327deb882cf90', 'password' => '5f4dcc3b5aa765d61d8327deb882cf90',
'test' => 'working' 'test' => 'working'
)); ));
$this->assertEquals(self::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Post']['created']);
$this->assertEquals(self::date(), $result[3]['Post']['updated']); $this->assertEquals(static::date(), $result[3]['Post']['updated']);
$this->assertEquals(self::date(), $result[3]['Author']['created']); $this->assertEquals(static::date(), $result[3]['Author']['created']);
$this->assertEquals(self::date(), $result[3]['Author']['updated']); $this->assertEquals(static::date(), $result[3]['Author']['updated']);
unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
unset($result[3]['Author']['created'], $result[3]['Author']['updated']); unset($result[3]['Author']['created'], $result[3]['Author']['updated']);
$this->assertEquals($expected, $result[3]); $this->assertEquals($expected, $result[3]);
@ -3191,10 +3191,10 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Second multi-record post', 'body' => 'Second multi-record post',
'published' => 'N' 'published' => 'N'
))); )));
$this->assertEquals(self::date(), $result[0]['Post']['created']); $this->assertEquals(static::date(), $result[0]['Post']['created']);
$this->assertEquals(self::date(), $result[0]['Post']['updated']); $this->assertEquals(static::date(), $result[0]['Post']['updated']);
$this->assertEquals(self::date(), $result[1]['Post']['created']); $this->assertEquals(static::date(), $result[1]['Post']['created']);
$this->assertEquals(self::date(), $result[1]['Post']['updated']); $this->assertEquals(static::date(), $result[1]['Post']['updated']);
unset($result[0]['Post']['created'], $result[0]['Post']['updated']); unset($result[0]['Post']['created'], $result[0]['Post']['updated']);
unset($result[1]['Post']['created'], $result[1]['Post']['updated']); unset($result[1]['Post']['created'], $result[1]['Post']['updated']);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -3220,8 +3220,8 @@ class ModelWriteTest extends BaseModelTest {
'comment' => 'New comment with attachment', 'comment' => 'New comment with attachment',
'published' => 'Y' 'published' => 'Y'
); );
$this->assertEquals(self::date(), $result[6]['Comment']['created']); $this->assertEquals(static::date(), $result[6]['Comment']['created']);
$this->assertEquals(self::date(), $result[6]['Comment']['updated']); $this->assertEquals(static::date(), $result[6]['Comment']['updated']);
unset($result[6]['Comment']['created'], $result[6]['Comment']['updated']); unset($result[6]['Comment']['created'], $result[6]['Comment']['updated']);
$this->assertEquals($expected, $result[6]['Comment']); $this->assertEquals($expected, $result[6]['Comment']);
@ -3230,8 +3230,8 @@ class ModelWriteTest extends BaseModelTest {
'comment_id' => '7', 'comment_id' => '7',
'attachment' => 'some_file.tgz' 'attachment' => 'some_file.tgz'
); );
$this->assertEquals(self::date(), $result[6]['Attachment']['created']); $this->assertEquals(static::date(), $result[6]['Attachment']['created']);
$this->assertEquals(self::date(), $result[6]['Attachment']['updated']); $this->assertEquals(static::date(), $result[6]['Attachment']['updated']);
unset($result[6]['Attachment']['created'], $result[6]['Attachment']['updated']); unset($result[6]['Attachment']['created'], $result[6]['Attachment']['updated']);
$this->assertEquals($expected, $result[6]['Attachment']); $this->assertEquals($expected, $result[6]['Attachment']);
} }
@ -4665,8 +4665,8 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'New Fourth Post', 'title' => 'New Fourth Post',
'body' => null, 'body' => null,
'published' => 'N', 'published' => 'N',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
)); ));
$expected[] = array( $expected[] = array(
@ -4676,8 +4676,8 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'New Fifth Post', 'title' => 'New Fifth Post',
'body' => null, 'body' => null,
'published' => 'N', 'published' => 'N',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
)); ));
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -4733,8 +4733,8 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'New Fourth Post', 'title' => 'New Fourth Post',
'body' => 'Third Post Body', 'body' => 'Third Post Body',
'published' => 'N', 'published' => 'N',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
)); ));
$expected[] = array( $expected[] = array(
@ -4744,8 +4744,8 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'Third Post', 'title' => 'Third Post',
'body' => 'Third Post Body', 'body' => 'Third Post Body',
'published' => 'N', 'published' => 'N',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
)); ));
} }
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -4870,10 +4870,10 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Fourth post body', 'body' => 'Fourth post body',
'published' => 'N' 'published' => 'N'
))); )));
$this->assertEquals(self::date(), $result[0]['Post']['updated']); $this->assertEquals(static::date(), $result[0]['Post']['updated']);
$this->assertEquals(self::date(), $result[1]['Post']['updated']); $this->assertEquals(static::date(), $result[1]['Post']['updated']);
$this->assertEquals(self::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Post']['created']);
$this->assertEquals(self::date(), $result[3]['Post']['updated']); $this->assertEquals(static::date(), $result[3]['Post']['updated']);
unset($result[0]['Post']['updated'], $result[1]['Post']['updated']); unset($result[0]['Post']['updated'], $result[1]['Post']['updated']);
unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -4964,10 +4964,10 @@ class ModelWriteTest extends BaseModelTest {
) )
); );
$this->assertEquals(self::date(), $result[0]['Post']['updated']); $this->assertEquals(static::date(), $result[0]['Post']['updated']);
$this->assertEquals(self::date(), $result[1]['Post']['updated']); $this->assertEquals(static::date(), $result[1]['Post']['updated']);
$this->assertEquals(self::date(), $result[3]['Post']['updated']); $this->assertEquals(static::date(), $result[3]['Post']['updated']);
$this->assertEquals(self::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Post']['created']);
unset( unset(
$result[0]['Post']['updated'], $result[1]['Post']['updated'], $result[0]['Post']['updated'], $result[1]['Post']['updated'],
$result[3]['Post']['updated'], $result[3]['Post']['created'] $result[3]['Post']['updated'], $result[3]['Post']['created']
@ -5348,10 +5348,10 @@ class ModelWriteTest extends BaseModelTest {
'password' => '5f4dcc3b5aa765d61d8327deb882cf90', 'password' => '5f4dcc3b5aa765d61d8327deb882cf90',
'test' => 'working' 'test' => 'working'
)); ));
$this->assertEquals(self::date(), $result[3]['Post']['updated']); $this->assertEquals(static::date(), $result[3]['Post']['updated']);
$this->assertEquals(self::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Post']['created']);
$this->assertEquals(self::date(), $result[3]['Author']['created']); $this->assertEquals(static::date(), $result[3]['Author']['created']);
$this->assertEquals(self::date(), $result[3]['Author']['updated']); $this->assertEquals(static::date(), $result[3]['Author']['updated']);
unset( unset(
$result[3]['Post']['updated'], $result[3]['Post']['created'], $result[3]['Post']['updated'], $result[3]['Post']['created'],
$result[3]['Author']['updated'], $result[3]['Author']['created'] $result[3]['Author']['updated'], $result[3]['Author']['created']
@ -5380,8 +5380,8 @@ class ModelWriteTest extends BaseModelTest {
'comment' => 'New comment with attachment', 'comment' => 'New comment with attachment',
'published' => 'Y' 'published' => 'Y'
); );
$this->assertEquals(self::date(), $result[6]['Comment']['updated']); $this->assertEquals(static::date(), $result[6]['Comment']['updated']);
$this->assertEquals(self::date(), $result[6]['Comment']['created']); $this->assertEquals(static::date(), $result[6]['Comment']['created']);
unset($result[6]['Comment']['updated'], $result[6]['Comment']['created']); unset($result[6]['Comment']['updated'], $result[6]['Comment']['created']);
$this->assertEquals($expected, $result[6]['Comment']); $this->assertEquals($expected, $result[6]['Comment']);
@ -5390,8 +5390,8 @@ class ModelWriteTest extends BaseModelTest {
'comment_id' => '7', 'comment_id' => '7',
'attachment' => 'some_file.tgz' 'attachment' => 'some_file.tgz'
); );
$this->assertEquals(self::date(), $result[6]['Attachment']['updated']); $this->assertEquals(static::date(), $result[6]['Attachment']['updated']);
$this->assertEquals(self::date(), $result[6]['Attachment']['created']); $this->assertEquals(static::date(), $result[6]['Attachment']['created']);
unset($result[6]['Attachment']['updated'], $result[6]['Attachment']['created']); unset($result[6]['Attachment']['updated'], $result[6]['Attachment']['created']);
$this->assertEquals($expected, $result[6]['Attachment']); $this->assertEquals($expected, $result[6]['Attachment']);
} }
@ -5491,10 +5491,10 @@ class ModelWriteTest extends BaseModelTest {
) )
) )
); );
$this->assertEquals(self::date(), $result[0]['Post']['updated']); $this->assertEquals(static::date(), $result[0]['Post']['updated']);
$this->assertEquals(self::date(), $result[0]['Post']['created']); $this->assertEquals(static::date(), $result[0]['Post']['created']);
$this->assertEquals(self::date(), $result[1]['Post']['updated']); $this->assertEquals(static::date(), $result[1]['Post']['updated']);
$this->assertEquals(self::date(), $result[1]['Post']['created']); $this->assertEquals(static::date(), $result[1]['Post']['created']);
unset($result[0]['Post']['updated'], $result[0]['Post']['created']); unset($result[0]['Post']['updated'], $result[0]['Post']['created']);
unset($result[1]['Post']['updated'], $result[1]['Post']['created']); unset($result[1]['Post']['updated'], $result[1]['Post']['created']);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -6184,10 +6184,10 @@ class ModelWriteTest extends BaseModelTest {
'published' => 'N', 'published' => 'N',
)); ));
$this->assertEquals(self::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Post']['created']);
$this->assertEquals(self::date(), $result[3]['Post']['updated']); $this->assertEquals(static::date(), $result[3]['Post']['updated']);
$this->assertEquals(self::date(), $result[4]['Post']['created']); $this->assertEquals(static::date(), $result[4]['Post']['created']);
$this->assertEquals(self::date(), $result[4]['Post']['updated']); $this->assertEquals(static::date(), $result[4]['Post']['updated']);
unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
unset($result[4]['Post']['created'], $result[4]['Post']['updated']); unset($result[4]['Post']['created'], $result[4]['Post']['updated']);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -6253,10 +6253,10 @@ class ModelWriteTest extends BaseModelTest {
'body' => 'Third Post Body', 'body' => 'Third Post Body',
'published' => 'N' 'published' => 'N'
)); ));
$this->assertEquals(self::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Post']['created']);
$this->assertEquals(self::date(), $result[3]['Post']['updated']); $this->assertEquals(static::date(), $result[3]['Post']['updated']);
$this->assertEquals(self::date(), $result[4]['Post']['created']); $this->assertEquals(static::date(), $result[4]['Post']['created']);
$this->assertEquals(self::date(), $result[4]['Post']['updated']); $this->assertEquals(static::date(), $result[4]['Post']['updated']);
unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
unset($result[4]['Post']['created'], $result[4]['Post']['updated']); unset($result[4]['Post']['created'], $result[4]['Post']['updated']);
} }
@ -6387,10 +6387,10 @@ class ModelWriteTest extends BaseModelTest {
) )
); );
$this->assertEquals(self::date(), $result[0]['Post']['updated']); $this->assertEquals(static::date(), $result[0]['Post']['updated']);
$this->assertEquals(self::date(), $result[1]['Post']['updated']); $this->assertEquals(static::date(), $result[1]['Post']['updated']);
$this->assertEquals(self::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Post']['created']);
$this->assertEquals(self::date(), $result[3]['Post']['updated']); $this->assertEquals(static::date(), $result[3]['Post']['updated']);
unset($result[0]['Post']['updated'], $result[1]['Post']['updated']); unset($result[0]['Post']['updated'], $result[1]['Post']['updated']);
unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -7147,15 +7147,15 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'Post without body', 'title' => 'Post without body',
'body' => null, 'body' => null,
'published' => 'N', 'published' => 'N',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date(), 'updated' => static::date(),
), ),
'Author' => array( 'Author' => array(
'id' => '5', 'id' => '5',
'user' => 'bob', 'user' => 'bob',
'password' => null, 'password' => null,
'created' => self::date(), 'created' => static::date(),
'updated' => self::date(), 'updated' => static::date(),
'test' => 'working', 'test' => 'working',
), ),
); );
@ -7210,15 +7210,15 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'Post title', 'title' => 'Post title',
'body' => 'Post body', 'body' => 'Post body',
'published' => 'N', 'published' => 'N',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
), ),
'Author' => array( 'Author' => array(
'id' => '6', 'id' => '6',
'user' => 'jack', 'user' => 'jack',
'password' => 'foobar', 'password' => 'foobar',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date(), 'updated' => static::date(),
'test' => 'working' 'test' => 'working'
), ),
); );
@ -7252,8 +7252,8 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'Multi-record post 1', 'title' => 'Multi-record post 1',
'body' => '', 'body' => '',
'published' => 'N', 'published' => 'N',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
) )
), ),
array( array(
@ -7263,8 +7263,8 @@ class ModelWriteTest extends BaseModelTest {
'title' => 'Multi-record post 2', 'title' => 'Multi-record post 2',
'body' => '', 'body' => '',
'published' => 'N', 'published' => 'N',
'created' => self::date(), 'created' => static::date(),
'updated' => self::date() 'updated' => static::date()
) )
) )
); );

View file

@ -41,7 +41,7 @@ class FolderTest extends CakeTestCase {
foreach (scandir(TMP) as $file) { foreach (scandir(TMP) as $file) {
if (is_dir(TMP . $file) && !in_array($file, array('.', '..'))) { if (is_dir(TMP . $file) && !in_array($file, array('.', '..'))) {
self::$_tmp[] = $file; static::$_tmp[] = $file;
} }
} }
} }
@ -62,7 +62,7 @@ class FolderTest extends CakeTestCase {
* @return void * @return void
*/ */
public function tearDown() { public function tearDown() {
$exclude = array_merge(self::$_tmp, array('.', '..')); $exclude = array_merge(static::$_tmp, array('.', '..'));
foreach (scandir(TMP) as $dir) { foreach (scandir(TMP) as $dir) {
if (is_dir(TMP . $dir) && !in_array($dir, $exclude)) { if (is_dir(TMP . $dir) && !in_array($dir, $exclude)) {
$iterator = new RecursiveDirectoryIterator(TMP . $dir); $iterator = new RecursiveDirectoryIterator(TMP . $dir);

View file

@ -198,7 +198,7 @@ class HashTest extends CakeTestCase {
$result = Hash::get($data, '1'); $result = Hash::get($data, '1');
$this->assertEquals('def', $result); $this->assertEquals('def', $result);
$data = self::articleData(); $data = static::articleData();
$result = Hash::get(array(), '1.Article.title'); $result = Hash::get(array(), '1.Article.title');
$this->assertNull($result); $this->assertNull($result);
@ -708,7 +708,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testExtractBasic() { public function testExtractBasic() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::extract($data, ''); $result = Hash::extract($data, '');
$this->assertEquals($data, $result); $this->assertEquals($data, $result);
@ -729,7 +729,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testExtractNumericKey() { public function testExtractNumericKey() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::extract($data, '{n}.Article.title'); $result = Hash::extract($data, '{n}.Article.title');
$expected = array( $expected = array(
'First Article', 'Second Article', 'First Article', 'Second Article',
@ -808,7 +808,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testExtractStringKey() { public function testExtractStringKey() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::extract($data, '{n}.{s}.user'); $result = Hash::extract($data, '{n}.{s}.user');
$expected = array( $expected = array(
'mariano', 'mariano',
@ -855,7 +855,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testExtractAttributePresence() { public function testExtractAttributePresence() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::extract($data, '{n}.Article[published]'); $result = Hash::extract($data, '{n}.Article[published]');
$expected = array($data[1]['Article']); $expected = array($data[1]['Article']);
@ -872,7 +872,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testExtractAttributeEquality() { public function testExtractAttributeEquality() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::extract($data, '{n}.Article[id=3]'); $result = Hash::extract($data, '{n}.Article[id=3]');
$expected = array($data[2]['Article']); $expected = array($data[2]['Article']);
@ -957,7 +957,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testExtractAttributeComparison() { public function testExtractAttributeComparison() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::extract($data, '{n}.Comment.{n}[user_id > 2]'); $result = Hash::extract($data, '{n}.Comment.{n}[user_id > 2]');
$expected = array($data[0]['Comment'][1]); $expected = array($data[0]['Comment'][1]);
@ -986,7 +986,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testExtractAttributeMultiple() { public function testExtractAttributeMultiple() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::extract($data, '{n}.Comment.{n}[user_id > 2][id=1]'); $result = Hash::extract($data, '{n}.Comment.{n}[user_id > 2][id=1]');
$this->assertEmpty($result); $this->assertEmpty($result);
@ -1003,7 +1003,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testExtractAttributePattern() { public function testExtractAttributePattern() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::extract($data, '{n}.Article[title=/^First/]'); $result = Hash::extract($data, '{n}.Article[title=/^First/]');
$expected = array($data[0]['Article']); $expected = array($data[0]['Article']);
@ -1426,7 +1426,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testInsertMulti() { public function testInsertMulti() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::insert($data, '{n}.Article.insert', 'value'); $result = Hash::insert($data, '{n}.Article.insert', 'value');
$this->assertEquals('value', $result[0]['Article']['insert']); $this->assertEquals('value', $result[0]['Article']['insert']);
@ -1552,7 +1552,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testRemoveMulti() { public function testRemoveMulti() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::remove($data, '{n}.Article.title'); $result = Hash::remove($data, '{n}.Article.title');
$this->assertFalse(isset($result[0]['Article']['title'])); $this->assertFalse(isset($result[0]['Article']['title']));
@ -1619,7 +1619,7 @@ class HashTest extends CakeTestCase {
$result = Hash::combine(array(), '{n}.User.id', '{n}.User.Data'); $result = Hash::combine(array(), '{n}.User.id', '{n}.User.Data');
$this->assertTrue(empty($result)); $this->assertTrue(empty($result));
$a = self::userData(); $a = static::userData();
$result = Hash::combine($a, '{n}.User.id'); $result = Hash::combine($a, '{n}.User.id');
$expected = array(2 => null, 14 => null, 25 => null); $expected = array(2 => null, 14 => null, 25 => null);
@ -1678,7 +1678,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testCombineWithGroupPath() { public function testCombineWithGroupPath() {
$a = self::userData(); $a = static::userData();
$result = Hash::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id'); $result = Hash::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id');
$expected = array( $expected = array(
@ -1735,7 +1735,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testCombineWithFormatting() { public function testCombineWithFormatting() {
$a = self::userData(); $a = static::userData();
$result = Hash::combine( $result = Hash::combine(
$a, $a,
@ -1801,7 +1801,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testFormat() { public function testFormat() {
$data = self::userData(); $data = static::userData();
$result = Hash::format( $result = Hash::format(
$data, $data,
@ -1861,7 +1861,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testMap() { public function testMap() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::map($data, '{n}.Article.id', array($this, 'mapCallback')); $result = Hash::map($data, '{n}.Article.id', array($this, 'mapCallback'));
$expected = array(2, 4, 6, 8, 10); $expected = array(2, 4, 6, 8, 10);
@ -1874,7 +1874,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testApply() { public function testApply() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::apply($data, '{n}.Article.id', 'array_sum'); $result = Hash::apply($data, '{n}.Article.id', 'array_sum');
$this->assertEquals(15, $result); $this->assertEquals(15, $result);
@ -1886,7 +1886,7 @@ class HashTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testReduce() { public function testReduce() {
$data = self::articleData(); $data = static::articleData();
$result = Hash::reduce($data, '{n}.Article.id', array($this, 'reduceCallback')); $result = Hash::reduce($data, '{n}.Article.id', array($this, 'reduceCallback'));
$this->assertEquals(15, $result); $this->assertEquals(15, $result);

View file

@ -406,7 +406,7 @@ class InflectorTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testInflectorSlugCharList() { public function testInflectorSlugCharList() {
foreach (self::$maps as $language => $list) { foreach (static::$maps as $language => $list) {
foreach ($list as $from => $to) { foreach ($list as $from => $to) {
$result = Inflector::slug($from); $result = Inflector::slug($from);
$this->assertEquals($to, $result, $from . ' (' . $language . ') should be ' . $to . ' - but is ' . $result); $this->assertEquals($to, $result, $from . ' (' . $language . ') should be ' . $to . ' - but is ' . $result);

View file

@ -548,7 +548,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
* @return void * @return void
*/ */
protected static function assertEqual($result, $expected, $message = '') { protected static function assertEqual($result, $expected, $message = '') {
return self::assertEquals($expected, $result, $message); return static::assertEquals($expected, $result, $message);
} }
/** /**
@ -561,7 +561,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
* @return void * @return void
*/ */
protected static function assertNotEqual($result, $expected, $message = '') { protected static function assertNotEqual($result, $expected, $message = '') {
return self::assertNotEquals($expected, $result, $message); return static::assertNotEquals($expected, $result, $message);
} }
/** /**
@ -574,7 +574,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
* @return void * @return void
*/ */
protected static function assertPattern($pattern, $string, $message = '') { protected static function assertPattern($pattern, $string, $message = '') {
return self::assertRegExp($pattern, $string, $message); return static::assertRegExp($pattern, $string, $message);
} }
/** /**
@ -587,7 +587,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
* @return void * @return void
*/ */
protected static function assertIdentical($actual, $expected, $message = '') { protected static function assertIdentical($actual, $expected, $message = '') {
return self::assertSame($expected, $actual, $message); return static::assertSame($expected, $actual, $message);
} }
/** /**
@ -600,7 +600,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
* @return void * @return void
*/ */
protected static function assertNotIdentical($actual, $expected, $message = '') { protected static function assertNotIdentical($actual, $expected, $message = '') {
return self::assertNotSame($expected, $actual, $message); return static::assertNotSame($expected, $actual, $message);
} }
/** /**
@ -613,7 +613,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
* @return void * @return void
*/ */
protected static function assertNoPattern($pattern, $string, $message = '') { protected static function assertNoPattern($pattern, $string, $message = '') {
return self::assertNotRegExp($pattern, $string, $message); return static::assertNotRegExp($pattern, $string, $message);
} }
/** /**
@ -662,7 +662,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
* @return void * @return void
*/ */
protected static function assertReference(&$first, &$second, $message = '') { protected static function assertReference(&$first, &$second, $message = '') {
return self::assertSame($first, $second, $message); return static::assertSame($first, $second, $message);
} }
/** /**
@ -675,7 +675,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
* @return void * @return void
*/ */
protected static function assertIsA($object, $type, $message = '') { protected static function assertIsA($object, $type, $message = '') {
return self::assertInstanceOf($type, $object, $message); return static::assertInstanceOf($type, $object, $message);
} }
/** /**
@ -690,7 +690,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
protected static function assertWithinMargin($result, $expected, $margin, $message = '') { protected static function assertWithinMargin($result, $expected, $margin, $message = '') {
$upper = $result + $margin; $upper = $result + $margin;
$lower = $result - $margin; $lower = $result - $margin;
return self::assertTrue((($expected <= $upper) && ($expected >= $lower)), $message); return static::assertTrue((($expected <= $upper) && ($expected >= $lower)), $message);
} }
/** /**

View file

@ -85,8 +85,8 @@ class CakeTestLoader extends PHPUnit_Runner_StandardTestSuiteLoader {
* @return array * @return array
*/ */
public static function generateTestList($params) { public static function generateTestList($params) {
$directory = self::_basePath($params); $directory = static::_basePath($params);
$fileList = self::_getRecursiveFileList($directory); $fileList = static::_getRecursiveFileList($directory);
$testCases = array(); $testCases = array();
foreach ($fileList as $testCaseFile) { foreach ($fileList as $testCaseFile) {

View file

@ -48,7 +48,7 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
*/ */
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) { public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) {
if (isset($arguments['printer'])) { if (isset($arguments['printer'])) {
self::$versionStringPrinted = true; static::$versionStringPrinted = true;
} }
$fixture = $this->_getFixtureManager($arguments); $fixture = $this->_getFixtureManager($arguments);

View file

@ -254,7 +254,7 @@ class CakeTestSuiteDispatcher {
restore_error_handler(); restore_error_handler();
try { try {
self::time(); static::time();
$command = new CakeTestSuiteCommand('CakeTestLoader', $commandArgs); $command = new CakeTestSuiteCommand('CakeTestLoader', $commandArgs);
$command->run($options); $command->run($options);
} catch (MissingConnectionException $exception) { } catch (MissingConnectionException $exception) {
@ -287,7 +287,7 @@ class CakeTestSuiteDispatcher {
* @return string formatted date * @return string formatted date
*/ */
public static function date($format) { public static function date($format) {
return date($format, self::time()); return date($format, static::time());
} }
} }

View file

@ -116,13 +116,13 @@ class CakeNumber {
case $size < 1024: case $size < 1024:
return __dn('cake', '%d Byte', '%d Bytes', $size, $size); return __dn('cake', '%d Byte', '%d Bytes', $size, $size);
case round($size / 1024) < 1024: case round($size / 1024) < 1024:
return __d('cake', '%s KB', self::precision($size / 1024, 0)); return __d('cake', '%s KB', static::precision($size / 1024, 0));
case round($size / 1024 / 1024, 2) < 1024: case round($size / 1024 / 1024, 2) < 1024:
return __d('cake', '%s MB', self::precision($size / 1024 / 1024, 2)); return __d('cake', '%s MB', static::precision($size / 1024 / 1024, 2));
case round($size / 1024 / 1024 / 1024, 2) < 1024: case round($size / 1024 / 1024 / 1024, 2) < 1024:
return __d('cake', '%s GB', self::precision($size / 1024 / 1024 / 1024, 2)); return __d('cake', '%s GB', static::precision($size / 1024 / 1024 / 1024, 2));
default: default:
return __d('cake', '%s TB', self::precision($size / 1024 / 1024 / 1024 / 1024, 2)); return __d('cake', '%s TB', static::precision($size / 1024 / 1024 / 1024 / 1024, 2));
} }
} }
@ -181,7 +181,7 @@ class CakeNumber {
if ($options['multiply']) { if ($options['multiply']) {
$value *= 100; $value *= 100;
} }
return self::precision($value, $precision) . '%'; return static::precision($value, $precision) . '%';
} }
/** /**
@ -221,8 +221,8 @@ class CakeNumber {
extract($options); extract($options);
} }
$value = self::_numberFormat($value, $places, '.', ''); $value = static::_numberFormat($value, $places, '.', '');
$out = $before . self::_numberFormat($value, $places, $decimals, $thousands) . $after; $out = $before . static::_numberFormat($value, $places, $decimals, $thousands) . $after;
if ($escape) { if ($escape) {
return h($out); return h($out);
@ -249,10 +249,10 @@ class CakeNumber {
*/ */
public static function formatDelta($value, $options = array()) { public static function formatDelta($value, $options = array()) {
$places = isset($options['places']) ? $options['places'] : 0; $places = isset($options['places']) ? $options['places'] : 0;
$value = self::_numberFormat($value, $places, '.', ''); $value = static::_numberFormat($value, $places, '.', '');
$sign = $value > 0 ? '+' : ''; $sign = $value > 0 ? '+' : '';
$options['before'] = isset($options['before']) ? $options['before'] . $sign : $sign; $options['before'] = isset($options['before']) ? $options['before'] . $sign : $sign;
return self::format($value, $options); return static::format($value, $options);
} }
/** /**
@ -265,10 +265,10 @@ class CakeNumber {
* @return string * @return string
*/ */
protected static function _numberFormat($value, $places = 0, $decimals = '.', $thousands = ',') { protected static function _numberFormat($value, $places = 0, $decimals = '.', $thousands = ',') {
if (!isset(self::$_numberFormatSupport)) { if (!isset(static::$_numberFormatSupport)) {
self::$_numberFormatSupport = version_compare(PHP_VERSION, '5.4.0', '>='); static::$_numberFormatSupport = version_compare(PHP_VERSION, '5.4.0', '>=');
} }
if (self::$_numberFormatSupport) { if (static::$_numberFormatSupport) {
return number_format($value, $places, $decimals, $thousands); return number_format($value, $places, $decimals, $thousands);
} }
$value = number_format($value, $places, '.', ''); $value = number_format($value, $places, '.', '');
@ -323,13 +323,13 @@ class CakeNumber {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::currency * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::currency
*/ */
public static function currency($value, $currency = null, $options = array()) { public static function currency($value, $currency = null, $options = array()) {
$defaults = self::$_currencyDefaults; $defaults = static::$_currencyDefaults;
if ($currency === null) { if ($currency === null) {
$currency = self::defaultCurrency(); $currency = static::defaultCurrency();
} }
if (isset(self::$_currencies[$currency])) { if (isset(static::$_currencies[$currency])) {
$defaults = self::$_currencies[$currency]; $defaults = static::$_currencies[$currency];
} elseif (is_string($currency)) { } elseif (is_string($currency)) {
$options['before'] = $currency; $options['before'] = $currency;
} }
@ -364,7 +364,7 @@ class CakeNumber {
$options[$position] = $options[$symbolKey . 'Symbol']; $options[$position] = $options[$symbolKey . 'Symbol'];
$abs = abs($value); $abs = abs($value);
$result = self::format($abs, $options); $result = static::format($abs, $options);
if ($value < 0) { if ($value < 0) {
if ($options['negative'] === '()') { if ($options['negative'] === '()') {
@ -396,7 +396,7 @@ class CakeNumber {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::addFormat * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::addFormat
*/ */
public static function addFormat($formatName, $options) { public static function addFormat($formatName, $options) {
self::$_currencies[$formatName] = $options + self::$_currencyDefaults; static::$_currencies[$formatName] = $options + static::$_currencyDefaults;
} }
/** /**
@ -408,9 +408,9 @@ class CakeNumber {
*/ */
public static function defaultCurrency($currency = null) { public static function defaultCurrency($currency = null) {
if ($currency) { if ($currency) {
self::$_defaultCurrency = $currency; static::$_defaultCurrency = $currency;
} }
return self::$_defaultCurrency; return static::$_defaultCurrency;
} }
} }

View file

@ -332,7 +332,7 @@ class CakeText {
} }
$options += array('width' => 72, 'wordWrap' => true, 'indent' => null, 'indentAt' => 0); $options += array('width' => 72, 'wordWrap' => true, 'indent' => null, 'indentAt' => 0);
if ($options['wordWrap']) { if ($options['wordWrap']) {
$wrapped = self::wordWrap($text, $options['width'], "\n"); $wrapped = static::wordWrap($text, $options['width'], "\n");
} else { } else {
$wrapped = trim(chunk_split($text, $options['width'] - 1, "\n")); $wrapped = trim(chunk_split($text, $options['width'] - 1, "\n"));
} }
@ -358,7 +358,7 @@ class CakeText {
public static function wordWrap($text, $width = 72, $break = "\n", $cut = false) { public static function wordWrap($text, $width = 72, $break = "\n", $cut = false) {
$paragraphs = explode($break, $text); $paragraphs = explode($break, $text);
foreach ($paragraphs as &$paragraph) { foreach ($paragraphs as &$paragraph) {
$paragraph = self::_wordWrap($paragraph, $width, $break, $cut); $paragraph = static::_wordWrap($paragraph, $width, $break, $cut);
} }
return implode($break, $paragraphs); return implode($break, $paragraphs);
} }
@ -657,7 +657,7 @@ class CakeText {
*/ */
public static function excerpt($text, $phrase, $radius = 100, $ellipsis = '...') { public static function excerpt($text, $phrase, $radius = 100, $ellipsis = '...') {
if (empty($text) || empty($phrase)) { if (empty($text) || empty($phrase)) {
return self::truncate($text, $radius * 2, array('ellipsis' => $ellipsis)); return static::truncate($text, $radius * 2, array('ellipsis' => $ellipsis));
} }
$append = $prepend = $ellipsis; $append = $prepend = $ellipsis;

View file

@ -100,7 +100,7 @@ class CakeTime {
public function __set($name, $value) { public function __set($name, $value) {
switch ($name) { switch ($name) {
case 'niceFormat': case 'niceFormat':
self::${$name} = $value; static::${$name} = $value;
break; break;
} }
} }
@ -115,7 +115,7 @@ class CakeTime {
public function __get($name) { public function __get($name) {
switch ($name) { switch ($name) {
case 'niceFormat': case 'niceFormat':
return self::${$name}; return static::${$name};
default: default:
return null; return null;
} }
@ -135,7 +135,7 @@ class CakeTime {
if (!$time) { if (!$time) {
$time = time(); $time = time();
} }
self::$_time = $time; static::$_time = $time;
return preg_replace_callback('/\%(\w+)/', array('CakeTime', '_translateSpecifier'), $format); return preg_replace_callback('/\%(\w+)/', array('CakeTime', '_translateSpecifier'), $format);
} }
@ -151,47 +151,47 @@ class CakeTime {
case 'a': case 'a':
$abday = __dc('cake', 'abday', 5); $abday = __dc('cake', 'abday', 5);
if (is_array($abday)) { if (is_array($abday)) {
return $abday[date('w', self::$_time)]; return $abday[date('w', static::$_time)];
} }
break; break;
case 'A': case 'A':
$day = __dc('cake', 'day', 5); $day = __dc('cake', 'day', 5);
if (is_array($day)) { if (is_array($day)) {
return $day[date('w', self::$_time)]; return $day[date('w', static::$_time)];
} }
break; break;
case 'c': case 'c':
$format = __dc('cake', 'd_t_fmt', 5); $format = __dc('cake', 'd_t_fmt', 5);
if ($format !== 'd_t_fmt') { if ($format !== 'd_t_fmt') {
return self::convertSpecifiers($format, self::$_time); return static::convertSpecifiers($format, static::$_time);
} }
break; break;
case 'C': case 'C':
return sprintf("%02d", date('Y', self::$_time) / 100); return sprintf("%02d", date('Y', static::$_time) / 100);
case 'D': case 'D':
return '%m/%d/%y'; return '%m/%d/%y';
case 'e': case 'e':
if (DS === '/') { if (DS === '/') {
return '%e'; return '%e';
} }
$day = date('j', self::$_time); $day = date('j', static::$_time);
if ($day < 10) { if ($day < 10) {
$day = ' ' . $day; $day = ' ' . $day;
} }
return $day; return $day;
case 'eS' : case 'eS' :
return date('jS', self::$_time); return date('jS', static::$_time);
case 'b': case 'b':
case 'h': case 'h':
$months = __dc('cake', 'abmon', 5); $months = __dc('cake', 'abmon', 5);
if (is_array($months)) { if (is_array($months)) {
return $months[date('n', self::$_time) - 1]; return $months[date('n', static::$_time) - 1];
} }
return '%b'; return '%b';
case 'B': case 'B':
$months = __dc('cake', 'mon', 5); $months = __dc('cake', 'mon', 5);
if (is_array($months)) { if (is_array($months)) {
return $months[date('n', self::$_time) - 1]; return $months[date('n', static::$_time) - 1];
} }
break; break;
case 'n': case 'n':
@ -199,7 +199,7 @@ class CakeTime {
case 'p': case 'p':
case 'P': case 'P':
$default = array('am' => 0, 'pm' => 1); $default = array('am' => 0, 'pm' => 1);
$meridiem = $default[date('a', self::$_time)]; $meridiem = $default[date('a', static::$_time)];
$format = __dc('cake', 'am_pm', 5); $format = __dc('cake', 'am_pm', 5);
if (is_array($format)) { if (is_array($format)) {
$meridiem = $format[$meridiem]; $meridiem = $format[$meridiem];
@ -209,27 +209,27 @@ class CakeTime {
case 'r': case 'r':
$complete = __dc('cake', 't_fmt_ampm', 5); $complete = __dc('cake', 't_fmt_ampm', 5);
if ($complete !== 't_fmt_ampm') { if ($complete !== 't_fmt_ampm') {
return str_replace('%p', self::_translateSpecifier(array('%p', 'p')), $complete); return str_replace('%p', static::_translateSpecifier(array('%p', 'p')), $complete);
} }
break; break;
case 'R': case 'R':
return date('H:i', self::$_time); return date('H:i', static::$_time);
case 't': case 't':
return "\t"; return "\t";
case 'T': case 'T':
return '%H:%M:%S'; return '%H:%M:%S';
case 'u': case 'u':
return ($weekDay = date('w', self::$_time)) ? $weekDay : 7; return ($weekDay = date('w', static::$_time)) ? $weekDay : 7;
case 'x': case 'x':
$format = __dc('cake', 'd_fmt', 5); $format = __dc('cake', 'd_fmt', 5);
if ($format !== 'd_fmt') { if ($format !== 'd_fmt') {
return self::convertSpecifiers($format, self::$_time); return static::convertSpecifiers($format, static::$_time);
} }
break; break;
case 'X': case 'X':
$format = __dc('cake', 't_fmt', 5); $format = __dc('cake', 't_fmt', 5);
if ($format !== 't_fmt') { if ($format !== 't_fmt') {
return self::convertSpecifiers($format, self::$_time); return static::convertSpecifiers($format, static::$_time);
} }
break; break;
} }
@ -254,7 +254,7 @@ class CakeTime {
if (is_numeric($timezone)) { if (is_numeric($timezone)) {
$userOffset = $timezone * (60 * 60); $userOffset = $timezone * (60 * 60);
} else { } else {
$timezone = self::timezone($timezone); $timezone = static::timezone($timezone);
$userOffset = $timezone->getOffset(new DateTime('@' . $gmtTime)); $userOffset = $timezone->getOffset(new DateTime('@' . $gmtTime));
} }
$userTime = $gmtTime + $userOffset; $userTime = $gmtTime + $userOffset;
@ -343,7 +343,7 @@ class CakeTime {
} }
if ($timezone !== null) { if ($timezone !== null) {
return self::convert($date, $timezone); return static::convert($date, $timezone);
} }
return $date; return $date;
} }
@ -364,12 +364,12 @@ class CakeTime {
if (!$dateString) { if (!$dateString) {
$dateString = time(); $dateString = time();
} }
$date = self::fromString($dateString, $timezone); $date = static::fromString($dateString, $timezone);
if (!$format) { if (!$format) {
$format = self::$niceFormat; $format = static::$niceFormat;
} }
return self::_strftime(self::convertSpecifiers($format, $date), $date); return static::_strftime(static::convertSpecifiers($format, $date), $date);
} }
/** /**
@ -391,19 +391,19 @@ class CakeTime {
if (!$dateString) { if (!$dateString) {
$dateString = time(); $dateString = time();
} }
$date = self::fromString($dateString, $timezone); $date = static::fromString($dateString, $timezone);
if (self::isToday($dateString, $timezone)) { if (static::isToday($dateString, $timezone)) {
return __d('cake', 'Today, %s', self::_strftime("%H:%M", $date)); return __d('cake', 'Today, %s', static::_strftime("%H:%M", $date));
} }
if (self::wasYesterday($dateString, $timezone)) { if (static::wasYesterday($dateString, $timezone)) {
return __d('cake', 'Yesterday, %s', self::_strftime("%H:%M", $date)); return __d('cake', 'Yesterday, %s', static::_strftime("%H:%M", $date));
} }
if (self::isTomorrow($dateString, $timezone)) { if (static::isTomorrow($dateString, $timezone)) {
return __d('cake', 'Tomorrow, %s', self::_strftime("%H:%M", $date)); return __d('cake', 'Tomorrow, %s', static::_strftime("%H:%M", $date));
} }
$d = self::_strftime("%w", $date); $d = static::_strftime("%w", $date);
$day = array( $day = array(
__d('cake', 'Sunday'), __d('cake', 'Sunday'),
__d('cake', 'Monday'), __d('cake', 'Monday'),
@ -413,18 +413,18 @@ class CakeTime {
__d('cake', 'Friday'), __d('cake', 'Friday'),
__d('cake', 'Saturday') __d('cake', 'Saturday')
); );
if (self::wasWithinLast('7 days', $dateString, $timezone)) { if (static::wasWithinLast('7 days', $dateString, $timezone)) {
return sprintf('%s %s', $day[$d], self::_strftime(self::$niceShortFormat, $date)); return sprintf('%s %s', $day[$d], static::_strftime(static::$niceShortFormat, $date));
} }
if (self::isWithinNext('7 days', $dateString, $timezone)) { if (static::isWithinNext('7 days', $dateString, $timezone)) {
return __d('cake', 'On %s %s', $day[$d], self::_strftime(self::$niceShortFormat, $date)); return __d('cake', 'On %s %s', $day[$d], static::_strftime(static::$niceShortFormat, $date));
} }
$y = ''; $y = '';
if (!self::isThisYear($date)) { if (!static::isThisYear($date)) {
$y = ' %Y'; $y = ' %Y';
} }
return self::_strftime(self::convertSpecifiers("%b %eS{$y}, %H:%M", $date), $date); return static::_strftime(static::convertSpecifiers("%b %eS{$y}, %H:%M", $date), $date);
} }
/** /**
@ -438,8 +438,8 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::daysAsSql * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::daysAsSql
*/ */
public static function daysAsSql($begin, $end, $fieldName, $timezone = null) { public static function daysAsSql($begin, $end, $fieldName, $timezone = null) {
$begin = self::fromString($begin, $timezone); $begin = static::fromString($begin, $timezone);
$end = self::fromString($end, $timezone); $end = static::fromString($end, $timezone);
$begin = date('Y-m-d', $begin) . ' 00:00:00'; $begin = date('Y-m-d', $begin) . ' 00:00:00';
$end = date('Y-m-d', $end) . ' 23:59:59'; $end = date('Y-m-d', $end) . ' 23:59:59';
@ -457,7 +457,7 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::dayAsSql * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::dayAsSql
*/ */
public static function dayAsSql($dateString, $fieldName, $timezone = null) { public static function dayAsSql($dateString, $fieldName, $timezone = null) {
return self::daysAsSql($dateString, $dateString, $fieldName, $timezone); return static::daysAsSql($dateString, $dateString, $fieldName, $timezone);
} }
/** /**
@ -469,8 +469,8 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isToday * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isToday
*/ */
public static function isToday($dateString, $timezone = null) { public static function isToday($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone); $timestamp = static::fromString($dateString, $timezone);
$now = self::fromString('now', $timezone); $now = static::fromString('now', $timezone);
return date('Y-m-d', $timestamp) === date('Y-m-d', $now); return date('Y-m-d', $timestamp) === date('Y-m-d', $now);
} }
@ -483,7 +483,7 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isFuture * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isFuture
*/ */
public static function isFuture($dateString, $timezone = null) { public static function isFuture($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone); $timestamp = static::fromString($dateString, $timezone);
return $timestamp > time(); return $timestamp > time();
} }
@ -496,7 +496,7 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isPast * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isPast
*/ */
public static function isPast($dateString, $timezone = null) { public static function isPast($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone); $timestamp = static::fromString($dateString, $timezone);
return $timestamp < time(); return $timestamp < time();
} }
@ -509,8 +509,8 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isThisWeek * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isThisWeek
*/ */
public static function isThisWeek($dateString, $timezone = null) { public static function isThisWeek($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone); $timestamp = static::fromString($dateString, $timezone);
$now = self::fromString('now', $timezone); $now = static::fromString('now', $timezone);
return date('W o', $timestamp) === date('W o', $now); return date('W o', $timestamp) === date('W o', $now);
} }
@ -523,8 +523,8 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isThisMonth * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isThisMonth
*/ */
public static function isThisMonth($dateString, $timezone = null) { public static function isThisMonth($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone); $timestamp = static::fromString($dateString, $timezone);
$now = self::fromString('now', $timezone); $now = static::fromString('now', $timezone);
return date('m Y', $timestamp) === date('m Y', $now); return date('m Y', $timestamp) === date('m Y', $now);
} }
@ -537,8 +537,8 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isThisYear * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isThisYear
*/ */
public static function isThisYear($dateString, $timezone = null) { public static function isThisYear($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone); $timestamp = static::fromString($dateString, $timezone);
$now = self::fromString('now', $timezone); $now = static::fromString('now', $timezone);
return date('Y', $timestamp) === date('Y', $now); return date('Y', $timestamp) === date('Y', $now);
} }
@ -551,8 +551,8 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::wasYesterday * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::wasYesterday
*/ */
public static function wasYesterday($dateString, $timezone = null) { public static function wasYesterday($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone); $timestamp = static::fromString($dateString, $timezone);
$yesterday = self::fromString('yesterday', $timezone); $yesterday = static::fromString('yesterday', $timezone);
return date('Y-m-d', $timestamp) === date('Y-m-d', $yesterday); return date('Y-m-d', $timestamp) === date('Y-m-d', $yesterday);
} }
@ -565,8 +565,8 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isTomorrow * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::isTomorrow
*/ */
public static function isTomorrow($dateString, $timezone = null) { public static function isTomorrow($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone); $timestamp = static::fromString($dateString, $timezone);
$tomorrow = self::fromString('tomorrow', $timezone); $tomorrow = static::fromString('tomorrow', $timezone);
return date('Y-m-d', $timestamp) === date('Y-m-d', $tomorrow); return date('Y-m-d', $timestamp) === date('Y-m-d', $tomorrow);
} }
@ -579,7 +579,7 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toQuarter * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toQuarter
*/ */
public static function toQuarter($dateString, $range = false) { public static function toQuarter($dateString, $range = false) {
$time = self::fromString($dateString); $time = static::fromString($dateString);
$date = (int)ceil(date('m', $time) / 3); $date = (int)ceil(date('m', $time) / 3);
if ($range === false) { if ($range === false) {
return $date; return $date;
@ -607,7 +607,7 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toUnix * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toUnix
*/ */
public static function toUnix($dateString, $timezone = null) { public static function toUnix($dateString, $timezone = null) {
return self::fromString($dateString, $timezone); return static::fromString($dateString, $timezone);
} }
/** /**
@ -658,7 +658,7 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toAtom * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toAtom
*/ */
public static function toAtom($dateString, $timezone = null) { public static function toAtom($dateString, $timezone = null) {
return date('Y-m-d\TH:i:s\Z', self::fromString($dateString, $timezone)); return date('Y-m-d\TH:i:s\Z', static::fromString($dateString, $timezone));
} }
/** /**
@ -670,7 +670,7 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toRSS * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::toRSS
*/ */
public static function toRSS($dateString, $timezone = null) { public static function toRSS($dateString, $timezone = null) {
$date = self::fromString($dateString, $timezone); $date = static::fromString($dateString, $timezone);
if ($timezone === null) { if ($timezone === null) {
return date("r", $date); return date("r", $date);
@ -737,9 +737,9 @@ class CakeTime {
*/ */
public static function timeAgoInWords($dateTime, $options = array()) { public static function timeAgoInWords($dateTime, $options = array()) {
$timezone = null; $timezone = null;
$accuracies = self::$wordAccuracy; $accuracies = static::$wordAccuracy;
$format = self::$wordFormat; $format = static::$wordFormat;
$relativeEnd = self::$wordEnd; $relativeEnd = static::$wordEnd;
$relativeStringPast = __d('cake', '%s ago'); $relativeStringPast = __d('cake', '%s ago');
$relativeStringFuture = __d('cake', 'in %s'); $relativeStringFuture = __d('cake', 'in %s');
$absoluteString = __d('cake', 'on %s'); $absoluteString = __d('cake', 'on %s');
@ -784,8 +784,8 @@ class CakeTime {
unset($options['end'], $options['format']); unset($options['end'], $options['format']);
} }
$now = self::fromString(time(), $timezone); $now = static::fromString(time(), $timezone);
$inSeconds = self::fromString($dateTime, $timezone); $inSeconds = static::fromString($dateTime, $timezone);
$isFuture = ($inSeconds > $now); $isFuture = ($inSeconds > $now);
if ($isFuture) { if ($isFuture) {
@ -801,12 +801,12 @@ class CakeTime {
return __d('cake', 'just now', 'just now'); return __d('cake', 'just now', 'just now');
} }
$isAbsoluteDate = $diff > abs($now - self::fromString($relativeEnd)); $isAbsoluteDate = $diff > abs($now - static::fromString($relativeEnd));
if ($isAbsoluteDate) { if ($isAbsoluteDate) {
if (strpos($format, '%') === false) { if (strpos($format, '%') === false) {
$date = date($format, $inSeconds); $date = date($format, $inSeconds);
} else { } else {
$date = self::_strftime($format, $inSeconds); $date = static::_strftime($format, $inSeconds);
} }
return sprintf($absoluteString, $date); return sprintf($absoluteString, $date);
} }
@ -958,9 +958,9 @@ class CakeTime {
$timeInterval = $tmp . ' ' . __d('cake', 'days'); $timeInterval = $tmp . ' ' . __d('cake', 'days');
} }
$date = self::fromString($dateString, $timezone); $date = static::fromString($dateString, $timezone);
$interval = self::fromString('-' . $timeInterval); $interval = static::fromString('-' . $timeInterval);
$now = self::fromString('now', $timezone); $now = static::fromString('now', $timezone);
return $date >= $interval && $date <= $now; return $date >= $interval && $date <= $now;
} }
@ -980,9 +980,9 @@ class CakeTime {
$timeInterval = $tmp . ' ' . __d('cake', 'days'); $timeInterval = $tmp . ' ' . __d('cake', 'days');
} }
$date = self::fromString($dateString, $timezone); $date = static::fromString($dateString, $timezone);
$interval = self::fromString('+' . $timeInterval); $interval = static::fromString('+' . $timeInterval);
$now = self::fromString('now', $timezone); $now = static::fromString('now', $timezone);
return $date <= $interval && $date >= $now; return $date <= $interval && $date >= $now;
} }
@ -997,7 +997,7 @@ class CakeTime {
public static function gmt($dateString = null) { public static function gmt($dateString = null) {
$time = time(); $time = time();
if ($dateString) { if ($dateString) {
$time = self::fromString($dateString); $time = static::fromString($dateString);
} }
return gmmktime( return gmmktime(
(int)date('G', $time), (int)date('G', $time),
@ -1035,10 +1035,10 @@ class CakeTime {
*/ */
public static function format($date, $format = null, $default = false, $timezone = null) { public static function format($date, $format = null, $default = false, $timezone = null) {
//Backwards compatible params re-order test //Backwards compatible params re-order test
$time = self::fromString($format, $timezone); $time = static::fromString($format, $timezone);
if ($time === false) { if ($time === false) {
return self::i18nFormat($date, $format, $default, $timezone); return static::i18nFormat($date, $format, $default, $timezone);
} }
return date($date, $time); return date($date, $time);
} }
@ -1055,7 +1055,7 @@ class CakeTime {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::i18nFormat * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#TimeHelper::i18nFormat
*/ */
public static function i18nFormat($date, $format = null, $default = false, $timezone = null) { public static function i18nFormat($date, $format = null, $default = false, $timezone = null) {
$date = self::fromString($date, $timezone); $date = static::fromString($date, $timezone);
if ($date === false && $default !== false) { if ($date === false && $default !== false) {
return $default; return $default;
} }
@ -1065,7 +1065,7 @@ class CakeTime {
if (empty($format)) { if (empty($format)) {
$format = '%x'; $format = '%x';
} }
return self::_strftime(self::convertSpecifiers($format, $date), $date); return static::_strftime(static::convertSpecifiers($format, $date), $date);
} }
/** /**

View file

@ -174,7 +174,7 @@ class Debugger {
* @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::dump * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::dump
*/ */
public static function dump($var, $depth = 3) { public static function dump($var, $depth = 3) {
pr(self::exportVar($var, $depth)); pr(static::exportVar($var, $depth));
} }
/** /**
@ -188,8 +188,8 @@ class Debugger {
* @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::log * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::log
*/ */
public static function log($var, $level = LOG_DEBUG, $depth = 3) { public static function log($var, $level = LOG_DEBUG, $depth = 3) {
$source = self::trace(array('start' => 1)) . "\n"; $source = static::trace(array('start' => 1)) . "\n";
CakeLog::write($level, "\n" . $source . self::exportVar($var, $depth)); CakeLog::write($level, "\n" . $source . static::exportVar($var, $depth));
} }
/** /**
@ -334,7 +334,7 @@ class Debugger {
} else { } else {
$tpl = $self->_templates['base']['traceLine']; $tpl = $self->_templates['base']['traceLine'];
} }
$trace['path'] = self::trimPath($trace['file']); $trace['path'] = static::trimPath($trace['file']);
$trace['reference'] = $reference; $trace['reference'] = $reference;
unset($trace['object'], $trace['args']); unset($trace['object'], $trace['args']);
$back[] = CakeText::insert($tpl, $trace, array('before' => '{:', 'after' => '}')); $back[] = CakeText::insert($tpl, $trace, array('before' => '{:', 'after' => '}'));
@ -408,7 +408,7 @@ class Debugger {
if (!isset($data[$i])) { if (!isset($data[$i])) {
continue; continue;
} }
$string = str_replace(array("\r\n", "\n"), "", self::_highlight($data[$i])); $string = str_replace(array("\r\n", "\n"), "", static::_highlight($data[$i]));
if ($i == $line) { if ($i == $line) {
$lines[] = '<span class="code-highlight">' . $string . '</span>'; $lines[] = '<span class="code-highlight">' . $string . '</span>';
} else { } else {
@ -468,7 +468,7 @@ class Debugger {
* @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::exportVar * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::exportVar
*/ */
public static function exportVar($var, $depth = 3) { public static function exportVar($var, $depth = 3) {
return self::_export($var, $depth, 0); return static::_export($var, $depth, 0);
} }
/** /**
@ -480,7 +480,7 @@ class Debugger {
* @return string The dumped variable. * @return string The dumped variable.
*/ */
protected static function _export($var, $depth, $indent) { protected static function _export($var, $depth, $indent) {
switch (self::getType($var)) { switch (static::getType($var)) {
case 'boolean': case 'boolean':
return ($var) ? 'true' : 'false'; return ($var) ? 'true' : 'false';
case 'integer': case 'integer':
@ -493,7 +493,7 @@ class Debugger {
} }
return "'" . $var . "'"; return "'" . $var . "'";
case 'array': case 'array':
return self::_array($var, $depth - 1, $indent + 1); return static::_array($var, $depth - 1, $indent + 1);
case 'resource': case 'resource':
return strtolower(gettype($var)); return strtolower(gettype($var));
case 'null': case 'null':
@ -501,7 +501,7 @@ class Debugger {
case 'unknown': case 'unknown':
return 'unknown'; return 'unknown';
default: default:
return self::_object($var, $depth - 1, $indent + 1); return static::_object($var, $depth - 1, $indent + 1);
} }
} }
@ -550,9 +550,9 @@ class Debugger {
if ($key === 'GLOBALS' && is_array($val) && isset($val['GLOBALS'])) { if ($key === 'GLOBALS' && is_array($val) && isset($val['GLOBALS'])) {
$val = '[recursion]'; $val = '[recursion]';
} elseif ($val !== $var) { } elseif ($val !== $var) {
$val = self::_export($val, $depth, $indent); $val = static::_export($val, $depth, $indent);
} }
$vars[] = $break . self::exportVar($key) . $vars[] = $break . static::exportVar($key) .
' => ' . ' => ' .
$val; $val;
} }
@ -583,7 +583,7 @@ class Debugger {
$break = "\n" . str_repeat("\t", $indent); $break = "\n" . str_repeat("\t", $indent);
$objectVars = get_object_vars($var); $objectVars = get_object_vars($var);
foreach ($objectVars as $key => $value) { foreach ($objectVars as $key => $value) {
$value = self::_export($value, $depth - 1, $indent); $value = static::_export($value, $depth - 1, $indent);
$props[] = "$key => " . $value; $props[] = "$key => " . $value;
} }
@ -600,7 +600,7 @@ class Debugger {
$reflectionProperty->setAccessible(true); $reflectionProperty->setAccessible(true);
$property = $reflectionProperty->getValue($var); $property = $reflectionProperty->getValue($var);
$value = self::_export($property, $depth - 1, $indent); $value = static::_export($property, $depth - 1, $indent);
$key = $reflectionProperty->name; $key = $reflectionProperty->name;
$props[] = sprintf('[%s] %s => %s', $visibility, $key, $value); $props[] = sprintf('[%s] %s => %s', $visibility, $key, $value);
} }

View file

@ -285,7 +285,7 @@ class Folder {
return $path[0] === '/' || return $path[0] === '/' ||
preg_match('/^[A-Z]:\\\\/i', $path) || preg_match('/^[A-Z]:\\\\/i', $path) ||
substr($path, 0, 2) === '\\\\' || substr($path, 0, 2) === '\\\\' ||
self::isRegisteredStreamWrapper($path); static::isRegisteredStreamWrapper($path);
} }
/** /**
@ -525,8 +525,8 @@ class Folder {
return true; return true;
} }
if (!self::isAbsolute($pathname)) { if (!static::isAbsolute($pathname)) {
$pathname = self::addPathElement($this->pwd(), $pathname); $pathname = static::addPathElement($this->pwd(), $pathname);
} }
if (!$mode) { if (!$mode) {

View file

@ -106,7 +106,7 @@ class Hash {
// Simple paths. // Simple paths.
if (!preg_match('/[{\[]/', $path)) { if (!preg_match('/[{\[]/', $path)) {
return (array)self::get($data, $path); return (array)static::get($data, $path);
} }
if (strpos($path, '[') === false) { if (strpos($path, '[') === false) {
@ -122,11 +122,11 @@ class Hash {
foreach ($tokens as $token) { foreach ($tokens as $token) {
$next = array(); $next = array();
list($token, $conditions) = self::_splitConditions($token); list($token, $conditions) = static::_splitConditions($token);
foreach ($context[$_key] as $item) { foreach ($context[$_key] as $item) {
foreach ((array)$item as $k => $v) { foreach ((array)$item as $k => $v) {
if (self::_matchToken($k, $token)) { if (static::_matchToken($k, $token)) {
$next[] = $v; $next[] = $v;
} }
} }
@ -136,7 +136,7 @@ class Hash {
if ($conditions) { if ($conditions) {
$filter = array(); $filter = array();
foreach ($next as $item) { foreach ($next as $item) {
if (is_array($item) && self::_matches($item, $conditions)) { if (is_array($item) && static::_matches($item, $conditions)) {
$filter[] = $item; $filter[] = $item;
} }
} }
@ -262,22 +262,22 @@ class Hash {
} }
if (strpos($path, '{') === false && strpos($path, '[') === false) { if (strpos($path, '{') === false && strpos($path, '[') === false) {
return self::_simpleOp('insert', $data, $tokens, $values); return static::_simpleOp('insert', $data, $tokens, $values);
} }
$token = array_shift($tokens); $token = array_shift($tokens);
$nextPath = implode('.', $tokens); $nextPath = implode('.', $tokens);
list($token, $conditions) = self::_splitConditions($token); list($token, $conditions) = static::_splitConditions($token);
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
if (self::_matchToken($k, $token)) { if (static::_matchToken($k, $token)) {
if ($conditions && self::_matches($v, $conditions)) { if ($conditions && static::_matches($v, $conditions)) {
$data[$k] = array_merge($v, $values); $data[$k] = array_merge($v, $values);
continue; continue;
} }
if (!$conditions) { if (!$conditions) {
$data[$k] = self::insert($v, $nextPath, $values); $data[$k] = static::insert($v, $nextPath, $values);
} }
} }
} }
@ -345,22 +345,22 @@ class Hash {
} }
if (strpos($path, '{') === false && strpos($path, '[') === false) { if (strpos($path, '{') === false && strpos($path, '[') === false) {
return self::_simpleOp('remove', $data, $tokens); return static::_simpleOp('remove', $data, $tokens);
} }
$token = array_shift($tokens); $token = array_shift($tokens);
$nextPath = implode('.', $tokens); $nextPath = implode('.', $tokens);
list($token, $conditions) = self::_splitConditions($token); list($token, $conditions) = static::_splitConditions($token);
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
$match = self::_matchToken($k, $token); $match = static::_matchToken($k, $token);
if ($match && is_array($v)) { if ($match && is_array($v)) {
if ($conditions && self::_matches($v, $conditions)) { if ($conditions && static::_matches($v, $conditions)) {
unset($data[$k]); unset($data[$k]);
continue; continue;
} }
$data[$k] = self::remove($v, $nextPath); $data[$k] = static::remove($v, $nextPath);
if (empty($data[$k])) { if (empty($data[$k])) {
unset($data[$k]); unset($data[$k]);
} }
@ -392,9 +392,9 @@ class Hash {
if (is_array($keyPath)) { if (is_array($keyPath)) {
$format = array_shift($keyPath); $format = array_shift($keyPath);
$keys = self::format($data, $keyPath, $format); $keys = static::format($data, $keyPath, $format);
} else { } else {
$keys = self::extract($data, $keyPath); $keys = static::extract($data, $keyPath);
} }
if (empty($keys)) { if (empty($keys)) {
return array(); return array();
@ -402,9 +402,9 @@ class Hash {
if (!empty($valuePath) && is_array($valuePath)) { if (!empty($valuePath) && is_array($valuePath)) {
$format = array_shift($valuePath); $format = array_shift($valuePath);
$vals = self::format($data, $valuePath, $format); $vals = static::format($data, $valuePath, $format);
} elseif (!empty($valuePath)) { } elseif (!empty($valuePath)) {
$vals = self::extract($data, $valuePath); $vals = static::extract($data, $valuePath);
} }
if (empty($vals)) { if (empty($vals)) {
$vals = array_fill(0, count($keys), null); $vals = array_fill(0, count($keys), null);
@ -418,7 +418,7 @@ class Hash {
} }
if ($groupPath !== null) { if ($groupPath !== null) {
$group = self::extract($data, $groupPath); $group = static::extract($data, $groupPath);
if (!empty($group)) { if (!empty($group)) {
$c = count($keys); $c = count($keys);
for ($i = 0; $i < $c; $i++) { for ($i = 0; $i < $c; $i++) {
@ -469,7 +469,7 @@ class Hash {
} }
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
$extracted[] = self::extract($data, $paths[$i]); $extracted[] = static::extract($data, $paths[$i]);
} }
$out = array(); $out = array();
$data = $extracted; $data = $extracted;
@ -539,7 +539,7 @@ class Hash {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::check * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::check
*/ */
public static function check(array $data, $path) { public static function check(array $data, $path) {
$results = self::extract($data, $path); $results = static::extract($data, $path);
if (!is_array($results)) { if (!is_array($results)) {
return false; return false;
} }
@ -551,14 +551,14 @@ class Hash {
* *
* @param array $data Either an array to filter, or value when in callback * @param array $data Either an array to filter, or value when in callback
* @param callable $callback A function to filter the data with. Defaults to * @param callable $callback A function to filter the data with. Defaults to
* `self::_filter()` Which strips out all non-zero empty values. * `static::_filter()` Which strips out all non-zero empty values.
* @return array Filtered array * @return array Filtered array
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::filter * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::filter
*/ */
public static function filter(array $data, $callback = array('self', '_filter')) { public static function filter(array $data, $callback = array('self', '_filter')) {
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
if (is_array($v)) { if (is_array($v)) {
$data[$k] = self::filter($v, $callback); $data[$k] = static::filter($v, $callback);
} }
} }
return array_filter($data, $callback); return array_filter($data, $callback);
@ -781,7 +781,7 @@ class Hash {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::map * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::map
*/ */
public static function map(array $data, $path, $function) { public static function map(array $data, $path, $function) {
$values = (array)self::extract($data, $path); $values = (array)static::extract($data, $path);
return array_map($function, $values); return array_map($function, $values);
} }
@ -795,7 +795,7 @@ class Hash {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::reduce * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::reduce
*/ */
public static function reduce(array $data, $path, $function) { public static function reduce(array $data, $path, $function) {
$values = (array)self::extract($data, $path); $values = (array)static::extract($data, $path);
return array_reduce($values, $function); return array_reduce($values, $function);
} }
@ -820,7 +820,7 @@ class Hash {
* @return mixed The results of the applied method. * @return mixed The results of the applied method.
*/ */
public static function apply(array $data, $path, $function) { public static function apply(array $data, $path, $function) {
$values = (array)self::extract($data, $path); $values = (array)static::extract($data, $path);
return call_user_func($function, $values); return call_user_func($function, $values);
} }
@ -856,7 +856,7 @@ class Hash {
if ($numeric) { if ($numeric) {
$data = array_values($data); $data = array_values($data);
} }
$sortValues = self::extract($data, $path); $sortValues = static::extract($data, $path);
$sortCount = count($sortValues); $sortCount = count($sortValues);
$dataCount = count($data); $dataCount = count($data);
@ -865,9 +865,9 @@ class Hash {
if ($sortCount < $dataCount) { if ($sortCount < $dataCount) {
$sortValues = array_pad($sortValues, $dataCount, null); $sortValues = array_pad($sortValues, $dataCount, null);
} }
$result = self::_squash($sortValues); $result = static::_squash($sortValues);
$keys = self::extract($result, '{n}.id'); $keys = static::extract($result, '{n}.id');
$values = self::extract($result, '{n}.value'); $values = static::extract($result, '{n}.value');
$dir = strtolower($dir); $dir = strtolower($dir);
$type = strtolower($type); $type = strtolower($type);
@ -922,7 +922,7 @@ class Hash {
$id = $key; $id = $key;
} }
if (is_array($r) && !empty($r)) { if (is_array($r) && !empty($r)) {
$stack = array_merge($stack, self::_squash($r, $id)); $stack = array_merge($stack, static::_squash($r, $id));
} else { } else {
$stack[] = array('id' => $id, 'value' => $r); $stack[] = array('id' => $id, 'value' => $r);
} }
@ -978,7 +978,7 @@ class Hash {
if (!array_key_exists($key, $data)) { if (!array_key_exists($key, $data)) {
$data[$key] = $value; $data[$key] = $value;
} elseif (is_array($value)) { } elseif (is_array($value)) {
$data[$key] = self::mergeDiff($data[$key], $compare[$key]); $data[$key] = static::mergeDiff($data[$key], $compare[$key]);
} }
} }
return $data; return $data;
@ -1052,7 +1052,7 @@ class Hash {
); );
$return = $idMap = array(); $return = $idMap = array();
$ids = self::extract($data, $options['idPath']); $ids = static::extract($data, $options['idPath']);
$idKeys = explode('.', $options['idPath']); $idKeys = explode('.', $options['idPath']);
array_shift($idKeys); array_shift($idKeys);
@ -1063,8 +1063,8 @@ class Hash {
foreach ($data as $result) { foreach ($data as $result) {
$result[$options['children']] = array(); $result[$options['children']] = array();
$id = self::get($result, $idKeys); $id = static::get($result, $idKeys);
$parentId = self::get($result, $parentKeys); $parentId = static::get($result, $parentKeys);
if (isset($idMap[$id][$options['children']])) { if (isset($idMap[$id][$options['children']])) {
$idMap[$id] = array_merge($result, (array)$idMap[$id]); $idMap[$id] = array_merge($result, (array)$idMap[$id]);
@ -1087,12 +1087,12 @@ class Hash {
if ($options['root']) { if ($options['root']) {
$root = $options['root']; $root = $options['root'];
} else { } else {
$root = self::get($return[0], $parentKeys); $root = static::get($return[0], $parentKeys);
} }
foreach ($return as $i => $result) { foreach ($return as $i => $result) {
$id = self::get($result, $idKeys); $id = static::get($result, $idKeys);
$parentId = self::get($result, $parentKeys); $parentId = static::get($result, $parentKeys);
if ($id !== $root && $parentId != $root) { if ($id !== $root && $parentId != $root) {
unset($return[$i]); unset($return[$i]);
} }

View file

@ -274,13 +274,13 @@ class Inflector {
$key = '_' . $key; $key = '_' . $key;
$type = '_' . $type; $type = '_' . $type;
if ($value !== false) { if ($value !== false) {
self::$_cache[$type][$key] = $value; static::$_cache[$type][$key] = $value;
return $value; return $value;
} }
if (!isset(self::$_cache[$type][$key])) { if (!isset(static::$_cache[$type][$key])) {
return false; return false;
} }
return self::$_cache[$type][$key]; return static::$_cache[$type][$key];
} }
/** /**
@ -290,13 +290,13 @@ class Inflector {
* @return void * @return void
*/ */
public static function reset() { public static function reset() {
if (empty(self::$_initialState)) { if (empty(static::$_initialState)) {
self::$_initialState = get_class_vars('Inflector'); static::$_initialState = get_class_vars('Inflector');
return; return;
} }
foreach (self::$_initialState as $key => $val) { foreach (static::$_initialState as $key => $val) {
if ($key !== '_initialState') { if ($key !== '_initialState') {
self::${$key} = $val; static::${$key} = $val;
} }
} }
} }
@ -328,9 +328,9 @@ class Inflector {
switch ($type) { switch ($type) {
case 'transliteration': case 'transliteration':
if ($reset) { if ($reset) {
self::$_transliteration = $rules; static::$_transliteration = $rules;
} else { } else {
self::$_transliteration = $rules + self::$_transliteration; static::$_transliteration = $rules + static::$_transliteration;
} }
break; break;
@ -338,26 +338,26 @@ class Inflector {
foreach ($rules as $rule => $pattern) { foreach ($rules as $rule => $pattern) {
if (is_array($pattern)) { if (is_array($pattern)) {
if ($reset) { if ($reset) {
self::${$var}[$rule] = $pattern; static::${$var}[$rule] = $pattern;
} else { } else {
if ($rule === 'uninflected') { if ($rule === 'uninflected') {
self::${$var}[$rule] = array_merge($pattern, self::${$var}[$rule]); static::${$var}[$rule] = array_merge($pattern, static::${$var}[$rule]);
} else { } else {
self::${$var}[$rule] = $pattern + self::${$var}[$rule]; static::${$var}[$rule] = $pattern + static::${$var}[$rule];
} }
} }
unset($rules[$rule], self::${$var}['cache' . ucfirst($rule)]); unset($rules[$rule], static::${$var}['cache' . ucfirst($rule)]);
if (isset(self::${$var}['merged'][$rule])) { if (isset(static::${$var}['merged'][$rule])) {
unset(self::${$var}['merged'][$rule]); unset(static::${$var}['merged'][$rule]);
} }
if ($type === 'plural') { if ($type === 'plural') {
self::$_cache['pluralize'] = self::$_cache['tableize'] = array(); static::$_cache['pluralize'] = static::$_cache['tableize'] = array();
} elseif ($type === 'singular') { } elseif ($type === 'singular') {
self::$_cache['singularize'] = array(); static::$_cache['singularize'] = array();
} }
} }
} }
self::${$var}['rules'] = $rules + self::${$var}['rules']; static::${$var}['rules'] = $rules + static::${$var}['rules'];
} }
} }
@ -369,39 +369,39 @@ class Inflector {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::pluralize * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::pluralize
*/ */
public static function pluralize($word) { public static function pluralize($word) {
if (isset(self::$_cache['pluralize'][$word])) { if (isset(static::$_cache['pluralize'][$word])) {
return self::$_cache['pluralize'][$word]; return static::$_cache['pluralize'][$word];
} }
if (!isset(self::$_plural['merged']['irregular'])) { if (!isset(static::$_plural['merged']['irregular'])) {
self::$_plural['merged']['irregular'] = self::$_plural['irregular']; static::$_plural['merged']['irregular'] = static::$_plural['irregular'];
} }
if (!isset(self::$_plural['merged']['uninflected'])) { if (!isset(static::$_plural['merged']['uninflected'])) {
self::$_plural['merged']['uninflected'] = array_merge(self::$_plural['uninflected'], self::$_uninflected); static::$_plural['merged']['uninflected'] = array_merge(static::$_plural['uninflected'], static::$_uninflected);
} }
if (!isset(self::$_plural['cacheUninflected']) || !isset(self::$_plural['cacheIrregular'])) { if (!isset(static::$_plural['cacheUninflected']) || !isset(static::$_plural['cacheIrregular'])) {
self::$_plural['cacheUninflected'] = '(?:' . implode('|', self::$_plural['merged']['uninflected']) . ')'; static::$_plural['cacheUninflected'] = '(?:' . implode('|', static::$_plural['merged']['uninflected']) . ')';
self::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_plural['merged']['irregular'])) . ')'; static::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(static::$_plural['merged']['irregular'])) . ')';
} }
if (preg_match('/(.*?(?:\\b|_))(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { if (preg_match('/(.*?(?:\\b|_))(' . static::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) {
self::$_cache['pluralize'][$word] = $regs[1] . static::$_cache['pluralize'][$word] = $regs[1] .
substr($regs[2], 0, 1) . substr($regs[2], 0, 1) .
substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1); substr(static::$_plural['merged']['irregular'][strtolower($regs[2])], 1);
return self::$_cache['pluralize'][$word]; return static::$_cache['pluralize'][$word];
} }
if (preg_match('/^(' . self::$_plural['cacheUninflected'] . ')$/i', $word, $regs)) { if (preg_match('/^(' . static::$_plural['cacheUninflected'] . ')$/i', $word, $regs)) {
self::$_cache['pluralize'][$word] = $word; static::$_cache['pluralize'][$word] = $word;
return $word; return $word;
} }
foreach (self::$_plural['rules'] as $rule => $replacement) { foreach (static::$_plural['rules'] as $rule => $replacement) {
if (preg_match($rule, $word)) { if (preg_match($rule, $word)) {
self::$_cache['pluralize'][$word] = preg_replace($rule, $replacement, $word); static::$_cache['pluralize'][$word] = preg_replace($rule, $replacement, $word);
return self::$_cache['pluralize'][$word]; return static::$_cache['pluralize'][$word];
} }
} }
} }
@ -414,48 +414,48 @@ class Inflector {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::singularize * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::singularize
*/ */
public static function singularize($word) { public static function singularize($word) {
if (isset(self::$_cache['singularize'][$word])) { if (isset(static::$_cache['singularize'][$word])) {
return self::$_cache['singularize'][$word]; return static::$_cache['singularize'][$word];
} }
if (!isset(self::$_singular['merged']['uninflected'])) { if (!isset(static::$_singular['merged']['uninflected'])) {
self::$_singular['merged']['uninflected'] = array_merge( static::$_singular['merged']['uninflected'] = array_merge(
self::$_singular['uninflected'], static::$_singular['uninflected'],
self::$_uninflected static::$_uninflected
); );
} }
if (!isset(self::$_singular['merged']['irregular'])) { if (!isset(static::$_singular['merged']['irregular'])) {
self::$_singular['merged']['irregular'] = array_merge( static::$_singular['merged']['irregular'] = array_merge(
self::$_singular['irregular'], static::$_singular['irregular'],
array_flip(self::$_plural['irregular']) array_flip(static::$_plural['irregular'])
); );
} }
if (!isset(self::$_singular['cacheUninflected']) || !isset(self::$_singular['cacheIrregular'])) { if (!isset(static::$_singular['cacheUninflected']) || !isset(static::$_singular['cacheIrregular'])) {
self::$_singular['cacheUninflected'] = '(?:' . implode('|', self::$_singular['merged']['uninflected']) . ')'; static::$_singular['cacheUninflected'] = '(?:' . implode('|', static::$_singular['merged']['uninflected']) . ')';
self::$_singular['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_singular['merged']['irregular'])) . ')'; static::$_singular['cacheIrregular'] = '(?:' . implode('|', array_keys(static::$_singular['merged']['irregular'])) . ')';
} }
if (preg_match('/(.*?(?:\\b|_))(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) { if (preg_match('/(.*?(?:\\b|_))(' . static::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) {
self::$_cache['singularize'][$word] = $regs[1] . static::$_cache['singularize'][$word] = $regs[1] .
substr($regs[2], 0, 1) . substr($regs[2], 0, 1) .
substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1); substr(static::$_singular['merged']['irregular'][strtolower($regs[2])], 1);
return self::$_cache['singularize'][$word]; return static::$_cache['singularize'][$word];
} }
if (preg_match('/^(' . self::$_singular['cacheUninflected'] . ')$/i', $word, $regs)) { if (preg_match('/^(' . static::$_singular['cacheUninflected'] . ')$/i', $word, $regs)) {
self::$_cache['singularize'][$word] = $word; static::$_cache['singularize'][$word] = $word;
return $word; return $word;
} }
foreach (self::$_singular['rules'] as $rule => $replacement) { foreach (static::$_singular['rules'] as $rule => $replacement) {
if (preg_match($rule, $word)) { if (preg_match($rule, $word)) {
self::$_cache['singularize'][$word] = preg_replace($rule, $replacement, $word); static::$_cache['singularize'][$word] = preg_replace($rule, $replacement, $word);
return self::$_cache['singularize'][$word]; return static::$_cache['singularize'][$word];
} }
} }
self::$_cache['singularize'][$word] = $word; static::$_cache['singularize'][$word] = $word;
return $word; return $word;
} }
@ -467,9 +467,9 @@ class Inflector {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::camelize * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::camelize
*/ */
public static function camelize($lowerCaseAndUnderscoredWord) { public static function camelize($lowerCaseAndUnderscoredWord) {
if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { if (!($result = static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) {
$result = str_replace(' ', '', Inflector::humanize($lowerCaseAndUnderscoredWord)); $result = str_replace(' ', '', Inflector::humanize($lowerCaseAndUnderscoredWord));
self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result);
} }
return $result; return $result;
} }
@ -482,10 +482,10 @@ class Inflector {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::underscore * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::underscore
*/ */
public static function underscore($camelCasedWord) { public static function underscore($camelCasedWord) {
if (!($result = self::_cache(__FUNCTION__, $camelCasedWord))) { if (!($result = static::_cache(__FUNCTION__, $camelCasedWord))) {
$underscoredWord = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord); $underscoredWord = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord);
$result = mb_strtolower($underscoredWord); $result = mb_strtolower($underscoredWord);
self::_cache(__FUNCTION__, $camelCasedWord, $result); static::_cache(__FUNCTION__, $camelCasedWord, $result);
} }
return $result; return $result;
} }
@ -499,13 +499,13 @@ class Inflector {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::humanize * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::humanize
*/ */
public static function humanize($lowerCaseAndUnderscoredWord) { public static function humanize($lowerCaseAndUnderscoredWord) {
if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { if (!($result = static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) {
$result = explode(' ', str_replace('_', ' ', $lowerCaseAndUnderscoredWord)); $result = explode(' ', str_replace('_', ' ', $lowerCaseAndUnderscoredWord));
foreach ($result as &$word) { foreach ($result as &$word) {
$word = mb_strtoupper(mb_substr($word, 0, 1)) . mb_substr($word, 1); $word = mb_strtoupper(mb_substr($word, 0, 1)) . mb_substr($word, 1);
} }
$result = implode(' ', $result); $result = implode(' ', $result);
self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result);
} }
return $result; return $result;
} }
@ -518,9 +518,9 @@ class Inflector {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::tableize * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::tableize
*/ */
public static function tableize($className) { public static function tableize($className) {
if (!($result = self::_cache(__FUNCTION__, $className))) { if (!($result = static::_cache(__FUNCTION__, $className))) {
$result = Inflector::pluralize(Inflector::underscore($className)); $result = Inflector::pluralize(Inflector::underscore($className));
self::_cache(__FUNCTION__, $className, $result); static::_cache(__FUNCTION__, $className, $result);
} }
return $result; return $result;
} }
@ -533,9 +533,9 @@ class Inflector {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::classify * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::classify
*/ */
public static function classify($tableName) { public static function classify($tableName) {
if (!($result = self::_cache(__FUNCTION__, $tableName))) { if (!($result = static::_cache(__FUNCTION__, $tableName))) {
$result = Inflector::camelize(Inflector::singularize($tableName)); $result = Inflector::camelize(Inflector::singularize($tableName));
self::_cache(__FUNCTION__, $tableName, $result); static::_cache(__FUNCTION__, $tableName, $result);
} }
return $result; return $result;
} }
@ -548,11 +548,11 @@ class Inflector {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::variable * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::variable
*/ */
public static function variable($string) { public static function variable($string) {
if (!($result = self::_cache(__FUNCTION__, $string))) { if (!($result = static::_cache(__FUNCTION__, $string))) {
$camelized = Inflector::camelize(Inflector::underscore($string)); $camelized = Inflector::camelize(Inflector::underscore($string));
$replace = strtolower(substr($camelized, 0, 1)); $replace = strtolower(substr($camelized, 0, 1));
$result = preg_replace('/\\w/', $replace, $camelized, 1); $result = preg_replace('/\\w/', $replace, $camelized, 1);
self::_cache(__FUNCTION__, $string, $result); static::_cache(__FUNCTION__, $string, $result);
} }
return $result; return $result;
} }
@ -575,7 +575,7 @@ class Inflector {
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '', sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
); );
$map = self::$_transliteration + $merge; $map = static::$_transliteration + $merge;
return preg_replace(array_keys($map), array_values($map), $string); return preg_replace(array_keys($map), array_values($map), $string);
} }

View file

@ -105,12 +105,12 @@ class Security {
*/ */
public static function hash($string, $type = null, $salt = false) { public static function hash($string, $type = null, $salt = false) {
if (empty($type)) { if (empty($type)) {
$type = self::$hashType; $type = static::$hashType;
} }
$type = strtolower($type); $type = strtolower($type);
if ($type === 'blowfish') { if ($type === 'blowfish') {
return self::_crypt($string, $salt); return static::_crypt($string, $salt);
} }
if ($salt) { if ($salt) {
if (!is_string($salt)) { if (!is_string($salt)) {
@ -145,7 +145,7 @@ class Security {
* @see Security::hash() * @see Security::hash()
*/ */
public static function setHash($hash) { public static function setHash($hash) {
self::$hashType = $hash; static::$hashType = $hash;
} }
/** /**
@ -163,7 +163,7 @@ class Security {
), E_USER_WARNING); ), E_USER_WARNING);
return null; return null;
} }
self::$hashCost = $cost; static::$hashCost = $cost;
} }
/** /**
@ -273,8 +273,8 @@ class Security {
*/ */
protected static function _crypt($password, $salt = false) { protected static function _crypt($password, $salt = false) {
if ($salt === false) { if ($salt === false) {
$salt = self::_salt(22); $salt = static::_salt(22);
$salt = vsprintf('$2a$%02d$%s', array(self::$hashCost, $salt)); $salt = vsprintf('$2a$%02d$%s', array(static::$hashCost, $salt));
} }
$invalidCipher = ( $invalidCipher = (
@ -307,7 +307,7 @@ class Security {
* @throws CakeException On invalid data or key. * @throws CakeException On invalid data or key.
*/ */
public static function encrypt($plain, $key, $hmacSalt = null) { public static function encrypt($plain, $key, $hmacSalt = null) {
self::_checkKey($key, 'encrypt()'); static::_checkKey($key, 'encrypt()');
if ($hmacSalt === null) { if ($hmacSalt === null) {
$hmacSalt = Configure::read('Security.salt'); $hmacSalt = Configure::read('Security.salt');
@ -350,7 +350,7 @@ class Security {
* @throws CakeException On invalid data or key. * @throws CakeException On invalid data or key.
*/ */
public static function decrypt($cipher, $key, $hmacSalt = null) { public static function decrypt($cipher, $key, $hmacSalt = null) {
self::_checkKey($key, 'decrypt()'); static::_checkKey($key, 'decrypt()');
if (empty($cipher)) { if (empty($cipher)) {
throw new CakeException(__d('cake_dev', 'The data to decrypt cannot be empty.')); throw new CakeException(__d('cake_dev', 'The data to decrypt cannot be empty.'));
} }

View file

@ -58,7 +58,7 @@ class Validation {
*/ */
public static function notEmpty($check) { public static function notEmpty($check) {
trigger_error('Validation::notEmpty() is deprecated. Use Validation::notBlank() instead.', E_USER_DEPRECATED); trigger_error('Validation::notEmpty() is deprecated. Use Validation::notBlank() instead.', E_USER_DEPRECATED);
return self::notBlank($check); return static::notBlank($check);
} }
/** /**
@ -74,13 +74,13 @@ class Validation {
*/ */
public static function notBlank($check) { public static function notBlank($check) {
if (is_array($check)) { if (is_array($check)) {
extract(self::_defaults($check)); extract(static::_defaults($check));
} }
if (empty($check) && (string)$check !== '0') { if (empty($check) && (string)$check !== '0') {
return false; return false;
} }
return self::_check($check, '/[^\s]+/m'); return static::_check($check, '/[^\s]+/m');
} }
/** /**
@ -96,13 +96,13 @@ class Validation {
*/ */
public static function alphaNumeric($check) { public static function alphaNumeric($check) {
if (is_array($check)) { if (is_array($check)) {
extract(self::_defaults($check)); extract(static::_defaults($check));
} }
if (empty($check) && $check != '0') { if (empty($check) && $check != '0') {
return false; return false;
} }
return self::_check($check, '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/Du'); return static::_check($check, '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/Du');
} }
/** /**
@ -131,7 +131,7 @@ class Validation {
* @deprecated Deprecated 2.6. Use Validator::lengthBetween() instead. * @deprecated Deprecated 2.6. Use Validator::lengthBetween() instead.
*/ */
public static function between($check, $min, $max) { public static function between($check, $min, $max) {
return self::lengthBetween($check, $min, $max); return static::lengthBetween($check, $min, $max);
} }
/** /**
@ -146,9 +146,9 @@ class Validation {
*/ */
public static function blank($check) { public static function blank($check) {
if (is_array($check)) { if (is_array($check)) {
extract(self::_defaults($check)); extract(static::_defaults($check));
} }
return !self::_check($check, '/[^\\s]/'); return !static::_check($check, '/[^\\s]/');
} }
/** /**
@ -167,7 +167,7 @@ class Validation {
*/ */
public static function cc($check, $type = 'fast', $deep = false, $regex = null) { public static function cc($check, $type = 'fast', $deep = false, $regex = null) {
if (is_array($check)) { if (is_array($check)) {
extract(self::_defaults($check)); extract(static::_defaults($check));
} }
$check = str_replace(array('-', ' '), '', $check); $check = str_replace(array('-', ' '), '', $check);
@ -176,8 +176,8 @@ class Validation {
} }
if ($regex !== null) { if ($regex !== null) {
if (self::_check($check, $regex)) { if (static::_check($check, $regex)) {
return self::luhn($check, $deep); return static::luhn($check, $deep);
} }
} }
$cards = array( $cards = array(
@ -205,23 +205,23 @@ class Validation {
foreach ($type as $value) { foreach ($type as $value) {
$regex = $cards['all'][strtolower($value)]; $regex = $cards['all'][strtolower($value)];
if (self::_check($check, $regex)) { if (static::_check($check, $regex)) {
return self::luhn($check, $deep); return static::luhn($check, $deep);
} }
} }
} elseif ($type === 'all') { } elseif ($type === 'all') {
foreach ($cards['all'] as $value) { foreach ($cards['all'] as $value) {
$regex = $value; $regex = $value;
if (self::_check($check, $regex)) { if (static::_check($check, $regex)) {
return self::luhn($check, $deep); return static::luhn($check, $deep);
} }
} }
} else { } else {
$regex = $cards['fast']; $regex = $cards['fast'];
if (self::_check($check, $regex)) { if (static::_check($check, $regex)) {
return self::luhn($check, $deep); return static::luhn($check, $deep);
} }
} }
return false; return false;
@ -282,7 +282,7 @@ class Validation {
} }
break; break;
default: default:
self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for %s', 'Validation::comparison()'); static::$errors[] = __d('cake_dev', 'You must define the $operator parameter for %s', 'Validation::comparison()');
} }
return false; return false;
} }
@ -297,13 +297,13 @@ class Validation {
*/ */
public static function custom($check, $regex = null) { public static function custom($check, $regex = null) {
if (is_array($check)) { if (is_array($check)) {
extract(self::_defaults($check)); extract(static::_defaults($check));
} }
if ($regex === null) { if ($regex === null) {
self::$errors[] = __d('cake_dev', 'You must define a regular expression for %s', 'Validation::custom()'); static::$errors[] = __d('cake_dev', 'You must define a regular expression for %s', 'Validation::custom()');
return false; return false;
} }
return self::_check($check, $regex); return static::_check($check, $regex);
} }
/** /**
@ -332,7 +332,7 @@ class Validation {
*/ */
public static function date($check, $format = 'ymd', $regex = null) { public static function date($check, $format = 'ymd', $regex = null) {
if ($regex !== null) { if ($regex !== null) {
return self::_check($check, $regex); return static::_check($check, $regex);
} }
$month = '(0[123456789]|10|11|12)'; $month = '(0[123456789]|10|11|12)';
$separator = '([- /.])'; $separator = '([- /.])';
@ -366,7 +366,7 @@ class Validation {
$format = (is_array($format)) ? array_values($format) : array($format); $format = (is_array($format)) ? array_values($format) : array($format);
foreach ($format as $key) { foreach ($format as $key) {
if (self::_check($check, $regex[$key]) === true) { if (static::_check($check, $regex[$key]) === true) {
return true; return true;
} }
} }
@ -391,7 +391,7 @@ class Validation {
if (!empty($parts) && count($parts) > 1) { if (!empty($parts) && count($parts) > 1) {
$time = array_pop($parts); $time = array_pop($parts);
$date = implode(' ', $parts); $date = implode(' ', $parts);
$valid = self::date($date, $dateFormat, $regex) && self::time($time); $valid = static::date($date, $dateFormat, $regex) && static::time($time);
} }
return $valid; return $valid;
} }
@ -405,7 +405,7 @@ class Validation {
* @return bool Success * @return bool Success
*/ */
public static function time($check) { public static function time($check) {
return self::_check($check, '%^((0?[1-9]|1[012])(:[0-5]\d){0,2} ?([AP]M|[ap]m))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$%'); return static::_check($check, '%^((0?[1-9]|1[012])(:[0-5]\d){0,2} ?([AP]M|[ap]m))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$%');
} }
/** /**
@ -461,7 +461,7 @@ class Validation {
$check = str_replace($data['thousands_sep'], '', $check); $check = str_replace($data['thousands_sep'], '', $check);
$check = str_replace($data['decimal_point'], '.', $check); $check = str_replace($data['decimal_point'], '.', $check);
return self::_check($check, $regex); return static::_check($check, $regex);
} }
/** /**
@ -477,18 +477,18 @@ class Validation {
*/ */
public static function email($check, $deep = false, $regex = null) { public static function email($check, $deep = false, $regex = null) {
if (is_array($check)) { if (is_array($check)) {
extract(self::_defaults($check)); extract(static::_defaults($check));
} }
if ($regex === null) { if ($regex === null) {
$regex = '/^[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/ui'; $regex = '/^[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . static::$_pattern['hostname'] . '$/ui';
} }
$return = self::_check($check, $regex); $return = static::_check($check, $regex);
if ($deep === false || $deep === null) { if ($deep === false || $deep === null) {
return $return; return $return;
} }
if ($return === true && preg_match('/@(' . self::$_pattern['hostname'] . ')$/i', $check, $regs)) { if ($return === true && preg_match('/@(' . static::$_pattern['hostname'] . ')$/i', $check, $regs)) {
if (function_exists('getmxrr') && getmxrr($regs[1], $mxhosts)) { if (function_exists('getmxrr') && getmxrr($regs[1], $mxhosts)) {
return true; return true;
} }
@ -520,7 +520,7 @@ class Validation {
*/ */
public static function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) { public static function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) {
if (is_array($check)) { if (is_array($check)) {
return self::extension(array_shift($check), $extensions); return static::extension(array_shift($check), $extensions);
} }
$extension = strtolower(pathinfo($check, PATHINFO_EXTENSION)); $extension = strtolower(pathinfo($check, PATHINFO_EXTENSION));
foreach ($extensions as $value) { foreach ($extensions as $value) {
@ -586,7 +586,7 @@ class Validation {
} else { } else {
$regex = '/^(?!\x{00a2})\p{Sc}?' . $money . '$/u'; $regex = '/^(?!\x{00a2})\p{Sc}?' . $money . '$/u';
} }
return self::_check($check, $regex); return static::_check($check, $regex);
} }
/** /**
@ -654,7 +654,7 @@ class Validation {
*/ */
public static function naturalNumber($check, $allowZero = false) { public static function naturalNumber($check, $allowZero = false) {
$regex = $allowZero ? '/^(?:0|[1-9][0-9]*)$/' : '/^[1-9][0-9]*$/'; $regex = $allowZero ? '/^(?:0|[1-9][0-9]*)$/' : '/^[1-9][0-9]*$/';
return self::_check($check, $regex); return static::_check($check, $regex);
} }
/** /**
@ -667,7 +667,7 @@ class Validation {
*/ */
public static function phone($check, $regex = null, $country = 'all') { public static function phone($check, $regex = null, $country = 'all') {
if (is_array($check)) { if (is_array($check)) {
extract(self::_defaults($check)); extract(static::_defaults($check));
} }
if ($regex === null) { if ($regex === null) {
@ -697,9 +697,9 @@ class Validation {
} }
} }
if (empty($regex)) { if (empty($regex)) {
return self::_pass('phone', $check, $country); return static::_pass('phone', $check, $country);
} }
return self::_check($check, $regex); return static::_check($check, $regex);
} }
/** /**
@ -712,7 +712,7 @@ class Validation {
*/ */
public static function postal($check, $regex = null, $country = 'us') { public static function postal($check, $regex = null, $country = 'us') {
if (is_array($check)) { if (is_array($check)) {
extract(self::_defaults($check)); extract(static::_defaults($check));
} }
if ($regex === null) { if ($regex === null) {
@ -738,9 +738,9 @@ class Validation {
} }
} }
if (empty($regex)) { if (empty($regex)) {
return self::_pass('postal', $check, $country); return static::_pass('postal', $check, $country);
} }
return self::_check($check, $regex); return static::_check($check, $regex);
} }
/** /**
@ -774,7 +774,7 @@ class Validation {
*/ */
public static function ssn($check, $regex = null, $country = null) { public static function ssn($check, $regex = null, $country = null) {
if (is_array($check)) { if (is_array($check)) {
extract(self::_defaults($check)); extract(static::_defaults($check));
} }
if ($regex === null) { if ($regex === null) {
@ -791,9 +791,9 @@ class Validation {
} }
} }
if (empty($regex)) { if (empty($regex)) {
return self::_pass('ssn', $check, $country); return static::_pass('ssn', $check, $country);
} }
return self::_check($check, $regex); return static::_check($check, $regex);
} }
/** /**
@ -814,14 +814,14 @@ class Validation {
* @return bool Success * @return bool Success
*/ */
public static function url($check, $strict = false) { public static function url($check, $strict = false) {
self::_populateIp(); static::_populateIp();
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9\p{L}\p{N}]|(%[0-9a-f]{2}))'; $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9\p{L}\p{N}]|(%[0-9a-f]{2}))';
$regex = '/^(?:(?:https?|ftps?|sftp|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') . $regex = '/^(?:(?:https?|ftps?|sftp|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
'(?:' . self::$_pattern['IPv4'] . '|\[' . self::$_pattern['IPv6'] . '\]|' . self::$_pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' . '(?:' . static::$_pattern['IPv4'] . '|\[' . static::$_pattern['IPv6'] . '\]|' . static::$_pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' .
'(?:\/?|\/' . $validChars . '*)?' . '(?:\/?|\/' . $validChars . '*)?' .
'(?:\?' . $validChars . '*)?' . '(?:\?' . $validChars . '*)?' .
'(?:#' . $validChars . '*)?$/iu'; '(?:#' . $validChars . '*)?$/iu';
return self::_check($check, $regex); return static::_check($check, $regex);
} }
/** /**
@ -863,7 +863,7 @@ class Validation {
*/ */
public static function uuid($check) { public static function uuid($check) {
$regex = '/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[0-5][a-fA-F0-9]{3}-[089aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$/'; $regex = '/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[0-5][a-fA-F0-9]{3}-[089aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$/';
return self::_check($check, $regex); return static::_check($check, $regex);
} }
/** /**
@ -912,7 +912,7 @@ class Validation {
* @return void * @return void
*/ */
protected static function _defaults($params) { protected static function _defaults($params) {
self::_reset(); static::_reset();
$defaults = array( $defaults = array(
'check' => null, 'check' => null,
'regex' => null, 'regex' => null,
@ -937,7 +937,7 @@ class Validation {
*/ */
public static function luhn($check, $deep = false) { public static function luhn($check, $deep = false) {
if (is_array($check)) { if (is_array($check)) {
extract(self::_defaults($check)); extract(static::_defaults($check));
} }
if ($deep !== true) { if ($deep !== true) {
return true; return true;
@ -981,7 +981,7 @@ class Validation {
} }
if (is_string($mimeTypes)) { if (is_string($mimeTypes)) {
return self::_check($mime, $mimeTypes); return static::_check($mime, $mimeTypes);
} }
foreach ($mimeTypes as $key => $val) { foreach ($mimeTypes as $key => $val) {
@ -1008,7 +1008,7 @@ class Validation {
} }
$filesize = filesize($check); $filesize = filesize($check);
return self::comparison($filesize, $operator, $size); return static::comparison($filesize, $operator, $size);
} }
/** /**
@ -1032,7 +1032,7 @@ class Validation {
* @return void * @return void
*/ */
protected static function _populateIp() { protected static function _populateIp() {
if (!isset(self::$_pattern['IPv6'])) { if (!isset(static::$_pattern['IPv6'])) {
$pattern = '((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}'; $pattern = '((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}';
$pattern .= '(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})'; $pattern .= '(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})';
$pattern .= '|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})'; $pattern .= '|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})';
@ -1048,11 +1048,11 @@ class Validation {
$pattern .= '\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4})'; $pattern .= '\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4})';
$pattern .= '{1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?'; $pattern .= '{1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?';
self::$_pattern['IPv6'] = $pattern; static::$_pattern['IPv6'] = $pattern;
} }
if (!isset(self::$_pattern['IPv4'])) { if (!isset(static::$_pattern['IPv4'])) {
$pattern = '(?:(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])'; $pattern = '(?:(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])';
self::$_pattern['IPv4'] = $pattern; static::$_pattern['IPv4'] = $pattern;
} }
} }
@ -1062,7 +1062,7 @@ class Validation {
* @return void * @return void
*/ */
protected static function _reset() { protected static function _reset() {
self::$errors = array(); static::$errors = array();
} }
} }

View file

@ -99,11 +99,11 @@ class Xml {
$options += $defaults; $options += $defaults;
if (is_array($input) || is_object($input)) { if (is_array($input) || is_object($input)) {
return self::fromArray((array)$input, $options); return static::fromArray((array)$input, $options);
} elseif (strpos($input, '<') !== false) { } elseif (strpos($input, '<') !== false) {
return self::_loadXml($input, $options); return static::_loadXml($input, $options);
} elseif ($options['readFile'] && file_exists($input)) { } elseif ($options['readFile'] && file_exists($input)) {
return self::_loadXml(file_get_contents($input), $options); return static::_loadXml(file_get_contents($input), $options);
} elseif ($options['readFile'] && strpos($input, 'http://') === 0 || strpos($input, 'https://') === 0) { } elseif ($options['readFile'] && strpos($input, 'http://') === 0 || strpos($input, 'https://') === 0) {
try { try {
$socket = new HttpSocket(array('request' => array('redirect' => 10))); $socket = new HttpSocket(array('request' => array('redirect' => 10)));
@ -111,7 +111,7 @@ class Xml {
if (!$response->isOk()) { if (!$response->isOk()) {
throw new XmlException(__d('cake_dev', 'XML cannot be read.')); throw new XmlException(__d('cake_dev', 'XML cannot be read.'));
} }
return self::_loadXml($response->body, $options); return static::_loadXml($response->body, $options);
} catch (SocketException $e) { } catch (SocketException $e) {
throw new XmlException(__d('cake_dev', 'XML cannot be read.')); throw new XmlException(__d('cake_dev', 'XML cannot be read.'));
} }
@ -218,7 +218,7 @@ class Xml {
if ($options['pretty']) { if ($options['pretty']) {
$dom->formatOutput = true; $dom->formatOutput = true;
} }
self::_fromArray($dom, $dom, $input, $options['format']); static::_fromArray($dom, $dom, $input, $options['format']);
$options['return'] = strtolower($options['return']); $options['return'] = strtolower($options['return']);
if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') { if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
@ -282,10 +282,10 @@ class Xml {
foreach ($value as $item) { foreach ($value as $item) {
$itemData = compact('dom', 'node', 'key', 'format'); $itemData = compact('dom', 'node', 'key', 'format');
$itemData['value'] = $item; $itemData['value'] = $item;
self::_createChild($itemData); static::_createChild($itemData);
} }
} else { // Struct } else { // Struct
self::_createChild(compact('dom', 'node', 'key', 'value', 'format')); static::_createChild(compact('dom', 'node', 'key', 'value', 'format'));
} }
} }
} else { } else {
@ -324,7 +324,7 @@ class Xml {
$child->setAttribute('xmlns', $childNS); $child->setAttribute('xmlns', $childNS);
} }
self::_fromArray($dom, $child, $value, $format); static::_fromArray($dom, $child, $value, $format);
$node->appendChild($child); $node->appendChild($child);
} }
@ -344,7 +344,7 @@ class Xml {
} }
$result = array(); $result = array();
$namespaces = array_merge(array('' => ''), $obj->getNamespaces(true)); $namespaces = array_merge(array('' => ''), $obj->getNamespaces(true));
self::_toArray($obj, $result, '', array_keys($namespaces)); static::_toArray($obj, $result, '', array_keys($namespaces));
return $result; return $result;
} }
@ -369,7 +369,7 @@ class Xml {
} }
foreach ($xml->children($namespace, true) as $child) { foreach ($xml->children($namespace, true) as $child) {
self::_toArray($child, $data, $namespace, $namespaces); static::_toArray($child, $data, $namespace, $namespaces);
} }
} }

View file

@ -428,7 +428,7 @@ class FormHelper extends AppHelper {
case 'delete': case 'delete':
$append .= $this->hidden('_method', array( $append .= $this->hidden('_method', array(
'name' => '_method', 'value' => strtoupper($options['type']), 'id' => null, 'name' => '_method', 'value' => strtoupper($options['type']), 'id' => null,
'secure' => self::SECURE_SKIP 'secure' => static::SECURE_SKIP
)); ));
default: default:
$htmlAttributes['method'] = 'post'; $htmlAttributes['method'] = 'post';
@ -488,7 +488,7 @@ class FormHelper extends AppHelper {
} }
return $this->hidden('_Token.key', array( return $this->hidden('_Token.key', array(
'value' => $this->request->params['_Token']['key'], 'id' => 'Token' . mt_rand(), 'value' => $this->request->params['_Token']['key'], 'id' => 'Token' . mt_rand(),
'secure' => self::SECURE_SKIP 'secure' => static::SECURE_SKIP
)); ));
} }
@ -1696,7 +1696,7 @@ class FormHelper extends AppHelper {
unset($options['secure']); unset($options['secure']);
$options = $this->_initInputField($fieldName, array_merge( $options = $this->_initInputField($fieldName, array_merge(
$options, array('secure' => self::SECURE_SKIP) $options, array('secure' => static::SECURE_SKIP)
)); ));
if ($secure === true) { if ($secure === true) {
@ -1717,7 +1717,7 @@ class FormHelper extends AppHelper {
public function file($fieldName, $options = array()) { public function file($fieldName, $options = array()) {
$options += array('secure' => true); $options += array('secure' => true);
$secure = $options['secure']; $secure = $options['secure'];
$options['secure'] = self::SECURE_SKIP; $options['secure'] = static::SECURE_SKIP;
$options = $this->_initInputField($fieldName, $options); $options = $this->_initInputField($fieldName, $options);
$field = $this->entity(); $field = $this->entity();
@ -2067,7 +2067,7 @@ class FormHelper extends AppHelper {
$id = $this->_extractOption('id', $attributes); $id = $this->_extractOption('id', $attributes);
$attributes = $this->_initInputField($fieldName, array_merge( $attributes = $this->_initInputField($fieldName, array_merge(
(array)$attributes, array('secure' => self::SECURE_SKIP) (array)$attributes, array('secure' => static::SECURE_SKIP)
)); ));
if (is_string($options) && isset($this->_options[$options])) { if (is_string($options) && isset($this->_options[$options])) {
@ -3007,7 +3007,7 @@ class FormHelper extends AppHelper {
$result['required'] = true; $result['required'] = true;
} }
if ($secure === self::SECURE_SKIP) { if ($secure === static::SECURE_SKIP) {
return $result; return $result;
} }

View file

@ -468,7 +468,7 @@ class View extends Object {
} }
if ($view !== false && $viewFileName = $this->_getViewFileName($view)) { if ($view !== false && $viewFileName = $this->_getViewFileName($view)) {
$this->_currentType = self::TYPE_VIEW; $this->_currentType = static::TYPE_VIEW;
$this->getEventManager()->dispatch(new CakeEvent('View.beforeRender', $this, array($viewFileName))); $this->getEventManager()->dispatch(new CakeEvent('View.beforeRender', $this, array($viewFileName)));
$this->Blocks->set('content', $this->_render($viewFileName)); $this->Blocks->set('content', $this->_render($viewFileName));
$this->getEventManager()->dispatch(new CakeEvent('View.afterRender', $this, array($viewFileName))); $this->getEventManager()->dispatch(new CakeEvent('View.afterRender', $this, array($viewFileName)));
@ -542,7 +542,7 @@ class View extends Object {
$this->viewVars['title_for_layout'] = $title; $this->viewVars['title_for_layout'] = $title;
$this->Blocks->set('title', $title); $this->Blocks->set('title', $title);
$this->_currentType = self::TYPE_LAYOUT; $this->_currentType = static::TYPE_LAYOUT;
$this->Blocks->set('content', $this->_render($layoutFileName)); $this->Blocks->set('content', $this->_render($layoutFileName));
$this->getEventManager()->dispatch(new CakeEvent('View.afterLayout', $this, array($layoutFileName))); $this->getEventManager()->dispatch(new CakeEvent('View.afterLayout', $this, array($layoutFileName)));
@ -728,11 +728,11 @@ class View extends Object {
* @throws LogicException when you extend an element which doesn't exist * @throws LogicException when you extend an element which doesn't exist
*/ */
public function extend($name) { public function extend($name) {
if ($name[0] === '/' || $this->_currentType === self::TYPE_VIEW) { if ($name[0] === '/' || $this->_currentType === static::TYPE_VIEW) {
$parent = $this->_getViewFileName($name); $parent = $this->_getViewFileName($name);
} else { } else {
switch ($this->_currentType) { switch ($this->_currentType) {
case self::TYPE_ELEMENT: case static::TYPE_ELEMENT:
$parent = $this->_getElementFileName($name); $parent = $this->_getElementFileName($name);
if (!$parent) { if (!$parent) {
list($plugin, $name) = $this->pluginSplit($name); list($plugin, $name) = $this->pluginSplit($name);
@ -745,7 +745,7 @@ class View extends Object {
)); ));
} }
break; break;
case self::TYPE_LAYOUT: case static::TYPE_LAYOUT:
$parent = $this->_getLayoutFileName($name); $parent = $this->_getLayoutFileName($name);
break; break;
default: default:
@ -1218,7 +1218,7 @@ class View extends Object {
protected function _renderElement($file, $data, $options) { protected function _renderElement($file, $data, $options) {
$current = $this->_current; $current = $this->_current;
$restore = $this->_currentType; $restore = $this->_currentType;
$this->_currentType = self::TYPE_ELEMENT; $this->_currentType = static::TYPE_ELEMENT;
if ($options['callbacks']) { if ($options['callbacks']) {
$this->getEventManager()->dispatch(new CakeEvent('View.beforeRender', $this, array($file))); $this->getEventManager()->dispatch(new CakeEvent('View.beforeRender', $this, array($file)));