diff --git a/lib/Cake/Cache/Cache.php b/lib/Cake/Cache/Cache.php index 416ef223d05..f7b855bb6aa 100644 --- a/lib/Cake/Cache/Cache.php +++ b/lib/Cake/Cache/Cache.php @@ -119,25 +119,25 @@ public static function config($name = null, $settings = array()) { } $current = array(); - if (isset(self::$_config[$name])) { - $current = self::$_config[$name]; + if (isset(static::$_config[$name])) { + $current = static::$_config[$name]; } if (!empty($settings)) { - self::$_config[$name] = array_merge($current, $settings); + static::$_config[$name] = array_merge($current, $settings); } - if (empty(self::$_config[$name]['engine'])) { + if (empty(static::$_config[$name]['engine'])) { return false; } - $engine = self::$_config[$name]['engine']; + $engine = static::$_config[$name]['engine']; - if (!isset(self::$_engines[$name])) { - self::_buildEngine($name); - $settings = self::$_config[$name] = self::settings($name); - } elseif ($settings = self::set(self::$_config[$name], null, $name)) { - self::$_config[$name] = $settings; + if (!isset(static::$_engines[$name])) { + static::_buildEngine($name); + $settings = static::$_config[$name] = static::settings($name); + } elseif ($settings = static::set(static::$_config[$name], null, $name)) { + static::$_config[$name] = $settings; } return compact('engine', 'settings'); } @@ -150,7 +150,7 @@ public static function config($name = null, $settings = array()) { * @throws CacheException */ protected static function _buildEngine($name) { - $config = self::$_config[$name]; + $config = static::$_config[$name]; $cacheClass = App::classname($config['engine'], 'Cache/Engine', 'Engine'); if (!$cacheClass) { @@ -159,10 +159,10 @@ protected static function _buildEngine($name) { if (!is_subclass_of($cacheClass, 'Cake\Cache\CacheEngine')) { throw new Error\CacheException(__d('cake_dev', 'Cache engines must use Cake\Cache\CacheEngine as a base class.')); } - self::$_engines[$name] = new $cacheClass(); - if (self::$_engines[$name]->init($config)) { - if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) { - self::$_engines[$name]->gc(); + static::$_engines[$name] = new $cacheClass(); + if (static::$_engines[$name]->init($config)) { + if (static::$_engines[$name]->settings['probability'] && time() % static::$_engines[$name]->settings['probability'] === 0) { + static::$_engines[$name]->gc(); } return true; } @@ -175,7 +175,7 @@ protected static function _buildEngine($name) { * @return array Array of configured Cache config names. */ public static function configured() { - return array_keys(self::$_config); + return array_keys(static::$_config); } /** @@ -187,10 +187,10 @@ public static function configured() { * @return boolean success of the removal, returns false when the config does not exist. */ public static function drop($name) { - if (!isset(self::$_config[$name])) { + if (!isset(static::$_config[$name])) { return false; } - unset(self::$_config[$name], self::$_engines[$name]); + unset(static::$_config[$name], static::$_engines[$name]); return true; } @@ -221,29 +221,29 @@ public static function set($settings = array(), $value = null, $config = 'defaul if (is_array($settings) && $value !== null) { $config = $value; } - if (!isset(self::$_config[$config]) || !isset(self::$_engines[$config])) { + if (!isset(static::$_config[$config]) || !isset(static::$_engines[$config])) { return false; } if (!empty($settings)) { - self::$_reset = true; + static::$_reset = true; } - if (self::$_reset === true) { + if (static::$_reset === true) { if (empty($settings)) { - self::$_reset = false; - $settings = self::$_config[$config]; + static::$_reset = false; + $settings = static::$_config[$config]; } else { if (is_string($settings) && $value !== null) { $settings = array($settings => $value); } - $settings = array_merge(self::$_config[$config], $settings); + $settings = array_merge(static::$_config[$config], $settings); if (isset($settings['duration']) && !is_numeric($settings['duration'])) { $settings['duration'] = strtotime($settings['duration']) - time(); } } - self::$_engines[$config]->settings = $settings; + static::$_engines[$config]->settings = $settings; } - return self::settings($config); + return static::settings($config); } /** @@ -256,7 +256,7 @@ public static function set($settings = array(), $value = null, $config = 'defaul * @return void */ public static function gc($config = 'default', $expires = null) { - self::$_engines[$config]->gc($expires); + static::$_engines[$config]->gc($expires); } /** @@ -280,29 +280,29 @@ public static function gc($config = 'default', $expires = null) { * @return boolean True if the data was successfully cached, false on failure */ public static function write($key, $value, $config = 'default') { - $settings = self::settings($config); + $settings = static::settings($config); if (empty($settings)) { return false; } - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $key = self::$_engines[$config]->key($key); + $key = static::$_engines[$config]->key($key); if (!$key || is_resource($value)) { return false; } - $success = self::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']); - self::set(null, $config); + $success = static::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']); + static::set(null, $config); if ($success === false && $value !== '') { trigger_error( __d('cake_dev', "%s cache was unable to write '%s' to %s cache", $config, $key, - self::$_engines[$config]->settings['engine'] + static::$_engines[$config]->settings['engine'] ), E_USER_WARNING ); @@ -330,19 +330,19 @@ public static function write($key, $value, $config = 'default') { * @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') { - $settings = self::settings($config); + $settings = static::settings($config); if (empty($settings)) { return false; } - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $key = self::$_engines[$config]->key($key); + $key = static::$_engines[$config]->key($key); if (!$key) { return false; } - return self::$_engines[$config]->read($settings['prefix'] . $key); + return static::$_engines[$config]->read($settings['prefix'] . $key); } /** @@ -355,21 +355,21 @@ public static function read($key, $config = 'default') { * or if there was an error fetching it. */ public static function increment($key, $offset = 1, $config = 'default') { - $settings = self::settings($config); + $settings = static::settings($config); if (empty($settings)) { return false; } - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $key = self::$_engines[$config]->key($key); + $key = static::$_engines[$config]->key($key); if (!$key || !is_integer($offset) || $offset < 0) { return false; } - $success = self::$_engines[$config]->increment($settings['prefix'] . $key, $offset); - self::set(null, $config); + $success = static::$_engines[$config]->increment($settings['prefix'] . $key, $offset); + static::set(null, $config); return $success; } @@ -383,21 +383,21 @@ public static function increment($key, $offset = 1, $config = 'default') { * or if there was an error fetching it */ public static function decrement($key, $offset = 1, $config = 'default') { - $settings = self::settings($config); + $settings = static::settings($config); if (empty($settings)) { return false; } - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $key = self::$_engines[$config]->key($key); + $key = static::$_engines[$config]->key($key); if (!$key || !is_integer($offset) || $offset < 0) { return false; } - $success = self::$_engines[$config]->decrement($settings['prefix'] . $key, $offset); - self::set(null, $config); + $success = static::$_engines[$config]->decrement($settings['prefix'] . $key, $offset); + static::set(null, $config); return $success; } @@ -419,21 +419,21 @@ public static function decrement($key, $offset = 1, $config = 'default') { * @return boolean 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') { - $settings = self::settings($config); + $settings = static::settings($config); if (empty($settings)) { return false; } - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $key = self::$_engines[$config]->key($key); + $key = static::$_engines[$config]->key($key); if (!$key) { return false; } - $success = self::$_engines[$config]->delete($settings['prefix'] . $key); - self::set(null, $config); + $success = static::$_engines[$config]->delete($settings['prefix'] . $key); + static::set(null, $config); return $success; } @@ -445,11 +445,11 @@ public static function delete($key, $config = 'default') { * @return boolean True if the cache was successfully cleared, false otherwise */ public static function clear($check = false, $config = 'default') { - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $success = self::$_engines[$config]->clear($check); - self::set(null, $config); + $success = static::$_engines[$config]->clear($check); + static::set(null, $config); return $success; } @@ -461,11 +461,11 @@ public static function clear($check = false, $config = 'default') { * @return boolean True if the cache group was successfully cleared, false otherwise */ public static function clearGroup($group, $config = 'default') { - if (!self::isInitialized($config)) { + if (!static::isInitialized($config)) { return false; } - $success = self::$_engines[$config]->clearGroup($group); - self::set(null, $config); + $success = static::$_engines[$config]->clearGroup($group); + static::set(null, $config); return $success; } @@ -479,7 +479,7 @@ public static function isInitialized($config = 'default') { if (Configure::read('Cache.disable')) { return false; } - return isset(self::$_engines[$config]); + return isset(static::$_engines[$config]); } /** @@ -490,8 +490,8 @@ public static function isInitialized($config = 'default') { * @see Cache::config() */ public static function settings($name = 'default') { - if (!empty(self::$_engines[$name])) { - return self::$_engines[$name]->settings(); + if (!empty(static::$_engines[$name])) { + return static::$_engines[$name]->settings(); } return array(); } diff --git a/lib/Cake/Console/ConsoleErrorHandler.php b/lib/Cake/Console/ConsoleErrorHandler.php index f979115ad0c..6de3db42212 100644 --- a/lib/Cake/Console/ConsoleErrorHandler.php +++ b/lib/Cake/Console/ConsoleErrorHandler.php @@ -40,10 +40,10 @@ class ConsoleErrorHandler { * @return ConsoleOutput */ public static function getStderr() { - if (empty(self::$stderr)) { - self::$stderr = new ConsoleOutput('php://stderr'); + if (empty(static::$stderr)) { + static::$stderr = new ConsoleOutput('php://stderr'); } - return self::$stderr; + return static::$stderr; } /** @@ -53,7 +53,7 @@ public static function getStderr() { * @return void */ public function handleException(\Exception $exception) { - $stderr = self::getStderr(); + $stderr = static::getStderr(); $stderr->write(__d('cake_console', "Error: %s\n%s", $exception->getMessage(), $exception->getTraceAsString() @@ -76,7 +76,7 @@ public function handleError($code, $description, $file = null, $line = null, $co if (error_reporting() === 0) { return; } - $stderr = self::getStderr(); + $stderr = static::getStderr(); list($name, $log) = ErrorHandler::mapErrorCode($code); $message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line); $stderr->write(__d('cake_console', "%s Error: %s\n", $name, $message)); diff --git a/lib/Cake/Console/ConsoleOutput.php b/lib/Cake/Console/ConsoleOutput.php index 78102b20f11..19304717e8a 100644 --- a/lib/Cake/Console/ConsoleOutput.php +++ b/lib/Cake/Console/ConsoleOutput.php @@ -154,7 +154,7 @@ public function __construct($stream = 'php://stdout') { $this->_output = fopen($stream, 'w'); if (DS == '\\' && !(bool)env('ANSICON')) { - $this->_outputAs = self::PLAIN; + $this->_outputAs = static::PLAIN; } } @@ -168,9 +168,9 @@ public function __construct($stream = 'php://stdout') { */ public function write($message, $newlines = 1) { 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))); } /** @@ -180,11 +180,11 @@ public function write($message, $newlines = 1) { * @return string String with color codes added. */ public function styleText($text) { - if ($this->_outputAs == self::RAW) { + if ($this->_outputAs == static::RAW) { return $text; } - if ($this->_outputAs == self::PLAIN) { - $tags = implode('|', array_keys(self::$_styles)); + if ($this->_outputAs == static::PLAIN) { + $tags = implode('|', array_keys(static::$_styles)); return preg_replace('##', '', $text); } return preg_replace_callback( @@ -205,16 +205,16 @@ protected function _replaceTags($matches) { } $styleInfo = array(); - if (!empty($style['text']) && isset(self::$_foregroundColors[$style['text']])) { - $styleInfo[] = self::$_foregroundColors[$style['text']]; + if (!empty($style['text']) && isset(static::$_foregroundColors[$style['text']])) { + $styleInfo[] = static::$_foregroundColors[$style['text']]; } - if (!empty($style['background']) && isset(self::$_backgroundColors[$style['background']])) { - $styleInfo[] = self::$_backgroundColors[$style['background']]; + if (!empty($style['background']) && isset(static::$_backgroundColors[$style['background']])) { + $styleInfo[] = static::$_backgroundColors[$style['background']]; } unset($style['text'], $style['background']); foreach ($style as $option => $value) { if ($value) { - $styleInfo[] = self::$_options[$option]; + $styleInfo[] = static::$_options[$option]; } } return "\033[" . implode($styleInfo, ';') . 'm' . $matches['text'] . "\033[0m"; @@ -257,16 +257,16 @@ protected function _write($message) { */ public function styles($style = null, $definition = null) { if ($style === null && $definition === null) { - return self::$_styles; + return static::$_styles; } 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) { - unset(self::$_styles[$style]); + unset(static::$_styles[$style]); return true; } - self::$_styles[$style] = $definition; + static::$_styles[$style] = $definition; return true; } diff --git a/lib/Cake/Controller/Component/Acl/PhpAcl.php b/lib/Cake/Controller/Component/Acl/PhpAcl.php index c09a63cfc9d..dab6cf65182 100644 --- a/lib/Cake/Controller/Component/Acl/PhpAcl.php +++ b/lib/Cake/Controller/Component/Acl/PhpAcl.php @@ -65,7 +65,7 @@ class PhpAcl extends Object implements AclInterface { */ public function __construct() { $this->options = array( - 'policy' => self::DENY, + 'policy' => static::DENY, 'config' => APP . 'Config' . DS . 'acl.php', ); } @@ -242,7 +242,7 @@ public function path($aco) { } 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])) { // merge allow/denies with $path of current level @@ -476,7 +476,7 @@ public function resolve($aro) { return $this->aliases[$mapped]; } } - return self::DEFAULT_ROLE; + return static::DEFAULT_ROLE; } /** diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 8dee00eef6d..1fdb88d2147 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -520,7 +520,7 @@ public function login($user = null) { } if ($user) { $this->Session->renew(); - $this->Session->write(self::$sessionKey, $user); + $this->Session->write(static::$sessionKey, $user); } return $this->loggedIn(); } @@ -545,7 +545,7 @@ public function logout() { foreach ($this->_authenticateObjects as $auth) { $auth->logout($user); } - $this->Session->delete(self::$sessionKey); + $this->Session->delete(static::$sessionKey); $this->Session->delete('Auth.redirect'); $this->Session->renew(); return Router::normalize($this->logoutRedirect); @@ -563,13 +563,13 @@ public function logout() { * @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#accessing-the-logged-in-user */ public static function user($key = null) { - if (empty(self::$_user) && !Session::check(self::$sessionKey)) { + if (empty(static::$_user) && !Session::check(static::$sessionKey)) { return null; } - if (!empty(self::$_user)) { - $user = self::$_user; + if (!empty(static::$_user)) { + $user = static::$_user; } else { - $user = Session::read(self::$sessionKey); + $user = Session::read(static::$sessionKey); } if ($key === null) { return $user; @@ -597,7 +597,7 @@ protected function _getUser() { foreach ($this->_authenticateObjects as $auth) { $result = $auth->getUser($this->request); if (!empty($result) && is_array($result)) { - self::$_user = $result; + static::$_user = $result; return true; } } diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 46bd8e79c4a..05cc426840f 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -156,9 +156,9 @@ public static function handleError($code, $description, $file = null, $line = nu return false; } $errorConfig = Configure::read('Error'); - list($error, $log) = self::mapErrorCode($code); + list($error, $log) = static::mapErrorCode($code); if ($log === LOG_ERR) { - return self::handleFatalError($code, $description, $file, $line); + return static::handleFatalError($code, $description, $file, $line); } $debug = Configure::read('debug'); diff --git a/lib/Cake/Event/EventManager.php b/lib/Cake/Event/EventManager.php index 1c2c952ff1e..c1618b5cd89 100644 --- a/lib/Cake/Event/EventManager.php +++ b/lib/Cake/Event/EventManager.php @@ -69,14 +69,14 @@ class EventManager { */ public static function instance($manager = null) { if ($manager instanceof EventManager) { - self::$_generalManager = $manager; + static::$_generalManager = $manager; } - if (empty(self::$_generalManager)) { - self::$_generalManager = new EventManager; + if (empty(static::$_generalManager)) { + static::$_generalManager = new EventManager; } - self::$_generalManager->_isGlobal = true; - return self::$_generalManager; + static::$_generalManager->_isGlobal = true; + return static::$_generalManager; } /** @@ -107,7 +107,7 @@ public function attach($callable, $eventKey = null, $options = array()) { $this->_attachSubscriber($callable); return; } - $options = $options + array('priority' => self::$defaultPriority, 'passParams' => false); + $options = $options + array('priority' => static::$defaultPriority, 'passParams' => false); $this->_listeners[$eventKey][$options['priority']][] = array( 'callable' => $callable, 'passParams' => $options['passParams'], @@ -229,7 +229,7 @@ public function dispatch($event) { } if (!$this->_isGlobal) { - self::instance()->dispatch($event); + static::instance()->dispatch($event); } if (empty($this->_listeners[$event->name()])) { diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 9bc5779d6fe..7cb56857956 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -162,7 +162,7 @@ public static function translate($singular, $plural = null, $domain = null, $cat } if (is_null($domain)) { - $domain = self::$defaultDomain; + $domain = static::$defaultDomain; } $_this->domain = $domain . '_' . $_this->l10n->lang; @@ -321,9 +321,9 @@ protected function _bindTextDomain($domain) { foreach ($this->l10n->languagePath as $lang) { $localeDef = $directory . $lang . DS . $this->category; if (is_file($localeDef)) { - $definitions = self::loadLocaleDefinition($localeDef); + $definitions = static::loadLocaleDefinition($localeDef); if ($definitions !== false) { - $this->_domains[$domain][$this->_lang][$this->category] = self::loadLocaleDefinition($localeDef); + $this->_domains[$domain][$this->_lang][$this->category] = static::loadLocaleDefinition($localeDef); $this->_noLocale = false; return $domain; } @@ -334,10 +334,10 @@ protected function _bindTextDomain($domain) { $translations = false; if (is_file($app . '.mo')) { - $translations = self::loadMo($app . '.mo'); + $translations = static::loadMo($app . '.mo'); } if ($translations === false && is_file($app . '.po')) { - $translations = self::loadPo($app . '.po'); + $translations = static::loadPo($app . '.po'); } if ($translations !== false) { @@ -352,10 +352,10 @@ protected function _bindTextDomain($domain) { $translations = false; if (is_file($file . '.mo')) { - $translations = self::loadMo($file . '.mo'); + $translations = static::loadMo($file . '.mo'); } if ($translations === false && is_file($file . '.po')) { - $translations = self::loadPo($file . '.po'); + $translations = static::loadPo($file . '.po'); } if ($translations !== false) { diff --git a/lib/Cake/I18n/Multibyte.php b/lib/Cake/I18n/Multibyte.php index 67fda3b2cfe..9773e3a6746 100644 --- a/lib/Cake/I18n/Multibyte.php +++ b/lib/Cake/I18n/Multibyte.php @@ -805,7 +805,7 @@ public static function strtolower($string) { $matched = true; } else { $matched = false; - $keys = self::_find($char, 'upper'); + $keys = static::_find($char, 'upper'); if (!empty($keys)) { foreach ($keys as $key => $value) { @@ -851,7 +851,7 @@ public static function strtoupper($string) { } else { $matched = false; - $keys = self::_find($char); + $keys = static::_find($char); $keyCount = count($keys); if (!empty($keys)) { @@ -1069,7 +1069,7 @@ protected static function _codepoint($decimal) { } else { $return = false; } - self::$_codeRange[$decimal] = $return; + static::$_codeRange[$decimal] = $return; return $return; } @@ -1082,8 +1082,8 @@ protected static function _codepoint($decimal) { */ protected static function _find($char, $type = 'lower') { $found = array(); - if (!isset(self::$_codeRange[$char])) { - $range = self::_codepoint($char); + if (!isset(static::$_codeRange[$char])) { + $range = static::_codepoint($char); if ($range === false) { return null; } @@ -1091,21 +1091,21 @@ protected static function _find($char, $type = 'lower') { Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS)); } Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_'); - self::$_caseFold[$range] = Configure::read($range); + static::$_caseFold[$range] = Configure::read($range); Configure::delete($range); } - if (!self::$_codeRange[$char]) { + if (!static::$_codeRange[$char]) { return null; } - self::$_table = self::$_codeRange[$char]; - $count = count(self::$_caseFold[self::$_table]); + static::$_table = static::$_codeRange[$char]; + $count = count(static::$_caseFold[static::$_table]); for ($i = 0; $i < $count; $i++) { - if ($type === 'lower' && self::$_caseFold[self::$_table][$i][$type][0] === $char) { - $found[] = self::$_caseFold[self::$_table][$i]; - } elseif ($type === 'upper' && self::$_caseFold[self::$_table][$i][$type] === $char) { - $found[] = self::$_caseFold[self::$_table][$i]; + if ($type === 'lower' && static::$_caseFold[static::$_table][$i][$type][0] === $char) { + $found[] = static::$_caseFold[static::$_table][$i]; + } elseif ($type === 'upper' && static::$_caseFold[static::$_table][$i][$type] === $char) { + $found[] = static::$_caseFold[static::$_table][$i]; } } return $found; diff --git a/lib/Cake/Log/Log.php b/lib/Cake/Log/Log.php index e4910180d46..b4741737ec5 100644 --- a/lib/Cake/Log/Log.php +++ b/lib/Cake/Log/Log.php @@ -120,8 +120,8 @@ class Log { * @return void */ protected static function _init() { - self::$_levels = self::defaultLevels(); - self::$_Collection = new LogEngineCollection(); + static::$_levels = static::defaultLevels(); + static::$_Collection = new LogEngineCollection(); } /** @@ -190,10 +190,10 @@ public static function config($key, $config) { if (empty($config['engine'])) { throw new Error\LogException(__d('cake_dev', 'Missing logger classname')); } - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - self::$_Collection->load($key, $config); + static::$_Collection->load($key, $config); return true; } @@ -203,10 +203,10 @@ public static function config($key, $config) { * @return array Array of configured log streams. */ public static function configured() { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - return self::$_Collection->attached(); + return static::$_Collection->attached(); } /** @@ -256,20 +256,20 @@ public static function configured() { * @return array active log levels */ public static function levels($levels = array(), $append = true) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } if (empty($levels)) { - return self::$_levels; + return static::$_levels; } $levels = array_values($levels); if ($append) { - self::$_levels = array_merge(self::$_levels, $levels); + static::$_levels = array_merge(static::$_levels, $levels); } else { - self::$_levels = $levels; + static::$_levels = $levels; } - self::$_levelMap = array_flip(self::$_levels); - return self::$_levels; + static::$_levelMap = array_flip(static::$_levels); + return static::$_levels; } /** @@ -278,9 +278,9 @@ public static function levels($levels = array(), $append = true) { * @return array default log levels */ public static function defaultLevels() { - self::$_levels = self::$_defaultLevels; - self::$_levelMap = array_flip(self::$_levels); - return self::$_levels; + static::$_levels = static::$_defaultLevels; + static::$_levelMap = array_flip(static::$_levels); + return static::$_levels; } /** @@ -291,10 +291,10 @@ public static function defaultLevels() { * @return void */ public static function drop($streamName) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - self::$_Collection->unload($streamName); + static::$_Collection->unload($streamName); } /** @@ -305,13 +305,13 @@ public static function drop($streamName) { * @throws Cake\Error\LogException */ public static function enabled($streamName) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - if (!isset(self::$_Collection->{$streamName})) { + if (!isset(static::$_Collection->{$streamName})) { throw new Error\LogException(__d('cake_dev', 'Stream %s not found', $streamName)); } - return self::$_Collection->enabled($streamName); + return static::$_Collection->enabled($streamName); } /** @@ -323,13 +323,13 @@ public static function enabled($streamName) { * @throws Cake\Error\LogException */ public static function enable($streamName) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - if (!isset(self::$_Collection->{$streamName})) { + if (!isset(static::$_Collection->{$streamName})) { throw new Error\LogException(__d('cake_dev', 'Stream %s not found', $streamName)); } - self::$_Collection->enable($streamName); + static::$_Collection->enable($streamName); } /** @@ -342,13 +342,13 @@ public static function enable($streamName) { * @throws Cake\Error\LogException */ public static function disable($streamName) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - if (!isset(self::$_Collection->{$streamName})) { + if (!isset(static::$_Collection->{$streamName})) { throw new Error\LogException(__d('cake_dev', 'Stream %s not found', $streamName)); } - self::$_Collection->disable($streamName); + static::$_Collection->disable($streamName); } /** @@ -359,11 +359,11 @@ public static function disable($streamName) { * @return $mixed instance of BaseLog or false if not found */ public static function stream($streamName) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - if (!empty(self::$_Collection->{$streamName})) { - return self::$_Collection->{$streamName}; + if (!empty(static::$_Collection->{$streamName})) { + return static::$_Collection->{$streamName}; } return false; } @@ -374,7 +374,7 @@ public static function stream($streamName) { * @return void */ protected static function _autoConfig() { - self::$_Collection->load('default', array( + static::$_Collection->load('default', array( 'engine' => 'Cake\Log\Engine\FileLog', 'path' => LOGS, )); @@ -411,19 +411,19 @@ protected static function _autoConfig() { * @return boolean Success */ public static function write($type, $message, $scope = array()) { - if (empty(self::$_Collection)) { - self::_init(); + if (empty(static::$_Collection)) { + static::_init(); } - if (is_int($type) && isset(self::$_levels[$type])) { - $type = self::$_levels[$type]; + if (is_int($type) && isset(static::$_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; } $logged = false; - foreach (self::$_Collection->enabled() as $streamName) { - $logger = self::$_Collection->{$streamName}; + foreach (static::$_Collection->enabled() as $streamName) { + $logger = static::$_Collection->{$streamName}; $types = null; $scopes = array(); if ($logger instanceof BaseLog) { @@ -447,8 +447,8 @@ public static function write($type, $message, $scope = array()) { } } if (!$logged) { - self::_autoConfig(); - self::stream('default')->write($type, $message); + static::_autoConfig(); + static::stream('default')->write($type, $message); } return true; } @@ -462,7 +462,7 @@ public static function write($type, $message, $scope = array()) { * @return boolean Success */ public static function emergency($message, $scope = array()) { - return self::write(self::$_levelMap['emergency'], $message, $scope); + return static::write(static::$_levelMap['emergency'], $message, $scope); } /** @@ -474,7 +474,7 @@ public static function emergency($message, $scope = array()) { * @return boolean Success */ public static function alert($message, $scope = array()) { - return self::write(self::$_levelMap['alert'], $message, $scope); + return static::write(static::$_levelMap['alert'], $message, $scope); } /** @@ -486,7 +486,7 @@ public static function alert($message, $scope = array()) { * @return boolean Success */ public static function critical($message, $scope = array()) { - return self::write(self::$_levelMap['critical'], $message, $scope); + return static::write(static::$_levelMap['critical'], $message, $scope); } /** @@ -498,7 +498,7 @@ public static function critical($message, $scope = array()) { * @return boolean Success */ public static function error($message, $scope = array()) { - return self::write(self::$_levelMap['error'], $message, $scope); + return static::write(static::$_levelMap['error'], $message, $scope); } /** @@ -510,7 +510,7 @@ public static function error($message, $scope = array()) { * @return boolean Success */ public static function warning($message, $scope = array()) { - return self::write(self::$_levelMap['warning'], $message, $scope); + return static::write(static::$_levelMap['warning'], $message, $scope); } /** @@ -522,7 +522,7 @@ public static function warning($message, $scope = array()) { * @return boolean Success */ public static function notice($message, $scope = array()) { - return self::write(self::$_levelMap['notice'], $message, $scope); + return static::write(static::$_levelMap['notice'], $message, $scope); } /** @@ -534,7 +534,7 @@ public static function notice($message, $scope = array()) { * @return boolean Success */ public static function debug($message, $scope = array()) { - return self::write(self::$_levelMap['debug'], $message, $scope); + return static::write(static::$_levelMap['debug'], $message, $scope); } /** @@ -546,7 +546,7 @@ public static function debug($message, $scope = array()) { * @return boolean Success */ public static function info($message, $scope = array()) { - return self::write(self::$_levelMap['info'], $message, $scope); + return static::write(static::$_levelMap['info'], $message, $scope); } } diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index 6ebf94b44ef..efcc134d4e0 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -70,9 +70,9 @@ protected static function _init() { include_once APP . 'Config' . DS . 'database.php'; $class = Configure::read('App.namespace') . '\Config\DATABASE_CONFIG'; if (class_exists($class)) { - self::$config = new $class(); + static::$config = new $class(); } - self::$_init = true; + static::$_init = true; } /** @@ -84,24 +84,24 @@ protected static function _init() { * @throws MissingDatasourceException */ public static function getDataSource($name) { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - if (!empty(self::$_dataSources[$name])) { - $return = self::$_dataSources[$name]; + if (!empty(static::$_dataSources[$name])) { + $return = static::$_dataSources[$name]; return $return; } - if (empty(self::$_connectionsEnum[$name])) { - self::_getConnectionObject($name); + if (empty(static::$_connectionsEnum[$name])) { + static::_getConnectionObject($name); } - $class = self::loadDataSource($name); - self::$_dataSources[$name] = new $class(self::$config->{$name}); - self::$_dataSources[$name]->configKeyName = $name; + $class = static::loadDataSource($name); + static::$_dataSources[$name] = new $class(static::$config->{$name}); + static::$_dataSources[$name]->configKeyName = $name; - return self::$_dataSources[$name]; + return static::$_dataSources[$name]; } /** @@ -112,10 +112,10 @@ public static function getDataSource($name) { * @return array List of available connections */ public static function sourceList() { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - return array_keys(self::$_dataSources); + return array_keys(static::$_dataSources); } /** @@ -126,10 +126,10 @@ public static function sourceList() { * in the ConnectionManager. */ public static function getSourceName($source) { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - foreach (self::$_dataSources as $name => $ds) { + foreach (static::$_dataSources as $name => $ds) { if ($ds === $source) { return $name; } @@ -147,14 +147,14 @@ public static function getSourceName($source) { * @throws Cake\Error\MissingDatasourceException */ public static function loadDataSource($connName) { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } if (is_array($connName)) { $conn = $connName; } else { - $conn = self::$_connectionsEnum[$connName]; + $conn = static::$_connectionsEnum[$connName]; } if (class_exists($conn['classname'], false)) { @@ -186,10 +186,10 @@ public static function loadDataSource($connName) { * (as defined in Connections), and the value is an array with keys 'filename' and 'classname'. */ public static function enumConnectionObjects() { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - return (array)self::$config; + return (array)static::$config; } /** @@ -200,16 +200,16 @@ public static function enumConnectionObjects() { * @return DataSource A reference to the DataSource object, or null if creation failed */ public static function create($name = '', $config = array()) { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_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; } - self::$config->{$name} = $config; - self::$_connectionsEnum[$name] = self::_connectionData($config); - $return = self::getDataSource($name); + static::$config->{$name} = $config; + static::$_connectionsEnum[$name] = static::_connectionData($config); + $return = static::getDataSource($name); return $return; } @@ -220,14 +220,14 @@ public static function create($name = '', $config = array()) { * @return boolean success if connection was removed, false if it does not exist */ public static function drop($name) { - if (empty(self::$_init)) { - self::_init(); + if (empty(static::$_init)) { + static::_init(); } - if (!isset(self::$config->{$name})) { + if (!isset(static::$config->{$name})) { return false; } - unset(self::$_connectionsEnum[$name], self::$_dataSources[$name], self::$config->{$name}); + unset(static::$_connectionsEnum[$name], static::$_dataSources[$name], static::$config->{$name}); return true; } @@ -239,8 +239,8 @@ public static function drop($name) { * @throws MissingDatasourceConfigException */ protected static function _getConnectionObject($name) { - if (!empty(self::$config->{$name})) { - self::$_connectionsEnum[$name] = self::_connectionData(self::$config->{$name}); + if (!empty(static::$config->{$name})) { + static::$_connectionsEnum[$name] = static::_connectionData(static::$config->{$name}); } else { throw new Error\MissingDatasourceConfigException(array('config' => $name)); } diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 276b5bc3e0a..802d5194c35 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -504,7 +504,7 @@ public function renderStatement($type, $data) { $page = intval($limitOffset[1] / $limitOffset[2]); $offset = intval($limitOffset[2] * $page); - $rowCounter = self::ROW_COUNTER; + $rowCounter = static::ROW_COUNTER; return " SELECT {$limit} * FROM ( SELECT {$fields}, ROW_NUMBER() OVER ({$order}) AS {$rowCounter} @@ -595,7 +595,7 @@ public function fetchResult() { $resultRow = array(); foreach ($this->map as $col => $meta) { list($table, $column, $type) = $meta; - if ($table === 0 && $column === self::ROW_COUNTER) { + if ($table === 0 && $column === static::ROW_COUNTER) { continue; } $resultRow[$table][$column] = $row[$col]; diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index d14d2bbe0c0..bf1f3d9b0fa 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -765,7 +765,7 @@ public function field($name, $sql) { */ public function flushMethodCache() { $this->_methodCacheChange = true; - self::$methodCache = array(); + static::$methodCache = array(); } /** @@ -784,14 +784,14 @@ public function cacheMethod($method, $key, $value = null) { if ($this->cacheMethods === false) { return $value; } - if (empty(self::$methodCache)) { - self::$methodCache = Cache::read('method_cache', '_cake_core_'); + if (empty(static::$methodCache)) { + static::$methodCache = Cache::read('method_cache', '_cake_core_'); } 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; - return self::$methodCache[$method][$key] = $value; + return static::$methodCache[$method][$key] = $value; } /** @@ -3268,7 +3268,7 @@ public function getQueryCache($sql, $params = array()) { */ public function __destruct() { if ($this->_methodCacheChange) { - Cache::write('method_cache', self::$methodCache, '_cake_core_'); + Cache::write('method_cache', static::$methodCache, '_cake_core_'); } } diff --git a/lib/Cake/Model/Datasource/Session.php b/lib/Cake/Model/Datasource/Session.php index f6fccdf70e3..f586c454ef2 100644 --- a/lib/Cake/Model/Datasource/Session.php +++ b/lib/Cake/Model/Datasource/Session.php @@ -129,14 +129,14 @@ class Session { * @return void */ public static function init($base = null) { - self::$time = time(); + static::$time = time(); $checkAgent = Configure::read('Session.checkAgent'); if (($checkAgent === true || $checkAgent === null) && env('HTTP_USER_AGENT') != null) { - 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); - self::_setHost(env('HTTP_HOST')); + static::_setPath($base); + static::_setHost(env('HTTP_HOST')); } /** @@ -147,7 +147,7 @@ public static function init($base = null) { */ protected static function _setPath($base = null) { if (empty($base)) { - self::$path = '/'; + static::$path = '/'; return; } if (strpos($base, 'index.php') !== false) { @@ -156,7 +156,7 @@ protected static function _setPath($base = null) { if (strpos($base, '?') !== false) { $base = str_replace('?', '', $base); } - self::$path = $base; + static::$path = $base; } /** @@ -166,9 +166,9 @@ protected static function _setPath($base = null) { * @return void */ protected static function _setHost($host) { - self::$host = $host; - if (strpos(self::$host, ':') !== false) { - self::$host = substr(self::$host, 0, strpos(self::$host, ':')); + static::$host = $host; + if (strpos(static::$host, ':') !== false) { + static::$host = substr(static::$host, 0, strpos(static::$host, ':')); } } @@ -178,21 +178,21 @@ protected static function _setHost($host) { * @return boolean True if session was started */ public static function start() { - if (self::started()) { + if (static::started()) { return true; } - self::init(); - $id = self::id(); + static::init(); + $id = static::id(); session_write_close(); - self::_configureSession(); - self::_startSession(); + static::_configureSession(); + static::_startSession(); - if (!$id && self::started()) { - self::_checkValid(); + if (!$id && static::started()) { + static::_checkValid(); } - self::$error = false; - return self::started(); + static::$error = false; + return static::started(); } /** @@ -211,7 +211,7 @@ public static function started() { * @return boolean True if variable is there */ public static function check($name = null) { - if (!self::started() && !self::start()) { + if (!static::started() && !static::start()) { return false; } if (empty($name)) { @@ -229,13 +229,13 @@ public static function check($name = null) { */ public static function id($id = null) { if ($id) { - self::$id = $id; - session_id(self::$id); + static::$id = $id; + session_id(static::$id); } - if (self::started()) { + if (static::started()) { return session_id(); } - return self::$id; + return static::$id; } /** @@ -245,11 +245,11 @@ public static function id($id = null) { * @return boolean Success */ public static function delete($name) { - if (self::check($name)) { - self::_overwrite($_SESSION, Hash::remove($_SESSION, $name)); - return (self::check($name) == false); + if (static::check($name)) { + static::_overwrite($_SESSION, Hash::remove($_SESSION, $name)); + return (static::check($name) == false); } - self::_setError(2, __d('cake_dev', "%s doesn't exist", $name)); + static::_setError(2, __d('cake_dev', "%s doesn't exist", $name)); return false; } @@ -280,10 +280,10 @@ protected static function _overwrite(&$old, $new) { * @return string Error as string */ 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; } else { - return self::$error[$errorNumber]; + return static::$error[$errorNumber]; } } @@ -293,8 +293,8 @@ protected static function _error($errorNumber) { * @return mixed Error description as a string, or false. */ public static function error() { - if (self::$lastError) { - return self::_error(self::$lastError); + if (static::$lastError) { + return static::_error(static::$lastError); } return false; } @@ -305,32 +305,32 @@ public static function error() { * @return boolean Success */ public static function valid() { - if (self::read('Config')) { - if (self::_validAgentAndTime() && self::$error === false) { - self::$valid = true; + if (static::read('Config')) { + if (static::_validAgentAndTime() && static::$error === false) { + static::$valid = true; } else { - self::$valid = false; - self::_setError(1, 'Session Highjacking Attempted !!!'); + static::$valid = false; + 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'. - * Since timeouts are implemented in Session it checks the current self::$time + * Since timeouts are implemented in Session it checks the current static::$time * against the time the session is set to expire. The User agent is only checked * if Session.checkAgent == true. * * @return boolean */ protected static function _validAgentAndTime() { - $config = self::read('Config'); + $config = static::read('Config'); $validAgent = ( Configure::read('Session.checkAgent') === false || - self::$_userAgent == $config['userAgent'] + static::$_userAgent == $config['userAgent'] ); - return ($validAgent && self::$time <= $config['time']); + return ($validAgent && static::$time <= $config['time']); } /** @@ -341,12 +341,12 @@ protected static function _validAgentAndTime() { */ public static function userAgent($userAgent = null) { if ($userAgent) { - self::$_userAgent = $userAgent; + static::$_userAgent = $userAgent; } - if (empty(self::$_userAgent)) { - Session::init(self::$path); + if (empty(static::$_userAgent)) { + Session::init(static::$path); } - return self::$_userAgent; + return static::$_userAgent; } /** @@ -356,11 +356,11 @@ public static function userAgent($userAgent = null) { * @return mixed The value of the session variable */ public static function read($name = null) { - if (!self::started() && !self::start()) { + if (!static::started() && !static::start()) { return false; } if (is_null($name)) { - return self::_returnSessionVars(); + return static::_returnSessionVars(); } if (empty($name)) { return false; @@ -370,7 +370,7 @@ public static function read($name = null) { if (isset($result)) { return $result; } - self::_setError(2, "$name doesn't exist"); + static::_setError(2, "$name doesn't exist"); return null; } @@ -383,7 +383,7 @@ protected static function _returnSessionVars() { if (!empty($_SESSION)) { return $_SESSION; } - self::_setError(2, 'No Session vars set'); + static::_setError(2, 'No Session vars set'); return false; } @@ -395,7 +395,7 @@ protected static function _returnSessionVars() { * @return boolean True if the write was successful, false if the write failed */ public static function write($name, $value = null) { - if (!self::started() && !self::start()) { + if (!static::started() && !static::start()) { return false; } if (empty($name)) { @@ -406,7 +406,7 @@ public static function write($name, $value = null) { $write = array($name => $value); } 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) { return false; } @@ -420,10 +420,10 @@ public static function write($name, $value = null) { * @return void */ public static function destroy() { - if (self::started()) { + if (static::started()) { session_destroy(); } - self::clear(); + static::clear(); } /** @@ -433,9 +433,9 @@ public static function destroy() { */ public static function clear() { $_SESSION = null; - self::$id = null; - self::start(); - self::renew(); + static::$id = null; + static::start(); + static::renew(); } /** @@ -451,7 +451,7 @@ protected static function _configureSession() { $iniSet = function_exists('ini_set'); if (isset($sessionConfig['defaults'])) { - $defaults = self::_defaultConfig($sessionConfig['defaults']); + $defaults = static::_defaultConfig($sessionConfig['defaults']); if ($defaults) { $sessionConfig = Hash::merge($defaults, $sessionConfig); } @@ -491,7 +491,7 @@ protected static function _configureSession() { call_user_func_array('session_set_save_handler', $sessionConfig['handler']); } if (!empty($sessionConfig['handler']['engine'])) { - $handler = self::_getHandler($sessionConfig['handler']['engine']); + $handler = static::_getHandler($sessionConfig['handler']['engine']); session_set_save_handler( array($handler, 'open'), array($handler, 'close'), @@ -502,7 +502,7 @@ protected static function _configureSession() { ); } Configure::write('Session', $sessionConfig); - self::$sessionTime = self::$time + ($sessionConfig['timeout'] * 60); + static::$sessionTime = static::$time + ($sessionConfig['timeout'] * 60); } /** @@ -536,7 +536,7 @@ protected static function _defaultConfig($name) { 'timeout' => 240, 'ini' => array( 'session.use_trans_sid' => 0, - 'session.cookie_path' => self::$path + 'session.cookie_path' => static::$path ) ), 'cake' => array( @@ -547,7 +547,7 @@ protected static function _defaultConfig($name) { 'url_rewriter.tags' => '', 'session.serialize_handler' => 'php', 'session.use_cookies' => 1, - 'session.cookie_path' => self::$path, + 'session.cookie_path' => static::$path, 'session.auto_start' => 0, 'session.save_path' => TMP . 'sessions', 'session.save_handler' => 'files' @@ -561,7 +561,7 @@ protected static function _defaultConfig($name) { 'url_rewriter.tags' => '', 'session.auto_start' => 0, 'session.use_cookies' => 1, - 'session.cookie_path' => self::$path, + 'session.cookie_path' => static::$path, 'session.save_handler' => 'user', ), 'handler' => array( @@ -577,7 +577,7 @@ protected static function _defaultConfig($name) { 'url_rewriter.tags' => '', 'session.auto_start' => 0, 'session.use_cookies' => 1, - 'session.cookie_path' => self::$path, + 'session.cookie_path' => static::$path, 'session.save_handler' => 'user', 'session.serialize_handler' => 'php', ), @@ -617,36 +617,36 @@ protected static function _startSession() { * @return void */ protected static function _checkValid() { - if (!self::started() && !self::start()) { - self::$valid = false; + if (!static::started() && !static::start()) { + static::$valid = false; return false; } - if ($config = self::read('Config')) { + if ($config = static::read('Config')) { $sessionConfig = Configure::read('Session'); - if (self::_validAgentAndTime()) { - self::write('Config.time', self::$sessionTime); + if (static::_validAgentAndTime()) { + static::write('Config.time', static::$sessionTime); if (isset($sessionConfig['autoRegenerate']) && $sessionConfig['autoRegenerate'] === true) { $check = $config['countdown']; $check -= 1; - self::write('Config.countdown', $check); + static::write('Config.countdown', $check); if ($check < 1) { - self::renew(); - self::write('Config.countdown', self::$requestCountdown); + static::renew(); + static::write('Config.countdown', static::$requestCountdown); } } - self::$valid = true; + static::$valid = true; } else { - self::destroy(); - self::$valid = false; - self::_setError(1, 'Session Highjacking Attempted !!!'); + static::destroy(); + static::$valid = false; + static::_setError(1, 'Session Highjacking Attempted !!!'); } } else { - self::write('Config.userAgent', self::$_userAgent); - self::write('Config.time', self::$sessionTime); - self::write('Config.countdown', self::$requestCountdown); - self::$valid = true; + static::write('Config.userAgent', static::$_userAgent); + static::write('Config.time', static::$sessionTime); + static::write('Config.countdown', static::$requestCountdown); + static::$valid = true; } } @@ -658,7 +658,7 @@ protected static function _checkValid() { public static function renew() { if (session_id()) { if (session_id() != '' || 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); } @@ -672,11 +672,11 @@ public static function renew() { * @return void */ protected static function _setError($errorNumber, $errorMessage) { - if (self::$error === false) { - self::$error = array(); + if (static::$error === false) { + static::$error = array(); } - self::$error[$errorNumber] = $errorMessage; - self::$lastError = $errorNumber; + static::$error[$errorNumber] = $errorMessage; + static::$lastError = $errorNumber; } } diff --git a/lib/Cake/Network/Email/Email.php b/lib/Cake/Network/Email/Email.php index e0d80892b8b..babad2bcd9d 100644 --- a/lib/Cake/Network/Email/Email.php +++ b/lib/Cake/Network/Email/Email.php @@ -704,7 +704,7 @@ public function getHeaders($include = array()) { $headers += $this->_headers; if (!isset($headers['X-Mailer'])) { - $headers['X-Mailer'] = self::EMAIL_CLIENT; + $headers['X-Mailer'] = static::EMAIL_CLIENT; } if (!isset($headers['Date'])) { $headers['Date'] = date(DATE_RFC2822); @@ -1005,9 +1005,9 @@ public function addAttachments($attachments) { */ public function message($type = null) { switch ($type) { - case self::MESSAGE_HTML: + case static::MESSAGE_HTML: return $this->_htmlMessage; - case self::MESSAGE_TEXT: + case static::MESSAGE_TEXT: return $this->_textMessage; } return $this->_message; @@ -1245,7 +1245,7 @@ protected function _wrap($message) { continue; } if (!preg_match('/\<[a-z]/i', $line)) { - $formatted = array_merge($formatted, explode("\n", wordwrap($line, self::LINE_LENGTH_SHOULD, "\n"))); + $formatted = array_merge($formatted, explode("\n", wordwrap($line, static::LINE_LENGTH_SHOULD, "\n"))); continue; } @@ -1258,7 +1258,7 @@ protected function _wrap($message) { $tag .= $char; if ($char === '>') { $tagLength = strlen($tag); - if ($tagLength + $tmpLineLength < self::LINE_LENGTH_SHOULD) { + if ($tagLength + $tmpLineLength < static::LINE_LENGTH_SHOULD) { $tmpLine .= $tag; $tmpLineLength += $tagLength; } else { @@ -1267,7 +1267,7 @@ protected function _wrap($message) { $tmpLine = ''; $tmpLineLength = 0; } - if ($tagLength > self::LINE_LENGTH_SHOULD) { + if ($tagLength > static::LINE_LENGTH_SHOULD) { $formatted[] = $tag; } else { $tmpLine = $tag; @@ -1284,14 +1284,14 @@ protected function _wrap($message) { $tag = '<'; continue; } - if ($char === ' ' && $tmpLineLength >= self::LINE_LENGTH_SHOULD) { + if ($char === ' ' && $tmpLineLength >= static::LINE_LENGTH_SHOULD) { $formatted[] = $tmpLine; $tmpLineLength = 0; continue; } $tmpLine .= $char; $tmpLineLength++; - if ($tmpLineLength === self::LINE_LENGTH_SHOULD) { + if ($tmpLineLength === static::LINE_LENGTH_SHOULD) { $nextChar = $line[$i + 1]; if ($nextChar === ' ' || $nextChar === '<') { $formatted[] = trim($tmpLine); diff --git a/lib/Cake/Network/Http/BasicAuthentication.php b/lib/Cake/Network/Http/BasicAuthentication.php index ba9f35a6182..e7e547bffc1 100644 --- a/lib/Cake/Network/Http/BasicAuthentication.php +++ b/lib/Cake/Network/Http/BasicAuthentication.php @@ -35,7 +35,7 @@ class BasicAuthentication { */ public static function authentication(HttpSocket $http, &$authInfo) { 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']); } } @@ -49,7 +49,7 @@ public static function authentication(HttpSocket $http, &$authInfo) { */ public static function proxyAuthentication(HttpSocket $http, &$proxyInfo) { 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']); } } diff --git a/lib/Cake/Network/Http/DigestAuthentication.php b/lib/Cake/Network/Http/DigestAuthentication.php index f16335f876f..e2eae75e3bf 100644 --- a/lib/Cake/Network/Http/DigestAuthentication.php +++ b/lib/Cake/Network/Http/DigestAuthentication.php @@ -35,10 +35,10 @@ class DigestAuthentication { */ public static function authentication(HttpSocket $http, &$authInfo) { if (isset($authInfo['user'], $authInfo['pass'])) { - if (!isset($authInfo['realm']) && !self::_getServerInformation($http, $authInfo)) { + if (!isset($authInfo['realm']) && !static::_getServerInformation($http, $authInfo)) { return; } - $http->request['header']['Authorization'] = self::_generateHeader($http, $authInfo); + $http->request['header']['Authorization'] = static::_generateHeader($http, $authInfo); } } diff --git a/lib/Cake/Network/Request.php b/lib/Cake/Network/Request.php index 45b85bffe6f..a5cc99f9cc3 100644 --- a/lib/Cake/Network/Request.php +++ b/lib/Cake/Network/Request.php @@ -727,7 +727,7 @@ public function parseAccept() { * @return If a $language is provided, a boolean. Otherwise the array of accepted languages. */ public static function acceptLanguage($language = null) { - $accepts = preg_split('/[;,]/', self::header('Accept-Language')); + $accepts = preg_split('/[;,]/', static::header('Accept-Language')); foreach ($accepts as &$accept) { $accept = strtolower($accept); if (strpos($accept, '_') !== false) { diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index b1eeca19d64..d25d89b1006 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -175,10 +175,10 @@ class Router { */ public static function defaultRouteClass($routeClass = null) { if (is_null($routeClass)) { - return self::$_routeClass; + return static::$_routeClass; } - self::$_routeClass = self::_validateRouteClass($routeClass); + static::$_routeClass = static::_validateRouteClass($routeClass); } /** @@ -203,7 +203,7 @@ protected static function _validateRouteClass($routeClass) { protected static function _setPrefixes() { $routing = Configure::read('Routing'); if (!empty($routing['prefixes'])) { - self::$_prefixes = array_merge(self::$_prefixes, (array)$routing['prefixes']); + static::$_prefixes = array_merge(static::$_prefixes, (array)$routing['prefixes']); } } @@ -214,7 +214,7 @@ protected static function _setPrefixes() { * @see Router::$_namedExpressions */ public static function getNamedExpressions() { - return self::$_namedExpressions; + return static::$_namedExpressions; } /** @@ -226,9 +226,9 @@ public static function getNamedExpressions() { */ public static function resourceMap($resourceMap = null) { if ($resourceMap === null) { - return self::$_resourceMap; + return static::$_resourceMap; } - self::$_resourceMap = $resourceMap; + static::$_resourceMap = $resourceMap; } /** @@ -288,7 +288,7 @@ public static function resourceMap($resourceMap = null) { * @throws RouterException */ public static function connect($route, $defaults = array(), $options = array()) { - foreach (self::$_prefixes as $prefix) { + foreach (static::$_prefixes as $prefix) { if (isset($defaults[$prefix])) { if ($defaults[$prefix]) { $defaults['prefix'] = $prefix; @@ -299,23 +299,23 @@ public static function connect($route, $defaults = array(), $options = array()) } } if (isset($defaults['prefix'])) { - self::$_prefixes[] = $defaults['prefix']; - self::$_prefixes = array_keys(array_flip(self::$_prefixes)); + static::$_prefixes[] = $defaults['prefix']; + static::$_prefixes = array_keys(array_flip(static::$_prefixes)); } $defaults += array('plugin' => null); if (empty($options['action'])) { $defaults += array('action' => 'index'); } - $routeClass = self::$_routeClass; + $routeClass = static::$_routeClass; if (isset($options['routeClass'])) { - $routeClass = self::_validateRouteClass($options['routeClass']); + $routeClass = static::_validateRouteClass($options['routeClass']); unset($options['routeClass']); } if ($routeClass === 'Cake\Routing\Route\RedirectRoute' && isset($defaults['redirect'])) { $defaults = $defaults['redirect']; } - self::$routes[] = new $routeClass($route, $defaults, $options); - return self::$routes; + static::$routes[] = new $routeClass($route, $defaults, $options); + return static::$routes; } /** @@ -355,7 +355,7 @@ public static function redirect($route, $url, $options = array()) { if (is_string($url)) { $url = array('redirect' => $url); } - return self::connect($route, $url, $options); + return static::connect($route, $url, $options); } /** @@ -412,7 +412,7 @@ public static function redirect($route, $url, $options = array()) { */ public static function connectNamed($named, $options = array()) { if (isset($options['separator'])) { - self::$_namedConfig['separator'] = $options['separator']; + static::$_namedConfig['separator'] = $options['separator']; unset($options['separator']); } @@ -423,23 +423,23 @@ public static function connectNamed($named, $options = array()) { $options = array_merge(array('default' => false, 'reset' => false, 'greedy' => true), $options); } - if ($options['reset'] == true || self::$_namedConfig['rules'] === false) { - self::$_namedConfig['rules'] = array(); + if ($options['reset'] == true || static::$_namedConfig['rules'] === false) { + static::$_namedConfig['rules'] = array(); } if ($options['default']) { - $named = array_merge($named, self::$_namedConfig['default']); + $named = array_merge($named, static::$_namedConfig['default']); } foreach ($named as $key => $val) { if (is_numeric($key)) { - self::$_namedConfig['rules'][$val] = true; + static::$_namedConfig['rules'][$val] = true; } else { - self::$_namedConfig['rules'][$key] = $val; + static::$_namedConfig['rules'][$key] = $val; } } - self::$_namedConfig['greedyNamed'] = $options['greedy']; - return self::$_namedConfig; + static::$_namedConfig['greedyNamed'] = $options['greedy']; + return static::$_namedConfig; } /** @@ -449,7 +449,7 @@ public static function connectNamed($named, $options = array()) { * @see Router::$_namedConfig */ public static function namedConfig() { - return self::$_namedConfig; + return static::$_namedConfig; } /** @@ -471,7 +471,7 @@ public static function mapResources($controller, $options = array()) { $hasPrefix = isset($options['prefix']); $options = array_merge(array( 'prefix' => '/', - 'id' => self::ID . '|' . self::UUID + 'id' => static::ID . '|' . static::UUID ), $options); $prefix = $options['prefix']; @@ -484,7 +484,7 @@ public static function mapResources($controller, $options = array()) { $prefix = '/' . $plugin . '/'; } - foreach (self::$_resourceMap as $params) { + foreach (static::$_resourceMap as $params) { $url = $prefix . $urlName . (($params['id']) ? '/:id' : ''); Router::connect($url, @@ -497,9 +497,9 @@ public static function mapResources($controller, $options = array()) { array('id' => $options['id'], 'pass' => array('id')) ); } - self::$_resourceMapped[] = $urlName; + static::$_resourceMapped[] = $urlName; } - return self::$_resourceMapped; + return static::$_resourceMapped; } /** @@ -508,7 +508,7 @@ public static function mapResources($controller, $options = array()) { * @return array A list of prefixes used in connected routes */ public static function prefixes() { - return self::$_prefixes; + return static::$_prefixes; } /** @@ -528,13 +528,13 @@ public static function parse($url) { $url = substr($url, 0, strpos($url, '?')); } - extract(self::_parseExtension($url)); + extract(static::_parseExtension($url)); - for ($i = 0, $len = count(self::$routes); $i < $len; $i++) { - $route =& self::$routes[$i]; + for ($i = 0, $len = count(static::$routes); $i < $len; $i++) { + $route =& static::$routes[$i]; if (($r = $route->parse($url)) !== false) { - self::$_currentRoute[] =& $route; + static::$_currentRoute[] =& $route; $out = $r; break; } @@ -558,14 +558,14 @@ public static function parse($url) { protected static function _parseExtension($url) { $ext = null; - if (self::$_parseExtensions) { + if (static::$_parseExtensions) { if (preg_match('/\.[0-9a-zA-Z]*$/', $url, $match) === 1) { $match = substr($match[0], 1); - if (empty(self::$_validExtensions)) { + if (empty(static::$_validExtensions)) { $url = substr($url, 0, strpos($url, '.' . $match)); $ext = $match; } else { - foreach (self::$_validExtensions as $name) { + foreach (static::$_validExtensions as $name) { if (strcasecmp($name, $match) === 0) { $url = substr($url, 0, strpos($url, '.' . $name)); $ext = $match; @@ -594,13 +594,13 @@ protected static function _parseExtension($url) { */ public static function setRequestInfo($request) { if ($request instanceof Request) { - self::$_requests[] = $request; + static::$_requests[] = $request; } else { $requestObj = new Request(); $request += array(array(), array()); $request[0] += array('controller' => false, 'action' => false, 'plugin' => null); $requestObj->addParams($request[0])->addPaths($request[1]); - self::$_requests[] = $requestObj; + static::$_requests[] = $requestObj; } } @@ -612,7 +612,7 @@ public static function setRequestInfo($request) { * @see Object::requestAction() */ public static function popRequest() { - return array_pop(self::$_requests); + return array_pop(static::$_requests); } /** @@ -623,10 +623,10 @@ public static function popRequest() { */ public static function getRequest($current = false) { if ($current) { - $i = count(self::$_requests) - 1; - return isset(self::$_requests[$i]) ? self::$_requests[$i] : null; + $i = count(static::$_requests) - 1; + 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; } /** @@ -637,10 +637,10 @@ public static function getRequest($current = false) { */ public static function getParams($current = false) { if ($current) { - return self::$_requests[count(self::$_requests) - 1]->params; + return static::$_requests[count(static::$_requests) - 1]->params; } - if (isset(self::$_requests[0])) { - return self::$_requests[0]->params; + if (isset(static::$_requests[0])) { + return static::$_requests[0]->params; } return array(); } @@ -668,12 +668,12 @@ public static function getParam($name = 'controller', $current = false) { */ public static function getPaths($current = false) { 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' => self::$_requests[0]->base); + return array('base' => static::$_requests[0]->base); } /** @@ -683,17 +683,17 @@ public static function getPaths($current = false) { * @return void */ public static function reload() { - if (empty(self::$_initialState)) { - self::$_initialState = get_class_vars(get_called_class()); - self::_setPrefixes(); + if (empty(static::$_initialState)) { + static::$_initialState = get_class_vars(get_called_class()); + static::_setPrefixes(); return; } - foreach (self::$_initialState as $key => $val) { + foreach (static::$_initialState as $key => $val) { if ($key != '_initialState') { - self::${$key} = $val; + static::${$key} = $val; } } - self::_setPrefixes(); + static::_setPrefixes(); } /** @@ -705,14 +705,14 @@ public static function reload() { */ public static function promote($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; } - $route =& self::$routes[$which]; - unset(self::$routes[$which]); - array_unshift(self::$routes, $route); + $route =& static::$routes[$which]; + unset(static::$routes[$which]); + array_unshift(static::$routes, $route); return true; } @@ -755,8 +755,8 @@ public static function url($url = null, $full = false) { } $path = array('base' => null); - if (!empty(self::$_requests)) { - $request = self::$_requests[count(self::$_requests) - 1]; + if (!empty(static::$_requests)) { + $request = static::$_requests[count(static::$_requests) - 1]; $params = $request->params; $path = array('base' => $request->base, 'here' => $request->here); } @@ -799,8 +799,8 @@ public static function url($url = null, $full = false) { } } - $prefixExists = (array_intersect_key($url, array_flip(self::$_prefixes))); - foreach (self::$_prefixes as $prefix) { + $prefixExists = (array_intersect_key($url, array_flip(static::$_prefixes))); + foreach (static::$_prefixes as $prefix) { if (!empty($params[$prefix]) && !$prefixExists) { $url[$prefix] = true; } elseif (isset($url[$prefix]) && !$url[$prefix]) { @@ -815,21 +815,21 @@ public static function url($url = null, $full = false) { $match = false; - for ($i = 0, $len = count(self::$routes); $i < $len; $i++) { + for ($i = 0, $len = count(static::$routes); $i < $len; $i++) { $originalUrl = $url; - if (isset(self::$routes[$i]->options['persist'], $params)) { - $url = self::$routes[$i]->persistParams($url, $params); + if (isset(static::$routes[$i]->options['persist'], $params)) { + $url = static::$routes[$i]->persistParams($url, $params); } - if ($match = self::$routes[$i]->match($url)) { + if ($match = static::$routes[$i]->match($url)) { $output = trim($match, '/'); break; } $url = $originalUrl; } if ($match === false) { - $output = self::_handleNoRoute($url); + $output = static::_handleNoRoute($url); } } else { if ( @@ -843,7 +843,7 @@ public static function url($url = null, $full = false) { if (substr($url, 0, 1) === '/') { $output = substr($url, 1); } else { - foreach (self::$_prefixes as $prefix) { + foreach (static::$_prefixes as $prefix) { if (isset($params[$prefix])) { $output .= $prefix . '/'; break; @@ -866,7 +866,7 @@ public static function url($url = null, $full = false) { $output = rtrim($output, '/'); } } - return $output . $extension . self::queryString($q, array(), $escape) . $frag; + return $output . $extension . static::queryString($q, array(), $escape) . $frag; } /** @@ -881,7 +881,7 @@ protected static function _handleNoRoute($url) { $named = $args = array(); $skip = array_merge( array('bare', 'action', 'controller', 'plugin', 'prefix'), - self::$_prefixes + static::$_prefixes ); $keys = array_values(array_diff(array_keys($url), $skip)); @@ -898,7 +898,7 @@ protected static function _handleNoRoute($url) { } list($args, $named) = array(Hash::filter($args), Hash::filter($named)); - foreach (self::$_prefixes as $prefix) { + foreach (static::$_prefixes as $prefix) { $prefixed = $prefix . '_'; if (!empty($url[$prefix]) && strpos($url['action'], $prefixed) === 0) { $url['action'] = substr($url['action'], strlen($prefixed) * -1); @@ -916,7 +916,7 @@ protected static function _handleNoRoute($url) { array_unshift($urlOut, $url['plugin']); } - foreach (self::$_prefixes as $prefix) { + foreach (static::$_prefixes as $prefix) { if (isset($url[$prefix])) { array_unshift($urlOut, $prefix); break; @@ -933,10 +933,10 @@ protected static function _handleNoRoute($url) { if (is_array($value)) { $flattend = Hash::flatten($value, ']['); foreach ($flattend as $namedKey => $namedValue) { - $output .= '/' . $name . "[$namedKey]" . self::$_namedConfig['separator'] . rawurlencode($namedValue); + $output .= '/' . $name . "[$namedKey]" . static::$_namedConfig['separator'] . rawurlencode($namedValue); } } else { - $output .= '/' . $name . self::$_namedConfig['separator'] . rawurlencode($value); + $output .= '/' . $name . static::$_namedConfig['separator'] . rawurlencode($value); } } } @@ -1056,7 +1056,7 @@ public static function normalize($url = '/') { * @return Cake\Routing\Route\Route Matching route object. */ public static function &requestRoute() { - return self::$_currentRoute[0]; + return static::$_currentRoute[0]; } /** @@ -1065,7 +1065,7 @@ public static function &requestRoute() { * @return Cake\Routing\Route\Route Matching route object. */ public static function ¤tRoute() { - return self::$_currentRoute[count(self::$_currentRoute) - 1]; + return static::$_currentRoute[count(static::$_currentRoute) - 1]; } /** @@ -1106,9 +1106,9 @@ public static function stripPlugin($base, $plugin = null) { * @see RequestHandler::startup() */ public static function parseExtensions() { - self::$_parseExtensions = true; + static::$_parseExtensions = true; if (func_num_args() > 0) { - self::setExtensions(func_get_args(), false); + static::setExtensions(func_get_args(), false); } } @@ -1120,7 +1120,7 @@ public static function parseExtensions() { * @return array Array of extensions Router is configured to parse. */ public static function extensions() { - return self::$_validExtensions; + return static::$_validExtensions; } /** @@ -1133,12 +1133,12 @@ public static function extensions() { */ public static function setExtensions($extensions, $merge = true) { if (!is_array($extensions)) { - return self::$_validExtensions; + return static::$_validExtensions; } 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); } } diff --git a/lib/Cake/Test/TestApp/Controller/Component/TestAuthComponent.php b/lib/Cake/Test/TestApp/Controller/Component/TestAuthComponent.php index b9fa9ec5f72..36e365c6a2b 100644 --- a/lib/Cake/Test/TestApp/Controller/Component/TestAuthComponent.php +++ b/lib/Cake/Test/TestApp/Controller/Component/TestAuthComponent.php @@ -42,7 +42,7 @@ function _stop($status = 0) { } public static function clearUser() { - self::$_user = array(); + static::$_user = array(); } } diff --git a/lib/Cake/Test/TestCase/Controller/Component/Auth/FormAuthenticateTest.php b/lib/Cake/Test/TestCase/Controller/Component/Auth/FormAuthenticateTest.php index bd0fe6cf6cb..18aae54d2e5 100644 --- a/lib/Cake/Test/TestCase/Controller/Component/Auth/FormAuthenticateTest.php +++ b/lib/Cake/Test/TestCase/Controller/Component/Auth/FormAuthenticateTest.php @@ -189,7 +189,7 @@ public function testPluginModel() { 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23' ); - $this->assertEquals(self::date(), $result['updated']); + $this->assertEquals(static::date(), $result['updated']); unset($result['updated']); $this->assertEquals($expected, $result); Plugin::unload(); diff --git a/lib/Cake/Test/TestCase/Controller/Component/SessionComponentTest.php b/lib/Cake/Test/TestCase/Controller/Component/SessionComponentTest.php index d8f2b8cdfc2..12f6a2c31a6 100644 --- a/lib/Cake/Test/TestCase/Controller/Component/SessionComponentTest.php +++ b/lib/Cake/Test/TestCase/Controller/Component/SessionComponentTest.php @@ -48,7 +48,7 @@ class SessionComponentTest extends TestCase { * @return void */ public static function setupBeforeClass() { - self::$_sessionBackup = Configure::read('Session'); + static::$_sessionBackup = Configure::read('Session'); Configure::write('Session', array( 'defaults' => 'php', 'timeout' => 100, @@ -62,7 +62,7 @@ public static function setupBeforeClass() { * @return void */ public static function teardownAfterClass() { - Configure::write('Session', self::$_sessionBackup); + Configure::write('Session', static::$_sessionBackup); } /** diff --git a/lib/Cake/Test/TestCase/Log/Engine/ConsoleLogTest.php b/lib/Cake/Test/TestCase/Log/Engine/ConsoleLogTest.php index cbd8fcad4b1..6ef47be3b06 100644 --- a/lib/Cake/Test/TestCase/Log/Engine/ConsoleLogTest.php +++ b/lib/Cake/Test/TestCase/Log/Engine/ConsoleLogTest.php @@ -29,7 +29,7 @@ class TestConsoleLog extends ConsoleLog { class TestCakeLog extends Log { public static function replace($key, &$engine) { - self::$_Collection->{$key} = $engine; + static::$_Collection->{$key} = $engine; } } diff --git a/lib/Cake/Test/TestCase/Model/Datasource/CakeSessionTest.php b/lib/Cake/Test/TestCase/Model/Datasource/CakeSessionTest.php index 9a730471792..08ea658a6c7 100644 --- a/lib/Cake/Test/TestCase/Model/Datasource/CakeSessionTest.php +++ b/lib/Cake/Test/TestCase/Model/Datasource/CakeSessionTest.php @@ -24,11 +24,11 @@ class TestCakeSession extends CakeSession { public static function setUserAgent($value) { - self::$_userAgent = $value; + static::$_userAgent = $value; } public static function setHost($host) { - self::_setHost($host); + static::_setHost($host); } } @@ -72,7 +72,7 @@ class CakeSessionTest extends CakeTestCase { */ public static function setupBeforeClass() { // 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'); } @@ -83,7 +83,7 @@ public static function setupBeforeClass() { */ public static function teardownAfterClass() { // Revert to the default setting - ini_set('session.gc_divisor', self::$_gcDivisor); + ini_set('session.gc_divisor', static::$_gcDivisor); } /** diff --git a/lib/Cake/Test/TestCase/Model/Datasource/Session/CacheSessionTest.php b/lib/Cake/Test/TestCase/Model/Datasource/Session/CacheSessionTest.php index d696d7cd808..6db2cedb414 100644 --- a/lib/Cake/Test/TestCase/Model/Datasource/Session/CacheSessionTest.php +++ b/lib/Cake/Test/TestCase/Model/Datasource/Session/CacheSessionTest.php @@ -35,7 +35,7 @@ public static function setupBeforeClass() { 'engine' => 'File', 'prefix' => 'session_test_' )); - self::$_sessionBackup = Configure::read('Session'); + static::$_sessionBackup = Configure::read('Session'); Configure::write('Session.handler.config', 'session_test'); } @@ -49,7 +49,7 @@ public static function teardownAfterClass() { Cache::clear(false, 'session_test'); Cache::drop('session_test'); - Configure::write('Session', self::$_sessionBackup); + Configure::write('Session', static::$_sessionBackup); } /** diff --git a/lib/Cake/Test/TestCase/Model/Datasource/Session/DatabaseSessionTest.php b/lib/Cake/Test/TestCase/Model/Datasource/Session/DatabaseSessionTest.php index 3276ae8646f..af1a503abc8 100644 --- a/lib/Cake/Test/TestCase/Model/Datasource/Session/DatabaseSessionTest.php +++ b/lib/Cake/Test/TestCase/Model/Datasource/Session/DatabaseSessionTest.php @@ -52,7 +52,7 @@ class DatabaseSessionTest extends CakeTestCase { * @return void */ public static function setupBeforeClass() { - self::$_sessionBackup = Configure::read('Session'); + static::$_sessionBackup = Configure::read('Session'); Configure::write('Session.handler', array( 'model' => 'SessionTestModel', )); @@ -65,7 +65,7 @@ public static function setupBeforeClass() { * @return void */ public static function teardownAfterClass() { - Configure::write('Session', self::$_sessionBackup); + Configure::write('Session', static::$_sessionBackup); } /** diff --git a/lib/Cake/Test/TestCase/Model/ModelIntegrationTest.php b/lib/Cake/Test/TestCase/Model/ModelIntegrationTest.php index a7063c0fd40..ae24a54b754 100644 --- a/lib/Cake/Test/TestCase/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/TestCase/Model/ModelIntegrationTest.php @@ -1919,7 +1919,7 @@ public function testWithAssociation() { ) ) ); - $this->assertEquals(self::date(), $result['Something']['updated']); + $this->assertEquals(static::date(), $result['Something']['updated']); unset($result['Something']['updated']); $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/TestCase/Model/ModelWriteTest.php b/lib/Cake/Test/TestCase/Model/ModelWriteTest.php index c497a4a8017..05efdcd8e2a 100644 --- a/lib/Cake/Test/TestCase/Model/ModelWriteTest.php +++ b/lib/Cake/Test/TestCase/Model/ModelWriteTest.php @@ -1626,7 +1626,7 @@ public function testSaveHabtmNoPrimaryData() { 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', - 'updated' => self::date() + 'updated' => static::date() ), 'Tag' => array( array( @@ -2565,23 +2565,23 @@ public function testSaveMultipleHabtm() { 'JoinA' => array( 'id' => '1', 'name' => 'New name for Join A 1', - 'updated' => self::date() + 'updated' => static::date() ), 'JoinB' => array( array( 'id' => 1, 'join_b_id' => 2, 'other' => 'New data for Join A 1 Join B 2', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )), 'JoinC' => array( array( 'id' => 1, 'join_c_id' => 2, 'other' => 'New data for Join A 1 Join C 2', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() ))); $TestModel->set($data); @@ -2594,7 +2594,7 @@ public function testSaveMultipleHabtm() { 'name' => 'New name for Join A 1', 'body' => 'Join A 1 Body', 'created' => '2008-01-03 10:54:23', - 'updated' => self::date() + 'updated' => static::date() ), 'JoinB' => array( 0 => array( @@ -2607,8 +2607,8 @@ public function testSaveMultipleHabtm() { 'join_a_id' => 1, 'join_b_id' => 2, 'other' => 'New data for Join A 1 Join B 2', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() ))), 'JoinC' => array( 0 => array( @@ -2621,8 +2621,8 @@ public function testSaveMultipleHabtm() { 'join_a_id' => 1, 'join_c_id' => 2, 'other' => 'New data for Join A 1 Join C 2', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )))); $this->assertEquals($expected, $result); @@ -2666,10 +2666,10 @@ public function testSaveAll() { 'password' => '5f4dcc3b5aa765d61d8327deb882cf90', 'test' => 'working' )); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Author']['created']); - $this->assertEquals(self::date(), $result[3]['Author']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Author']['created']); + $this->assertEquals(static::date(), $result[3]['Author']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[3]['Author']['created'], $result[3]['Author']['updated']); $this->assertEquals($expected, $result[3]); @@ -2714,10 +2714,10 @@ public function testSaveAll() { 'body' => 'Second multi-record post', 'published' => 'N' ))); - $this->assertEquals(self::date(), $result[0]['Post']['created']); - $this->assertEquals(self::date(), $result[0]['Post']['updated']); - $this->assertEquals(self::date(), $result[1]['Post']['created']); - $this->assertEquals(self::date(), $result[1]['Post']['updated']); + $this->assertEquals(static::date(), $result[0]['Post']['created']); + $this->assertEquals(static::date(), $result[0]['Post']['updated']); + $this->assertEquals(static::date(), $result[1]['Post']['created']); + $this->assertEquals(static::date(), $result[1]['Post']['updated']); unset($result[0]['Post']['created'], $result[0]['Post']['updated']); unset($result[1]['Post']['created'], $result[1]['Post']['updated']); $this->assertEquals($expected, $result); @@ -2743,8 +2743,8 @@ public function testSaveAll() { 'comment' => 'New comment with attachment', 'published' => 'Y' ); - $this->assertEquals(self::date(), $result[6]['Comment']['created']); - $this->assertEquals(self::date(), $result[6]['Comment']['updated']); + $this->assertEquals(static::date(), $result[6]['Comment']['created']); + $this->assertEquals(static::date(), $result[6]['Comment']['updated']); unset($result[6]['Comment']['created'], $result[6]['Comment']['updated']); $this->assertEquals($expected, $result[6]['Comment']); @@ -2753,8 +2753,8 @@ public function testSaveAll() { 'comment_id' => '7', 'attachment' => 'some_file.tgz' ); - $this->assertEquals(self::date(), $result[6]['Attachment']['created']); - $this->assertEquals(self::date(), $result[6]['Attachment']['updated']); + $this->assertEquals(static::date(), $result[6]['Attachment']['created']); + $this->assertEquals(static::date(), $result[6]['Attachment']['updated']); unset($result[6]['Attachment']['created'], $result[6]['Attachment']['updated']); $this->assertEquals($expected, $result[6]['Attachment']); } @@ -4083,8 +4083,8 @@ public function testSaveAllTransaction() { 'title' => 'New Fourth Post', 'body' => null, 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )); $expected[] = array( @@ -4094,8 +4094,8 @@ public function testSaveAllTransaction() { 'title' => 'New Fifth Post', 'body' => null, 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )); $this->assertEquals($expected, $result); @@ -4151,8 +4151,8 @@ public function testSaveAllTransaction() { 'title' => 'New Fourth Post', 'body' => 'Third Post Body', 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )); $expected[] = array( @@ -4162,8 +4162,8 @@ public function testSaveAllTransaction() { 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() )); } $this->assertEquals($expected, $result); @@ -4288,10 +4288,10 @@ public function testSaveAllValidation() { 'body' => 'Fourth post body', 'published' => 'N' ))); - $this->assertEquals(self::date(), $result[0]['Post']['updated']); - $this->assertEquals(self::date(), $result[1]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[0]['Post']['updated']); + $this->assertEquals(static::date(), $result[1]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); unset($result[0]['Post']['updated'], $result[1]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); $this->assertEquals($expected, $result); @@ -4382,10 +4382,10 @@ public function testSaveAllValidation() { ) ); - $this->assertEquals(self::date(), $result[0]['Post']['updated']); - $this->assertEquals(self::date(), $result[1]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[0]['Post']['updated']); + $this->assertEquals(static::date(), $result[1]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); unset( $result[0]['Post']['updated'], $result[1]['Post']['updated'], $result[3]['Post']['updated'], $result[3]['Post']['created'] @@ -4740,10 +4740,10 @@ public function testSaveAssociated() { 'password' => '5f4dcc3b5aa765d61d8327deb882cf90', 'test' => 'working' )); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Author']['created']); - $this->assertEquals(self::date(), $result[3]['Author']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Author']['created']); + $this->assertEquals(static::date(), $result[3]['Author']['updated']); unset( $result[3]['Post']['updated'], $result[3]['Post']['created'], $result[3]['Author']['updated'], $result[3]['Author']['created'] @@ -4772,8 +4772,8 @@ public function testSaveAssociated() { 'comment' => 'New comment with attachment', 'published' => 'Y' ); - $this->assertEquals(self::date(), $result[6]['Comment']['updated']); - $this->assertEquals(self::date(), $result[6]['Comment']['created']); + $this->assertEquals(static::date(), $result[6]['Comment']['updated']); + $this->assertEquals(static::date(), $result[6]['Comment']['created']); unset($result[6]['Comment']['updated'], $result[6]['Comment']['created']); $this->assertEquals($expected, $result[6]['Comment']); @@ -4782,8 +4782,8 @@ public function testSaveAssociated() { 'comment_id' => '7', 'attachment' => 'some_file.tgz' ); - $this->assertEquals(self::date(), $result[6]['Attachment']['updated']); - $this->assertEquals(self::date(), $result[6]['Attachment']['created']); + $this->assertEquals(static::date(), $result[6]['Attachment']['updated']); + $this->assertEquals(static::date(), $result[6]['Attachment']['created']); unset($result[6]['Attachment']['updated'], $result[6]['Attachment']['created']); $this->assertEquals($expected, $result[6]['Attachment']); } @@ -4838,10 +4838,10 @@ public function testSaveMany() { ) ) ); - $this->assertEquals(self::date(), $result[0]['Post']['updated']); - $this->assertEquals(self::date(), $result[0]['Post']['created']); - $this->assertEquals(self::date(), $result[1]['Post']['updated']); - $this->assertEquals(self::date(), $result[1]['Post']['created']); + $this->assertEquals(static::date(), $result[0]['Post']['updated']); + $this->assertEquals(static::date(), $result[0]['Post']['created']); + $this->assertEquals(static::date(), $result[1]['Post']['updated']); + $this->assertEquals(static::date(), $result[1]['Post']['created']); unset($result[0]['Post']['updated'], $result[0]['Post']['created']); unset($result[1]['Post']['updated'], $result[1]['Post']['created']); $this->assertEquals($expected, $result); @@ -5445,10 +5445,10 @@ public function testSaveManyTransaction() { 'published' => 'N', )); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); - $this->assertEquals(self::date(), $result[4]['Post']['created']); - $this->assertEquals(self::date(), $result[4]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[4]['Post']['created']); + $this->assertEquals(static::date(), $result[4]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[4]['Post']['created'], $result[4]['Post']['updated']); $this->assertEquals($expected, $result); @@ -5514,10 +5514,10 @@ public function testSaveManyTransaction() { 'body' => 'Third Post Body', 'published' => 'N' )); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); - $this->assertEquals(self::date(), $result[4]['Post']['created']); - $this->assertEquals(self::date(), $result[4]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[4]['Post']['created']); + $this->assertEquals(static::date(), $result[4]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); unset($result[4]['Post']['created'], $result[4]['Post']['updated']); } @@ -5648,10 +5648,10 @@ public function testSaveManyValidation() { ) ); - $this->assertEquals(self::date(), $result[0]['Post']['updated']); - $this->assertEquals(self::date(), $result[1]['Post']['updated']); - $this->assertEquals(self::date(), $result[3]['Post']['created']); - $this->assertEquals(self::date(), $result[3]['Post']['updated']); + $this->assertEquals(static::date(), $result[0]['Post']['updated']); + $this->assertEquals(static::date(), $result[1]['Post']['updated']); + $this->assertEquals(static::date(), $result[3]['Post']['created']); + $this->assertEquals(static::date(), $result[3]['Post']['updated']); unset($result[0]['Post']['updated'], $result[1]['Post']['updated']); unset($result[3]['Post']['created'], $result[3]['Post']['updated']); $this->assertEquals($expected, $result); @@ -6372,15 +6372,15 @@ public function testSaveAllFieldListValidateBelongsTo() { 'title' => 'Post without body', 'body' => null, 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date(), + 'created' => static::date(), + 'updated' => static::date(), ), 'Author' => array ( 'id' => '5', 'user' => 'bob', 'password' => null, - 'created' => self::date(), - 'updated' => self::date(), + 'created' => static::date(), + 'updated' => static::date(), 'test' => 'working', ), ); @@ -6417,8 +6417,8 @@ public function testSaveAllFieldListValidateBelongsTo() { 'title' => 'Multi-record post 1', 'body' => '', 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() ) ), array( @@ -6428,8 +6428,8 @@ public function testSaveAllFieldListValidateBelongsTo() { 'title' => 'Multi-record post 2', 'body' => '', 'published' => 'N', - 'created' => self::date(), - 'updated' => self::date() + 'created' => static::date(), + 'updated' => static::date() ) ) ); diff --git a/lib/Cake/Test/TestCase/Utility/FolderTest.php b/lib/Cake/Test/TestCase/Utility/FolderTest.php index 52a6e56cf95..00bec3492bc 100644 --- a/lib/Cake/Test/TestCase/Utility/FolderTest.php +++ b/lib/Cake/Test/TestCase/Utility/FolderTest.php @@ -38,7 +38,7 @@ class FolderTest extends TestCase { public static function setUpBeforeClass() { foreach (scandir(TMP) as $file) { if (is_dir(TMP . $file) && !in_array($file, array('.', '..'))) { - self::$_tmp[] = $file; + static::$_tmp[] = $file; } } } @@ -59,7 +59,7 @@ public function setUp() { * @return void */ public function tearDown() { - $exclude = array_merge(self::$_tmp, array('.', '..')); + $exclude = array_merge(static::$_tmp, array('.', '..')); foreach (scandir(TMP) as $dir) { if (is_dir(TMP . $dir) && !in_array($dir, $exclude)) { $iterator = new \RecursiveDirectoryIterator(TMP . $dir); diff --git a/lib/Cake/Test/TestCase/Utility/HashTest.php b/lib/Cake/Test/TestCase/Utility/HashTest.php index b5b3edc6c6e..53156890704 100644 --- a/lib/Cake/Test/TestCase/Utility/HashTest.php +++ b/lib/Cake/Test/TestCase/Utility/HashTest.php @@ -172,7 +172,7 @@ public static function userData() { * return void */ public function testGet() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::get(array(), '1.Article.title'); $this->assertNull($result); @@ -637,7 +637,7 @@ public function testNumeric() { * @return void */ public function testExtractBasic() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, ''); $this->assertEquals($data, $result); @@ -655,7 +655,7 @@ public function testExtractBasic() { * @return void */ public function testExtractNumericKey() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Article.title'); $expected = array( 'First Article', 'Second Article', @@ -734,7 +734,7 @@ public function testExtractNumericNonZero() { * @return void */ public function testExtractStringKey() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.{s}.user'); $expected = array( 'mariano', @@ -755,7 +755,7 @@ public function testExtractStringKey() { * @return void */ public function testExtractAttributePresence() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Article[published]'); $expected = array($data[1]['Article']); @@ -772,7 +772,7 @@ public function testExtractAttributePresence() { * @return void */ public function testExtractAttributeEquality() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Article[id=3]'); $expected = array($data[2]['Article']); @@ -795,7 +795,7 @@ public function testExtractAttributeEquality() { * @return void */ public function testExtractAttributeComparison() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Comment.{n}[user_id > 2]'); $expected = array($data[0]['Comment'][1]); @@ -824,7 +824,7 @@ public function testExtractAttributeComparison() { * @return void */ public function testExtractAttributeMultiple() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Comment.{n}[user_id > 2][id=1]'); $this->assertEmpty($result); @@ -841,7 +841,7 @@ public function testExtractAttributeMultiple() { * @return void */ public function testExtractAttributePattern() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::extract($data, '{n}.Article[title=/^First/]'); $expected = array($data[0]['Article']); @@ -1195,7 +1195,7 @@ public function testInsertSimple() { * @return void */ public function testInsertMulti() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::insert($data, '{n}.Article.insert', 'value'); $this->assertEquals('value', $result[0]['Article']['insert']); @@ -1275,7 +1275,7 @@ public function testRemove() { * @return void */ public function testRemoveMulti() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::remove($data, '{n}.Article.title'); $this->assertFalse(isset($result[0]['Article']['title'])); @@ -1326,7 +1326,7 @@ public function testCombine() { $result = Hash::combine(array(), '{n}.User.id', '{n}.User.Data'); $this->assertTrue(empty($result)); - $a = self::userData(); + $a = static::userData(); $result = Hash::combine($a, '{n}.User.id'); $expected = array(2 => null, 14 => null, 25 => null); @@ -1357,7 +1357,7 @@ public function testCombine() { * @return void */ public function testCombineWithGroupPath() { - $a = self::userData(); + $a = static::userData(); $result = Hash::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id'); $expected = array( @@ -1414,7 +1414,7 @@ public function testCombineWithGroupPath() { * @return void */ public function testCombineWithFormatting() { - $a = self::userData(); + $a = static::userData(); $result = Hash::combine( $a, @@ -1480,7 +1480,7 @@ public function testCombineWithFormatting() { * @return void */ public function testFormat() { - $data = self::userData(); + $data = static::userData(); $result = Hash::format( $data, @@ -1540,7 +1540,7 @@ public function testFormatNullValues() { * @return void */ public function testMap() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::map($data, '{n}.Article.id', array($this, 'mapCallback')); $expected = array(2, 4, 6, 8, 10); @@ -1548,7 +1548,7 @@ public function testMap() { } public function testApply() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::apply($data, '{n}.Article.id', 'array_sum'); $this->assertEquals(15, $result); @@ -1560,7 +1560,7 @@ public function testApply() { * @return void */ public function testReduce() { - $data = self::articleData(); + $data = static::articleData(); $result = Hash::reduce($data, '{n}.Article.id', array($this, 'reduceCallback')); $this->assertEquals(15, $result); diff --git a/lib/Cake/TestSuite/TestCase.php b/lib/Cake/TestSuite/TestCase.php index d3af7ed00ab..efcb832f50f 100644 --- a/lib/Cake/TestSuite/TestCase.php +++ b/lib/Cake/TestSuite/TestCase.php @@ -535,7 +535,7 @@ protected function _arrayPermute($items, $perms = array()) { * @return void */ protected static function assertEqual($result, $expected, $message = '') { - return self::assertEquals($expected, $result, $message); + return static::assertEquals($expected, $result, $message); } /** @@ -547,7 +547,7 @@ protected static function assertEqual($result, $expected, $message = '') { * @return void */ protected static function assertNotEqual($result, $expected, $message = '') { - return self::assertNotEquals($expected, $result, $message); + return static::assertNotEquals($expected, $result, $message); } /** @@ -559,7 +559,7 @@ protected static function assertNotEqual($result, $expected, $message = '') { * @return void */ protected static function assertPattern($pattern, $string, $message = '') { - return self::assertRegExp($pattern, $string, $message); + return static::assertRegExp($pattern, $string, $message); } /** @@ -571,7 +571,7 @@ protected static function assertPattern($pattern, $string, $message = '') { * @return void */ protected static function assertIdentical($actual, $expected, $message = '') { - return self::assertSame($expected, $actual, $message); + return static::assertSame($expected, $actual, $message); } /** @@ -583,7 +583,7 @@ protected static function assertIdentical($actual, $expected, $message = '') { * @return void */ protected static function assertNotIdentical($actual, $expected, $message = '') { - return self::assertNotSame($expected, $actual, $message); + return static::assertNotSame($expected, $actual, $message); } /** @@ -595,7 +595,7 @@ protected static function assertNotIdentical($actual, $expected, $message = '') * @return void */ protected static function assertNoPattern($pattern, $string, $message = '') { - return self::assertNotRegExp($pattern, $string, $message); + return static::assertNotRegExp($pattern, $string, $message); } protected function assertNoErrors() { @@ -635,7 +635,7 @@ protected function expectException($name = 'Exception', $message = '') { * @return void */ protected static function assertReference(&$first, &$second, $message = '') { - return self::assertSame($first, $second, $message); + return static::assertSame($first, $second, $message); } /** @@ -647,7 +647,7 @@ protected static function assertReference(&$first, &$second, $message = '') { * @return void */ protected static function assertIsA($object, $type, $message = '') { - return self::assertInstanceOf($type, $object, $message); + return static::assertInstanceOf($type, $object, $message); } /** @@ -662,7 +662,7 @@ protected static function assertIsA($object, $type, $message = '') { protected static function assertWithinMargin($result, $expected, $margin, $message = '') { $upper = $result + $margin; $lower = $result - $margin; - return self::assertTrue((($expected <= $upper) && ($expected >= $lower)), $message); + return static::assertTrue((($expected <= $upper) && ($expected >= $lower)), $message); } /** diff --git a/lib/Cake/TestSuite/TestLoader.php b/lib/Cake/TestSuite/TestLoader.php index e2301cf3abc..36963e94c5b 100644 --- a/lib/Cake/TestSuite/TestLoader.php +++ b/lib/Cake/TestSuite/TestLoader.php @@ -86,8 +86,8 @@ protected static function _basePath($params) { * @return void */ public static function generateTestList($params) { - $directory = self::_basePath($params); - $fileList = self::_getRecursiveFileList($directory); + $directory = static::_basePath($params); + $fileList = static::_getRecursiveFileList($directory); $testCases = array(); foreach ($fileList as $testCaseFile) { diff --git a/lib/Cake/TestSuite/TestRunner.php b/lib/Cake/TestSuite/TestRunner.php index 17b751bc765..30f450ad594 100644 --- a/lib/Cake/TestSuite/TestRunner.php +++ b/lib/Cake/TestSuite/TestRunner.php @@ -47,7 +47,7 @@ public function __construct($loader, $params) { */ public function doRun(\PHPUnit_Framework_Test $suite, array $arguments = array()) { if (isset($arguments['printer'])) { - self::$versionStringPrinted = true; + static::$versionStringPrinted = true; } $autoloader = new ClassLoader('TestApp', dirname(__DIR__) . '/Test'); diff --git a/lib/Cake/TestSuite/TestSuiteDispatcher.php b/lib/Cake/TestSuite/TestSuiteDispatcher.php index ea40848e30a..251018b2f60 100644 --- a/lib/Cake/TestSuite/TestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/TestSuiteDispatcher.php @@ -248,7 +248,7 @@ protected function _runTestCase() { restore_error_handler(); try { - self::time(); + static::time(); $command = new TestSuiteCommand('Cake\TestSuite\TestLoader', $commandArgs); $result = $command->run($options); } catch (Error\MissingConnectionException $exception) { @@ -281,7 +281,7 @@ public static function time($reset = false) { * @return string formatted date */ public static function date($format) { - return date($format, self::time()); + return date($format, static::time()); } } diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index 67827f08ea5..8e4170fd5e6 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -177,7 +177,7 @@ public static function &getInstance($class = null) { * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::dump */ public static function dump($var) { - pr(self::exportVar($var)); + pr(static::exportVar($var)); } /** @@ -190,8 +190,8 @@ public static function dump($var) { * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::log */ public static function log($var, $level = LOG_DEBUG) { - $source = self::trace(array('start' => 1)) . "\n"; - Log::write($level, "\n" . $source . self::exportVar($var)); + $source = static::trace(array('start' => 1)) . "\n"; + Log::write($level, "\n" . $source . static::exportVar($var)); } /** @@ -214,7 +214,7 @@ public static function showError($code, $description, $file = null, $line = null if (empty($line)) { $line = '??'; } - $path = self::trimPath($file); + $path = static::trimPath($file); $info = compact('code', 'description', 'file', 'line'); if (!in_array($info, $self->errors)) { @@ -338,7 +338,7 @@ public static function trace($options = array()) { } else { $tpl = $self->_templates['base']['traceLine']; } - $trace['path'] = self::trimPath($trace['file']); + $trace['path'] = static::trimPath($trace['file']); $trace['reference'] = $reference; unset($trace['object'], $trace['args']); $back[] = String::insert($tpl, $trace, array('before' => '{:', 'after' => '}')); @@ -410,7 +410,7 @@ public static function excerpt($file, $line, $context = 2) { if (!isset($data[$i])) { 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) { $lines[] = '' . $string . ''; } else { @@ -460,7 +460,7 @@ protected static function _highlight($str) { * @link http://book.cakephp.org/2.0/en/development/debugging.html#Debugger::exportVar */ public static function exportVar($var, $depth = 3) { - return self::_export($var, $depth, 0); + return static::_export($var, $depth, 0); } /** @@ -472,7 +472,7 @@ public static function exportVar($var, $depth = 3) { * @return string The dumped variable. */ protected static function _export($var, $depth, $indent) { - switch (self::getType($var)) { + switch (static::getType($var)) { case 'boolean': return ($var) ? 'true' : 'false'; break; @@ -488,7 +488,7 @@ protected static function _export($var, $depth, $indent) { return "'" . $var . "'"; break; case 'array': - return self::_array($var, $depth - 1, $indent + 1); + return static::_array($var, $depth - 1, $indent + 1); break; case 'resource': return strtolower(gettype($var)); @@ -496,7 +496,7 @@ protected static function _export($var, $depth, $indent) { case 'null': return 'null'; default: - return self::_object($var, $depth - 1, $indent + 1); + return static::_object($var, $depth - 1, $indent + 1); break; } } @@ -543,9 +543,9 @@ protected static function _array(array $var, $depth, $indent) { if ($depth >= 0) { foreach ($var as $key => $val) { - $vars[] = $break . self::exportVar($key) . + $vars[] = $break . static::exportVar($key) . ' => ' . - self::_export($val, $depth - 1, $indent); + static::_export($val, $depth - 1, $indent); } } return $out . implode(',', $vars) . $end . ')'; @@ -572,7 +572,7 @@ protected static function _object($var, $depth, $indent) { $break = "\n" . str_repeat("\t", $indent); $objectVars = get_object_vars($var); foreach ($objectVars as $key => $value) { - $value = self::_export($value, $depth - 1, $indent); + $value = static::_export($value, $depth - 1, $indent); $props[] = "$key => " . $value; } $out .= $break . implode($break, $props) . $end; diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index cb002fad94b..a0c18d1aee7 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -93,7 +93,7 @@ public static function extract(array $data, $path) { // Simple paths. if (!preg_match('/[{\[]/', $path)) { - return (array)self::get($data, $path); + return (array)static::get($data, $path); } if (strpos('[', $path) === false) { @@ -119,7 +119,7 @@ public static function extract(array $data, $path) { foreach ($context[$_key] as $item) { foreach ($item as $k => $v) { - if (self::_matchToken($k, $token)) { + if (static::_matchToken($k, $token)) { $next[] = $v; } } @@ -129,7 +129,7 @@ public static function extract(array $data, $path) { if ($conditions) { $filter = array(); foreach ($next as $item) { - if (self::_matches($item, $conditions)) { + if (static::_matches($item, $conditions)) { $filter[] = $item; } } @@ -230,14 +230,14 @@ protected static function _matches(array $data, $selector) { public static function insert(array $data, $path, $values = null) { $tokens = explode('.', $path); if (strpos($path, '{') === false) { - return self::_simpleOp('insert', $data, $tokens, $values); + return static::_simpleOp('insert', $data, $tokens, $values); } $token = array_shift($tokens); $nextPath = implode('.', $tokens); foreach ($data as $k => $v) { - if (self::_matchToken($k, $token)) { - $data[$k] = self::insert($v, $nextPath, $values); + if (static::_matchToken($k, $token)) { + $data[$k] = static::insert($v, $nextPath, $values); } } return $data; @@ -298,15 +298,15 @@ protected static function _simpleOp($op, $data, $path, $values = null) { public static function remove(array $data, $path) { $tokens = explode('.', $path); if (strpos($path, '{') === false) { - return self::_simpleOp('remove', $data, $tokens); + return static::_simpleOp('remove', $data, $tokens); } $token = array_shift($tokens); $nextPath = implode('.', $tokens); foreach ($data as $k => $v) { - $match = self::_matchToken($k, $token); + $match = static::_matchToken($k, $token); if ($match && is_array($v)) { - $data[$k] = self::remove($v, $nextPath); + $data[$k] = static::remove($v, $nextPath); } elseif ($match) { unset($data[$k]); } @@ -334,9 +334,9 @@ public static function combine(array $data, $keyPath, $valuePath = null, $groupP if (is_array($keyPath)) { $format = array_shift($keyPath); - $keys = self::format($data, $keyPath, $format); + $keys = static::format($data, $keyPath, $format); } else { - $keys = self::extract($data, $keyPath); + $keys = static::extract($data, $keyPath); } if (empty($keys)) { return array(); @@ -344,9 +344,9 @@ public static function combine(array $data, $keyPath, $valuePath = null, $groupP if (!empty($valuePath) && is_array($valuePath)) { $format = array_shift($valuePath); - $vals = self::format($data, $valuePath, $format); + $vals = static::format($data, $valuePath, $format); } elseif (!empty($valuePath)) { - $vals = self::extract($data, $valuePath); + $vals = static::extract($data, $valuePath); } $count = count($keys); @@ -355,7 +355,7 @@ public static function combine(array $data, $keyPath, $valuePath = null, $groupP } if ($groupPath !== null) { - $group = self::extract($data, $groupPath); + $group = static::extract($data, $groupPath); if (!empty($group)) { $c = count($keys); for ($i = 0; $i < $c; $i++) { @@ -405,7 +405,7 @@ public static function format(array $data, array $paths, $format) { } for ($i = 0; $i < $count; $i++) { - $extracted[] = self::extract($data, $paths[$i]); + $extracted[] = static::extract($data, $paths[$i]); } $out = array(); $data = $extracted; @@ -475,7 +475,7 @@ public static function contains(array $data, array $needle) { * @see Hash::extract() */ public static function check(array $data, $path) { - $results = self::extract($data, $path); + $results = static::extract($data, $path); if (!is_array($results)) { return false; } @@ -487,14 +487,14 @@ public static function check(array $data, $path) { * * @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 - * `self::_filter()` Which strips out all non-zero empty values. + * `static::_filter()` Which strips out all non-zero empty values. * @return array Filtered array * @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')) { foreach ($data as $k => $v) { if (is_array($v)) { - $data[$k] = self::filter($v, $callback); + $data[$k] = static::filter($v, $callback); } } return array_filter($data, $callback); @@ -576,7 +576,7 @@ public static function expand($data, $separator = '.') { $k => $child ); } - $result = self::merge($result, $child); + $result = static::merge($result, $child); } return $result; } @@ -602,7 +602,7 @@ public static function merge(array $data, $merge) { while (($arg = next($args)) !== false) { foreach ((array)$arg as $key => $val) { if (!empty($return[$key]) && is_array($return[$key]) && is_array($val)) { - $return[$key] = self::merge($return[$key], $val); + $return[$key] = static::merge($return[$key], $val); } elseif (is_int($key)) { $return[] = $val; } else { @@ -669,7 +669,7 @@ public static function maxDimensions(array $data) { $depth = array(); if (is_array($data) && reset($data) !== false) { foreach ($data as $value) { - $depth[] = self::dimensions((array)$value) + 1; + $depth[] = static::dimensions((array)$value) + 1; } } return max($depth); @@ -685,7 +685,7 @@ public static function maxDimensions(array $data) { * @return array An array of the modified values. */ 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); } @@ -697,7 +697,7 @@ public static function map(array $data, $path, $function) { * @return mixed The reduced value. */ 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); } @@ -710,7 +710,7 @@ public static function reduce(array $data, $path, $function) { * @return mixed The results of the applied method. */ 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); } @@ -742,7 +742,7 @@ public static function sort(array $data, $path, $dir, $type = 'regular') { if ($numeric) { $data = array_values($data); } - $sortValues = self::extract($data, $path); + $sortValues = static::extract($data, $path); $sortCount = count($sortValues); $dataCount = count($data); @@ -751,9 +751,9 @@ public static function sort(array $data, $path, $dir, $type = 'regular') { if ($sortCount < $dataCount) { $sortValues = array_pad($sortValues, $dataCount, null); } - $result = self::_squash($sortValues); - $keys = self::extract($result, '{n}.id'); - $values = self::extract($result, '{n}.value'); + $result = static::_squash($sortValues); + $keys = static::extract($result, '{n}.id'); + $values = static::extract($result, '{n}.value'); $dir = strtolower($dir); $type = strtolower($type); @@ -808,7 +808,7 @@ protected static function _squash($data, $key = null) { $id = $key; } if (is_array($r) && !empty($r)) { - $stack = array_merge($stack, self::_squash($r, $id)); + $stack = array_merge($stack, static::_squash($r, $id)); } else { $stack[] = array('id' => $id, 'value' => $r); } @@ -863,7 +863,7 @@ public static function mergeDiff(array $data, $compare) { if (!array_key_exists($key, $data)) { $data[$key] = $value; } elseif (is_array($value)) { - $data[$key] = self::mergeDiff($data[$key], $compare[$key]); + $data[$key] = static::mergeDiff($data[$key], $compare[$key]); } } return $data; @@ -935,7 +935,7 @@ public static function nest(array $data, $options = array()) { ); $return = $idMap = array(); - $ids = self::extract($data, $options['idPath']); + $ids = static::extract($data, $options['idPath']); $idKeys = explode('.', $options['idPath']); array_shift($idKeys); @@ -946,8 +946,8 @@ public static function nest(array $data, $options = array()) { foreach ($data as $result) { $result[$options['children']] = array(); - $id = self::get($result, $idKeys); - $parentId = self::get($result, $parentKeys); + $id = static::get($result, $idKeys); + $parentId = static::get($result, $parentKeys); if (isset($idMap[$id][$options['children']])) { $idMap[$id] = array_merge($result, (array)$idMap[$id]); @@ -964,12 +964,12 @@ public static function nest(array $data, $options = array()) { if ($options['root']) { $root = $options['root']; } else { - $root = self::get($return[0], $parentKeys); + $root = static::get($return[0], $parentKeys); } foreach ($return as $i => $result) { - $id = self::get($result, $idKeys); - $parentId = self::get($result, $parentKeys); + $id = static::get($result, $idKeys); + $parentId = static::get($result, $parentKeys); if ($id !== $root && $parentId != $root) { unset($return[$i]); } diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index dbd84af9c87..922252f1bb0 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -249,13 +249,13 @@ protected static function _cache($type, $key, $value = false) { $key = '_' . $key; $type = '_' . $type; if ($value !== false) { - self::$_cache[$type][$key] = $value; + static::$_cache[$type][$key] = $value; return $value; } - if (!isset(self::$_cache[$type][$key])) { + if (!isset(static::$_cache[$type][$key])) { return false; } - return self::$_cache[$type][$key]; + return static::$_cache[$type][$key]; } /** @@ -265,13 +265,13 @@ protected static function _cache($type, $key, $value = false) { * @return void */ public static function reset() { - if (empty(self::$_initialState)) { - self::$_initialState = get_class_vars(__CLASS__); + if (empty(static::$_initialState)) { + static::$_initialState = get_class_vars(__CLASS__); return; } - foreach (self::$_initialState as $key => $val) { + foreach (static::$_initialState as $key => $val) { if ($key != '_initialState') { - self::${$key} = $val; + static::${$key} = $val; } } } @@ -303,9 +303,9 @@ public static function rules($type, $rules, $reset = false) { switch ($type) { case 'transliteration': if ($reset) { - self::$_transliteration = $rules; + static::$_transliteration = $rules; } else { - self::$_transliteration = $rules + self::$_transliteration; + static::$_transliteration = $rules + static::$_transliteration; } break; @@ -313,26 +313,26 @@ public static function rules($type, $rules, $reset = false) { foreach ($rules as $rule => $pattern) { if (is_array($pattern)) { if ($reset) { - self::${$var}[$rule] = $pattern; + static::${$var}[$rule] = $pattern; } else { if ($rule === 'uninflected') { - self::${$var}[$rule] = array_merge($pattern, self::${$var}[$rule]); + static::${$var}[$rule] = array_merge($pattern, static::${$var}[$rule]); } else { - self::${$var}[$rule] = $pattern + self::${$var}[$rule]; + static::${$var}[$rule] = $pattern + static::${$var}[$rule]; } } - unset($rules[$rule], self::${$var}['cache' . ucfirst($rule)]); - if (isset(self::${$var}['merged'][$rule])) { - unset(self::${$var}['merged'][$rule]); + unset($rules[$rule], static::${$var}['cache' . ucfirst($rule)]); + if (isset(static::${$var}['merged'][$rule])) { + unset(static::${$var}['merged'][$rule]); } if ($type === 'plural') { - self::$_cache['pluralize'] = self::$_cache['tableize'] = array(); + static::$_cache['pluralize'] = static::$_cache['tableize'] = array(); } 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']; break; } } @@ -345,37 +345,37 @@ public static function rules($type, $rules, $reset = false) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::pluralize */ public static function pluralize($word) { - if (isset(self::$_cache['pluralize'][$word])) { - return self::$_cache['pluralize'][$word]; + if (isset(static::$_cache['pluralize'][$word])) { + return static::$_cache['pluralize'][$word]; } - if (!isset(self::$_plural['merged']['irregular'])) { - self::$_plural['merged']['irregular'] = self::$_plural['irregular']; + if (!isset(static::$_plural['merged']['irregular'])) { + static::$_plural['merged']['irregular'] = static::$_plural['irregular']; } - if (!isset(self::$_plural['merged']['uninflected'])) { - self::$_plural['merged']['uninflected'] = array_merge(self::$_plural['uninflected'], self::$_uninflected); + if (!isset(static::$_plural['merged']['uninflected'])) { + static::$_plural['merged']['uninflected'] = array_merge(static::$_plural['uninflected'], static::$_uninflected); } - if (!isset(self::$_plural['cacheUninflected']) || !isset(self::$_plural['cacheIrregular'])) { - self::$_plural['cacheUninflected'] = '(?:' . implode('|', self::$_plural['merged']['uninflected']) . ')'; - self::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(self::$_plural['merged']['irregular'])) . ')'; + if (!isset(static::$_plural['cacheUninflected']) || !isset(static::$_plural['cacheIrregular'])) { + static::$_plural['cacheUninflected'] = '(?:' . implode('|', static::$_plural['merged']['uninflected']) . ')'; + static::$_plural['cacheIrregular'] = '(?:' . implode('|', array_keys(static::$_plural['merged']['irregular'])) . ')'; } - if (preg_match('/(.*)\\b(' . self::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { - self::$_cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$_plural['merged']['irregular'][strtolower($regs[2])], 1); - return self::$_cache['pluralize'][$word]; + if (preg_match('/(.*)\\b(' . static::$_plural['cacheIrregular'] . ')$/i', $word, $regs)) { + static::$_cache['pluralize'][$word] = $regs[1] . substr($word, 0, 1) . substr(static::$_plural['merged']['irregular'][strtolower($regs[2])], 1); + return static::$_cache['pluralize'][$word]; } - if (preg_match('/^(' . self::$_plural['cacheUninflected'] . ')$/i', $word, $regs)) { - self::$_cache['pluralize'][$word] = $word; + if (preg_match('/^(' . static::$_plural['cacheUninflected'] . ')$/i', $word, $regs)) { + static::$_cache['pluralize'][$word] = $word; return $word; } - foreach (self::$_plural['rules'] as $rule => $replacement) { + foreach (static::$_plural['rules'] as $rule => $replacement) { if (preg_match($rule, $word)) { - self::$_cache['pluralize'][$word] = preg_replace($rule, $replacement, $word); - return self::$_cache['pluralize'][$word]; + static::$_cache['pluralize'][$word] = preg_replace($rule, $replacement, $word); + return static::$_cache['pluralize'][$word]; } } } @@ -388,46 +388,46 @@ public static function pluralize($word) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::singularize */ public static function singularize($word) { - if (isset(self::$_cache['singularize'][$word])) { - return self::$_cache['singularize'][$word]; + if (isset(static::$_cache['singularize'][$word])) { + return static::$_cache['singularize'][$word]; } - if (!isset(self::$_singular['merged']['uninflected'])) { - self::$_singular['merged']['uninflected'] = array_merge( - self::$_singular['uninflected'], - self::$_uninflected + if (!isset(static::$_singular['merged']['uninflected'])) { + static::$_singular['merged']['uninflected'] = array_merge( + static::$_singular['uninflected'], + static::$_uninflected ); } - if (!isset(self::$_singular['merged']['irregular'])) { - self::$_singular['merged']['irregular'] = array_merge( - self::$_singular['irregular'], - array_flip(self::$_plural['irregular']) + if (!isset(static::$_singular['merged']['irregular'])) { + static::$_singular['merged']['irregular'] = array_merge( + static::$_singular['irregular'], + array_flip(static::$_plural['irregular']) ); } - if (!isset(self::$_singular['cacheUninflected']) || !isset(self::$_singular['cacheIrregular'])) { - self::$_singular['cacheUninflected'] = '(?:' . join('|', self::$_singular['merged']['uninflected']) . ')'; - self::$_singular['cacheIrregular'] = '(?:' . join('|', array_keys(self::$_singular['merged']['irregular'])) . ')'; + if (!isset(static::$_singular['cacheUninflected']) || !isset(static::$_singular['cacheIrregular'])) { + static::$_singular['cacheUninflected'] = '(?:' . join('|', static::$_singular['merged']['uninflected']) . ')'; + static::$_singular['cacheIrregular'] = '(?:' . join('|', array_keys(static::$_singular['merged']['irregular'])) . ')'; } - if (preg_match('/(.*)\\b(' . self::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) { - self::$_cache['singularize'][$word] = $regs[1] . substr($word, 0, 1) . substr(self::$_singular['merged']['irregular'][strtolower($regs[2])], 1); - return self::$_cache['singularize'][$word]; + if (preg_match('/(.*)\\b(' . static::$_singular['cacheIrregular'] . ')$/i', $word, $regs)) { + static::$_cache['singularize'][$word] = $regs[1] . substr($word, 0, 1) . substr(static::$_singular['merged']['irregular'][strtolower($regs[2])], 1); + return static::$_cache['singularize'][$word]; } - if (preg_match('/^(' . self::$_singular['cacheUninflected'] . ')$/i', $word, $regs)) { - self::$_cache['singularize'][$word] = $word; + if (preg_match('/^(' . static::$_singular['cacheUninflected'] . ')$/i', $word, $regs)) { + static::$_cache['singularize'][$word] = $word; return $word; } - foreach (self::$_singular['rules'] as $rule => $replacement) { + foreach (static::$_singular['rules'] as $rule => $replacement) { if (preg_match($rule, $word)) { - self::$_cache['singularize'][$word] = preg_replace($rule, $replacement, $word); - return self::$_cache['singularize'][$word]; + static::$_cache['singularize'][$word] = preg_replace($rule, $replacement, $word); + return static::$_cache['singularize'][$word]; } } - self::$_cache['singularize'][$word] = $word; + static::$_cache['singularize'][$word] = $word; return $word; } @@ -439,9 +439,9 @@ public static function singularize($word) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::camelize */ public static function camelize($lowerCaseAndUnderscoredWord) { - if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { + if (!($result = static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { $result = str_replace(' ', '', Inflector::humanize($lowerCaseAndUnderscoredWord)); - self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); + static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); } return $result; } @@ -454,9 +454,9 @@ public static function camelize($lowerCaseAndUnderscoredWord) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::underscore */ public static function underscore($camelCasedWord) { - if (!($result = self::_cache(__FUNCTION__, $camelCasedWord))) { + if (!($result = static::_cache(__FUNCTION__, $camelCasedWord))) { $result = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord)); - self::_cache(__FUNCTION__, $camelCasedWord, $result); + static::_cache(__FUNCTION__, $camelCasedWord, $result); } return $result; } @@ -470,9 +470,9 @@ public static function underscore($camelCasedWord) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::humanize */ public static function humanize($lowerCaseAndUnderscoredWord) { - if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { + if (!($result = static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) { $result = ucwords(str_replace('_', ' ', $lowerCaseAndUnderscoredWord)); - self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); + static::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord, $result); } return $result; } @@ -485,9 +485,9 @@ public static function humanize($lowerCaseAndUnderscoredWord) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::tableize */ public static function tableize($className) { - if (!($result = self::_cache(__FUNCTION__, $className))) { + if (!($result = static::_cache(__FUNCTION__, $className))) { $result = Inflector::pluralize(Inflector::underscore($className)); - self::_cache(__FUNCTION__, $className, $result); + static::_cache(__FUNCTION__, $className, $result); } return $result; } @@ -500,9 +500,9 @@ public static function tableize($className) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::classify */ public static function classify($tableName) { - if (!($result = self::_cache(__FUNCTION__, $tableName))) { + if (!($result = static::_cache(__FUNCTION__, $tableName))) { $result = Inflector::camelize(Inflector::singularize($tableName)); - self::_cache(__FUNCTION__, $tableName, $result); + static::_cache(__FUNCTION__, $tableName, $result); } return $result; } @@ -515,11 +515,11 @@ public static function classify($tableName) { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector::variable */ public static function variable($string) { - if (!($result = self::_cache(__FUNCTION__, $string))) { + if (!($result = static::_cache(__FUNCTION__, $string))) { $camelized = Inflector::camelize(Inflector::underscore($string)); $replace = strtolower(substr($camelized, 0, 1)); $result = preg_replace('/\\w/', $replace, $camelized, 1); - self::_cache(__FUNCTION__, $string, $result); + static::_cache(__FUNCTION__, $string, $result); } return $result; } @@ -542,7 +542,7 @@ public static function slug($string, $replacement = '_') { sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '', ); - $map = self::$_transliteration + $merge; + $map = static::$_transliteration + $merge; return preg_replace(array_keys($map), array_values($map), $string); } diff --git a/lib/Cake/Utility/Number.php b/lib/Cake/Utility/Number.php index 906b185d827..772df4345a1 100644 --- a/lib/Cake/Utility/Number.php +++ b/lib/Cake/Utility/Number.php @@ -93,13 +93,13 @@ public static function toReadableSize($size) { case $size < 1024: return __dn('cake', '%d Byte', '%d Bytes', $size, $size); case round($size / 1024) < 1024: - return __d('cake', '%d KB', self::precision($size / 1024, 0)); + return __d('cake', '%d KB', static::precision($size / 1024, 0)); case round($size / 1024 / 1024, 2) < 1024: - return __d('cake', '%.2f MB', self::precision($size / 1024 / 1024, 2)); + return __d('cake', '%.2f MB', static::precision($size / 1024 / 1024, 2)); case round($size / 1024 / 1024 / 1024, 2) < 1024: - return __d('cake', '%.2f GB', self::precision($size / 1024 / 1024 / 1024, 2)); + return __d('cake', '%.2f GB', static::precision($size / 1024 / 1024 / 1024, 2)); default: - return __d('cake', '%.2f TB', self::precision($size / 1024 / 1024 / 1024 / 1024, 2)); + return __d('cake', '%.2f TB', static::precision($size / 1024 / 1024 / 1024 / 1024, 2)); } } @@ -112,7 +112,7 @@ public static function toReadableSize($size) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::toPercentage */ public static function toPercentage($number, $precision = 2) { - return self::precision($number, $precision) . '%'; + return static::precision($number, $precision) . '%'; } /** @@ -151,7 +151,7 @@ public static function format($number, $options = false) { extract($options); } - $out = $before . self::_numberFormat($number, $places, $decimals, $thousands) . $after; + $out = $before . static::_numberFormat($number, $places, $decimals, $thousands) . $after; if ($escape) { return h($out); @@ -169,10 +169,10 @@ public static function format($number, $options = false) { * @return string */ protected static function _numberFormat($number, $places = 0, $decimals = '.', $thousands = ',') { - if (!isset(self::$_numberFormatSupport)) { - self::$_numberFormatSupport = version_compare(PHP_VERSION, '5.4.0', '>='); + if (!isset(static::$_numberFormatSupport)) { + static::$_numberFormatSupport = version_compare(PHP_VERSION, '5.4.0', '>='); } - if (self::$_numberFormatSupport) { + if (static::$_numberFormatSupport) { return number_format($number, $places, $decimals, $thousands); } $number = number_format($number, $places, '.', ''); @@ -223,10 +223,10 @@ protected static function _numberFormat($number, $places = 0, $decimals = '.', $ * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::currency */ public static function currency($number, $currency = 'USD', $options = array()) { - $default = self::$_currencyDefaults; + $default = static::$_currencyDefaults; - if (isset(self::$_currencies[$currency])) { - $default = self::$_currencies[$currency]; + if (isset(static::$_currencies[$currency])) { + $default = static::$_currencies[$currency]; } elseif (is_string($currency)) { $options['before'] = $currency; } @@ -260,7 +260,7 @@ public static function currency($number, $currency = 'USD', $options = array()) $options[$position] = $options[$symbolKey . 'Symbol']; $abs = abs($number); - $result = self::format($abs, $options); + $result = static::format($abs, $options); if ($number < 0 ) { if ($options['negative'] == '()') { @@ -292,7 +292,7 @@ public static function currency($number, $currency = 'USD', $options = array()) * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/number.html#NumberHelper::addFormat */ public static function addFormat($formatName, $options) { - self::$_currencies[$formatName] = $options + self::$_currencyDefaults; + static::$_currencies[$formatName] = $options + static::$_currencyDefaults; } } diff --git a/lib/Cake/Utility/Security.php b/lib/Cake/Utility/Security.php index 6c4134bd0e8..6ff681b704e 100644 --- a/lib/Cake/Utility/Security.php +++ b/lib/Cake/Utility/Security.php @@ -93,7 +93,7 @@ public static function hash($string, $type = null, $salt = false) { } if (empty($type)) { - $type = self::$hashType; + $type = static::$hashType; } $type = strtolower($type); @@ -124,7 +124,7 @@ public static function hash($string, $type = null, $salt = false) { * @see Security::hash() */ public static function setHash($hash) { - self::$hashType = $hash; + static::$hashType = $hash; } /** diff --git a/lib/Cake/Utility/String.php b/lib/Cake/Utility/String.php index 2550855d5e1..c71151282a1 100644 --- a/lib/Cake/Utility/String.php +++ b/lib/Cake/Utility/String.php @@ -556,7 +556,7 @@ class_exists('Multibyte'); */ public static function excerpt($text, $phrase, $radius = 100, $ending = '...') { if (empty($text) || empty($phrase)) { - return self::truncate($text, $radius * 2, array('ending' => $ending)); + return static::truncate($text, $radius * 2, array('ending' => $ending)); } $append = $prepend = $ending; diff --git a/lib/Cake/Utility/Time.php b/lib/Cake/Utility/Time.php index 512e52227d8..205e0adeca1 100644 --- a/lib/Cake/Utility/Time.php +++ b/lib/Cake/Utility/Time.php @@ -99,7 +99,7 @@ class Time { public function __set($name, $value) { switch ($name) { case 'niceFormat': - self::${$name} = $value; + static::${$name} = $value; break; default: break; @@ -114,7 +114,7 @@ public function __set($name, $value) { public function __get($name) { switch ($name) { case 'niceFormat': - return self::${$name}; + return static::${$name}; break; default: return null; @@ -136,7 +136,7 @@ public static function convertSpecifiers($format, $time = null) { if (!$time) { $time = time(); } - self::$_time = $time; + static::$_time = $time; return preg_replace_callback('/\%(\w+)/', array(__CLASS__, '_translateSpecifier'), $format); } @@ -152,47 +152,47 @@ protected static function _translateSpecifier($specifier) { case 'a': $abday = __dc('cake', 'abday', 5); if (is_array($abday)) { - return $abday[date('w', self::$_time)]; + return $abday[date('w', static::$_time)]; } break; case 'A': $day = __dc('cake', 'day', 5); if (is_array($day)) { - return $day[date('w', self::$_time)]; + return $day[date('w', static::$_time)]; } break; case 'c': $format = __dc('cake', 'd_t_fmt', 5); if ($format != 'd_t_fmt') { - return self::convertSpecifiers($format, self::$_time); + return static::convertSpecifiers($format, static::$_time); } break; case 'C': - return sprintf("%02d", date('Y', self::$_time) / 100); + return sprintf("%02d", date('Y', static::$_time) / 100); case 'D': return '%m/%d/%y'; case 'e': if (DS === '/') { return '%e'; } - $day = date('j', self::$_time); + $day = date('j', static::$_time); if ($day < 10) { $day = ' ' . $day; } return $day; case 'eS' : - return date('jS', self::$_time); + return date('jS', static::$_time); case 'b': case 'h': $months = __dc('cake', 'abmon', 5); if (is_array($months)) { - return $months[date('n', self::$_time) - 1]; + return $months[date('n', static::$_time) - 1]; } return '%b'; case 'B': $months = __dc('cake', 'mon', 5); if (is_array($months)) { - return $months[date('n', self::$_time) - 1]; + return $months[date('n', static::$_time) - 1]; } break; case 'n': @@ -200,7 +200,7 @@ protected static function _translateSpecifier($specifier) { case 'p': case 'P': $default = array('am' => 0, 'pm' => 1); - $meridiem = $default[date('a', self::$_time)]; + $meridiem = $default[date('a', static::$_time)]; $format = __dc('cake', 'am_pm', 5); if (is_array($format)) { $meridiem = $format[$meridiem]; @@ -210,27 +210,27 @@ protected static function _translateSpecifier($specifier) { case 'r': $complete = __dc('cake', 't_fmt_ampm', 5); 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; case 'R': - return date('H:i', self::$_time); + return date('H:i', static::$_time); case 't': return "\t"; case 'T': return '%H:%M:%S'; case 'u': - return ($weekDay = date('w', self::$_time)) ? $weekDay : 7; + return ($weekDay = date('w', static::$_time)) ? $weekDay : 7; case 'x': $format = __dc('cake', 'd_fmt', 5); if ($format != 'd_fmt') { - return self::convertSpecifiers($format, self::$_time); + return static::convertSpecifiers($format, static::$_time); } break; case 'X': $format = __dc('cake', 't_fmt', 5); if ($format != 't_fmt') { - return self::convertSpecifiers($format, self::$_time); + return static::convertSpecifiers($format, static::$_time); } break; } @@ -255,7 +255,7 @@ public static function convert($serverTime, $timezone) { if (is_numeric($timezone)) { $userOffset = $timezone * (60 * 60); } else { - $timezone = self::timezone($timezone); + $timezone = static::timezone($timezone); $userOffset = $timezone->getOffset(new \DateTime('@' . $gmtTime)); } $userTime = $gmtTime + $userOffset; @@ -329,7 +329,7 @@ public static function fromString($dateString, $timezone = null) { } if ($timezone !== null) { - return self::convert($date, $timezone); + return static::convert($date, $timezone); } if ($date === -1) { return false; @@ -353,13 +353,13 @@ public static function nice($dateString = null, $timezone = null, $format = null if (!$dateString) { $dateString = time(); } - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); if (!$format) { - $format = self::$niceFormat; + $format = static::$niceFormat; } - $format = self::convertSpecifiers($format, $date); - return self::_strftime($format, $date); + $format = static::convertSpecifiers($format, $date); + return static::_strftime($format, $date); } /** @@ -381,11 +381,11 @@ public static function niceShort($dateString = null, $timezone = null) { if (!$dateString) { $dateString = time(); } - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); - $y = self::isThisYear($date) ? '' : ' %Y'; + $y = static::isThisYear($date) ? '' : ' %Y'; - $d = self::_strftime("%w", $date); + $d = static::_strftime("%w", $date); $day = array( __d('cake', 'Sunday'), __d('cake', 'Monday'), @@ -396,19 +396,19 @@ public static function niceShort($dateString = null, $timezone = null) { __d('cake', 'Saturday') ); - if (self::isToday($dateString, $timezone)) { - $ret = __d('cake', 'Today, %s', self::_strftime("%H:%M", $date)); - } elseif (self::wasYesterday($dateString, $timezone)) { - $ret = __d('cake', 'Yesterday, %s', self::_strftime("%H:%M", $date)); - } elseif (self::isTomorrow($dateString, $timezone)) { - $ret = __d('cake', 'Tomorrow, %s', self::_strftime("%H:%M", $date)); - } elseif (self::wasWithinLast('7 days', $dateString, $timezone)) { - $ret = sprintf('%s %s', $day[$d], self::_strftime(self::$niceShortFormat, $date)); - } elseif (self::isWithinNext('7 days', $dateString, $timezone)) { - $ret = __d('cake', 'On %s %s', $day[$d], self::_strftime(self::$niceShortFormat, $date)); + if (static::isToday($dateString, $timezone)) { + $ret = __d('cake', 'Today, %s', static::_strftime("%H:%M", $date)); + } elseif (static::wasYesterday($dateString, $timezone)) { + $ret = __d('cake', 'Yesterday, %s', static::_strftime("%H:%M", $date)); + } elseif (static::isTomorrow($dateString, $timezone)) { + $ret = __d('cake', 'Tomorrow, %s', static::_strftime("%H:%M", $date)); + } elseif (static::wasWithinLast('7 days', $dateString, $timezone)) { + $ret = sprintf('%s %s', $day[$d], static::_strftime(static::$niceShortFormat, $date)); + } elseif (static::isWithinNext('7 days', $dateString, $timezone)) { + $ret = __d('cake', 'On %s %s', $day[$d], static::_strftime(static::$niceShortFormat, $date)); } else { - $format = self::convertSpecifiers("%b %eS{$y}, %H:%M", $date); - $ret = self::_strftime($format, $date); + $format = static::convertSpecifiers("%b %eS{$y}, %H:%M", $date); + $ret = static::_strftime($format, $date); } return $ret; } @@ -424,8 +424,8 @@ public static function niceShort($dateString = null, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ public static function daysAsSql($begin, $end, $fieldName, $timezone = null) { - $begin = self::fromString($begin, $timezone); - $end = self::fromString($end, $timezone); + $begin = static::fromString($begin, $timezone); + $end = static::fromString($end, $timezone); $begin = date('Y-m-d', $begin) . ' 00:00:00'; $end = date('Y-m-d', $end) . ' 23:59:59'; @@ -443,7 +443,7 @@ public static function daysAsSql($begin, $end, $fieldName, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ public static function dayAsSql($dateString, $fieldName, $timezone = null) { - return self::daysAsSql($dateString, $dateString, $fieldName); + return static::daysAsSql($dateString, $dateString, $fieldName); } /** @@ -455,7 +455,7 @@ public static function dayAsSql($dateString, $fieldName, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time */ public static function isToday($dateString, $timezone = null) { - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); return date('Y-m-d', $date) == date('Y-m-d', time()); } @@ -468,7 +468,7 @@ public static function isToday($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time */ public static function isThisWeek($dateString, $timezone = null) { - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); return date('W o', $date) == date('W o', time()); } @@ -480,7 +480,7 @@ public static function isThisWeek($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time */ public static function isThisMonth($dateString, $timezone = null) { - $date = self::fromString($dateString); + $date = static::fromString($dateString); return date('m Y', $date) == date('m Y', time()); } @@ -493,7 +493,7 @@ public static function isThisMonth($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time */ public static function isThisYear($dateString, $timezone = null) { - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); return date('Y', $date) == date('Y', time()); } @@ -507,7 +507,7 @@ public static function isThisYear($dateString, $timezone = null) { * */ public static function wasYesterday($dateString, $timezone = null) { - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); return date('Y-m-d', $date) == date('Y-m-d', strtotime('yesterday')); } @@ -520,7 +520,7 @@ public static function wasYesterday($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time */ public static function isTomorrow($dateString, $timezone = null) { - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); return date('Y-m-d', $date) == date('Y-m-d', strtotime('tomorrow')); } @@ -533,7 +533,7 @@ public static function isTomorrow($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ public static function toQuarter($dateString, $range = false) { - $time = self::fromString($dateString); + $time = static::fromString($dateString); $date = ceil(date('m', $time) / 3); if ($range === true) { @@ -569,7 +569,7 @@ public static function toQuarter($dateString, $range = false) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ public static function toUnix($dateString, $timezone = null) { - return self::fromString($dateString, $timezone); + return static::fromString($dateString, $timezone); } /** @@ -619,7 +619,7 @@ public static function toServer($dateString, $timezone = null, $format = 'Y-m-d * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ public static function toAtom($dateString, $timezone = null) { - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); return date('Y-m-d\TH:i:s\Z', $date); } @@ -632,7 +632,7 @@ public static function toAtom($dateString, $timezone = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ public static function toRSS($dateString, $timezone = null) { - $date = self::fromString($dateString, $timezone); + $date = static::fromString($dateString, $timezone); if (!is_null($timezone)) { if (is_numeric($timezone)) { @@ -696,9 +696,9 @@ public static function toRSS($dateString, $timezone = null) { */ public static function timeAgoInWords($dateTime, $options = array()) { $timezone = null; - $format = self::$wordFormat; - $end = self::$wordEnd; - $accuracy = self::$wordAccuracy; + $format = static::$wordFormat; + $end = static::$wordEnd; + $accuracy = static::$wordAccuracy; if (is_array($options)) { if (isset($options['userOffset'])) { @@ -729,8 +729,8 @@ public static function timeAgoInWords($dateTime, $options = array()) { $format = $options; } - $now = self::fromString(time(), $timezone); - $inSeconds = self::fromString($dateTime, $timezone); + $now = static::fromString(time(), $timezone); + $inSeconds = static::fromString($dateTime, $timezone); $backwards = ($inSeconds > $now); if ($backwards) { @@ -807,7 +807,7 @@ public static function timeAgoInWords($dateTime, $options = array()) { $relativeDate = ''; $diff = $futureTime - $pastTime; - if ($diff > abs($now - self::fromString($end))) { + if ($diff > abs($now - static::fromString($end))) { $relativeDate = __d('cake', 'on %s', date($format, $inSeconds)); } else { if ($years > 0) { @@ -842,8 +842,8 @@ public static function timeAgoInWords($dateTime, $options = array()) { } // If within the last or next 7 days - if (self::wasWithinLast('7 days', $dateTime, $timezone) || self::isWithinNext('7 days', $dateTime, $timezone)) { - $relativeDate = self::niceShort($dateTime , $timezone); + if (static::wasWithinLast('7 days', $dateTime, $timezone) || static::isWithinNext('7 days', $dateTime, $timezone)) { + $relativeDate = static::niceShort($dateTime , $timezone); } // If now @@ -869,8 +869,8 @@ public static function wasWithinLast($timeInterval, $dateString, $timezone = nul $timeInterval = $tmp . ' ' . __d('cake', 'days'); } - $date = self::fromString($dateString, $timezone); - $interval = self::fromString('-' . $timeInterval); + $date = static::fromString($dateString, $timezone); + $interval = static::fromString('-' . $timeInterval); if ($date >= $interval && $date <= time()) { return true; @@ -894,8 +894,8 @@ public static function isWithinNext($timeInterval, $dateString, $timezone = null $timeInterval = $tmp . ' ' . __d('cake', 'days'); } - $date = self::fromString($dateString, $timezone); - $interval = self::fromString('+' . $timeInterval); + $date = static::fromString($dateString, $timezone); + $interval = static::fromString('+' . $timeInterval); if ($date <= $interval && $date >= time()) { return true; @@ -912,7 +912,7 @@ public static function isWithinNext($timeInterval, $dateString, $timezone = null */ public static function gmt($dateString = null) { if ($dateString != null) { - $time = self::fromString($dateString); + $time = static::fromString($dateString); } else { $time = time(); } @@ -938,12 +938,12 @@ public static function gmt($dateString = null) { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ public static function format($format, $date = null, $invalid = false, $timezone = null) { - $time = self::fromString($date, $timezone); - $_time = is_numeric($time) ? false : self::fromString($format, $timezone); + $time = static::fromString($date, $timezone); + $_time = is_numeric($time) ? false : static::fromString($format, $timezone); if (is_numeric($_time) && $time === false) { $format = $date; - return self::i18nFormat($_time, $format, $invalid, $timezone); + return static::i18nFormat($_time, $format, $invalid, $timezone); } if ($time === false && $invalid !== false) { return $invalid; @@ -963,15 +963,15 @@ public static function format($format, $date = null, $invalid = false, $timezone * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ public static function i18nFormat($date, $format = null, $invalid = false, $timezone = null) { - $date = self::fromString($date, $timezone); + $date = static::fromString($date, $timezone); if ($date === false && $invalid !== false) { return $invalid; } if (empty($format)) { $format = '%x'; } - $format = self::convertSpecifiers($format, $date); - return self::_strftime($format, $date); + $format = static::convertSpecifiers($format, $date); + return static::_strftime($format, $date); } /** diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 624cfed1fa6..0cb47a5e1de 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -63,13 +63,13 @@ class Validation { */ public static function notEmpty($check) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if (empty($check) && $check != '0') { return false; } - return self::_check($check, '/[^\s]+/m'); + return static::_check($check, '/[^\s]+/m'); } /** @@ -85,13 +85,13 @@ public static function notEmpty($check) { */ public static function alphaNumeric($check) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if (empty($check) && $check != '0') { return false; } - return self::_check($check, '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/mu'); + return static::_check($check, '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/mu'); } /** @@ -121,9 +121,9 @@ public static function between($check, $min, $max) { */ public static function blank($check) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } - return !self::_check($check, '/[^\\s]/'); + return !static::_check($check, '/[^\\s]/'); } /** @@ -141,7 +141,7 @@ public static function blank($check) { */ public static function cc($check, $type = 'fast', $deep = false, $regex = null) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } $check = str_replace(array('-', ' '), '', $check); @@ -150,8 +150,8 @@ public static function cc($check, $type = 'fast', $deep = false, $regex = null) } if (!is_null($regex)) { - if (self::_check($check, $regex)) { - return self::luhn($check, $deep); + if (static::_check($check, $regex)) { + return static::luhn($check, $deep); } } $cards = array( @@ -177,23 +177,23 @@ public static function cc($check, $type = 'fast', $deep = false, $regex = null) foreach ($type as $value) { $regex = $cards['all'][strtolower($value)]; - if (self::_check($check, $regex)) { - return self::luhn($check, $deep); + if (static::_check($check, $regex)) { + return static::luhn($check, $deep); } } } elseif ($type == 'all') { foreach ($cards['all'] as $value) { $regex = $value; - if (self::_check($check, $regex)) { - return self::luhn($check, $deep); + if (static::_check($check, $regex)) { + return static::luhn($check, $deep); } } } else { $regex = $cards['fast']; - if (self::_check($check, $regex)) { - return self::luhn($check, $deep); + if (static::_check($check, $regex)) { + return static::luhn($check, $deep); } } return false; @@ -254,7 +254,7 @@ public static function comparison($check1, $operator = null, $check2 = null) { } break; default: - self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for Validation::comparison()'); + static::$errors[] = __d('cake_dev', 'You must define the $operator parameter for Validation::comparison()'); break; } return false; @@ -270,13 +270,13 @@ public static function comparison($check1, $operator = null, $check2 = null) { */ public static function custom($check, $regex = null) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if ($regex === null) { - self::$errors[] = __d('cake_dev', 'You must define a regular expression for Validation::custom()'); + static::$errors[] = __d('cake_dev', 'You must define a regular expression for Validation::custom()'); return false; } - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -297,7 +297,7 @@ public static function custom($check, $regex = null) { */ public static function date($check, $format = 'ymd', $regex = null) { if (!is_null($regex)) { - return self::_check($check, $regex); + return static::_check($check, $regex); } $regex['dmy'] = '%^(?:(?:31(\\/|-|\\.|\\x20)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(\\/|-|\\.|\\x20)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(\\/|-|\\.|\\x20)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(\\/|-|\\.|\\x20)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$%'; @@ -310,7 +310,7 @@ public static function date($check, $format = 'ymd', $regex = null) { $format = (is_array($format)) ? array_values($format) : array($format); foreach ($format as $key) { - if (self::_check($check, $regex[$key]) === true) { + if (static::_check($check, $regex[$key]) === true) { return true; } } @@ -344,7 +344,7 @@ public static function datetime($check, $dateFormat = 'ymd', $regex = null) { if (!empty($parts) && count($parts) > 1) { $time = array_pop($parts); $date = implode(' ', $parts); - $valid = self::date($date, $dateFormat, $regex) && self::time($time); + $valid = static::date($date, $dateFormat, $regex) && static::time($time); } return $valid; } @@ -358,7 +358,7 @@ public static function datetime($check, $dateFormat = 'ymd', $regex = null) { * @return boolean Success */ 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}$%'); } /** @@ -389,7 +389,7 @@ public static function decimal($check, $places = null, $regex = null) { $regex = '/^[-+]?[0-9]*(\\.{1}[0-9]{' . $places . '})?$/'; } } - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -405,18 +405,18 @@ public static function decimal($check, $places = null, $regex = null) { */ public static function email($check, $deep = false, $regex = null) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if (is_null($regex)) { - $regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/i'; + $regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . static::$_pattern['hostname'] . '$/i'; } - $return = self::_check($check, $regex); + $return = static::_check($check, $regex); if ($deep === false || $deep === null) { 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)) { return true; } @@ -448,7 +448,7 @@ public static function equalTo($check, $comparedTo) { */ public static function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) { if (is_array($check)) { - return self::extension(array_shift($check), $extensions); + return static::extension(array_shift($check), $extensions); } $pathSegments = explode('.', $check); $extension = strtolower(array_pop($pathSegments)); @@ -515,7 +515,7 @@ public static function money($check, $symbolPosition = 'left') { } else { $regex = '/^(?!\x{00a2})\p{Sc}?' . $money . '$/u'; } - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -575,7 +575,7 @@ public static function numeric($check) { */ public static function naturalNumber($check, $allowZero = false) { $regex = $allowZero ? '/^(?:0|[1-9][0-9]*)$/' : '/^[1-9][0-9]*$/'; - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -588,7 +588,7 @@ public static function naturalNumber($check, $allowZero = false) { */ public static function phone($check, $regex = null, $country = 'all') { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if (is_null($regex)) { @@ -603,9 +603,9 @@ public static function phone($check, $regex = null, $country = 'all') { } } 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); } /** @@ -618,7 +618,7 @@ public static function phone($check, $regex = null, $country = 'all') { */ public static function postal($check, $regex = null, $country = 'us') { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if (is_null($regex)) { @@ -642,9 +642,9 @@ public static function postal($check, $regex = null, $country = 'us') { } } 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); } /** @@ -677,7 +677,7 @@ public static function range($check, $lower = null, $upper = null) { */ public static function ssn($check, $regex = null, $country = null) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if (is_null($regex)) { @@ -694,9 +694,9 @@ public static function ssn($check, $regex = null, $country = null) { } } 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); } /** @@ -717,14 +717,14 @@ public static function ssn($check, $regex = null, $country = null) { * @return boolean Success */ public static function url($check, $strict = false) { - self::_populateIp(); + static::_populateIp(); $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))'; $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 . '*)?$/iu'; - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -760,7 +760,7 @@ public static function userDefined($check, $object, $method, $args = null) { */ public static function uuid($check) { $regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i'; - return self::_check($check, $regex); + return static::_check($check, $regex); } /** @@ -796,10 +796,10 @@ protected static function _pass($method, $check, $classPrefix) { */ protected static function _check($check, $regex) { if (preg_match($regex, $check)) { - self::$errors[] = false; + static::$errors[] = false; return true; } else { - self::$errors[] = true; + static::$errors[] = true; return false; } } @@ -812,7 +812,7 @@ protected static function _check($check, $regex) { * @return void */ protected static function _defaults($params) { - self::_reset(); + static::_reset(); $defaults = array( 'check' => null, 'regex' => null, @@ -837,7 +837,7 @@ protected static function _defaults($params) { */ public static function luhn($check, $deep = false) { if (is_array($check)) { - extract(self::_defaults($check)); + extract(static::_defaults($check)); } if ($deep !== true) { return true; @@ -899,7 +899,7 @@ public static function uploadError($check) { * @return void */ 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 .= '(:|((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})'; @@ -915,11 +915,11 @@ protected static function _populateIp() { $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})))(%.+)?'; - 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])'; - self::$_pattern['IPv4'] = $pattern; + static::$_pattern['IPv4'] = $pattern; } } @@ -929,7 +929,7 @@ protected static function _populateIp() { * @return void */ protected static function _reset() { - self::$errors = array(); + static::$errors = array(); } } diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index 33391e318b0..8cf18354489 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -94,7 +94,7 @@ public static function build($input, $options = array()) { $options = array_merge($defaults, $options); if (is_array($input) || is_object($input)) { - return self::fromArray((array)$input, $options); + return static::fromArray((array)$input, $options); } elseif (strpos($input, '<') !== false) { if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') { return new \SimpleXMLElement($input, LIBXML_NOCDATA); @@ -173,7 +173,7 @@ public static function fromArray($input, $options = array()) { $options = array_merge($defaults, $options); $dom = new \DOMDocument($options['version'], $options['encoding']); - self::_fromArray($dom, $dom, $input, $options['format']); + static::_fromArray($dom, $dom, $input, $options['format']); $options['return'] = strtolower($options['return']); if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') { @@ -237,10 +237,10 @@ protected static function _fromArray($dom, $node, &$data, $format) { foreach ($value as $item) { $itemData = compact('dom', 'node', 'key', 'format'); $itemData['value'] = $item; - self::_createChild($itemData); + static::_createChild($itemData); } } else { // Struct - self::_createChild(compact('dom', 'node', 'key', 'value', 'format')); + static::_createChild(compact('dom', 'node', 'key', 'value', 'format')); } } } else { @@ -280,7 +280,7 @@ protected static function _createChild($data) { $child->setAttribute('xmlns', $childNS); } - self::_fromArray($dom, $child, $value, $format); + static::_fromArray($dom, $child, $value, $format); $node->appendChild($child); } @@ -300,7 +300,7 @@ public static function toArray($obj) { } $result = array(); $namespaces = array_merge(array('' => ''), $obj->getNamespaces(true)); - self::_toArray($obj, $result, '', array_keys($namespaces)); + static::_toArray($obj, $result, '', array_keys($namespaces)); return $result; } @@ -325,7 +325,7 @@ protected static function _toArray($xml, &$parentData, $ns, $namespaces) { } foreach ($xml->children($namespace, true) as $child) { - self::_toArray($child, $data, $namespace, $namespaces); + static::_toArray($child, $data, $namespace, $namespaces); } } diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 690db751ee0..c60931a4dcf 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -405,7 +405,7 @@ public function create($model = null, $options = array()) { case 'delete': $append .= $this->hidden('_method', array( 'name' => '_method', 'value' => strtoupper($options['type']), 'id' => null, - 'secure' => self::SECURE_SKIP + 'secure' => static::SECURE_SKIP )); default: $htmlAttributes['method'] = 'post'; @@ -462,7 +462,7 @@ protected function _csrfField() { } return $this->hidden('_Token.key', array( 'value' => $this->request->params['_Token']['key'], 'id' => 'Token' . mt_rand(), - 'secure' => self::SECURE_SKIP + 'secure' => static::SECURE_SKIP )); } @@ -1492,10 +1492,10 @@ public function hidden($fieldName, $options = array()) { unset($options['secure']); } $options = $this->_initInputField($fieldName, array_merge( - $options, array('secure' => self::SECURE_SKIP) + $options, array('secure' => static::SECURE_SKIP) )); - if ($secure && $secure !== self::SECURE_SKIP) { + if ($secure && $secure !== static::SECURE_SKIP) { $this->_secure(true, null, '' . $options['value']); } @@ -1513,7 +1513,7 @@ public function hidden($fieldName, $options = array()) { public function file($fieldName, $options = array()) { $options += array('secure' => true); $secure = $options['secure']; - $options['secure'] = self::SECURE_SKIP; + $options['secure'] = static::SECURE_SKIP; $options = $this->_initInputField($fieldName, $options); $field = $this->entity(); @@ -1820,7 +1820,7 @@ public function select($fieldName, $options = array(), $attributes = array()) { $id = $this->_extractOption('id', $attributes); $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])) { @@ -2574,7 +2574,7 @@ protected function _initInputField($field, $options = array()) { if ($this->tagIsInvalid() !== false) { $result = $this->addClass($result, 'form-error'); } - if (!empty($result['disabled']) || $secure === self::SECURE_SKIP) { + if (!empty($result['disabled']) || $secure === static::SECURE_SKIP) { return $result; } diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index ecdfaff7c73..d75da0c525d 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -422,7 +422,7 @@ public function element($name, $data = array(), $options = array()) { $this->getEventManager()->dispatch(new Event('View.beforeRender', $this, array($file))); } - $this->_currentType = self::TYPE_ELEMENT; + $this->_currentType = static::TYPE_ELEMENT; $element = $this->_render($file, array_merge($this->viewVars, $data)); if ($callbacks) { @@ -472,7 +472,7 @@ public function render($view = null, $layout = null) { $this->Blocks->set('content', ''); if ($view !== false && $viewFileName = $this->_getViewFileName($view)) { - $this->_currentType = self::TYPE_VIEW; + $this->_currentType = static::TYPE_VIEW; $this->getEventManager()->dispatch(new Event('View.beforeRender', $this, array($viewFileName))); $this->Blocks->set('content', $this->_render($viewFileName)); $this->getEventManager()->dispatch(new Event('View.afterRender', $this, array($viewFileName))); @@ -537,7 +537,7 @@ public function renderLayout($content, $layout = null) { $this->viewVars['title_for_layout'] = Inflector::humanize($this->viewPath); } - $this->_currentType = self::TYPE_LAYOUT; + $this->_currentType = static::TYPE_LAYOUT; $this->Blocks->set('content', $this->_render($layoutFileName)); $this->getEventManager()->dispatch(new Event('View.afterLayout', $this, array($layoutFileName))); @@ -691,11 +691,11 @@ public function end() { * @throws LogicException when you extend an element which doesn't exist */ public function extend($name) { - if ($name[0] === '/' || $this->_currentType === self::TYPE_VIEW) { + if ($name[0] === '/' || $this->_currentType === static::TYPE_VIEW) { $parent = $this->_getViewFileName($name); } else { switch ($this->_currentType) { - case self::TYPE_ELEMENT: + case static::TYPE_ELEMENT: $parent = $this->_getElementFileName($name); if (!$parent) { list($plugin, $name) = $this->pluginSplit($name); @@ -708,7 +708,7 @@ public function extend($name) { )); } break; - case self::TYPE_LAYOUT: + case static::TYPE_LAYOUT: $parent = $this->_getLayoutFileName($name); break; default: