Skip to content
Permalink
Browse files

Replaced self by static

  • Loading branch information...
jrbasso committed May 31, 2012
1 parent 1e57bef commit 012e4b503087a9a17ffefb5493972af479eb22b0
Showing with 796 additions and 796 deletions.
  1. +61 −61 lib/Cake/Cache/Cache.php
  2. +5 −5 lib/Cake/Console/ConsoleErrorHandler.php
  3. +15 −15 lib/Cake/Console/ConsoleOutput.php
  4. +3 −3 lib/Cake/Controller/Component/Acl/PhpAcl.php
  5. +7 −7 lib/Cake/Controller/Component/AuthComponent.php
  6. +2 −2 lib/Cake/Error/ErrorHandler.php
  7. +7 −7 lib/Cake/Event/EventManager.php
  8. +7 −7 lib/Cake/I18n/I18n.php
  9. +13 −13 lib/Cake/I18n/Multibyte.php
  10. +55 −55 lib/Cake/Log/Log.php
  11. +36 −36 lib/Cake/Model/ConnectionManager.php
  12. +2 −2 lib/Cake/Model/Datasource/Database/Sqlserver.php
  13. +6 −6 lib/Cake/Model/Datasource/DboSource.php
  14. +84 −84 lib/Cake/Model/Datasource/Session.php
  15. +8 −8 lib/Cake/Network/Email/Email.php
  16. +2 −2 lib/Cake/Network/Http/BasicAuthentication.php
  17. +2 −2 lib/Cake/Network/Http/DigestAuthentication.php
  18. +1 −1 lib/Cake/Network/Request.php
  19. +82 −82 lib/Cake/Routing/Router.php
  20. +1 −1 lib/Cake/Test/TestApp/Controller/Component/TestAuthComponent.php
  21. +1 −1 lib/Cake/Test/TestCase/Controller/Component/Auth/FormAuthenticateTest.php
  22. +2 −2 lib/Cake/Test/TestCase/Controller/Component/SessionComponentTest.php
  23. +1 −1 lib/Cake/Test/TestCase/Log/Engine/ConsoleLogTest.php
  24. +4 −4 lib/Cake/Test/TestCase/Model/Datasource/CakeSessionTest.php
  25. +2 −2 lib/Cake/Test/TestCase/Model/Datasource/Session/CacheSessionTest.php
  26. +2 −2 lib/Cake/Test/TestCase/Model/Datasource/Session/DatabaseSessionTest.php
  27. +1 −1 lib/Cake/Test/TestCase/Model/ModelIntegrationTest.php
  28. +71 −71 lib/Cake/Test/TestCase/Model/ModelWriteTest.php
  29. +2 −2 lib/Cake/Test/TestCase/Utility/FolderTest.php
  30. +18 −18 lib/Cake/Test/TestCase/Utility/HashTest.php
  31. +9 −9 lib/Cake/TestSuite/TestCase.php
  32. +2 −2 lib/Cake/TestSuite/TestLoader.php
  33. +1 −1 lib/Cake/TestSuite/TestRunner.php
  34. +2 −2 lib/Cake/TestSuite/TestSuiteDispatcher.php
  35. +13 −13 lib/Cake/Utility/Debugger.php
  36. +36 −36 lib/Cake/Utility/Hash.php
  37. +70 −70 lib/Cake/Utility/Inflector.php
  38. +14 −14 lib/Cake/Utility/Number.php
  39. +2 −2 lib/Cake/Utility/Security.php
  40. +1 −1 lib/Cake/Utility/String.php
  41. +70 −70 lib/Cake/Utility/Time.php
  42. +53 −53 lib/Cake/Utility/Validation.php
  43. +7 −7 lib/Cake/Utility/Xml.php
  44. +7 −7 lib/Cake/View/Helper/FormHelper.php
  45. +6 −6 lib/Cake/View/View.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();
}
@@ -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>Error:</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', "<error>%s Error:</error> %s\n", $name, $message));
Oops, something went wrong.

0 comments on commit 012e4b5

Please sign in to comment.
You can’t perform that action at this time.