Skip to content

Commit 012e4b5

Browse files
committed
Replaced self by static
1 parent 1e57bef commit 012e4b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+796
-796
lines changed

lib/Cake/Cache/Cache.php

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -119,25 +119,25 @@ public static function config($name = null, $settings = array()) {
119119
}
120120

121121
$current = array();
122-
if (isset(self::$_config[$name])) {
123-
$current = self::$_config[$name];
122+
if (isset(static::$_config[$name])) {
123+
$current = static::$_config[$name];
124124
}
125125

126126
if (!empty($settings)) {
127-
self::$_config[$name] = array_merge($current, $settings);
127+
static::$_config[$name] = array_merge($current, $settings);
128128
}
129129

130-
if (empty(self::$_config[$name]['engine'])) {
130+
if (empty(static::$_config[$name]['engine'])) {
131131
return false;
132132
}
133133

134-
$engine = self::$_config[$name]['engine'];
134+
$engine = static::$_config[$name]['engine'];
135135

136-
if (!isset(self::$_engines[$name])) {
137-
self::_buildEngine($name);
138-
$settings = self::$_config[$name] = self::settings($name);
139-
} elseif ($settings = self::set(self::$_config[$name], null, $name)) {
140-
self::$_config[$name] = $settings;
136+
if (!isset(static::$_engines[$name])) {
137+
static::_buildEngine($name);
138+
$settings = static::$_config[$name] = static::settings($name);
139+
} elseif ($settings = static::set(static::$_config[$name], null, $name)) {
140+
static::$_config[$name] = $settings;
141141
}
142142
return compact('engine', 'settings');
143143
}
@@ -150,7 +150,7 @@ public static function config($name = null, $settings = array()) {
150150
* @throws CacheException
151151
*/
152152
protected static function _buildEngine($name) {
153-
$config = self::$_config[$name];
153+
$config = static::$_config[$name];
154154

155155
$cacheClass = App::classname($config['engine'], 'Cache/Engine', 'Engine');
156156
if (!$cacheClass) {
@@ -159,10 +159,10 @@ protected static function _buildEngine($name) {
159159
if (!is_subclass_of($cacheClass, 'Cake\Cache\CacheEngine')) {
160160
throw new Error\CacheException(__d('cake_dev', 'Cache engines must use Cake\Cache\CacheEngine as a base class.'));
161161
}
162-
self::$_engines[$name] = new $cacheClass();
163-
if (self::$_engines[$name]->init($config)) {
164-
if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) {
165-
self::$_engines[$name]->gc();
162+
static::$_engines[$name] = new $cacheClass();
163+
if (static::$_engines[$name]->init($config)) {
164+
if (static::$_engines[$name]->settings['probability'] && time() % static::$_engines[$name]->settings['probability'] === 0) {
165+
static::$_engines[$name]->gc();
166166
}
167167
return true;
168168
}
@@ -175,7 +175,7 @@ protected static function _buildEngine($name) {
175175
* @return array Array of configured Cache config names.
176176
*/
177177
public static function configured() {
178-
return array_keys(self::$_config);
178+
return array_keys(static::$_config);
179179
}
180180

181181
/**
@@ -187,10 +187,10 @@ public static function configured() {
187187
* @return boolean success of the removal, returns false when the config does not exist.
188188
*/
189189
public static function drop($name) {
190-
if (!isset(self::$_config[$name])) {
190+
if (!isset(static::$_config[$name])) {
191191
return false;
192192
}
193-
unset(self::$_config[$name], self::$_engines[$name]);
193+
unset(static::$_config[$name], static::$_engines[$name]);
194194
return true;
195195
}
196196

@@ -221,29 +221,29 @@ public static function set($settings = array(), $value = null, $config = 'defaul
221221
if (is_array($settings) && $value !== null) {
222222
$config = $value;
223223
}
224-
if (!isset(self::$_config[$config]) || !isset(self::$_engines[$config])) {
224+
if (!isset(static::$_config[$config]) || !isset(static::$_engines[$config])) {
225225
return false;
226226
}
227227
if (!empty($settings)) {
228-
self::$_reset = true;
228+
static::$_reset = true;
229229
}
230230

231-
if (self::$_reset === true) {
231+
if (static::$_reset === true) {
232232
if (empty($settings)) {
233-
self::$_reset = false;
234-
$settings = self::$_config[$config];
233+
static::$_reset = false;
234+
$settings = static::$_config[$config];
235235
} else {
236236
if (is_string($settings) && $value !== null) {
237237
$settings = array($settings => $value);
238238
}
239-
$settings = array_merge(self::$_config[$config], $settings);
239+
$settings = array_merge(static::$_config[$config], $settings);
240240
if (isset($settings['duration']) && !is_numeric($settings['duration'])) {
241241
$settings['duration'] = strtotime($settings['duration']) - time();
242242
}
243243
}
244-
self::$_engines[$config]->settings = $settings;
244+
static::$_engines[$config]->settings = $settings;
245245
}
246-
return self::settings($config);
246+
return static::settings($config);
247247
}
248248

249249
/**
@@ -256,7 +256,7 @@ public static function set($settings = array(), $value = null, $config = 'defaul
256256
* @return void
257257
*/
258258
public static function gc($config = 'default', $expires = null) {
259-
self::$_engines[$config]->gc($expires);
259+
static::$_engines[$config]->gc($expires);
260260
}
261261

262262
/**
@@ -280,29 +280,29 @@ public static function gc($config = 'default', $expires = null) {
280280
* @return boolean True if the data was successfully cached, false on failure
281281
*/
282282
public static function write($key, $value, $config = 'default') {
283-
$settings = self::settings($config);
283+
$settings = static::settings($config);
284284

285285
if (empty($settings)) {
286286
return false;
287287
}
288-
if (!self::isInitialized($config)) {
288+
if (!static::isInitialized($config)) {
289289
return false;
290290
}
291-
$key = self::$_engines[$config]->key($key);
291+
$key = static::$_engines[$config]->key($key);
292292

293293
if (!$key || is_resource($value)) {
294294
return false;
295295
}
296296

297-
$success = self::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']);
298-
self::set(null, $config);
297+
$success = static::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']);
298+
static::set(null, $config);
299299
if ($success === false && $value !== '') {
300300
trigger_error(
301301
__d('cake_dev',
302302
"%s cache was unable to write '%s' to %s cache",
303303
$config,
304304
$key,
305-
self::$_engines[$config]->settings['engine']
305+
static::$_engines[$config]->settings['engine']
306306
),
307307
E_USER_WARNING
308308
);
@@ -330,19 +330,19 @@ public static function write($key, $value, $config = 'default') {
330330
* @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
331331
*/
332332
public static function read($key, $config = 'default') {
333-
$settings = self::settings($config);
333+
$settings = static::settings($config);
334334

335335
if (empty($settings)) {
336336
return false;
337337
}
338-
if (!self::isInitialized($config)) {
338+
if (!static::isInitialized($config)) {
339339
return false;
340340
}
341-
$key = self::$_engines[$config]->key($key);
341+
$key = static::$_engines[$config]->key($key);
342342
if (!$key) {
343343
return false;
344344
}
345-
return self::$_engines[$config]->read($settings['prefix'] . $key);
345+
return static::$_engines[$config]->read($settings['prefix'] . $key);
346346
}
347347

348348
/**
@@ -355,21 +355,21 @@ public static function read($key, $config = 'default') {
355355
* or if there was an error fetching it.
356356
*/
357357
public static function increment($key, $offset = 1, $config = 'default') {
358-
$settings = self::settings($config);
358+
$settings = static::settings($config);
359359

360360
if (empty($settings)) {
361361
return false;
362362
}
363-
if (!self::isInitialized($config)) {
363+
if (!static::isInitialized($config)) {
364364
return false;
365365
}
366-
$key = self::$_engines[$config]->key($key);
366+
$key = static::$_engines[$config]->key($key);
367367

368368
if (!$key || !is_integer($offset) || $offset < 0) {
369369
return false;
370370
}
371-
$success = self::$_engines[$config]->increment($settings['prefix'] . $key, $offset);
372-
self::set(null, $config);
371+
$success = static::$_engines[$config]->increment($settings['prefix'] . $key, $offset);
372+
static::set(null, $config);
373373
return $success;
374374
}
375375

@@ -383,21 +383,21 @@ public static function increment($key, $offset = 1, $config = 'default') {
383383
* or if there was an error fetching it
384384
*/
385385
public static function decrement($key, $offset = 1, $config = 'default') {
386-
$settings = self::settings($config);
386+
$settings = static::settings($config);
387387

388388
if (empty($settings)) {
389389
return false;
390390
}
391-
if (!self::isInitialized($config)) {
391+
if (!static::isInitialized($config)) {
392392
return false;
393393
}
394-
$key = self::$_engines[$config]->key($key);
394+
$key = static::$_engines[$config]->key($key);
395395

396396
if (!$key || !is_integer($offset) || $offset < 0) {
397397
return false;
398398
}
399-
$success = self::$_engines[$config]->decrement($settings['prefix'] . $key, $offset);
400-
self::set(null, $config);
399+
$success = static::$_engines[$config]->decrement($settings['prefix'] . $key, $offset);
400+
static::set(null, $config);
401401
return $success;
402402
}
403403

@@ -419,21 +419,21 @@ public static function decrement($key, $offset = 1, $config = 'default') {
419419
* @return boolean True if the value was successfully deleted, false if it didn't exist or couldn't be removed
420420
*/
421421
public static function delete($key, $config = 'default') {
422-
$settings = self::settings($config);
422+
$settings = static::settings($config);
423423

424424
if (empty($settings)) {
425425
return false;
426426
}
427-
if (!self::isInitialized($config)) {
427+
if (!static::isInitialized($config)) {
428428
return false;
429429
}
430-
$key = self::$_engines[$config]->key($key);
430+
$key = static::$_engines[$config]->key($key);
431431
if (!$key) {
432432
return false;
433433
}
434434

435-
$success = self::$_engines[$config]->delete($settings['prefix'] . $key);
436-
self::set(null, $config);
435+
$success = static::$_engines[$config]->delete($settings['prefix'] . $key);
436+
static::set(null, $config);
437437
return $success;
438438
}
439439

@@ -445,11 +445,11 @@ public static function delete($key, $config = 'default') {
445445
* @return boolean True if the cache was successfully cleared, false otherwise
446446
*/
447447
public static function clear($check = false, $config = 'default') {
448-
if (!self::isInitialized($config)) {
448+
if (!static::isInitialized($config)) {
449449
return false;
450450
}
451-
$success = self::$_engines[$config]->clear($check);
452-
self::set(null, $config);
451+
$success = static::$_engines[$config]->clear($check);
452+
static::set(null, $config);
453453
return $success;
454454
}
455455

@@ -461,11 +461,11 @@ public static function clear($check = false, $config = 'default') {
461461
* @return boolean True if the cache group was successfully cleared, false otherwise
462462
*/
463463
public static function clearGroup($group, $config = 'default') {
464-
if (!self::isInitialized($config)) {
464+
if (!static::isInitialized($config)) {
465465
return false;
466466
}
467-
$success = self::$_engines[$config]->clearGroup($group);
468-
self::set(null, $config);
467+
$success = static::$_engines[$config]->clearGroup($group);
468+
static::set(null, $config);
469469
return $success;
470470
}
471471

@@ -479,7 +479,7 @@ public static function isInitialized($config = 'default') {
479479
if (Configure::read('Cache.disable')) {
480480
return false;
481481
}
482-
return isset(self::$_engines[$config]);
482+
return isset(static::$_engines[$config]);
483483
}
484484

485485
/**
@@ -490,8 +490,8 @@ public static function isInitialized($config = 'default') {
490490
* @see Cache::config()
491491
*/
492492
public static function settings($name = 'default') {
493-
if (!empty(self::$_engines[$name])) {
494-
return self::$_engines[$name]->settings();
493+
if (!empty(static::$_engines[$name])) {
494+
return static::$_engines[$name]->settings();
495495
}
496496
return array();
497497
}

lib/Cake/Console/ConsoleErrorHandler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ class ConsoleErrorHandler {
4040
* @return ConsoleOutput
4141
*/
4242
public static function getStderr() {
43-
if (empty(self::$stderr)) {
44-
self::$stderr = new ConsoleOutput('php://stderr');
43+
if (empty(static::$stderr)) {
44+
static::$stderr = new ConsoleOutput('php://stderr');
4545
}
46-
return self::$stderr;
46+
return static::$stderr;
4747
}
4848

4949
/**
@@ -53,7 +53,7 @@ public static function getStderr() {
5353
* @return void
5454
*/
5555
public function handleException(\Exception $exception) {
56-
$stderr = self::getStderr();
56+
$stderr = static::getStderr();
5757
$stderr->write(__d('cake_console', "<error>Error:</error> %s\n%s",
5858
$exception->getMessage(),
5959
$exception->getTraceAsString()
@@ -76,7 +76,7 @@ public function handleError($code, $description, $file = null, $line = null, $co
7676
if (error_reporting() === 0) {
7777
return;
7878
}
79-
$stderr = self::getStderr();
79+
$stderr = static::getStderr();
8080
list($name, $log) = ErrorHandler::mapErrorCode($code);
8181
$message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line);
8282
$stderr->write(__d('cake_console', "<error>%s Error:</error> %s\n", $name, $message));

0 commit comments

Comments
 (0)